Terrain collision

Tibo6

25-06-2010 20:38:29

Hello,

I created a map with a software (Ogitor). I have 2 pages in my terrain.
To make it collidable I did this :

TerrainGroup::TerrainIterator terrainIterator = m_sceneLoader->getTerrainGroup()->getTerrainIterator();
while(terrainIterator.hasMoreElements())
{
Terrain* terrain = terrainIterator.getNext()->instance;
m_physicRenderSystem->createTerrain(terrain);
}

I have also missile which move with NxOgre.
My terrain has lakes and the collision is done like if the terrain is flat. The same thing goes with montains.
Do you understand what I mean?
So, what is wrong please?

Thanks.
Bye.

Tibo6

27-06-2010 17:49:35

Hello hello ? :)

Tibo6

30-06-2010 18:43:17

Ok I tried something else.
I used this code here but I have an error on "OGRE_NEW_T" unfortunately :(
I really don't see what's the problem.

betajaen

30-06-2010 18:50:16

No need to "new/delete" manual objects, just keep it on the stack.

Tibo6

30-06-2010 19:07:29

I also tried this.
You mean this

NxOgre::ManualHeightField mhf;

instead of

NxOgre::ManualHeightField *mhf = OGRE_NEW_T(NxOgre::ManualHeightField, Ogre::MEMCATEGORY_GENERAL)();
?

I tried. But my program crash (yes, I deleted the "delete" instruction :D )

I call my function like this :

while(terrainIterator.hasMoreElements())
{
Terrain* terrain = terrainIterator.getNext()->instance;

if(! terrain)
continue;

loadTerrainGeometry(terrain->getMaterialName(), terrain->getHeightData(), terrain->getSize(), terrain->getWorldSize(), terrain->getMinHeight(), terrain->getMaxHeight(), terrain->getPosition());
}


But my first code should works no ?

TerrainGroup::TerrainIterator terrainIterator = m_sceneLoader->getTerrainGroup()->getTerrainIterator();
while(terrainIterator.hasMoreElements())
{
Terrain* terrain = terrainIterator.getNext()->instance;
m_physicRenderSystem->createTerrain(terrain);
}

Tibo6

01-07-2010 12:58:06

Apparently the code from here, it's this instruction which crash :

NxOgre::HeightField *hf = mhf.end(name.c_str());

I also tried this :

NxOgre::HeightField *hf = mhf.end();

But still doesn't work :(

betajaen

01-07-2010 13:03:27

"end" is a pretty big function and does a lot of things. Can you trace it more?

Sounds like though PhysX had a problem with the sample data. The code snippet you've used is a well used one so that can't be the problem. Are you passing/using on any null or invalid pointers?

Also is this Detritus or BloodyMess?

Tibo6

01-07-2010 13:22:36

Well I log a message before and after this instruction to know that she doesn't work.

I use this code to call my function, so I think I am not using null or invalid pointers.


TerrainGroup::TerrainIterator terrainIterator = m_sceneLoader->getTerrainGroup()->getTerrainIterator();
while(terrainIterator.hasMoreElements())
{
Terrain* terrain = terrainIterator.getNext()->instance;

if(! terrain)
continue;

loadTerrainGeometry(terrain->getMaterialName(), terrain->getHeightData(), terrain->getSize(), terrain->getWorldSize(), terrain->getMinHeight(), terrain->getMaxHeight(), terrain->getPosition());
}


What surprise me is that the "end" instruction have a first parameter (a bool) and the code snippet give a "char *" and VS doesn't cry xD
But I also tried with no parameters and the result is the same.

Finally, I use Detritus :)

Tibo6

06-07-2010 17:31:24

Hello,

Still stuck. I don't know what to do.
So, Critter::RenderSystem::createTerrain works for somebody ?

Thanks.
Bye.

betajaen

06-07-2010 18:05:37

I believe the terrain code on the Wiki works. I didn't write it or even understand it, the one in Critter is based upon that code. So if it has bugs then the one in Critter will have the same bugs as well.

Tibo6

06-07-2010 18:31:31

I don't think that it is the wiki code which crash. In fact, yes, but it is one line, and she comes from NxOgre xD Did you change anything in this function recently?

NxOgre::HeightField *hf = mhf.end(name.c_str());

betajaen

06-07-2010 18:40:29

Not that I can recall. If you can trace the offending line within NxOgre then I could fix it.

Tibo6

07-07-2010 20:59:10

Ok, here are the messages returned :

[NxOgre/HeightFields] Attempting to cook to resource
[NxOgre/HeightFields] Attempting to read heightfield.
[NxOgre/HeightFields] load via CookingResource

And sometimes it changes, I have this :

[NxOgre/HeightFields] Attempting to cook to resource
[NxOgre/HeightFields] Attempting to read heightfield.

I just run my application two times. That's odd.

So, sometimes this crash I imagine :

hf = HeightFieldManager::getSingleton()->load(cookingResource);
or this :

if (cookingResource->getStatus() == Enums::ResourceStatus_Opened)
ResourceSystem::getSingleton()->close(cookingResource);

or

cookingResource->seekBeginning();
HeightField* hf = 0;
if (mHeightField->mName.length() == 0)


Good luck xD