AnimatLab  2
Test
FluidPlane.cpp
1 // FluidPlane.cpp: implementation of the FluidPlane class.
2 //
4 
5 #include "StdAfx.h"
6 #include "IMovableItemCallback.h"
7 #include "ISimGUICallback.h"
8 #include "AnimatBase.h"
9 
10 #include "Node.h"
11 #include "IPhysicsMovableItem.h"
12 #include "IPhysicsBody.h"
13 #include "BoundingBox.h"
14 #include "MovableItem.h"
15 #include "BodyPart.h"
16 #include "Joint.h"
17 #include "ReceptiveField.h"
18 #include "ContactSensor.h"
19 #include "RigidBody.h"
20 #include "Plane.h"
21 #include "FluidPlane.h"
22 #include "Structure.h"
23 #include "Organism.h"
24 #include "ActivatedItem.h"
25 #include "ActivatedItemMgr.h"
26 #include "DataChartMgr.h"
27 #include "ExternalStimuliMgr.h"
28 #include "KeyFrame.h"
29 #include "SimulationRecorder.h"
30 #include "OdorType.h"
31 #include "Odor.h"
32 #include "Light.h"
33 #include "LightManager.h"
34 #include "Simulator.h"
35 
36 namespace AnimatSim
37 {
38  namespace Environment
39  {
40  namespace Bodies
41  {
42 
50 {
51 }
52 
60 {
61 
62 }
63 
64 
73 CStdFPoint FluidPlane::Velocity() {return m_vVelocity;}
74 
85 void FluidPlane::Velocity(CStdFPoint &oPoint, bool bUseScaling)
86 {
87  if(bUseScaling)
89  else
90  m_vVelocity = oPoint;
91 }
92 
105 void FluidPlane::Velocity(float fltX, float fltY, float fltZ, bool bUseScaling)
106 {
107  CStdFPoint vPos(fltX, fltY, fltZ);
108  Velocity(vPos, bUseScaling);
109 }
110 
122 void FluidPlane::Velocity(std::string strXml, bool bUseScaling)
123 {
124  CStdXml oXml;
125  oXml.Deserialize(strXml);
126  oXml.FindElement("Root");
127  oXml.FindChildElement("Velocity");
128 
129  CStdFPoint vPos;
130  Std_LoadPoint(oXml, "Velocity", vPos);
131  Velocity(vPos, bUseScaling);
132 }
133 
144 {}
145 
146 bool FluidPlane::AllowRotateDragX() {return false;}
147 
148 bool FluidPlane::AllowRotateDragY() {return false;}
149 
150 bool FluidPlane::AllowRotateDragZ() {return false;}
151 
152 bool FluidPlane::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
153 {
154  std::string strType = Std_CheckString(strDataType);
155 
156  if(Plane::SetData(strType, strValue, false))
157  return true;
158 
159  if(strType == "VELOCITY")
160  {
161  Velocity(strValue);
162  return true;
163  }
164 
165  if(strType == "GRAVITY")
166  {
167  SetGravity();
168  return true;
169  }
170 
171  //If it was not one of those above then we have a problem.
172  if(bThrowError)
173  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
174 
175  return false;
176 }
177 
178 void FluidPlane::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
179 {
180  Plane::QueryProperties(aryProperties);
181 
182  aryProperties.Add(new TypeProperty("Velocity", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
183  aryProperties.Add(new TypeProperty("Gravity", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
184 }
185 
186 void FluidPlane::Load(CStdXml &oXml)
187 {
188  Plane::Load(oXml);
189 
190  oXml.IntoElem(); //Into RigidBody Element
191 
192  CStdFPoint vPoint;
193  Std_LoadPoint(oXml, "Velocity", vPoint, false);
194  Velocity(vPoint);
195 
196  oXml.OutOfElem(); //OutOf RigidBody Element
197 }
198 
199  } //Bodies
200  } //Environment
201 } //AnimatSim
virtual void Deserialize(std::string &strXml)
Deserializes a string into an xml document.
Definition: StdXml.cpp:162
Base class file for all Animat simulation objects.
CStdFPoint m_vVelocity
This is the velocity of the fluid.
Definition: FluidPlane.h:34
Declares the simulation recorder class.
virtual bool FindChildElement(std::string strElementName, bool fThrowError=true)
Finds a child element by name.
Definition: StdXml.cpp:256
Simulator * m_lpMovableSim
The pointer to a Simulation.
Definition: MovableItem.h:23
virtual bool AllowRotateDragZ()
Gets whether this body part can be rotated along the z-axis by the user with the drag handlers...
Definition: FluidPlane.cpp:150
Root namespace for the base simulation library for AnimatLab.
virtual bool AllowRotateDragX()
Gets whether this body part can be rotated along the x-axis by the user with the drag handlers...
Definition: FluidPlane.cpp:146
Declares the body part class.
virtual bool FindElement(std::string strElementName, bool fThrowError=true)
Finds an element with the specified name.
Definition: StdXml.cpp:179
virtual bool IntoElem()
Goes into the next element where the cursor is located.
Definition: StdXml.cpp:42
Class that stores information about types for QueryProperty information.
Definition: TypeProperty.h:35
Declares the key frame class.
Declares the plane class.
Declares the joint class.
Declares the organism class.
Declares a light object.
Declares the activated item class.
Declares a light manager object.
Declares the bounding box class.
A standard xml manipulation class.
Definition: StdXml.h:19
virtual CStdFPoint Velocity()
Gets the velocity of the fluid.
Definition: FluidPlane.cpp:73
Declares the node class.
virtual bool AllowRotateDragY()
Gets whether this body part can be rotated along the y-axis by the user with the drag handlers...
Definition: FluidPlane.cpp:148
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
Definition: StdXml.cpp:56
Declares the fluid plane class.
Declares the data chart manager class.
Declares the rigid body class.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
bool Std_LoadPoint(CStdXml &oXml, std::string strName, CStdIPoint &oPoint, bool bThrowError)
Standard load point.
Declares the structure class.
Declares the odor type class.
virtual void SetGravity()
Sets the gravity of the fluid.
Definition: FluidPlane.cpp:143
virtual float InverseDistanceUnits()
Gets the inverse distance units.
Definition: Simulator.cpp:1742
Declares the odor class.
Declares the simulator class.
Declares the activated item manager class.
Declares the contact sensor class.
Declares the external stimuli manager class.
Declares the receptive field class.