Programming error : A so stupid user cannot use NxOgre !

SniperBinaire

24-05-2010 11:16:42

Well, i'm coming here to put on your mind an another problem quite strange

Here is some poor information on my system
-Ogre 1.7.1 midnight compiled from source using VC9
-Windows Xp Sp3
-PhysX 2.8.1 with PhysX System Software properly installed (PhysX samples works fine)
-NxOgre 1.5.5 Bloody Mess
-Unreal Tournament 3 (Useless here)

My code is compiled and linked fine. !
But....
The problem is just that the program crash when he reach the mTimeController->advance(); command.
Hopelessly the log don't tell me anything, as a violent crash, no exception, no visible error, just th classical and useless Xp error window
I must precise a few things :
- Compiling Cake is quite a task because i get a lot of errors from the compiler, so I lean how NxOgre work with his source code only, added to all tutorials i've founded. (Official Website and Wiki's ones)
- i use the terrain scene manager, combinated with SkyX, Hydrax and in the future i will implement Paged Geometry

Here is how i start NxOgre (Headers are inclued in a global included file)

// ==================
// Set up PhysX
// ==================

NxOgre::World* mWorld;
NxOgre::Scene* mScene;
OGRE3DRenderSystem* mRenderSystem;
NxOgre::TimeController* mTimeController;

mTimeController = NxOgre::TimeController::getSingleton();
mWorld = NxOgre::World::createWorld();

// Create scene description
NxOgre::SceneDescription scndesc;
scndesc.mGravity = NxOgre::Vec3(0, -9.8f, 0);
scndesc.mName = "NamuhScene";

// Create scene
mScene = mWorld->createScene(scndesc);

// Set some physical scene values
mScene->getMaterial(0)->setStaticFriction(0.5);
mScene->getMaterial(0)->setDynamicFriction(0.5);
mScene->getMaterial(0)->setRestitution(0.1);
// Create render system
mRenderSystem = new OGRE3DRenderSystem(mScene);

OGRE3DBody* mCube;
mCube = mRenderSystem->createBody(new NxOgre::Box(50, 50, 50), NxOgre::Vec3(40000,600,39500), "Cube.mesh");


And I'm updating the real world with this holy commands (The Holy one that make me get a crash)

mTimeController->advance();

betajaen

24-05-2010 11:27:48

Your getting a null pointer exception.

Swap these lines around:

mTimeController = NxOgre::TimeController::getSingleton();
mWorld = NxOgre::World::createWorld();

SniperBinaire

24-05-2010 12:19:33

Ok, it works Perfectly !
Many thanks !
I now can reach my destiny....

SniperBinaire

26-05-2010 07:50:19

Ok, now it works just fine

But I'm wondering now how to get hydrax in Nxogre (Or a simple water plane effect)

Just to simulate the flotability of my boat, because object are just passing trought my ocean...
So if you have an idea, it will be very helpfull

betajaen

26-05-2010 10:39:30

Remember, if you put anything in Ogre. You have to put something in NxOgre to match it.

You need a "volume" my friend which the size of the hydrax plane (and below it), then in the volume callback, you have to write the code to simulate buoyancy.

The code to simulate buoyancy is a bit difficult if you don't understand physics, but there is plenty of articles on the web explaining it.

And this wiki page will explain how to use Volumes, it even has code to reduce or remove gravity per Actor -- which you will need in your buoyancy code. ;)

SniperBinaire

29-05-2010 20:25:32

The difficult part is to calculate the center of this force
Because if i take the gravity center, stability will not depends of the object shape or his orientation

And I've seen to function to calculate a volume (Witch will be useful for a precise Archimedes force)
So I can't use it to calculate the center of the underwater part of the object, needed to put my force