ETM and NxOgre?

kungfoomasta

13-02-2008 07:39:20

How do you create a terrain shape (actor) from terrain created by ETM? I'm assuming you just need the heightmap and terrain dimensions, right? I'm using a .raw file. If anybody could post code or point me to where to look it would be greatly appreciated.

betajaen

13-02-2008 11:19:00

Roughly it goes:

mScene->createActor("terrain", new TerrainShape("terrain.raw", 100, "mesh-scale: 2 1 2", Vector3::ZERO, "static: yes");

"100"

Half the maximum height of the terrain.

"2 1 2"

Is the scale of the mesh. Using the normal Ogre terrain code we use this formula.

x = PageWorldX/XSizeofheightmap (1024 metres across / 512 px image)
y = 1
z = PageWorldZ/YSizeofheightmap (1024 metres across / 512 px image)

For ETM it's the same you just need to get those values from ETM and not the terrain.cfg file.

kungfoomasta

13-02-2008 18:05:04

I see a red bounding box which I think outlines the heightmap shape, is there a way to render a more detailed debug shape, so I can see how to come up with the correct offset of the shape, to sync with the terrain?

betajaen

13-02-2008 18:29:12

The DebugRenderer should do the trick (if your not using it already) otherwise you may be able to judge the distances (if you use a third actor as a point of reference) with the Remote Debugger.

But as it stands the terrain most up/left corner is at 0,0 and comes out the X+, Z+ direction (I think), if ETM is making the terrain centered or in an odd position you may be in for some rough times. ;)

kungfoomasta

13-02-2008 18:38:40

You're exactly right, ETM centers the terrain. I actually prefer centering of the terrain instead of 0,0 in the corner. But the downside is that I have to figure out how much to offset the shape so that its in sync with the rendered terrain. I'm also wondering if ETM and TSM create terrain differently, maybe a difference of clockwise/counter clockwise winding for polygon creation.

I'll run some tests tonight, hopefully I figure this out.

- Which nxOgre file lists all the options used for visual debug display? Is there something like NX_VISUALIZE_ALL_SHAPES? I can see capsules, cubes, and spheres, but only a box for the heightfield shape..

betajaen

13-02-2008 19:07:38

I prefer a centered terrain myself (it makes more sense), however centering the terrain actor is beyond easy so we don't have to worry about that.

It's in the PhysX Documentation or you can use intellisense to find the enum (NX_VISUALIZE), you just set the parameter via:

mWorld->getPhysXDriver()->getSDK()->setParameter(NX_VISUALIZE_xxx, 1);

But as far as I'm aware terrain shows up in the debug renderer.

kungfoomasta

13-02-2008 21:35:31

According to NxHeightFieldShape.h these are the visualization flags related to the HeightFieldShape:


<h3>Visualizations:</h3>
\li #NX_VISUALIZE_COLLISION_AABBS
\li #NX_VISUALIZE_COLLISION_SHAPES
\li #NX_VISUALIZE_COLLISION_AXES
\li #NX_VISUALIZE_COLLISION_VNORMALS
\li #NX_VISUALIZE_COLLISION_FNORMALS
\li #NX_VISUALIZE_COLLISION_EDGES
\li #NX_VISUALIZE_COLLISION_SPHERES


Just wanted to post this up so others might find it useful.