40 #ifndef _physicsmultispherecollisionshape_cpp
41 #define _physicsmultispherecollisionshape_cpp
43 #include "Physics/multispherecollisionshape.h"
44 #include "collisionshapemanager.h"
45 #include "stringtool.h"
47 #include "btBulletDynamicsCommon.h"
58 if(Locations.size() != Radii.size())
60 Whole Spheres = Locations.size();
61 btVector3* BulletLocs =
new btVector3[Spheres];
62 btScalar* BulletRadii =
new btScalar[Spheres];
63 for(
Whole X = 0 ; X < Spheres ; X++ )
65 BulletLocs[X] = Locations[X].GetBulletVector3();
66 BulletRadii[X] = Radii[X];
69 Construct(Name,
new btMultiSphereShape(BulletLocs,BulletRadii,Spheres));
105 std::vector<Vector3> Locations;
106 std::vector<Real> Radii;
151 {
return static_cast<btMultiSphereShape*
>(
ShapeBase); }
202 {
return String(
"MultiSphereCollisionShape"); }
This is a generic sphere class used for spacial queries.
std::ostream & operator<<(std::ostream &stream, const Mezzanine::LinearInterpolator< T > &Lint)
Used to Serialize an Mezzanine::LinearInterpolator to a human readable stream.
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
Indicates the class is a MultiSphereCollisionShape.
A light-weight handle for manipulating attributes in DOM tree.
virtual Whole GetNumSpheres() const
Gets the number of spheres contained within this shape.
virtual Real GetSphereRadius(const Whole &Index) const
Gets the radius of the sphere at the specified index.
A physics shape comprised of multiple sphere's placed in local space.
String ToString(const T &Datum)
Converts whatever to a String as long as a streaming operator is available for it.
Attribute GetFirstAttribute() const
Get the First Attribute in this Node.
virtual void ProtoDeSerialize(const XML::Node &OneNode)
Node GetFirstChild() const
Get the first child Node of this Node.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
std::ostream & Serialize(std::ostream &Stream, const T &Converted, const String &Indent=String(""))
Convert any class that supports serialization or has a serializer to a string of chars in a stream...
virtual btMultiSphereShape * GetMultiSphereShape() const
static String GetSerializableName()
Get the name of the the XML tag this class will leave behind as its instances are serialized...
const Char8 * AsString(const Char8 *def="") const
Attempts to convert the value of the attribute to a String and returns the results.
Node GetNextSibling() const
Attempt to retrieve the next sibling of this Node.
virtual void ProtoSerialize(XML::Node &CurrentRoot) const
float Real
A Datatype used to represent a real floating point number.
bool SetValue(const Char8 *rhs)
Set the value of this.
static String GetSerializableName()
Get the name of the the XML tag this class will leave behind as its instances are serialized...
A light-weight handle for manipulating nodes in DOM tree.
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
virtual void ProtoDeSerialize(const XML::Node &OneNode)
ShapeType
This enum describes what kind of shape you are currently working with.
Real AsReal(Real def=0) const
Attempts to convert the value of the attribute to a Real and returns the results. ...
std::istream & DeSerialize(std::istream &Stream, T &Converted)
Deserialize the next xml tag in the stream into a specific in memory class instance.
virtual Vector3 GetSphereLocation(const Whole &Index) const
Gets the location(in local space) of the sphere at the specified index.
virtual CollisionShape::ShapeType GetType() const
Gets the type of Collision shape this is.
void DeSerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
Thrown when parameters are checked at runtime and found invalid.
virtual void ProtoSerialize(XML::Node &CurrentRoot) const
This is used to represent a point in space, or a vector through space.
void SetPointers(btConvexInternalShape *Shape)
Sets the internal pointers on the base classes.
void Construct(const String &Name, const std::vector< Vector3 > &Locations, const std::vector< Real > &Radii)
Creates a btMultiSphereShape* from two vectors to help unify constructor logic.
virtual ~MultiSphereCollisionShape()
Class Destructor.
String Name
Storage for the name of this class instance.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
std::istream & operator>>(std::istream &stream, Mezzanine::LinearInterpolator< T > &Lint)
Used to de-serialize an Mezzanine::LinearInterpolator from a stream.
btCollisionShape * ShapeBase
A pointer to the bullet collision this uses.
MultiSphereCollisionShape(const String &Name, const std::vector< Vector3 > &Locations, const std::vector< Real > &Radii)
Class Constructor.
const Char8 * Name() const
ptrdiff_tGet the name of this Node.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
std::string String
A datatype used to a series of characters.
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
void ProtoSerialize(XML::Node &CurrentRoot) const
Convert this class to an XML::Node ready for serialization.
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.