Physics engine and dynamic heightmaps

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
bymulker
Kobold
Posts: 36
Joined: Sat Mar 12, 2005 10:45 am

Physics engine and dynamic heightmaps

Post by bymulker » Tue Apr 05, 2005 9:53 am

Greetings

I'm learning the basics of Ogre and integrating Newton with Ogre. I know there are several pre-built libraries like Newt, Ogretok etc. but as i know they dont handle the dynamic heightmap loading issue.

As far as i know, when a terrain is loaded by setWorldGeometry method, it is loaded from a raw file and the pages are dynamically loaded (requested) . In one of the threads walaber said the terrain should be loaded at the heighest LOD and sent to Newton (or tokamak whatever). Then what is the use of dynamically loading the terrain? :)

I thought of dynamically sending the objects to physics engine by
TerrainPageSourceListeners pageConstructed method but that seems
tricky;

Say i have a physical cube body and i throw it to somewhere at which pages are not loaded. Bam! it goes to nowhere! :) Does anyone have any idea?

Paging landscape scene manager at http://tuan.kuranes.free.fr/Ogre.html
hmm i shall have a look at..

Regards.
0 x

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Post by :wumpus: » Tue Apr 05, 2005 10:50 am

Paging is not really useful for physics. You would want, depending on the type of game, either

a) load the entire landscape at a lower resolution into your physics engine at the beginning, so that physics can occur throughout the entire map

b) disable physics on pages that are not near the player (not loaded)
0 x

User avatar
psyclonist
OGRE Expert User
OGRE Expert User
Posts: 286
Joined: Fri Nov 01, 2002 3:54 pm
Location: Berlin & Nuremberg, Germany
Contact:

Post by psyclonist » Tue Apr 05, 2005 11:41 am

You can implement paging analogue to the graphics. I did this for a little prototype of a car demo with the paging landscape scene manager. Physics pages of lower resolution were swapped in and out as necessary (depending on distance and whether important physics objects were still there...). It worked pretty nice and you could drive around in really large environments...

Paging helps to keep the memory profile low. Even though the physics data's memory footprint is way smaller than the graphics equivalent it may still be impossible to preload all pages.

-psy
0 x

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Post by :wumpus: » Tue Apr 05, 2005 11:45 am

psyclonist wrote: Paging helps to keep the memory profile low. Even though the physics data's memory footprint is way smaller than the graphics equivalent it may still be impossible to preload all pages.
I was refering to this:
Say i have a physical cube body and i throw it to somewhere at which pages are not loaded. Bam! it goes to nowhere! Smile Does anyone have any idea?
*if* you do paging for physics you have to make sure you run physics only on the pages that are actually loaded.

In, for example. a racing game that wouldn't make sense :) The AIs cars would never catch up with you as they get frozen in time outside the screen area.
0 x

User avatar
psyclonist
OGRE Expert User
OGRE Expert User
Posts: 286
Joined: Fri Nov 01, 2002 3:54 pm
Location: Berlin & Nuremberg, Germany
Contact:

Post by psyclonist » Tue Apr 05, 2005 1:45 pm

I totally agree. Sorry for not having made my point clear enough before. I think, we're quite d'accord ;)

-psy
0 x

User avatar
monster
OGRE Community Helper
OGRE Community Helper
Posts: 1098
Joined: Mon Sep 22, 2003 2:40 am
Location: Melbourne, Australia
Contact:

Post by monster » Tue Apr 05, 2005 2:56 pm

The OgreOde terrain collision primitive uses the ray queries provided by the terrain scene manager to provide you with accurate physics collisions without paging, or indeed any memory overhead at all.

You might need to hack around with it a bit to get it to work with the PLSM, but if that supports ray queries outside of loaded pages (i.e. it loads them when you query them, or something) then the collision primitive will be able to make use of that automagically. If not, then it won't!
;)
0 x

bymulker
Kobold
Posts: 36
Joined: Sat Mar 12, 2005 10:45 am

Post by bymulker » Tue Apr 05, 2005 4:48 pm

Thank you all for the answers. Well, i got excellent results integrating Newton to ogre (as i'm going step by step i didnt launch walaber's great library) .
Oh yes i shall have a look at PLSM2. It splits arbitrarily large scenes into a set of pages which have their own heightmap. Then these heightmaps could be safely passed to physics engine.

I tried to get the heightmap by the following code but as mPagingEnabled was = 0 the getHeightAt method returned -1. Whats the problem? Is it because no paging is loaded at the beginning of the program?
I set World geometry by; mSceneMgr->setWorldGeometry( "terrain.cfg" );

My 'attempt' to get heightmap :

TerrainSceneManager* SceneMgr = (TerrainSceneManager*) mSceneMgr;

int page_size = SceneMgr->getPageSize();
float h;

Vector3 scale = SceneMgr->getScale();
Vector3 page_dim(page_size*scale.x,scale.y,page_size*scale.z);

for(float x = scale.x; x < page_dim.x; x += scale.x)
{
for(float z = scale.z; z < page_dim.z; z += scale.z)
{
h = SceneMgr->getHeightAt(x, z);

}

}
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Post by jacmoe » Tue Apr 05, 2005 5:42 pm

I think you are trying to use the standard terrainscenemanager.
The PLSM2 is from ogreaddons - and use a different cfg-file. Read about it on the Wiki. :wink:
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber » Tue Apr 05, 2005 7:23 pm

also, have a look at the "UserMeshCollision" primitive available in Newton... it allows you to handle collision geometry in your own way, by providing callbacks that give Newton lists of polygons given a specific bounding box. basically Newton asks: give me all polygons that intersect a specific AABB, and then it handles the collision from there.

for things like a heightfield, it's great because there's no wasted memory in re-creating the terrain in memory just for the physics.

bacsically you will need a way to convert an AABB into a list of triangles / polygons that you can send to newton. even if the scene manager doesn't include this by default, it shouldn't be too complicated seeing as the terrain is just a grid of points..

I've been wanting to try and get this working with Newton for a while, but have never quite gotten around to it... :)
0 x
Go Go Gadget OGRE!!
Image

Post Reply