we are making a 3d car race game.for physics we are using bullet and we are using maya for animation purpose i.e. for making models,we know how to make collidable shapes in bullet but the problem is how to make a full collidable race track because a race track will be quite big,how to make collidable mesh for the track boundaries and other objects in the world.please help
A race track is just a piece of static environment. Like any other static rigid body. You would not use a plane shape, because this looks boring. A triangle mesh shape is what you probably want to have, or a heighfield mesh shape. The manual and the samples show how to create such shapes. But I guess this is not what you had in mind when writing this question. What concrete issues do you have?
thanks for the reply,
I can put these shapes in the code and then attach the visible geom,but my track is too big,how can i attach the whole track boundaries into triangle shapes,or isn’t there a way to export the collide mesh as well as visible geom directly from maya to a egg file,i know how to export models to egg,i tried exporting collision mesh from maya itself to egg,but when i am using it in my game my car is not colliding with the track.please help and sorry if i am still not being clear.
So you have a separate visible mesh and a collision mesh. This is fine. After exporting from you modlling application you should have two .egg files. Both should contain geometry.
First load the collision mesh .egg file like you would load any other model (e. g. loader.loadModel). The next steps depend on what the substructure of your loaded collision model is. Is it a single GeomNode without transform, or many GeomNodes, or even many GeomNodes with with transforms. Use the “ls()” function on the loaded NodePath and post the result here.
i have done what you asked,here is the output of ls()
ModelRoot testenv.egg PandaNode PandaNode T:m(hpr 0 90 0 scale 12 1 12) CollisionNode groundPlane_transform (0 solids) (hidden) PandaNode T:m(pos 19.9088 0.126122 0 scale 21.1383 5.4254 1) CollisionNode pPlane9 (1 solids) (hidden) GeomNode (1 geoms: S:(ColorAttrib)) PandaNode T:m(pos 2.28121 -14.8671 3.91751) CollisionNode pCube12 (6 solids) (hidden) GeomNode (1 geoms: S:(ColorAttrib)) PandaNode T:m(pos 8.33069 -0.832038 0.503194 scale 0.0626831 0.271771 0.108 025) CollisionNode pCube13 (6 solids) (hidden) GeomNode (1 geoms: S:(ColorAttrib))
Ok, so you have a mix of GeomNodes and CollisionNodes. I assume that the CollisionNodes are of no relevance (1 plane and two cubes). So the “real” geometry for collision is inside the four GeomNodes. Each have transforms.
You could create one BulleTriangleMesh for each GeomNode. Then create one BulletTriangleMeshShape for each BulletTriangleMesh. Now create a static rigid body and add the four shapes to it. When adding the shapes also provide the GeomNode’s transform: addShape(shape, ts).
The bad thing is that your transforms have not only translation/rotation, but also scale. Scale is always problematic when using physics. You should get rid of these transforms inside you modelling application! In Blender it would be one of the “apply” function. Don’t know what it is in Maya. Or you use the GeomTransformer.transformVertices method to modify your Geoms BEFORE passing them to mesh.addGeom. But this might cost some time, depending on how complex the Geoms are.
hey i got rid of the scalars and used the bullet triangle mesh,i want to know for example imagine i have 50 independent obstacles(of all shapes and sizes) in my track ,do i have to make 50 collision shapes in my code and then match their coordinates with the models or is there any other way
I don’t understand what the actual question is.
If you have INDEPENDENT obstacles, i. g. in the sense that they be add/remove while playing the game, then you should not only use separate shapes for each obstacle, but use separate static rigs bodies (one for each obstacle).
If it is about combining several meshes into one huge mesh (assuming all obstacle are tirangle meshes?) then yes, this is possible. But see my above post: you have to make sure all of them have the same transform, e. g. using GeomTransformer.
hey i got it to work,i used bullet triangle mesh and in maya i combined all the polygons to make a single mesh,so when i loaded the egg into panda the triangle mesh took the shape of the track,thank you very much for the help