frier
15-08-2007 13:53:08
Hi,
I need help with tips on how to setup collision between a custom terrain we have created in 3dsmax To PhysX.
Our level is like a more open race track, so its confined with-in a certain area, but players arn't confined to a specified track like a typical racer. Basically its a open space with obstacles like trees,rocks etc.
Side note:
I was looking at this PML file loading on the PhysX site. looks like a great way to setup 3d and create collision meshes/boxes for the models straight away in 3ds then just export them to your NxOgre Scene. Does anyone use PML files?
Thanks!
FrieR
betajaen
15-08-2007 14:05:02
a)
You should be able to throw many things at NxOgre/PhysX and it should handle it. When you mean custom terrain do you mean racetrack type terrain or the terrain you go strolling across fields with? The latter can be read by NxOgre (as an image or RAW) and visually represented with one of the many terrain scene managers we have with Ogre, else you can just save it out as a mesh and NxOgre will read it in.
b)
NxOgre doesn't support PML.
We have a serialisation interface that can load COLLADA and XML generated by the 3DS and Maya PhysX exporters. Unfortantly they do not support embedding of the mesh data or anything to do with NxOgre's needed information (entities filenames and scenenode structure). So when you save your layout of the race track, you'll have to export the models with it, usually with oFusion or something similar to turn them into an Ogre mesh.
Once you loaded the COLLADA/XML files into NxOgre, you won't see anything on the screen, you'll have to re-save them out as "JSON" file, which is NxOgre's favourite format. You can hand-edit it in Notepad easily to attach which Ogre mesh goes to with Actor, then load it back in. It'll work then.
Unfortantly this is the best we have at the moment; without a dedicated JSON exporter for 3DSMax or Maya, or some sort of Editor.
frier
15-08-2007 14:46:38
Hi betajaen,
a)
its set to be a race track type field at the moment, pretty flat with some jumps and platforms.
So from my understanding of what your saying is i can load the collision mesh from 3ds of the terrain into an Actor/body for the terrain. Is there a limit to the amount of polys/vertices a collision mesh should be?
b)
Ok sweet.. that sounds great.. ill go find myself the 3ds exporter, update my NxOgre to the serialisation release and go from there!
Thanks betajean!
FrieR
betajaen
15-08-2007 14:56:14
a.
Nothing over the top. But things like jumps (say flat pieces coming out of the ground) could be cubes on an angle. Just don't use the same mesh you use for seeing the racetrack as with NxOgre. Six triangles on flat slope may seem pretty but PhysX would prefer two. In other words optimise.
b.
It'll get better in future versions.
frier
15-08-2007 15:07:21
You're a legend betajaen. Everyone knows it, I'm just saying it!
frier
12-09-2007 10:58:16
another question on this topic.
Ive just got a basic collision mesh and terrain from my artist but the collision is acting werid.. as in the collison is occuring around 20-30 meters above the visual mesh.
mScene->createBody("CollisionMesh.mesh",new NxOgre::ConvexShape("CollisionMesh.mesh"), NxOgre::Pose(Ogre::Vector3(0,20,0)),"static: yes, scale: 1 1 1, group: world");
hopper = new BugActor("racecar.mesh",mScene,new CubeShape(1,1,3),NxOgre::Pose(Vector3(0,100,-30)),this->mInputHandler->mInputManager,"mass: 1000, group: bugz");
So what i did was use the collision mesh as the Visual mesh as well as the collision mesh(as you can see in the above pictures) to see if the collision mesh wasn't out of whack.
The car is definitely colliding with the terrain because i used the bodys trigger code to set the terrain red once its collided with the terrain.
I'm just wondering if anyone knows what im doing wrong in this case. Why are my collisions occurring so high above?
p.s. the collision mesh is made from triangular polygons.
im using:
Ogre:: Shoggoth (1.5.0)
nxOgre:: 0.9(33)
PhysX::PhysX_2.7.2_SDK_Core.exe
betajaen
12-09-2007 11:03:03
I'm a little confused, the convex mesh is your terrain? Or you have some terrain code somewhere else which isn't in the snapshot. I noticed the convex mesh code is 20 metres higher than 0. Is it that?
Betajaen, needs more information.
frier
12-09-2007 11:30:12
Um in that previous pic, the Convex Mesh is also my terrain. i have another mesh thats alot more complicated for the terrain but im not using it because im having problems.
yeah i put it 20 metres high so it sits well above the floor mesh thats default to cakebox. I set the y to 0 on the
Pose(Ogre::Vector3(0,20,0)) TO Pose(Ogre::Vector3(0,0,0))
and the collision seems to STILL occur a fair distance above the Terrain.
basically i want to know if im doing correct coding to implement the collision mesh using a body and all the params are right. seems like the collision mesh is offsetting above the terrain mesh? i uploaded the collision mesh also.
Mesh And
Material
i wish my new PC arrived so i could do some remote debugging.
FYI.. this is a picture of my terrain mesh. was made in like 30 minutes.
i should resize these.
betajaen
12-09-2007 11:38:06
Alrighty. I'll finish what I'm doing with NxOgre (which involves convexes funnily enough) and have a fiddle.
betajaen
12-09-2007 21:44:41
mScene->createBody("test; CollisionMesh.mesh", new TriangleMeshShape("CollisionMesh.mesh"), Vector3(0,0,0), "static: yes");
The meshes seem to line up perfectly with me. However I am using a TriangleMesh shape, which it should be, Convexes will not work like that. Because they are convex not concave.
Also, you can remote debug on your computer. You just have to alt-tab between them, like I do
p.s. Are you making some sort of modern version of stunt car racer by any chance?
frier
12-09-2007 22:56:37
I just did a quick test and TrangleMeshShape seems to work fine!
lol, stunt car racer, yeah i actually got some of the ideas of the track from stunt car racer. that was a cool game, think i was playing it on the Amiga when i was very young.
The non-detailed textures make it look even more like it!
I might have to make it after i do this project now

.
Memories