39 force = Ogre::Vector3::ZERO;
40 torque = Ogre::Vector3::ZERO;
147 SBoneMap::iterator iRootBones = rootBoneList.begin();
148 while (iRootBones != rootBoneList.end())
150 iRootBones->second->ResetNode();
157 SNodeMap::iterator iChildNodeList = childNodeList.begin();
158 while (iChildNodeList != childNodeList.end())
160 iChildNodeList->second->ResetNode();
174 Ogre::Quaternion orient;
187 SBoneMap::iterator iRootBones = rootBoneList.begin();
188 while (iRootBones != rootBoneList.end())
190 iRootBones->second->UpdateNodeFromBody();
197 SNodeMap::iterator iChildNodeList = childNodeList.begin();
198 while (iChildNodeList != childNodeList.end())
200 iChildNodeList->second->UpdateNodeFromBody();
212 Ogre::Vector3 inertia;
235 force = Ogre::Vector3::ZERO;
240 torque = Ogre::Vector3::ZERO;
274 NewtonBodyGetMassMatrix(visitor->
getNewtonBody(), &mass, &Ixx, &Iyy, &Izz);
280 dVector accelPerUnitMass;
281 dVector torquePerUnitMass;
284 Ogre::Vector3 gravity(Ogre::Vector3::ZERO);
289 dVector plane(0.0f, 1.0f, 0.0f, 1.5f);
295 NewtonCollisionCalculateAABB(pcollision, &offmatrix[0][0], &minABB[0], &maxABB[0]);
298 Ogre::Vector3 dir = pquat * Ogre::Vector3::UNIT_Y;
301 NewtonCollision*
const collision = NewtonBodyGetCollision(visitor->
getNewtonBody());
302 NewtonBodyGetMatrix(visitor->
getNewtonBody(), &matrix[0][0]);
304 NewtonBodyGetCentreOfMass(visitor->
getNewtonBody(), &cog[0]);
305 cog = matrix.TransformVector(cog);
311 plane.m_w = dir.dotProduct(-(Ogre::Vector3(maxABB.m_x, maxABB.m_y, maxABB.m_z) * dir));
313 dFloat shapeVolume = NewtonConvexCollisionCalculateVolume(collision);
319 NewtonConvexCollisionCalculateBuoyancyAcceleration(collision, &matrix[0][0], &cog[0], &gravity.x, &plane[0], fluidDentity,
mFluidViscosity, &accelPerUnitMass[0], &torquePerUnitMass[0]);
320 if (accelPerUnitMass[0] != 0.0 || accelPerUnitMass[1] != 0.0 || accelPerUnitMass[2] != 0.0 || torquePerUnitMass[0] != 0.0 || torquePerUnitMass[1] != 0.0 || torquePerUnitMass[2] != 0.0)
331 NewtonBodyAddForce(visitor->
getNewtonBody(), &accelPerUnitMass[0]);
332 NewtonBodyAddTorque(visitor->
getNewtonBody(), &torquePerUnitMass[0]);
612#ifndef USE_COLLISION_NOSCALE
622 void SBody::SetMatrix(
const Ogre::Vector3& mDerivedPos,
const Ogre::Quaternion& mDerivedOrientation)
656 SO3_SAFE_DELETE(mUpJoint);
662 SO3_SAFE_DELETE(mUpJoint);
789 void SBody::newtonPerPoly(
void* userData,
int vertexCount,
const float* faceVertec,
int id)
791 Ogre::ManualObject* lines = (Ogre::ManualObject*)userData;
792 Ogre::Vector3 p0, p1;
794 Ogre::Vector3 invscale = Ogre::Vector3::UNIT_SCALE / lines->getParentNode()->_getDerivedScale();
798 int i = vertexCount - 1;
799 p0 = Ogre::Vector3(faceVertec[(i * 3) + 0], faceVertec[(i * 3) + 1], faceVertec[(i * 3) + 2]) * invscale;
801 for (i = 0; i < vertexCount; i++)
803 p1 = Ogre::Vector3(faceVertec[(i * 3) + 0], faceVertec[(i * 3) + 1], faceVertec[(i * 3) + 2]) * invscale;
843 mDebugBody->begin(
"BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST);
main class for all Rigid Bodies in the system.
void MoveToPosition(const Ogre::Vector3 &destPos, const Ogre::Real &stiffness, Ogre::Real timestep)
void updatePositionOrientation(const Ogre::Vector3 &pos, const Ogre::Quaternion &orient, int threadIndex=-1)
void getMassMatrix(Ogre::Real &mass, Ogre::Vector3 &inertia) const
get Ogre::Real(mass) and Ogre::Vector3(inertia) of the body.
void enableSimulation(bool state)
void setContinuousCollisionMode(unsigned state)
prevents fast moving bodies from "tunneling" through other bodies.
void setUserData(const Ogre::Any &data)
set user data to connect this class to another.
void setScale(const Ogre::Vector3 &scale, const Ogre::Quaternion &orient, Ogre::Vector3 &pos)
set the collision scale
void setCustomForceAndTorqueCallback(ForceCallback callback)
set a custom force callback for this body to use.
bool isFreezed()
is the body freezed?
Ogre::Vector3 getForce() const
get the force acting on the body.
void getInvMass(Ogre::Real &mass, Ogre::Vector3 &inertia) const
get invert mass + inertia for the body.
void addLocalForce(const Ogre::Vector3 &force, const Ogre::Vector3 &pos)
void setAngularDamping(const Ogre::Vector3 &damp)
set the angular damping for the body.
void setMaterialGroupID(const MaterialID *ID)
set the material for the body
void addImpulse(const Ogre::Vector3 &deltav, const Ogre::Vector3 &posit)
get the freeze threshold
const OgreNewt::MaterialID * getMaterialGroupID() const
get a pointer to the Material assigned to this body.
int getAutoSleep()
get whether the body should "sleep" when equilibrium is reached.
void freeze()
freeze the rigid body.
void addGlobalForce(const Ogre::Vector3 &force, const Ogre::Vector3 &pos)
helper function that adds a force (and resulting torque) to an object in global cordinates.
Ogre::Vector3 getVelocity() const
get velocity of the body. in global coordinates.
void addTorque(const Ogre::Vector3 &torque)
add torque to the body.
void setMassMatrix(Ogre::Real mass, const Ogre::Vector3 &inertia)
set the mass and inertia for the body.
void addForce(const Ogre::Vector3 &force)
add force to the body.
Ogre::Vector3 getCenterOfMass() const
get the center of mass.
Ogre::Vector3 getOmega() const
get omega of the body. in global space.
int getType() const
get the type set for this body.
void setPositionOrientationFromNode(int threadIndex=-1)
position and orient the body from node.
void setMass(Ogre::Real mass)
Ogre::Vector3 calculateOffset() const
Ogre::Real getLinearDamping() const
get linear damping
void setType(int type)
set the type for this body.
NewtonBody * getNewtonBody() const
get a pointer to the NewtonBody object
void setPositionOrientation(const Ogre::Vector3 &pos, const Ogre::Quaternion &orient, int threadIndex=-1)
position and orient the body arbitrarily.
void attachNode(Ogre::Node *node)
attach this body to an Ogre::Node*
Ogre::Vector3 getForceAcceleration() const
get the linear acceleration due to forces acting on the body.
int getContinuousCollisionMode() const
returns current setting for this body.
void setNodeUpdateNotify(NodeUpdateNotifyCallback callback)
set a custom node update notify.
void setOmega(const Ogre::Vector3 &omega)
set an arbitrary omega for the body.
void setVelocity(const Ogre::Vector3 &vel)
set an arbitrary velocity for the body.
void setLinearDamping(Ogre::Real damp)
set the linear damping for the body.
void RotateToOrientation(const Ogre::Quaternion &destquat, const Ogre::Real &stiffness, Ogre::Real timestep)
void getVisualPositionOrientation(Ogre::Vector3 &pos, Ogre::Quaternion &orient) const
get the node position and orientation in form of an Ogre::Vector(position) and Ogre::Quaternion(orien...
Ogre::Vector3 getAngularDamping() const
get angular damping
void setTriggerInsideCallback(TriggerInsideCallback callback)
void setAutoSleep(int flag)
set whether the body should "sleep" when equilibruim is reached.
void getPositionOrientation(Ogre::Vector3 &pos, Ogre::Quaternion &orient) const
get position and orientation in form of an Ogre::Vector(position) and Ogre::Quaternion(orientation)
void setCenterOfMass(const Ogre::Vector3 ¢erOfMass)
set the body's center of mass
void unFreeze()
unfreeze the rigid body.
const MaterialID * getDefaultMaterialID() const
get the default materialID object.
void waitForUpdateToFinish() const
Ogre::Vector3 globalForce
void SetScale(const Ogre::Vector3 &mDerivedScale)
void SetType(const int &value)
float GetFluidViscosity()
void AddImpulse(const Ogre::Vector3 &delta, const Ogre::Vector3 &pos)
Ogre::Real rotateStiffness
void SetForce(const Ogre::Vector3 &mForce)
void SetAngularDamping(const Ogre::Vector3 &vec)
void EnableSimulation(const bool &enable)
const std::string GetMaterialName()
Ogre::Vector3 constantForce
void AddConstantForce(const Ogre::Vector3 &mForce)
void SetPositionOrientation(const Ogre::Vector3 &mDerivedPos, const Ogre::Quaternion &mDerivedOrientation)
Ogre::Vector3 GetVelocity()
void ShowDebug(bool state)
Ogre::Real mFluidWaterToVolume
void SetConstantTorque(const Ogre::Vector3 &mTorque)
void SetContinuousCollisionMode(const bool &enable)
void SetGlobalForce(const Ogre::Vector3 &mGlobalForce)
OgreNewt::Body * getOgreNewtBodyPointer()
void AddConstantTorque(const Ogre::Vector3 &mTorque)
void SetLinearDamping(const Ogre::Real &ang)
Ogre::Real mFluidViscosity
Ogre::Vector3 GetGlobalForce()
Ogre::Vector3 globalLocationForce
Ogre::Vector3 destPosition
void SetFluidState(bool state)
Ogre::Vector3 constantTorque
Ogre::ManualObject * mDebugBody
void SetAutoSleep(const bool &enable)
Ogre::Vector3 GetCenterOfMass()
Ogre::Vector3 GetTorque()
void GetMassMatrix(Ogre::Real &mass, Ogre::Vector3 &inertia)
Ogre::Vector3 localLocationForce
Ogre::Vector3 GetConstantForce()
Ogre::Vector3 CalculateBodyOffset()
void SetConstantForce(const Ogre::Vector3 &mForce)
Ogre::Vector3 GetGlobalLocationForce()
void BuoyancyForce(OgreNewt::Body *visitor)
void SetVelocity(const Ogre::Vector3 &velocity)
void SetTorque(const Ogre::Vector3 &mTorque)
Ogre::Quaternion destOrientation
bool GetSimulationState()
void MoveToPosition(const Ogre::Vector3 &destPos, const Ogre::Real &stiffness)
void SetLocalForce(const Ogre::Vector3 &mLocalForce)
Ogre::Vector3 GetLocalForce()
const OgreNewt::MaterialID * GetMaterialID()
void UpdatePositionOrientation()
void SetGravityEnable(bool state)
void SetFreezeState(const bool &state)
Ogre::Vector3 GetLocalLocationForce()
void SetUpJoint(const Ogre::Vector3 &vec)
float GetFluidWaterToVolumeRatio()
Ogre::Vector3 GetAngularDamping()
void SetMatrix(const Ogre::Vector3 &mDerivedPos, const Ogre::Quaternion &mDerivedOrientation)
void GetPositionOrientation(Ogre::Vector3 &pos, Ogre::Quaternion &orient)
void SetFluidViscosity(float viscosity)
Ogre::Vector3 GetConstantTorque()
void GetInvMass(Ogre::Real &mass, Ogre::Vector3 &inertia)
bool GetIgnoreCollision()
void BodyUpdateCallback(OgreNewt::Body *body)
void BodyAddForceCallback(OgreNewt::Body *body, float timeStep, int threadIndex)
void SetIgnoreCollision(const bool &state)
Ogre::Real GetLinearDamping()
void SetFluidVolumeRatio(float waterToVolume)
void SetOmega(const Ogre::Vector3 &omega)
void SetCenterOfMass(const Ogre::Vector3 &vec)
void SetGlobalLocationForce(const Ogre::Vector3 &mGlobalLocationForce)
void RotateToOrientation(const Ogre::Quaternion &destQuat, const Ogre::Real &stiffness)
void SetMass(const Ogre::Real &mass)
bool GetContinuousCollisionMode()
void SetMassMatrix(const Ogre::Real &mass, const Ogre::Vector3 &inertial)
const SMaterialID * GetMaterial()
void SetLocalLocationForce(const Ogre::Vector3 &mLocalLocationForce)
void SetMaterialID(SMaterialID *matID)
void AttachToBone(Ogre::MovableObject *ogreObject)
void DetachFromBone(Ogre::MovableObject *ogreObject)
virtual void ResetToInitialPRS()
std::string GetName() const
SSkeleton * GetSkeleton()
OgreNewt::MaterialID * getOgreNewtMaterialID()
virtual Ogre::Quaternion GetGlobalOrientation()
const SNodeMap GetChildrenNodes() const
SScene * GetParentScene()
virtual void SetGlobalPosition(const Ogre::Vector3 &pos, bool updateBody=true)
virtual void SetGlobalOrientation(const Ogre::Quaternion &quat, bool updateBody=true)
virtual Ogre::Vector3 GetGlobalPosition()
virtual Ogre::Vector3 GetGlobalScale()
virtual void ResetToInitialPRS()
Ogre::SceneNode * GetOgreSceneNodePointer()
void RemoveBodyPair(SBody *body)
OgreNewt::World * GetPhysicWorld()
void RemoveBodyContraint(SBody *body)
Ogre::Vector3 GetPhysicGravity()
SPhysicWorld * GetPhysicsWorld()
Ogre::Quaternion GetBaseRotation()
Ogre::Vector3 GetBaseScale()
OgreNewt::CollisionPtr GetOgreNewtCollisionPtr()
Ogre::Vector3 GetComputedOffset()
_OgreNewtExport void QuatPosToMatrix(const Ogre::Quaternion &quat, const Ogre::Vector3 &pos, dFloat *matrix)
Take a Quaternion and Position Matrix and create a Newton-happy float matrix!
std::unordered_map< std::string, SBone * > SBoneMap
std::unordered_map< std::string, SNode * > SNodeMap