How to Disable specified actor's gravity, like camera

zhucde

04-09-2009 16:35:39

[NxOgre.1.0.22T5]
I create a camera actor with gravity on, the scene gravity is Vector3(0,-9.8,0),

NodeRenderableParams renderableParams;
renderableParams.setToDefault();
renderableParams.mIdentifier = "CameraActor";
renderableParams.mIdentifierUsage = NodeRenderableParams::IU_Create;
renderableParams.mMode = RenderableSource::RM_Interpolate;


ActorParams actorParams;
actorParams.setToDefault();
actorParams.mMass = 1;
actorParams.mDensity = 11.0f;
actorParams.mLinearDamping = 2.5f;
// actorParams.mAngularDamping = 10;
actorParams.mBodyFlags.mDisableGravity = false;
actorParams.mFreeze.FreezeRotation();

mCameraActor = mScene->createBody<Body>("CakeSmartCamera", new NxOgre::Sphere(1.25f), Vector3(0,15,22), renderableParams, actorParams);


somtimes, i have to disable the camera actor's gravity, only this actor, only disable its gravity, i also can move, collision.

with BloodyMess1.54, i only add CamActor->addForce(-gravity) to balance out the scene gravity,
but in NxOgre.1.0.22T5, if i do this, the camera raise up slightly,

how to do ?

betajaen

04-09-2009 16:40:23

This in Bleeding;

actorParams.mBodyFlags.mDisableGravity = true;

This in Mess/Git;

rigidbody_desc.mBodyFlags |= NxOgre::Enums::BodyFlags_DisableGravity;

zhucde

04-09-2009 16:46:08

I mean, after creating this actor,
anytime, i can enable or disable its gravity.

betajaen

04-09-2009 18:06:15

In Bleeding I think it's:

actor->setBodyFlags(NX_BF_DISABLEGRAVITY);

In Mess/Git the setBodyFlags isn't in the Actor class for some reason. If your want, I can implement it and do a Git commit this weekend with it in.

zhucde

05-09-2009 02:39:22

Thank you betajaen,
it works perfectly.

one modification,
in bleeding,
it is
Actor->clearBodyFlag(NX_BF_DISABLE_GRAVITY);

nargil

05-09-2009 08:44:27

if you clear the NX_BF_DISABLE_GRAVITY flag then you enable gravity
you need to call actor->raiseBodyFlag(NX_BF_DISABLE_GRAVITY) to disable gravity