character wobble?

njw1985

25-03-2009 08:38:06

I set up a character with Ellipsoid in OgreNewt and ogre version is 1.6.1, the character wobble from back to front time to time,but in ogre version 1.4.6 has no problem,why?

melven

25-03-2009 16:18:55

I don't know what you're exactly doing, so please post the related code and tell us what version of newton/OgreNewt and what platform you use...

njw1985

26-03-2009 03:22:29

I use the newton of version 1.53,OgreNewt version 0.11 and platform is vc8.0 on windows!!
part of code like this:
Ogre::Vector3 size=Vector3(ent->getBoundingBox().getSize().x/2,ent->getBoundingBox().getSize().y/2,ent->getBoundingBox().getSize().z/2);
Ogre::Real mass=size.x*size.y*size.z*1000;
Ogre::Vector3 inertia=OgreNewt::MomentOfInertia::CalcEllipsoidSolid(mass,size);
OgreNewt::Collision* col=new OgreNewt::CollisionPrimitives::Ellipsoid(mWorld,Vector3(mSize.x,mSize.y-6,mSize.z));

I use ogre version 1.4.6, the character not wobble,but use ogre 1.6.1 and these code has not be changed,the character wobble,why?

melven

26-03-2009 10:42:39

Hmm I don't know what causes the problem, but I think I already encountered something similar (wobble front and back), though I'm using different versions now, I'll try to check this in some days...
Can you check if your inertia is calculated correctly?
And are you using an up-vector joint or so (there's still some code missing, that would be useful to analyse this problem...)?

njw1985

26-03-2009 13:21:09

Yes,I can! I post my code like this:
Ogre::Vector3 size=Vector3(ent->getBoundingBox().getSize().x/2,ent->getBoundingBox().getSize().y/2,ent->getBoundingBox().getSize().z/2);
Ogre::Real mass=size.x*size.y*size.z*1000;
Ogre::Vector3 inertia=OgreNewt::MomentOfInertia::CalcEllipsoidSolid(mass,size);
OgreNewt::Collision* col=new OgreNewt::CollisionPrimitives::Ellipsoid(mWorld,Vector3(mSize.x,mSize.y-6,mSize.z));
// Ogre::Vector3 inertia=OgreNewt::MomentOfInertia::CalcBoxSolid(mass,size);
// OgreNewt::Collision* col=new OgreNewt::CollisionPrimitives::Box(mWorld,Vector3(mSize.x,mSize.y-5,mSize.z));
col->setUserID(MeyaRun::CT_BODY);

OgreNewt::Body* mCharacter=new OgreNewt::Body(mWorld,col,1);

delete col;

// add body to prizepeople
mPrizePeople[type].mBody=mCharacter;

mCharacter->attachToNode(node);
mCharacter->setType(bodytype);
mCharacter->setMaterialGroupID(mat);
mCharacter->setMassMatrix(mass,inertia);
mCharacter->setAngularDamping(Vector3(10,50,10));
mCharacter->setLinearDamping(10);
mCharacter->setAutoFreeze(0);
mCharacter->unFreeze();

//mCharacter->setStandardForceCallback();
mCharacter->setPositionOrientation(mPosition,mOrient);
mCharacter->setUserData(this);
mCharacter->setCustomForceAndTorqueCallback<Character>(&Character::CallBack,this);

OgreNewt::BasicJoints::UpVector* uy = new OgreNewt::BasicJoints::UpVector(mWorld,mCharacter,Vector3::UNIT_Y);

I post most of my code out!!

njw1985

09-04-2009 03:23:09

I post my code out,could melven or anyone help me?

melven

09-04-2009 12:01:45

The problem in my code was that we did forget sometimes to create the UpVector-joint...
For me the joint is working quite well!

Another question, I don't know if it's related to the 'wobble' in any way:
Why do you set these things here?

mCharacter->setAngularDamping(Vector3(10,50,10));
mCharacter->setLinearDamping(10);

The 'freeze' things should not be necessary neither...

njw1985

10-04-2009 03:13:39

ok,thanks!!