terrain problem

Romep

03-01-2008 00:19:56

hello,

i just tried to add some terrain to nxogre, but it doesnt work -.-
the ninja always falls through the terrain


mWorld = new NxOgre::World("log:html, framelistener: yes");

mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));


NxOgre::Scene* mScene = mWorld->createScene("myScene", mSceneMgr, "gravity: yes, floor: yes");

// load the terrain
mSceneMgr->setWorldGeometry("jungle1.cfg");
mScene->createActor("terrain", new NxOgre::TerrainShape("jungle1_HM.png", 100), Vector3::ZERO, "static: yes");

NxOgre::Body* actor = mScene->createBody("ninja;ninja.mesh", new NxOgre::TriangleMeshShape("ninja.mesh"), Vector3(80, 80, 100), "mass: 10, node-scale:0.025 0.025 0.025");


any posts on these forums obviously use an outdated constructor, so they didnt help me a lot :(

SiWi

03-01-2008 09:54:46

Try to add a mesh-scale as last parameter in the constructor of the TerrainShape. Use PageWorldX/XSizeofheightmap and PageWorldZ/>Sizeofheightmap for X and Z scale.
For example:
pageworldx and and pageworldy are 100. your heightmap has an size of 50*50.
new NxOgre::TerrainShape("jungle1_HM.png", 100,"mesh-scale:2,1,2")

Romep

03-01-2008 10:26:36

this is my code from the terrain config file:

# The size of a terrain page, in world units
PageWorldX=1024
PageWorldZ=1024
# Maximum height of the terrain
MaxHeight=100


the heightmap is a 2049x2049 pixel image. so i used
mScene->createActor("terrain", new NxOgre::TerrainShape("jungle1_HM.png", 100, "mesh-scale: 0.5, 1, 0.5"), Vector3::ZERO, "static: yes");

and it still doesnt work -.-

betajaen

03-01-2008 11:05:50

The vertical position of the terrain needs to be half the maximum height; in your case 50.

Romep

03-01-2008 11:08:06

edit: sorry vertical position should be:


mScene->createActor("terrain", new NxOgre::TerrainShape("jungle1_HM.png", 100, "mesh-scale: 0.5, 1, 0.5"), Vector3(0, 50, 0), "static: yes");

but it still doesnt work?

betajaen

03-01-2008 11:31:23

Are you sure you've got the scale right? And have you checked if it looks okay in the remote debugger?

Romep

03-01-2008 12:17:58

the remote debugger looks like a useful tool, but my app doesnt start if i create the terrain.

what i did:

1. start remote debugger
2. add mWorld->getPhysXDriver()->createDebuggerConnection();
3. start app -> crashed


then i commented out the terrain line in my app and it starts fine. NxOgre.log says:

<div class="log debug">
<h2>NxOgre::PhysXDriver::PhysXDriver#142<small>T0 F0</small></h2>
<pre><code>NxOgre (NxOgre 0.9-38) Started, working with:

- PhysX =&gt; 2.7.3
- Ogre =&gt; 1.4.5 'Eihort'
- Platform =&gt; Windows
</code></pre>
</div><div class="log debug">
<h2>NxOgre::RemoteDebuggerConnection::RemoteDebuggerConnection#40<small>T0 F0</small></h2>
<pre><code>Remote Debugger Connected
- localhost:5425
</code></pre>
</div><div class="log warning">
<h2>NxOgre::Error::reportError#78<small>T0 F0</small></h2>
<pre><code>PhysX Error (NXE_DB_WARNING) 'HeightField::load: vertical extent is deprecated. Use thickness!' in line 58 of g:\scm\release\PhysX_2.7.3\novodex\SDKs\Core\Common\src\HeightField.cpp
</code></pre>
</div>



edit: furhter information:

Exception is in NxOgre.dll, nxogreuserallocator.cpp, line 223 which is:


blockStart[0] = 0xDeadBabe;

dbrock

03-01-2008 22:11:37

My terrain code:
Ogre::AxisAlignedBox terrainAAB = mTerrainInfo->getExtents();
Ogre::Vector3 min = terrainAAB.getMinimum();
Ogre::Vector3 max = terrainAAB.getMaximum();
Ogre::Vector3 center = terrainAAB.getCenter();

Ogre::Vector3 terrainSize = Ogre::Vector3(
fabs(max.x - min.x), //x
fabs(max.y - min.y), //y
fabs(max.z - min.z) //z
);

Ogre::Vector3 terrainScale = Ogre::Vector3( (terrainSize.x / 129.0f), ( 1.0f ), (terrainSize.z / 129.0f) );

NxOgre::ShapeParams shapeParams;
shapeParams.setToDefault();
shapeParams.mMeshScale = NxVec3( terrainScale.x, terrainScale.y, terrainScale.z );

NxOgre::ActorParams actorParams;
actorParams.setToDefault();
actorParams.mMass = 0.0f;
actorParams.mDensity = 0.0f;
actorParams.mLinearDamping = 0.75f;
actorParams.mAngularDamping = 0.75f;
actorParams.mNodeScale = terrainScale;

NxOgre::ShapeBlueprint *shapeBluePrint = new NxOgre::TerrainShape( filename, terrainSize.y, shapeParams );

NxOgre::Actor* terrainActor = mPhysScene->createActor(
"Terrain", // ID
shapeBluePrint, // Shape blueprint
NxOgre::Pose( Ogre::Vector3::ZERO, Ogre::Quaternion::IDENTITY ), // Pose
actorParams // Parameters
);

SiWi

04-01-2008 09:08:05

I can´t help you with the Debugger, but try to set the vertical position to 1.
I don´t know why, but that works for me instead of setting it to 50.

Romep

07-02-2008 17:50:09

still the same problem here :-(

now i use the createTerrainFromWorldGeometry function written by betajaen in the code snippets thread. "good thing": the debugger obviously works with the ogre sample terrain.cfg but not with my terrain. but the debugger doesnt show the terrain. only the standard plane floor below the terrain so that my ninja falls through the terrain.


void myApp::createScene(void) {
mWorld = new NxOgre::World("log:html, framelistener: yes");
mWorld->getPhysXDriver()->createDebuggerConnection();

mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));


NxOgre::Scene* mScene = mWorld->createScene("myScene", mSceneMgr, "gravity: yes, floor: yes");

createTerrainFromWorldGeometry("terrain.cfg", mScene);

NxOgre::Body* actor = mScene->createBody("ninja;ninja.mesh", new NxOgre::TriangleMeshShape("ninja.mesh"), Vector3(80, 80, 100), "mass: 10, node-scale:0.025 0.025 0.025");
}

SiWi

08-02-2008 09:03:17

You create your ninja with a triangle shape. Those are only working with static bodies. Use convex shape instead.

Romep

08-02-2008 10:00:30

Yes, right. the trianglemesh always falls through the terrain and the convexshape doesnt. but the convexshape doesnt look like the ninja ... its a lot bigger and looks a little bit like a diamond. so i think thats not the right way ...

so how do i get a pretty good shape for a player? i also want to keep in mind, that - later - i want to know where a bullet or rockt or whatever hit the player (leg, arm, head). i think that a collision detection like that can be done with nxogre but i have to read a little bit more about that.


edit: are there any more tutorials i can read? just found the uncomplete shortguide.

SiWi

08-02-2008 10:56:53

No there aren´t any more tutorials. Play around with Cake.
This leg, arm, head collision means that u want a ragdoll.
Search in the forum for it.