Characters falling through floor

jchmack

03-01-2007 07:56:17


mScene->createStaticBody("characterBase","",new cubeShape(Vector3(1024,0.1,1024)),Vector3(0,-0.05,0));

//mScene->createStaticBody("stairs.1","int.mesh",new meshShape("int.mesh",mScene),pose(Vector3(0,3,0)));

blueprint<character> bp;
bp.setToDefault();
bp.setGravity(true);
bp.setSlopeLimit(45);
bp.setStep(0.3);
bp.setShapeAsCapsule(0.4,1.4);
bp.setMesh("");

mPlayer = bp.create("myCharacter",Vector3(0,7,0),mScene);
SceneNode *ninjaNode = mPlayer->mNode->createChildSceneNode();
Entity *ninjaEntity = mSceneMgr->createEntity("ninja","cube.1m.mesh");
ninjaNode->scale(0.4,2,0.4);
ninjaNode->attachObject(ninjaEntity);


Ive basically copy pasted the code from NXtutorial606.

When i uncomment the
mScene->createStaticBody("stairs.1","int.mesh",new meshShape("int.mesh",mScene),pose(Vector3(0,3,0)));

The new character collides and interacts with the stairs.1 mesh fine

but when i take them off he falls through the floor.

shouldn't the Static body characterBase catch him?
mScene->createStaticBody("characterBase","",new cubeShape(Vector3(1024,0.1,1024)),Vector3(0,-0.05,0));

or even after that shouldn't he just collide with the floor given by
mScene->hasFloor();
catch him?

What am i missing?

ive also tried bp.setGravity(false); But he still just falls through the floor.

DieHard

03-01-2007 08:50:30

I remember compiling and running the tutorial 606 two months ago, the character went right through the floor of the room. But, I didn't bother to report it or figure it out because the engine I'm developing hadn't reach that obstacle. I was just site-seeing through the tutorials.

The "hasFloor();" works. (Which, I see it being used for debugging and physics simulation.) The real floor is below the room's floor. Put the camera on "free/fly mode."

But yeah, I would like to know answer for the character falling right through the room's floor?

jchmack

03-01-2007 09:02:12

I remember compiling and running the tutorial 606 two months ago, the character went right through the floor of the room. But, I didn't bother to report it or figure it out because the engine I'm developing hadn't reach that obstacle. I was just site-seeing through the tutorials.

The "hasFloor();" works. (Which, I see it being used for debugging and physics simulation.) The real floor is below the room's floor. Put the camera on "free/fly mode."

But yeah, I would like to know answer for the character falling right through the room's floor?


I don't exactly see the real floor you are talking about i have the camera in free/fly mode and ive looked below both the world floor made by mScene->hasFloor(); .

And the mesh floor created by mScene->createStaticBody("stairs.1","int.mesh",new meshShape("int.mesh",mScene),pose(Vector3(0,3,0)));

The character base shouldn't have a visual representation because the second parameter is empty. (if this is the real floor you are talking about)
mScene->createStaticBody("characterBase","",new cubeShape(Vector3(1024,0.1,1024)),Vector3(0,-0.05,0));

By the way DieHard did you ever get NxOgre 0.4 RC3 to work in dagon? Last i read you were really close =). Im reading betajaen has done alot of work with the characters. Hopefully i can get this fixed before i gotta go back to class =).

betajaen

03-01-2007 11:23:35

The Floor is a tricky thing with the character; it's had that "feature" for many versions of PhysX now, and it's not just a NxOgre thing I've seen it with the CellFactor editor too, which says that the new Unreal Engine has/had the same problem.

I "fixed" it with a fake floor for the character to move upon which is the most easiest and sensible solution, however it your level of meshes and simple shapes that would make up the world would cover it up anyway.

jchmack

03-01-2007 12:36:15

The Floor is a tricky thing with the character; it's had that "feature" for many versions of PhysX now, and it's not just a NxOgre thing I've seen it with the CellFactor editor too, which says that the new Unreal Engine has/had the same problem.

I "fixed" it with a fake floor for the character to move upon which is the most easiest and sensible solution, however it your level of meshes and simple shapes that would make up the world would cover it up anyway.


well for now im just trying to get a character to move on a floor other than the "int.mesh" in tutorial606

so i never loaded that and just loaded a basic static object like a flat cube:
mScene->createStaticBody("characterBase","",new cubeShape(Vector3(1024,0.1,1024)),Vector3(0,-0.05,0));

so the only 2 objects in my scene are a static flat cube and the character. And the character still falls through the cube.


mScene->createStaticBody("characterBase","",new cubeShape(Vector3(1024,0.1,1024)),Vector3(0,-0.05,0));

blueprint<character> bp;
bp.setToDefault();
bp.setGravity(false);
bp.setSlopeLimit(45);
bp.setStep(0.3);
bp.setShapeAsCapsule(0.4,1.4);
bp.setMesh("");

mPlayer = bp.create("myCharacter",Vector3(0,7,0),mScene);
SceneNode *ninjaNode = mPlayer->mNode->createChildSceneNode();
Entity *ninjaEntity = mSceneMgr->createEntity("ninja","cube.1m.mesh");
ninjaNode->scale(0.4,2,0.4);
ninjaNode->attachObject(ninjaEntity);



can my character not stand on a new cubeShape? Because as long as i use a new meshShape the character collides fine. I just figured the character would be able to walk on any static object. The character can even walk on non-static objects in tutorial606... Why does it fall right through my cube?

betajaen

03-01-2007 13:56:13

Right, cube trick works for me in RC3 (I just tested it).

However, I remember fixing a bug where I was placing way too much "force" on the controller which would push it through very thin shapes. Are you using RC2?

DieHard

03-01-2007 17:18:34

I'm very close to getting RC3 to compile without errors. I just got replies from betajaen this morning, I'll get it working by tonight (EST time).

By the way, my 606 tutorial is probably different than yours. Don't know.

betajaen

03-01-2007 19:49:06

Yep, you have that bug I squashed, also 606 has changed in RC3 so you'll have a nice surprise :D

jchmack

03-01-2007 20:59:01

perfect i love your suprises =).

jchmack

03-01-2007 21:11:58

Right, cube trick works for me in RC3 (I just tested it).

However, I remember fixing a bug where I was placing way too much "force" on the controller which would push it through very thin shapes. Are you using RC2?


yes im using RC2 + PhysX 2.6.0

betajaen

03-01-2007 22:17:21

Alright, RC3 will fix your problems. Go forth and upgrade :D

jchmack

04-01-2007 00:41:25

Alright, RC3 will fix your problems. Go forth and upgrade :D

But im also using Dagon 1.2.3 and last i heard it doesn't work with RC3. What version's of ogre work with RC3?

betajaen

04-01-2007 01:07:41

Eihort out of the box, Dagon with a few code changes; See the RC3 post for details.

DieHard

04-01-2007 04:59:18

I'm getting compiling errors on Tutorial606 and same on Tutorial103:
1>------ Build started: Project: 606.Character Controller in the Underground Evil Doings Complex, Configuration: Debug Win32 ------
1>Compiling...
1>606.cpp
1>d:\my projects\visual studio 2005\projects\ogresdk\project1\discover\mod\ageia\nxogre\tutorials\nxtutorials\common\tutorialapplicationdagon.h(679) : error C2248: 'nxOgre::rayCaster::rayCaster' : cannot access protected member declared in class 'nxOgre::rayCaster'
1> d:\my projects\visual studio 2005\projects\ogresdk\project1\discover\mod\ageia\nxogre\include\nxogre_raycaster.h(55) : see declaration of 'nxOgre::rayCaster::rayCaster'
1> d:\my projects\visual studio 2005\projects\ogresdk\project1\discover\mod\ageia\nxogre\include\nxogre_raycaster.h(30) : see declaration of 'nxOgre::rayCaster'
1>d:\my projects\visual studio 2005\projects\ogresdk\project1\discover\mod\ageia\nxogre\tutorials\nxtutorials\common\tutorialapplicationdagon.h(688) : error C2248: 'nxOgre::rayCaster::~rayCaster' : cannot access protected member declared in class 'nxOgre::rayCaster'
1> d:\my projects\visual studio 2005\projects\ogresdk\project1\discover\mod\ageia\nxogre\include\nxogre_raycaster.h(72) : compiler has generated 'nxOgre::rayCaster::~rayCaster' here
1> d:\my projects\visual studio 2005\projects\ogresdk\project1\discover\mod\ageia\nxogre\include\nxogre_raycaster.h(30) : see declaration of 'nxOgre::rayCaster'
1>Build log was saved at "file://d:\My Projects\Visual Studio 2005\Projects\OgreSDK\project1\discover\mod\ageia\NxOgre\tutorials\NxTutorials\VC8\Debug\BuildLog.htm"
1>606.Character Controller in the Underground Evil Doings Complex - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


The compiler is complaining in "tutorialapplicationdagon.h" header file:
error C2248: 'nxOgre::rayCaster::rayCaster' : cannot access protected member declared in class 'nxOgre::rayCaster'
error C2248: 'nxOgre::rayCaster::~rayCaster' : cannot access protected member declared in class 'nxOgre::rayCaster'


The constructor and destructor are protected members. So, I temporarily changed the members to public. But, then I get linking errors on the rayCaster.

betajaen

04-01-2007 10:58:26

Figures. The Eihort and Dagon tutorial application code is quite different now, as you see the Dagon code is using the old code for the raycasters.

This is why I thought the Dagon tutorial code would not work.

DieHard

04-01-2007 22:45:18

Is the "tutorial application" deeply woven to Ogre Eihort? But, for other simpler tutorials like 103 does it really need Ogre Eihort to do physics.

Are you going make it compatible to Dagon? Please. :D

DieHard

27-01-2007 20:22:56

I followed the tutorial 606 in NxOgre 0.4 RC3, but my character sinks through both hasFloor(); and my dotscene's floor.

The character's mesh and collision's mesh is working fine. I shoot boxes at the character and it bounces off.

// Create physics body.
nxOgre::blueprint<nxOgre::character> bpCharacter;
bpCharacter.setToDefault();
bpCharacter.setGravity(true);
bpCharacter.setSlopeLimit(45);
bpCharacter.setStep(0.15);
bpCharacter.setShapeAsCapsule(6, 12);
bpCharacter.setMesh("");
mCharacter = bpCharacter.create("Character_1", Ogre::Vector3(10, 100, 0), glbObject->physicsScene);

// Render character body.
mEnt = glbObject->renderSceneMgr->createEntity("Robot", "robot.mesh");
mEnt->setCastShadows(true);
mNode = mCharacter->mNode->createChildSceneNode();
mNode->attachObject(mEnt);

// Initial position, scale.
vecPosition = Ogre::Vector3(0, -8, 0);
vecSize = Ogre::Vector3(0.2, 0.2, 0.2);

// Set position, scale.
mNode->setPosition(vecPosition);
mNode->setScale(vecSize);

betajaen

27-01-2007 21:07:40

Unfortunately Characters fall through any groundShapes. You can cheat and just use a large thin cube, a planeShape or even a meshShape instead though. The Cube shape is the easiest though.

DieHard

27-01-2007 21:29:36

hasfloor(); is part of groundShapes?

For your information, my dotScene (Level/Environment) is using meshShape:
tmpPhysicsBody = mPhysicsScene->createStaticBody(tmpPhysicsName, tmpPhysicsMeshFilename, new nxOgre::meshShape(tmpPhysicsMeshFilename, mPhysicsScene), nxOgre::pose(TempVec, TempQuat));

meshShape does not work on Characters. Bug?

Anyway, I'll try using a cubeShape cheat.

betajaen

27-01-2007 21:37:35

hasFloor creates an invisible body that has a GroundShape.

Characters most definitely work on meshShapes, if they fall through then the character force being applied to the floor is to much.

DieHard

27-01-2007 21:53:41

That's good I'm using meshShape for the dotscene. But, the character sinks very slowly pass the ground.

Gravity is untouched. I looked at the "member list" of both mCharacter and bpCharacter and I see no force adjustment.

I'll make another meshShape (separate from dotScene) under the character to see where the problem is at.

betajaen

27-01-2007 22:14:10

I'm pretty sure I fixed the character sinking problem in RC3, in the character code there is some gravity code I wrote. Perhaps if you alter that it'll stop it.

DieHard

27-01-2007 22:15:18

Another update:
I made a isolated test case, Character versus Static meshShape. The result, same problem character sinking through. I just read your quick reply, I'll look for force in your NxOgre source code and adjust it.

Code Snippet:
void ObjectManager::createObjectStatic(Ogre::String uniquename, Ogre::String filename, Ogre::Vector3 scale, Ogre::Vector3 position, Ogre::Quaternion orientation) {
nxOgre::body* mPhysicsBody;
mPhysicsBody = physicsScene->createStaticBody(uniquename, filename, new nxOgre::meshShape(filename, physicsScene), nxOgre::pose(position, orientation));
}


Screenshots:

DieHard

27-01-2007 23:51:12

I don't know if I found the right place to adjust the force. But, I reduced it to 0.80 and the character still sinks through the static meshShape. Even, though it took a while for the character to fall.

In your "void character::simulateFalling()", I change this to:
mMovementVector.y -= 0.80665; // *_time;

betajaen

28-01-2007 00:14:47

I've been doing some research as well, and I believe it's how the meshShape is built. It may be the normals or some flags, or perhaps the character is directly on a edge. If you look at images you posted, the point the capsule is touching directly on the two triangle edges.

However, I do get this now and again, perhaps it's time to get the experts involved - Aegia.

DieHard

28-01-2007 00:55:49

Okay. I made a thread at the Ageia Developer Support Forum:
http://devsupport.ageia.com/ics/forum/C ... ntID=49920

Ridhan

28-01-2007 17:47:37

I've always fixed that problem increasing the value that comes by default in SkinWidth in nxOgre_character.cpp. It's set in 0.0025, and I change it to 0.0125, then recompile nxOgre. Ageia sets it as 0.1 as a default value, but it can be noticeable (Like floating).

beatjaen once told that it doesn't work changing the value, but it does for me and a friend who has the same problem.

DieHard

29-01-2007 19:41:36

It works for now! Thanks for the tip!

By the way, Ageia's support replied back and said the same thing:
Re: Character/Controller versus Static Body meshShape
Posted on 1/28/2007 10:17 PM

It seems you used a too small skinWidth for this Capsule Controller. Please try to increase a bit to get better result.


Another weird bug smashed. :) I would like to make a request for the gravity and skinWidth variables in the character class should be publicly available to change values.

betajaen

29-01-2007 20:02:20

Request granted. :D

ocrim74

16-02-2007 14:22:07

Hi,

I tried to change the skinWidth by setting the mSkinWidth member of the blueprint<character> class in the nxOgre_character.h. I have been confused that the fix described before is not working in my case. Now I found out that the member mSkinWidth is never used in the code and does not change the skinWidth. I changed the value of desc.skinWidth in the nxOgre_character.cpp and it works now!

I just want to mention it here, so that other people have the chance not to do the same mistake.

I hope this will be cleared up in the next release of NxOgre so that it is not necessary to make this changes after an update.

Cheers,

ocrim74 :)

betajaen

16-02-2007 14:26:42

Don't worry it will.

jchmack

23-03-2007 19:49:53

um i just upgraded to 0.6 and i had to make the change outlined by ocrim74 in order to keep my characters from falling through. What values for SkinWidth are you guys using? My character kinda get stuck in the mud if i dont move him for a while.

ocrim74

23-03-2007 22:11:10

Hi,

I set desc.skinWidth from 0.0025f to 0.0125f to avoid the character is falling through the floor.

In my case it is working. I start my character in a high position so that is falling down. But then is does not get stuck on a plane. Sometimes inside a building or on the stairs it gets stuck.

Cheers,

ocrim74