Initialisierungsarbeiten:
// Physiksystem initialisieren (maximal 3000 Rigid Bodies):
PhysicalSimulationParameter = new CPhysicalSimulationParameter;
PhysicalSimulationParameter->Init_PhysicalSimulationParameter(
"../Physics/SimulationParameter.txt");
SimpleBodyMasspointModel = new CSimplePhysicsBodyMasspointModel;
SimpleBodyMasspointModel->Init_MasspointModel(
"../Physics/MasspointModels/Box1.txt");
OpenCLPhysicsManager = new COpenCLPhysicsManager;
OpenCLPhysicsManager->Init_CollisionGrid(71, 71, 71, 50);
OpenCLPhysicsManager->Init_OpenCL_3DBodyPhysicsManager(
"../Physics/SimplePhysicsCalculations.cl", 3000,
27000, 10, 75000, false);
SimplePhysicsBodyManager = new CSimplePhysicsBodyManager;
SimplePhysicsBodyManager->Init_SimplePhysicsBodyManager(3000,
OpenCLPhysicsManager->MassElementPool,
OpenCLPhysicsManager->BondingPool);
Asteroids = new CAsteroidPhysicsManager;
Asteroids->Set_PhysicalSimulationParameter(PhysicalSimulationParameter);
Asteroids->Set_OpenCLPhysicsManager(OpenCLPhysicsManager);
// 2000 Asteroiden generieren:
Asteroids->Init_Asteroids(SimplePhysicsBodyManager,
SimpleBodyMasspointModel,
InstancedObjectTextureAndMeshDesc,
SimpleObjectInstanceMemoryManager,
2000);
PhysicalSimulationParameter = new CPhysicalSimulationParameter;
PhysicalSimulationParameter->Init_PhysicalSimulationParameter(
"../Physics/SimulationParameter.txt");
SimpleBodyMasspointModel = new CSimplePhysicsBodyMasspointModel;
SimpleBodyMasspointModel->Init_MasspointModel(
"../Physics/MasspointModels/Box1.txt");
OpenCLPhysicsManager = new COpenCLPhysicsManager;
OpenCLPhysicsManager->Init_CollisionGrid(71, 71, 71, 50);
OpenCLPhysicsManager->Init_OpenCL_3DBodyPhysicsManager(
"../Physics/SimplePhysicsCalculations.cl", 3000,
27000, 10, 75000, false);
SimplePhysicsBodyManager = new CSimplePhysicsBodyManager;
SimplePhysicsBodyManager->Init_SimplePhysicsBodyManager(3000,
OpenCLPhysicsManager->MassElementPool,
OpenCLPhysicsManager->BondingPool);
Asteroids = new CAsteroidPhysicsManager;
Asteroids->Set_PhysicalSimulationParameter(PhysicalSimulationParameter);
Asteroids->Set_OpenCLPhysicsManager(OpenCLPhysicsManager);
// 2000 Asteroiden generieren:
Asteroids->Init_Asteroids(SimplePhysicsBodyManager,
SimpleBodyMasspointModel,
InstancedObjectTextureAndMeshDesc,
SimpleObjectInstanceMemoryManager,
2000);
Bewegungs- und Kollisionsberechnungen:
if(g_FrameTime > g_MaximalAcceptedFrameTimeUsedForPhysicalCalculations)
{
PhysicalSimulationParameter->Calculate_NumTimeSteps(
g_MaximalAcceptedFrameTimeUsedForPhysicalCalculations,
0.33f*g_MaximalAcceptedFrameTimeUsedForPhysicalCalculations);
}
else
{
PhysicalSimulationParameter->Calculate_NumTimeSteps(g_FrameTime,
0.33f*g_FrameTime);
}
Asteroids->Update_PhysicalCalculations();
Asteroids->Update_Movement();
//Asteroids->Update_Collisions();
Asteroids->Update_AsteroidCollisionsThread();
//Asteroids->Update_AsteroidMovementThread();
{
PhysicalSimulationParameter->Calculate_NumTimeSteps(
g_MaximalAcceptedFrameTimeUsedForPhysicalCalculations,
0.33f*g_MaximalAcceptedFrameTimeUsedForPhysicalCalculations);
}
else
{
PhysicalSimulationParameter->Calculate_NumTimeSteps(g_FrameTime,
0.33f*g_FrameTime);
}
Asteroids->Update_PhysicalCalculations();
Asteroids->Update_Movement();
//Asteroids->Update_Collisions();
Asteroids->Update_AsteroidCollisionsThread();
//Asteroids->Update_AsteroidMovementThread();
Hinweise zum Erstellen eines neuen Projekts:
- Kopieren Sie den Ordner GraphicsAndPhysicsFrameworkImports ins Projektverzeichnis
- Kopieren sie alle dll-Dateien sowie die Konfigurationsdatei ResolutionAndRendering.txt aus besagtem Ordner ins gleiche Verzeichnis, in dem sich auch die exe-Datei befindet (in unseren Programmbeispielen ist dies das Bin-Verzeichnis)
- Binden Sie die folgenden Dateien in Ihr Projekt ein: GraphicsAndPhysics_Framework_Imports.h, GraphicsAndPhysics_Framework_Imports.lib, glew32.lib, glew32s.lib, glut32.lib. Die Glew- und Glut-Bibliotheken ermöglichen die Nutzung der aktuellen OpenGL-Spezifikationen unabhängig vom Framework.
GraphicsAndPhysicsFrameworkDemo22.zip