Problem creating character

Rez

08-06-2008 11:32:03

Hello, i've been searching around and i can't seem to find the solution for this specifically. I am creating an FPS kind of game. I think it is best to use character for my player and also for my enemies. Now i am doing the player.
Here is how my code looks like...

NxOgre::Character *mPlayer; // player
NxOgre::CharacterParams mParams; // player params

mParams.setToDefault();

// when i run the app i get error on this line
mPlayer = mScene->createCharacter("Player", NxOgre::Pose(0, 200, 0), mParams);

The error i get is this...
Unhandled exception at 0x00687155 (NxOgre_d.dll) in App.exe: 0xC0000005: Access violation reading location 0x00000000.

Something to do with the dll, but I build NxOgre without any problems. According to the changes.txt, the NxOgre version is 0.9-38 and the PhysX version is Ageia PhysX SDK 2.7.2. Please help.

fatpwnage

08-06-2008 14:31:58

Are you sure that mScene is initialized?

Rez

08-06-2008 15:29:41

Yes i have those...

NxOgre::World *mWorld;
NxOgre::Scene *mScene;

NxOgre::Character *mPlayer;
NxOgre::CharacterParams mParams;

mWorld = new NxOgre::World ();

mScene = mWorld->createScene ("myScene", mSceneMgr, "gravity: 0 -980 0, floor: yes");

mParams.setToDefault();
mPlayer = mScene->createCharacter("Player", NxOgre::Pose(0, 200, 0), mParams);

I am able to create body and actor with this code but i just can't create the character.

xadh00m

09-06-2008 09:55:59

I got the same problems. For two reasons in the past. The first reason was I did not set the parameter to default (you did that right) and the second reason was, I used not corresponding libs/dll...

LFMS

09-06-2008 14:37:40

try to do this

CharacterParams cp;
cp.setToDefault();
cp.mType = CharacterParams::CT_Box;
cp.mDimensions.set(0.5f, 2.0f, 0.5f);
cp.mSkinWidth = 1.0f;

here is working

Rez

09-06-2008 18:15:19

i'm sorry. It is still not working. i get the same error. I managed to go deeper and see at the point of the crash.

In NxOgreCharacter.h:

96|mNxActorUserData = new NxActorUserData(this, NxActorUserData::T_Character);
97|mCharacter->getActor()->setGroup(0);
98|mCharacter->getActor()->userData = mNxActorUserData;
99|mCharacter->setCollision(true);

It crashes at line 97.

betajaen

09-06-2008 18:24:52

Then the character wasn't created, probably due to an invalid NxCharacterControllerDesc. Is there any errors in the log or console window related to this?

Rez

10-06-2008 05:02:24

There are two errors shown in the NxOgre.log...


NxOgre::Error::reportError#78T0 F0

PhysX Error (NXE_INVALID_PARAMETER) 'Actor::loadFromDescInternal: Can't compute mass from shapes: must have at least one non-trigger shape!' in line 388 of g:\scm\release\PhysX_2.7.2\novodex\SDKs\Physics\src\Actor.cpp


NxOgre::Error::reportError#78T0 F0

PhysX Error (NXE_INVALID_PARAMETER) 'Actor Initialisation failed: returned NULL.' in line 776 of g:\scm\release\PhysX_2.7.2\novodex\SDKs\Physics\src\NpScene.cpp

xadh00m

10-06-2008 08:41:27

Try to add "mass: 100" to your params. But normally there should be a default value.

By the way is gravity -980 a valid value? Betajaen?

Rez

10-06-2008 11:55:20

No..That didn't work neither..

betajaen

10-06-2008 13:10:07

PhysX Error (NXE_INVALID_PARAMETER) 'Actor Initialisation failed: returned NULL.' in line 776 of g:\scm\release\PhysX_2.7.2\novodex\SDKs\Physics\src\NpScene.cpp

That's your problem of the Character or another actor. Let's see your Character code again.

@xadh00m

It's extremely high. It's four times higher than the sun.

Rez

10-06-2008 14:24:40

Here is everything from start to end...

NxOgre::World *mWorld;
NxOgre::Scene *mScene;

mWorld = new NxOgre::World ();

mScene = mWorld->createScene ("myScene", mSceneMgr, "gravity: 0 -980 0, floor: yes, renderer: ogre");

// Create a box
mCube = mScene->createBody ("box.mesh"
,new NxOgre::CubeShape (100.0f) // Collision Model
,Vector3 (0,200,0) // starting position
,"density: 0.00785");

// create a character
NxOgre::Character *mCharacter = 0;
NxOgre::CharacterParams mCP;
mCP.setToDefault();

mCharacter = mScene->createCharacter("Player", NxOgre::Pose(0, 50, 0), mCP);

// create a sphere
NxOgre::Body *mSphere = 0;

// add a sphere in the game
mSphere = mScene->createBody ("sphere.mesh"
,new NxOgre::SphereShape(100.0f) // Collision Model
,Vector3 (10,200,0) // starting position
,"density: 0.00785");

From this code I am able to create the cube. Debug will crash when creating the character. Commenting the create character line will allow me to create the sphere successfully.

betajaen

10-06-2008 14:37:39

Do what LFMS said:

try to do this

CharacterParams cp;
cp.setToDefault();
cp.mType = CharacterParams::CT_Box;
cp.mDimensions.set(0.5f, 2.0f, 0.5f);
cp.mSkinWidth = 1.0f;

here is working

Rez

11-06-2008 03:18:50

Ok, my code now looks like this...

NxOgre::World *mWorld;
NxOgre::Scene *mScene;

mWorld = new NxOgre::World ();

mScene = mWorld->createScene ("myScene", mSceneMgr, "gravity: 0 -980 0, floor: yes, renderer: ogre");

// Create a box
mCube = mScene->createBody ("box.mesh"
,new NxOgre::CubeShape (100.0f) // Collision Model
,Vector3 (0,200,0) // starting position
,"density: 0.00785");

// create a character
NxOgre::Character *mCharacter = 0;
NxOgre::CharacterParams cp;
cp.setToDefault();
cp.mType = CharacterParams::CT_Box;
cp.mDimensions.set(0.5f, 2.0f, 0.5f);
cp.mSkinWidth = 1.0f;

mCharacter = mScene->createCharacter("Player", NxOgre::Pose(0, 50, 0), cp);

// create a sphere
NxOgre::Body *mSphere = 0;

// add a sphere in the game
mSphere = mScene->createBody ("sphere.mesh"
,new NxOgre::SphereShape(100.0f) // Collision Model
,Vector3 (10,200,0) // starting position
,"density: 0.00785");

It still crashes at the same place with the same error. I tried changing the type to CT_CAPSULE I would still get the same error.

xadh00m

11-06-2008 09:41:52

hmmm...
Did you test this code snippet in Cake with the same libs?

PhysX Error (NXE_INVALID_PARAMETER) 'Actor Initialisation failed: returned NULL.' in line 776 of g:\scm\release\PhysX_2.7.2\novodex\SDKs\Physics\src\NpScene.cpp

That's your problem of the Character or another actor. Let's see your Character code again.

@xadh00m

It's extremely high. It's four times higher than the sun.


Correctly spoken its a very low value, isn´t it? Is it right to set a negative value? I currently use 9.81.