[Solved]Terrain ag,bodies fall as the terrain does not exist

lexchou

15-08-2007 13:27:22

PhysX SDK: 2.7.2
NxOgre: 0.9-33 (from SVN)
OGRE: 1.4.3(Eihort)


Bodies fall through the terrain, and stoped under a certain distance below the terrain.
Here's my code:

SceneManager *sceneMgr=root->createSceneManager("TerrainSceneManager","Main");
Camera *camera=sceneMgr->createCamera("MainCamera");
NxOgre::World * world=new NxOgre::World();
NxOgre::Scene * scene=world->createScene("Main",sceneMgr,"gravity: yes, floor: yes");
....................................
sceneMgr->setWorldGeometry("terrain.cfg");
scene->createBody("terrain",new NxOgre::TerrainShape("terrain.png", 100, "material:terrain_texture.jpg"),Vector3::ZERO,"static: yes");


The terrain.cfg comes from Ogre DEMO(I removed some comments in the following code):

WorldTexture=terrain_texture.jpg
DetailTexture=terrain_detail.jpg
DetailTile=3
PageSource=Heightmap
Heightmap.image=terrain.png
PageSize=513
TileSize=65
MaxPixelError=3
PageWorldX=3000
PageWorldZ=3000
MaxHeight=100
MaxMipMapLevel=5
VertexProgramMorph=yes
LODMorphStart=0.2



I've searched in this forum, many guys got the same fucking problem, some of them solved, and some not. none of those posts can help me.

For those posts here about the same problem, their NxOgre::TerrainShape's constructor accepts many parameters, but my SVN version NxOgre only accepts three, is the problem happened due to the lack of some important parameters? maybe not, but I don't understand why this code doesn't work. :shock:

Thank you what ever helped me solved this problem.

betajaen

15-08-2007 14:11:16

Don't swear. The Terrain code treats one pixel as one metre by default, you can override this and introduce a scale.

So say your image is 512x512 and you want it to be 1024x1024 then 2 1 2, or 3000x3000 then 5.859375 1 5.859375.

scene->createBody("terrain",new NxOgre::TerrainShape("terrain.png", 100, "mesh-scale: 2 1 2"),Vector3::ZERO,"static: yes");

Also you don't need "material:terrain_texture.jpg", infact it doesn't do anything at all.

lexchou

15-08-2007 14:36:06

Wow, that works, thank you ! :D

betajaen

15-08-2007 14:40:11

Glad to hear.

Oh, use createActor instead of createBody with terrain. It's slighty faster.