Physics are... pretty choppy...

katzenjoghurt

10-08-2007 14:31:54

Hi! :D

Tried to follow the installation guide and let a Ogre Head fall from the sky...

Uhm... yet it's not falling very smooth... although the scene is rendered with 700fps...



... any ideas why it behaves like that?



#include "NxOgre.h"

...

NxOgre::World *mWorld = new NxOgre::World();
NxOgre::Scene* mScene = mWorld->createScene("Main", sceneMgr, "gravity: yes, floor: yes");
mScene->setGravity(Vector3(0,-200,0));

NxOgre::Body *myBody = mScene->createBody("ogrehead.mesh",new NxOgre::CubeShape(10,10,10),Vector3(0,600.5,-600), "mass: 10");

betajaen

10-08-2007 14:39:14

Yep. I found a bug with the FixedSceneController; in Windows Vista, I had this weird "lag" during the first second. I've fixed it now, I'm expecting your having the same problem.

But just be sure, change the timestep to variable.

NxOgre::Scene* mScene = mWorld->createScene("Main", sceneMgr, "gravity: yes, floor: yes, time-step-method: variable");


Nice animation by the way ;)

katzenjoghurt

10-08-2007 15:05:59



I use XP here ... but anyway ... much better! The gif here plays far too slow... but the chops are obviously reduced massively.

Thx! :D



Nice animation by the way ;)


Masterpiece, eh? :wink:

betajaen

10-08-2007 15:23:56

That's better, and probably related to the bug.

Just to make sure, you'll have to do a bit of hacking. Goto the NxOgre project, and open the file "NxOgreSceneController.cpp", and find and replace the following method (it's around line 166):

bool FixedSceneController::Simulate(NxReal deltaTime) {

mTiming_CurrentStep += deltaTime;

if (mTiming_CurrentStep < mTiming_MaxStep) {
mRenderFrame = false;
return false;
}

mNxScene->simulate(mTiming_MaxStep - (mTiming_MaxStep - mTiming_CurrentStep));
mNxScene->flushStream();

while(!mNxScene->checkResults(NX_RIGID_BODY_FINISHED, false)) {}

mNxScene->fetchResults(NX_RIGID_BODY_FINISHED, true);

mRenderFrame = true;
mTiming_CurrentStep=0;

return true;
}


Change your Scene params from "time-step-method: variable" to "time-step-method: fixed", recompile NxOgre and your application and you should be good to go.


I think we could do with a bit of animation here and there, considering this is a real-time 3D graphics forum. ;)

katzenjoghurt

10-08-2007 15:42:31

Hmmm ... changed the code ... recompiled... changed the time-step-method to fixed... and it's choppy again.

With "variable" behaviour is a bit .. indeterministic... sometimes the head's just a bit shaking when crashing to the ground sometimes it's completely rolling over ... residing upside down afterwards. :(


EDIT: SILLY ME! Forgot to copy the new dlls ... everything seems to be fine. :D

betajaen

10-08-2007 16:25:22

Excellente, and here I showed it to Luis a few days back and he said "Bah! Useless Betajaen"*.


* Not exactly what he said, but it didn't fix his jittering bug.

katzenjoghurt

10-08-2007 16:55:02

*laughs*

... it did the trick for me...

http://www.wikifortio.com/128309/ogrehead.avi

betajaen

10-08-2007 17:03:33

Heh, poor Ogre. Is that still using a cube shape?

katzenjoghurt

10-08-2007 17:05:21

Yeah... but it fits ... sort of... :D

kenny.bsp

10-08-2007 23:58:22

I have the same problem, will read through the thread later, only watched the last avi now ...
theres something wrong in between frames 47-52
don't know if it's the avi or the demo itself

katzenjoghurt

11-08-2007 03:22:52

Hmm... I see what you mean, I think. One pic seems to "jump back in time".
The same thing happens before in frame 15.

http://srv006.pixpack.net/2007081104193 ... fvbsal.jpg

The lower pictures are from a second capturing.

Don't know either if it's just Fraps causing these pictures or if something's wrong with the demo.
Capturing runs with constant 60fps.

Toby

11-08-2007 12:45:08

Hi, which version of nxOgre do you use? If I understand well your head animation was not smooth.

I use 0.4RC3 and they are not "NxOgreSceneController.cpp" file in nxOgre project.

Then SceneNode attached to a body have tremor. I find a trick to do not appears on screen. But when I attach a 3D sound to my car node, sound tremor when I move my car.

If I do not use my tricks then Node appears at two very near location at same times.

How to solve this problem on 0.4RC3?

Thx

katzenjoghurt

11-08-2007 16:19:33

Hi, which version of nxOgre do you use?
0.9


If I understand well your head animation was not smooth.

At least I don't see that anything is wrong.
The simulation seems to be deterministic and I don't see any lags.

---

OT: Is there a way to render/show the shape a physical object is using?

betajaen

11-08-2007 18:17:31

How to solve this problem on 0.4RC3?

You don't, you can upgrade to 0.9 or find the simulation code and change it that.

NickM

12-08-2007 09:42:20

Hi, which version of nxOgre do you use? If I understand
How to solve this problem on 0.4RC3?

I'm still using 0.4 RC3 for my car game too, it does everything I want it to do at this stage so I'm reluctant to upgrade especially since the wheel code was change alot in newer versions. If you write a fix for this problem in 0.4 RC3 I'd be greatful for the code, if I find the time to look into it, I'll post up the code for you.

Cheers
Nick.

Leviathan

10-08-2008 03:48:13

Hi. I’m working in Windows Vista with OGRE 1.4.9 [Eihort] in Visual C++ Express Edition 2008 and compile NxOgre 1.0 with PhysX SDK 2.8.1 without any problem. I compile and run the first example successfully, but I notice a minor “lagâ€

betajaen

10-08-2008 10:51:28

I have the same setup as you, and don't experience anything like that. This problem is with Cake right? Or your application or both?

Leviathan

10-08-2008 16:47:00

Just in my application at runtime, for example:

I create a Body in the position Vector3(50,100,0), but just in the first second (a blink of and eye I mean), the body draws in Vector3(0,0,0) and then just in less than a second draws in the correct position and all the simulation runs fine. It happens in fullscreen mode and window mode, in all posible resolutions, vsync yes and no.
Body *myBody = mScene->createBody("Ogre;ogrehead.mesh", new Cube(50), Vector3(50,100,0), "mass: 10");

betajaen

10-08-2008 17:17:17

Hmm. What happens say if you make a second body into a few seconds in the applications life-time? Does it pause then?

Leviathan

10-08-2008 18:14:14

I check again, I create other bodies and the aplication behaviour is the same for all bodies. When the application start first draws all bodies in the center of the stage an then in less than blink of an eye all the bodies draws in their correct position and all goes fine.

betajaen

10-08-2008 19:24:39

The scenenodes normally start at 0,0,0; until the next render() update. However; I am puzzled why it does pause during the first frame rendered. All I can think of is either DirectX is causing the pause or even PhysX. But I'm not sure which is the one causing it.

Leviathan

10-08-2008 23:17:01

I think is something releated to PhysX, because when I create other scene nodes in the same scene, the scenes nodes draws fine at the begining, just the created bodies take one frame to get his right position.
//This draw in the right position at the begining
Entity *ent1 = mSceneMgr->createEntity( "Ogre", "ogrehead.mesh" );
SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "OgreNode", Vector3( 50,50,0 ) );
node1->attachObject( ent1 );

//This draws first at center of the stage and one frame later gets his right position
Body *myBody = mScene->createBody("Ogre;ogrehead.mesh", new Cube(50), Vector3(0,100,0), "mass: 10");

betajaen

10-08-2008 23:27:10

Yep. I think it may PhysX causing that delay for the first frame. But the position of each actor (0,0,0) at the beginning of it's life time, is nature of NxOgre. It can be fixed though.

NxOgreBody.cpp; Line 45-ish. Add the middle line.
mNodeRenderable = static_cast<NodeRenderable*>(mRenderable);
mNodeRenderable->setPose(getGlobalPose());
mVoidPointer->RenderPtr = this;


However; the pause - I don't think I can fix. Considering I don't get the same problem, the error must be random or due to a very specific version of PhysX, SystemSoftware or even Vista.

Leviathan

11-08-2008 00:07:48

Thanks, I really appreciate the fast response. Now the application works fine, the delay is almost imperceptible. I keep searching the posible cause of the pause. I will test the application in other computers and with different system configurations.