Initialisierungsarbeiten
// Physiksystem initialisieren (maximal 3000 Partikel/Massenpunkte):
PhysicalSimulationParameter = new CPhysicalSimulationParameter;
PhysicalSimulationParameter->Init_PhysicalSimulationParameter(
"../Physics/SimulationParameter.txt");
OpenCLPhysicsManager = new COpenCLPhysicsManager;
OpenCLPhysicsManager->Init_CollisionGrid(100, 100, 100, 50);
OpenCLPhysicsManager->Init_OpenCL_ParticlePhysicsManager(
"../Physics/PhysicsCalculations.cl", 3000, false);
OpenCLParticleManager = new COpenCLParticleManager;
OpenCLParticleManager->Init_OpenCLParticleManager(3000,
OpenCLPhysicsManager->ParticlePool);
PhysicalTestBodies = new CPhysicalTestBodyPhysicsManager;
PhysicalTestBodies->Set_PhysicalSimulationParameter(
PhysicalSimulationParameter);
PhysicalTestBodies->Set_OpenCLPhysicsManager(OpenCLPhysicsManager);
// 2000 Partikel generieren:
PhysicalTestBodies->Init_PhysicalTestBodies(OpenCLParticleManager,
InstancedObjectTextureAndMeshDesc,
SimpleObjectInstanceMemoryManager, 2000);
[...]
// Terrain-Surface-Daten laden und dem Physiksystem zuweisen:
TerrainTileSet_SurfaceData = new CTerrainTileSet_SurfaceData;
TerrainTileSet_SurfaceData->Init_TileSet("../Models/TileSet1",
"MeshTestSet1.bin", true);
TerrainTileSet_SurfaceData->Init_OpenCL_DistanceToTerrainCalculation(
OpenCLPhysicsManager->OpenCLDevice_ParticlePhysics,
"../Physics/DistanceToTerrainCalculation.cl", 0, 3000);
OpenCLPhysicsManager->Set_TerrainSurfaceData(TerrainTileSet_SurfaceData);
TerrainTileSet_SurfaceData->Set_GroundFrictionValues(150.0f);
TerrainTileSet_SurfaceData->
Update_OpenCLBuffer_TriangleGroundFrictionValue();
PhysicalSimulationParameter = new CPhysicalSimulationParameter;
PhysicalSimulationParameter->Init_PhysicalSimulationParameter(
"../Physics/SimulationParameter.txt");
OpenCLPhysicsManager = new COpenCLPhysicsManager;
OpenCLPhysicsManager->Init_CollisionGrid(100, 100, 100, 50);
OpenCLPhysicsManager->Init_OpenCL_ParticlePhysicsManager(
"../Physics/PhysicsCalculations.cl", 3000, false);
OpenCLParticleManager = new COpenCLParticleManager;
OpenCLParticleManager->Init_OpenCLParticleManager(3000,
OpenCLPhysicsManager->ParticlePool);
PhysicalTestBodies = new CPhysicalTestBodyPhysicsManager;
PhysicalTestBodies->Set_PhysicalSimulationParameter(
PhysicalSimulationParameter);
PhysicalTestBodies->Set_OpenCLPhysicsManager(OpenCLPhysicsManager);
// 2000 Partikel generieren:
PhysicalTestBodies->Init_PhysicalTestBodies(OpenCLParticleManager,
InstancedObjectTextureAndMeshDesc,
SimpleObjectInstanceMemoryManager, 2000);
[...]
// Terrain-Surface-Daten laden und dem Physiksystem zuweisen:
TerrainTileSet_SurfaceData = new CTerrainTileSet_SurfaceData;
TerrainTileSet_SurfaceData->Init_TileSet("../Models/TileSet1",
"MeshTestSet1.bin", true);
TerrainTileSet_SurfaceData->Init_OpenCL_DistanceToTerrainCalculation(
OpenCLPhysicsManager->OpenCLDevice_ParticlePhysics,
"../Physics/DistanceToTerrainCalculation.cl", 0, 3000);
OpenCLPhysicsManager->Set_TerrainSurfaceData(TerrainTileSet_SurfaceData);
TerrainTileSet_SurfaceData->Set_GroundFrictionValues(150.0f);
TerrainTileSet_SurfaceData->
Update_OpenCLBuffer_TriangleGroundFrictionValue();
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);
}
PhysicalTestBodies->Consider_ActualSimulationParameter();
PhysicalTestBodies->Update_Movement();
PhysicalTestBodies->Update_PhysicalTestBodyCollisionsThread();
//PhysicalTestBodies->Update_PhysicalTestBodyMovementThread();
//PhysicalTestBodies->Update_Collisions();
{
PhysicalSimulationParameter->Calculate_NumTimeSteps(
g_MaximalAcceptedFrameTimeUsedForPhysicalCalculations,
0.33f*g_MaximalAcceptedFrameTimeUsedForPhysicalCalculations);
}
else
{
PhysicalSimulationParameter->Calculate_NumTimeSteps(g_FrameTime,
0.33f*g_FrameTime);
}
PhysicalTestBodies->Consider_ActualSimulationParameter();
PhysicalTestBodies->Update_Movement();
PhysicalTestBodies->Update_PhysicalTestBodyCollisionsThread();
//PhysicalTestBodies->Update_PhysicalTestBodyMovementThread();
//PhysicalTestBodies->Update_Collisions();
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.
GraphicsAndPhysicsFrameworkDemo23.zip