00001
00008 #include "SO3ShapeEllipsoid.h"
00009 #include "../SO3SceneGraph/SO3NodeScol.h"
00010 #include "../SO3SceneGraph/SO3Entity.h"
00011 #include "../SO3SceneGraph/SO3Scene.h"
00012
00013 namespace SO3
00014 {
00015
00016 SShapeEllipsoid::SShapeEllipsoid() : SShape("", SShape::SO3_NULL_COLLISION)
00017 {
00018
00019 }
00020
00021 SShapeEllipsoid::SShapeEllipsoid(std::string shapeName, SNode* node, Ogre::Vector3 size) : SShape(shapeName, SShape::SO3_ELLIPSOID_COLLISION)
00022 {
00023 Ogre::Vector3 poffset = Ogre::Vector3::ZERO;
00024 if (node->GetNodeType() == SNode::ENTITY_TYPE_ID)
00025 {
00026 SEntity* entity = static_cast<SEntity*> (node);
00027 poffset = entity->GetBoundingBoxCenter();
00028 }
00029
00030 mCollisionPtr = OgreNewt::CollisionPtr(new OgreNewt::CollisionPrimitives::Ellipsoid(node->GetParentScene()->GetPhysicsWorld()->GetPhysicWorld(), size, 0, Ogre::Quaternion::IDENTITY, poffset));
00031 mSize = size;
00032 }
00033
00034 SShapeEllipsoid::~SShapeEllipsoid()
00035 {
00036 }
00037
00038 Ogre::Vector3 SShapeEllipsoid::GetSize()
00039 {
00040 return mSize;
00041 }
00042
00043 Ogre::Vector3 SShapeEllipsoid::CalculateInertialMatrix()
00044 {
00045 Ogre::Vector3 iner, off;
00046 (static_cast<OgreNewt::CollisionPrimitives::Ellipsoid*>(mCollisionPtr.get()))->calculateInertialMatrix(iner, off);
00047 return iner;
00048 }
00049
00050 Ogre::Vector3 SShapeEllipsoid::CalculateOffset()
00051 {
00052 Ogre::Vector3 iner, off;
00053 (static_cast<OgreNewt::CollisionPrimitives::Ellipsoid*>(mCollisionPtr.get()))->calculateInertialMatrix(iner, off);
00054 return off;
00055 }
00056
00057 }