40 #ifndef _collisionshape_cpp
41 #define _collisionshape_cpp
43 #include "Physics/collisionshape.h"
44 #include "collisionshapemanager.h"
45 #include "stringtool.h"
48 #include "Physics/boxcollisionshape.h"
49 #include "Physics/capsulecollisionshape.h"
50 #include "Physics/conecollisionshape.h"
51 #include "Physics/convexhullcollisionshape.h"
52 #include "Physics/cylindercollisionshape.h"
53 #include "Physics/multispherecollisionshape.h"
54 #include "Physics/spherecollisionshape.h"
55 #include "Physics/dynamicmeshcollisionshape.h"
56 #include "Physics/heightfieldcollisionshape.h"
57 #include "Physics/planecollisionshape.h"
58 #include "Physics/softcollisionshape.h"
59 #include "Physics/staticmeshcollisionshape.h"
60 #include "Physics/compoundcollisionshape.h"
62 #include "btBulletDynamicsCommon.h"
163 {
return String(
"CollisionShape"); }
170 this->
Name = NewName;
185 switch(ShapeToCreate)
227 switch(ShapeToCreate)
265 switch(InternalShapeType)
287 switch(ShapeToConvert)
309 if(TypeName.size()<5)
311 switch(TypeName.at(3))
314 if (
String(
"BoxCollisionShape")==TypeName)
319 if (
String(
"CapsuleCollisionShape")==TypeName)
324 if (
String(
"SphereCollisionShape")==TypeName)
326 else if (
String(
"ConeCollisionShape")==TypeName)
331 if (
String(
"ConvexHullCollisionShape")==TypeName)
336 if (
String(
"CylinderCollisionShape")==TypeName)
341 if (
String(
"StaticMeshCollisionShape")==TypeName)
343 else if (
String(
"MultiSphereCollisionShape")==TypeName)
348 if (
String(
"DynamicMeshCollisionShape")==TypeName)
353 if (
String(
"HeightfieldCollisionShapeString")==TypeName)
358 if (
String(
"PlaneCollisionShape")==TypeName)
363 if (
String(
"SoftCollisionShape")==TypeName)
368 if (
String(
"CompoundCollisionShape")==TypeName)
383 if(!Doc->
Load(OneTag.c_str()))
407 {
return String(
"Shapes"); }
String GetOneTag(std::istream &stream)
Gets the first tag out of the Stream and returns it as a String.
std::ostream & operator<<(std::ostream &stream, const Mezzanine::LinearInterpolator< T > &Lint)
Used to Serialize an Mezzanine::LinearInterpolator to a human readable stream.
This is the base class for all collision shapes.
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 void ProtoSerialize(XML::Node &CurrentRoot) const
Convert this class to an XML::Node ready for serialization.
A triangle mesh collsion shape based on a graphics mesh.
virtual ~CollisionShape()
Class Destructor.
Indicates the class is a SoftCollisionShape.
Indicates the class is a ConeCollisionShape.
A physics shape comprised of multiple sphere's placed in local space.
CollisionShape * CreateShape(CollisionShape::ShapeType ShapeToCreate, const String &Name_, btCollisionShape *ShapeToModel)
Create A shape of a type and optionally model it after an example.
Indicates the class is a HeightfieldCollisionShape.
Indicates the class is a StaticMeshCollisionShape.
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.
Thrown when we just have not coded a thing yet, but we knew what the API should look like...
A triangle mesh collsion shape based on a graphics mesh.
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...
CollisionShape()
Class Constructor.
virtual Vector3 GetScaling() const
Gets the current scaling being applied to the collision shape.
Indicates the class is a DynamicMeshCollisionShape.
const Char8 * AsString(const Char8 *def="") const
Attempts to convert the value of the attribute to a String and returns the results.
static String GetSerializableName()
Get the name of the the XML tag this class will leave behind as its instances are serialized...
virtual btCollisionShape * _GetInternalShape() const
Gets the internal shape pointer this collision shape is based on.
virtual void SetMargin(const Real &Margin)
Sets the padding that will be applied when checking for collisions.
A simple convex shape built from a low number of points in local space.
ParseResult Load(std::basic_istream< char, std::char_traits< char > > &stream, unsigned int options=ParseDefault, Encoding DocumentEncoding=EncodingAuto)
Load XML from a stream.
String ShapeTypeToString(CollisionShape::ShapeType ShapeToConvert)
Get a string suitable for human eyes from a CollisionShape::ShapeType, may not be suitable for enduse...
Indicates the class is a CompoundCollisionShape.
float Real
A Datatype used to represent a real floating point number.
bool SetValue(const Char8 *rhs)
Set the value of this.
Indicates the class is a PlaneCollisionShape.
Indicates the class is a SphereCollisionShape.
btVector3 GetBulletVector3() const
Gets a Bullet vector3.
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 CollisionShape * PerformDeSerialization(std::istream &Stream)
This Performs the work of Deserializing that DeSerialize and DeSerializeAndRetrieve need to do...
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. ...
Indicates the class is a CylinderCollisionShape.
virtual String ContainerName() const
This will return the Name of the element that Contains multiple of the items to be DeSerialized...
virtual CollisionShape * DeSerializeAndRetrieve(std::istream &Stream)
Create a collision shape from the serialized version in a stream.
std::istream & DeSerialize(std::istream &Stream, T &Converted)
Deserialize the next xml tag in the stream into a specific in memory class instance.
virtual void ProtoDeSerialize(const XML::Node &OneNode)
Take the data stored in an XML and overwrite this instance of this object with it.
void DeSerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
A collision shape for soft proxies.
virtual std::istream & DeSerialize(std::istream &Stream)
Create a collision shape from the serialized version in a stream.
Thrown when parameters are checked at runtime and found invalid.
virtual void SetScaling(const Vector3 &Scaling)
Scales the collision shape on each of it's axes.
A cylinder physics shape.
The root node of any xml hierarchy is a Document.
virtual void _SetShapeName(const String &NewName)
Sets the name of this collision shape.
virtual Real GetMargin() const
Gets the amount of padding currently being applied to the collision shape.
Indicates the class is a BoxCollisionShape.
This is used to represent a point in space, or a vector through space.
String Name
Storage for the name of this class instance.
The bulk of the engine components go in this namspace.
virtual CollisionShape * ProtoDeSerialize(const XML::Node &OneNode)
Convert An XML Node containing and one collision shape into a CollisionShape of the corresponding typ...
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.
A Flat wall/floor of limitless size.
CollisionShape::ShapeType StringToShapeType(const String &TypeName)
Convert a human readable string (as provided by ShapeTypeToString()) and convert it to a CollisionSha...
const Char8 * Name() const
ptrdiff_tGet the name of this Node.
CollisionShape::ShapeType InternalShapeTypeToShapeType(int InternalShapeType)
Convert from a Internal Collision Shape to a CollisionShape::ShapeType.
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.
Indicates the class is a CapsuleCollisionShape.
Indicates the class is a ConvexHullCollisionShape.
A series of values that store hieght in a grid like fashion.
void ProtoSerialize(XML::Node &CurrentRoot) const
Convert this class to an XML::Node ready for serialization.
A collision shape composed of many other collision shapes placed and oriented in local space...
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
virtual const String & GetName() const
Gets the name of this shape.