40 #ifndef _gravitywell_cpp
41 #define _gravitywell_cpp
43 #include "gravitywell.h"
45 #include "Physics/rigidproxy.h"
46 #include "Physics/ghostproxy.h"
47 #include "Physics/physicsmanager.h"
53 #include "stringtool.h"
96 {
return Mezzanine::WO_AreaEffectGravityWell; }
113 (*AddedIt)->GetProxies(Mezzanine::PT_Physics_RigidProxy,RigidProxies);
114 for(
ProxyIterator ProxIt = RigidProxies.begin() ; ProxIt != RigidProxies.end() ; ++ProxIt )
125 Real Distance = 0,AppliedStrength = 0;
130 (*ObjIt)->GetProxies(Mezzanine::PT_Physics_RigidProxy,RigidProxies);
131 if( RigidProxies.empty() )
134 Distance = ObjectLoc.
Distance(SelfLoc);
135 Direction = (SelfLoc - ObjectLoc) / Distance;
150 for(
ProxyIterator ProxIt = RigidProxies.begin() ; ProxIt != RigidProxies.end() ; ++ProxIt )
155 if( 0 > AppliedStrength ) {
159 RigProx->
ApplyForce( Direction * (AppliedStrength * Mass ) );
170 (*RemovedIt)->GetProxies(Mezzanine::PT_Physics_RigidProxy,RigidProxies);
171 for(
ProxyIterator ProxIt = RigidProxies.begin() ; ProxIt != RigidProxies.end() ; ++ProxIt )
241 if( !PropertiesNode.
Empty() ) {
243 CurrAttrib = PropertiesNode.
GetAttribute(
"AttenAmount");
244 if( !CurrAttrib.
Empty() )
248 if( !CurrAttrib.
Empty() )
252 if( !CurrAttrib.
Empty() )
255 CurrAttrib = PropertiesNode.
GetAttribute(
"AllowWorldGravity");
256 if( !CurrAttrib.
Empty() )
270 {
return "GravityWell"; }
300 {
delete ToBeDestroyed; }
virtual void SetFieldStrength(const Real FieldStrength)
Sets the strenth of the field.
virtual void SetAttenuationAmount(const Real Amount)
Sets the amount of force that is attenuated over distance.
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.
WorldManager * GetManager(const Whole ManagerToGet)
This is will find the manager of a given type.
A light-weight handle for manipulating attributes in DOM tree.
virtual void ApplyForce(const Vector3 &Force)
Push/Apply force to an proxy.
virtual ~GravityWellFactory()
Class destructor.
ObjectContainer AddedObjects
Container of actors that have been added since last frame.
bool Boole
Generally acts a single bit, true or false.
Quadratic/Exponential Attentuation, similar to real gravity, it tapers of more the further from the c...
ObjectContainer::iterator ObjectIterator
Iterator type for Object instances stored by this class.
Thrown when the requested identity could not be found.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Real AttenAmount
how much does the Gravity attenuate.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
This is a gravity well implementation of the AreaEffect class.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
virtual Vector3 GetLocation() const
Gets this objects current location.
virtual Boole GetAllowWorldGravity() const
Gets whether or not world gravity is is removed for objects inside this field.
virtual String GetDerivedSerializableName() const
Gets the most derived serializable name of this WorldObject.
const Char8 * AsString(const Char8 *def="") const
Attempts to convert the value of the attribute to a String and returns the results.
virtual void SetAllowWorldGravity(Boole WorldGravity)
Sets whether or not world gravity should be removed for objects in this field.
World * ParentWorld
This is the world this object belongs to and will be inserted in/removed from.
static String GetSerializableName()
Get the name of the the XML tag the proxy class will leave behind as its instances are serialized...
virtual void DestroyAreaEffect(AreaEffect *ToBeDestroyed)
virtual AreaEffect * CreateAreaEffect(const String &Name, World *TheWorld, const NameValuePairMap &Params)
ObjectContainer OverlappingObjects
Container for actors within the field area.
virtual Real GetFieldStrength() const
Gets the strength of the field.
No Attentuation, Equal strength through.
bool Empty() const
Is this storing anything at all?
virtual ~GravityWell()
Class destructor.
This implements the exception hiearchy for Mezzanine.
virtual String GetTypeName() const
Real Distance(const Vector3 &OtherVec) const
Gets the distance between this and another vector.
Linear attentuation, Strength weaker farther from center.
float Real
A Datatype used to represent a real floating point number.
The interface for serialization.
std::vector< WorldProxy * > ProxyContainer
Basic container type for WorldProxy storage by this class.
bool SetValue(const Char8 *rhs)
Set the value of this.
This class is used to define area's in the world that have unique effects.
Boole AllowWorldGrav
Should world gravity ne ignored.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Whole AsWhole(Whole def=0) const
Attempts to convert the value of the attribute to a Whole and returns the results.
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 ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
bool Empty() const
Is this storing anything at all?
virtual Real GetAttenuationAmount() const
Gets the amount force is attenuated over distance.
virtual GravityWell * CreateGravityWell(const String &Name, World *TheWorld)
Creates a GravityWell object.
Real AsReal(Real def=0) const
Attempts to convert the value of the attribute to a Real and returns the results. ...
Physics::GhostProxy * Ghost
A pointer to the ghost powering this AE field.
virtual Mezzanine::WorldObjectType GetType() const
Gets the type of the object instance.
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
GravityWellFactory()
Class constructor.
This is a proxy from which rigid body proxys are handled.
This is simply a place for storing all the Physics Related functions.
GravityWell(World *TheWorld)
Blank constructor.
Mezzanine::AttenuationStyle AttenStyle
How does gravity.
ProxyContainer::iterator ProxyIterator
Iterator type for WorldProxy instances stored by this class.
This is used to represent a point in space, or a vector through space.
virtual void ApplyEffect()
virtual void SetAttenuation(const Real Amount, const Mezzanine::AttenuationStyle Style)
Sets the attenuation for this field.
WorldObjectType
Used by various classes to help identify what class an object is.
The bulk of the engine components go in this namspace.
This class represents a world for objects to interact within.
virtual void SetAttenuationStyle(const Mezzanine::AttenuationStyle Style)
Sets the method of attenuation of force over a distance.
virtual void SetGravity(const Vector3 &Gravity)
Sets the gravity for only this proxy.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
ObjectContainer RemovedObjects
Container of actors that have been removed since last frame.
std::map< String, String > NameValuePairMap
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
Real Strength
The amount of force exerted on other objects.
std::string String
A datatype used to a series of characters.
AttenuationStyle
These values represent the kind of attenuation applied to the field strength over a distance...
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
virtual Mezzanine::AttenuationStyle GetAttenuationStyle() const
Gets the Style of attenuation applied.
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
virtual Real GetMass() const
Get the total Mass of the proxy.