so you want to make a level into a compund collision? that will definitlly no work in any away.
Yezide wrote:Now, if compound is not good for this, what should I be using? Would it perhaps be better to have some premade collide meshes (box, cylinder,etc) and then use these to build simplified version (using mesh collison). This will not solve the compile time problem though (not completly at least). Any ideas are welcome!
I mention before there is a new collision shape in newton is the SceneCollision, It is a compund collision for static mesh.
It uses a different spacial organization that is fastr for shapes queries and ray casting since the pieces are static.
It is very eassy to used, and there is a demo in teh SDK teh uses it show how to use it.
It support, and remove, move of queries and you can add all of the oteh promitives, convex or concaves.
for what I can see in the video it is the ideal shape for what you are doing.
It should handle movement of separate shapes althuight the functionality is not ready yet (no one have paid atention so I have not put more effort on it)
but the shape is so fast that you can build and rebuild every time by having two copies and use dowble buffer (wigh waht I was going to use inteenally anyway
one tree is on while othe is rebuild)
could you check shape instead and see how is works?
here is a sample file that show the usage
- Code: Select all
ScenePrimitive::ScenePrimitive(const NewtonWorld* nWorld, const char* name, int optimized)
:OGLModel()
{
NewtonCollision* scene;
// create a body and with a scene collision
scene = NewtonCreateSceneCollision (nWorld);
// add a collision tree to the scene
AddCollisionTree(scene, nWorld, name, optimized);
// add some shapes
AddPrimitives(scene, nWorld);
// finish the scene contrution, optimize the collision scene
NewtonSceneCollisionOptimize (scene);
// set the world size base on the scene size
dVector boxP0;
dVector boxP1;
// get the position of the aabb of this geometry
NewtonCollisionCalculateAABB (scene, &m_matrix[0][0], &boxP0.m_x, &boxP1.m_x);
// add some extra padding the world size
boxP0.m_x -= 50.0f;
boxP0.m_y -= 50.0f;
boxP0.m_z -= 50.0f;
boxP1.m_x += 50.0f;
boxP1.m_y += 500.0f;
boxP1.m_z += 50.0f;
// set the world size
NewtonSetWorldSize (nWorld, &boxP0.m_x, &boxP1.m_x);
// set the application level callback
// create the level body and add it to the world
m_level = NewtonCreateBody (nWorld, scene);
NewtonReleaseCollision (nWorld, scene);
// set the global position of this body
NewtonBodySetMatrix (m_level, &m_matrix[0][0]);
}
void ScenePrimitive::AddPrimitives(NewtonCollision* scene, const NewtonWorld* nWorld)
{
NewtonCollision* collision1;
NewtonCollision* collision2;
dMatrix rotMat (dRollMatrix (0.5f * 3.141592f));
collision2 = NewtonCreateCylinder (nWorld, 2.0f, 0.5f, &rotMat[0][0]);
collision1 = NewtonCreateBox (nWorld, 4.0f, 0.5, 4.0f, NULL);
dMatrix matrix (GetIdentityMatrix());
for (int y = 0; y < 10; y ++) {
for (int x = 0; x < 10; x ++) {
for (int z = 0; z < 10; z ++) {
NewtonCollision* collision;
NewtonSceneProxy* sceneProxy;
matrix.m_posit.m_y = 5.0f + y * 4.0f ;
matrix.m_posit.m_x = x * 6.0f - 20.0f;
matrix.m_posit.m_z = z * 6.0f - 24.0f;
collision = (rand () & 0x010) ? collision1 : collision2;
sceneProxy = NewtonSceneCollisionCreateProxy (scene, collision);
NewtonSceneProxySetMatrix (sceneProxy, &matrix[0][0]);
VisualProxy& shape = m_pieces.Append()->GetInfo();
shape.m_sceneProxi = sceneProxy;
shape.m_mesh = new OGLMesh (collision, "smilli.tga", "smilli.tga", "smilli.tga");
shape.m_matrix = matrix;
}
}
}
NewtonReleaseCollision (nWorld, collision1);
NewtonReleaseCollision (nWorld, collision2);
}