6 #include "VsClassFactory.h"
8 #include "VsConstraintRelaxation.h"
9 #include "VsConstraintFriction.h"
10 #include "VsMovableItem.h"
13 #include "VsMotorizedJoint.h"
14 #include "VsRigidBody.h"
18 #include "VsBoxTest.h"
19 #include "VsCylinder.h"
27 #include "VsMeshBase.h"
29 #include "VsTerrain.h"
36 #include "VsFreeJoint.h"
39 #include "VsAttachment.h"
42 #include "VsLinearHillMuscle.h"
43 #include "VsLinearHillStretchReceptor.h"
48 #include "VsSimulator.h"
50 #include "VsMaterialType.h"
56 #include "VsForceStimulus.h"
61 #include "VsSimulationWindow.h"
62 #include "VsScriptedSimulationWindow.h"
63 #include "VsDragger.h"
74 VsClassFactory::VsClassFactory()
79 VsClassFactory::~VsClassFactory()
86 RigidBody *VsClassFactory::CreateRigidBody(std::string strType,
bool bThrowError)
88 RigidBody *lpPart=NULL;
96 else if(strType ==
"BOXTEST")
98 else if(strType ==
"BOXCONTACTSENSOR")
103 else if(strType ==
"CYLINDER")
105 else if(strType ==
"CYLINDERCONTACTSENSOR")
110 else if(strType ==
"CONE")
112 else if(strType ==
"SPHERE")
114 else if(strType ==
"PLANE")
116 else if(strType ==
"PLANETEST")
118 else if(strType ==
"ATTACHMENT")
120 else if(strType ==
"LINEARHILLMUSCLE")
122 else if(strType ==
"LINEARHILLSTRETCHRECEPTOR")
124 else if(strType ==
"SPRING")
126 else if(strType ==
"TORUS")
128 else if(strType ==
"ELLIPSOID")
130 else if(strType ==
"MOUTH")
132 else if(strType ==
"ODORSENSOR")
134 else if(strType ==
"FLUIDPLANE")
136 else if(strType ==
"TERRAIN")
138 else if(strType ==
"MESH")
140 else if(strType ==
"STOMACH")
141 lpPart =
new Stomach;
146 THROW_PARAM_ERROR(Al_Err_lInvalidPartType, Al_Err_strInvalidPartType,
"PartType", strType);
151 catch(CStdErrorInfo oError)
153 if(lpPart)
delete lpPart;
159 if(lpPart)
delete lpPart;
160 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
170 Joint *VsClassFactory::CreateJoint(std::string strType,
bool bThrowError)
178 if(strType ==
"HINGE")
180 else if(strType ==
"PRISMATIC")
182 else if(strType ==
"BALLSOCKET")
184 else if(strType ==
"RPRO")
186 else if(strType ==
"STATIC")
188 else if(strType ==
"UNIVERSAL")
190 else if(strType ==
"FREEJOINT")
192 else if(strType ==
"DISTANCE")
198 THROW_PARAM_ERROR(Al_Err_lInvalidJointType, Al_Err_strInvalidJointType,
"JointType", strType);
203 catch(CStdErrorInfo oError)
205 if(lpJoint)
delete lpJoint;
211 if(lpJoint)
delete lpJoint;
212 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
221 Structure *VsClassFactory::CreateStructure(std::string strType,
bool bThrowError)
223 Structure *lpStructure=NULL;
229 if(strType ==
"BASIC")
231 else if(strType ==
"ORGANISM")
233 else if(strType ==
"STRUCTURE")
239 THROW_PARAM_ERROR(Al_Err_lInvalidOrganismType, Al_Err_strInvalidOrganismType,
"OrganismType", strType);
244 catch(CStdErrorInfo oError)
246 if(lpStructure)
delete lpStructure;
252 if(lpStructure)
delete lpStructure;
253 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
263 Simulator *VsClassFactory::CreateSimulator(std::string strType,
bool bThrowError)
265 Simulator *lpSimulator=NULL;
271 if(strType ==
"VORTEXSIMULATOR")
273 else if(strType ==
"")
279 THROW_PARAM_ERROR(Al_Err_lInvalidSimulatorType, Al_Err_strInvalidSimulatorType,
"SimulatorType", strType);
284 catch(CStdErrorInfo oError)
286 if(lpSimulator)
delete lpSimulator;
292 if(lpSimulator)
delete lpSimulator;
293 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
303 KeyFrame *VsClassFactory::CreateKeyFrame(std::string strType,
bool bThrowError)
305 KeyFrame *lpFrame=NULL;
324 catch(CStdErrorInfo oError)
326 if(lpFrame)
delete lpFrame;
332 if(lpFrame)
delete lpFrame;
333 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
343 DataChart *VsClassFactory::CreateDataChart(std::string strType,
bool bThrowError)
345 DataChart *lpChart=NULL;
351 if(strType ==
"TABFILE")
352 lpChart =
new FileChart;
353 else if(strType ==
"FILECHART")
354 lpChart =
new FileChart;
355 else if(strType ==
"MEMORYCHART")
356 lpChart =
new MemoryChart;
357 else if(strType ==
"ARRAYCHART")
358 lpChart =
new ArrayChart;
363 THROW_PARAM_ERROR(Al_Err_lInvalidDataChartType, Al_Err_strInvalidDataChartType,
"DataChartType", strType);
368 catch(CStdErrorInfo oError)
370 if(lpChart)
delete lpChart;
376 if(lpChart)
delete lpChart;
377 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
386 DataColumn *VsClassFactory::CreateDataColumn(std::string strType,
bool bThrowError)
388 DataColumn *lpColumn=NULL;
394 if(strType ==
"DATACOLUMN")
395 lpColumn =
new DataColumn;
406 THROW_PARAM_ERROR(Al_Err_lInvalidDataColumnType, Al_Err_strInvalidDataColumnType,
"DataColumnType", strType);
411 catch(CStdErrorInfo oError)
413 if(lpColumn)
delete lpColumn;
419 if(lpColumn)
delete lpColumn;
420 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
430 Adapter *VsClassFactory::CreateAdapter(std::string strType,
bool bThrowError)
432 Adapter *lpAdapter=NULL;
438 if(strType ==
"NODETONODE")
439 lpAdapter =
new Adapter;
440 else if(strType ==
"NODETOPHYSICAL")
441 lpAdapter =
new Adapter;
442 else if(strType ==
"PHYSICALTONODE")
443 lpAdapter =
new Adapter;
444 else if(strType ==
"CONTACT")
445 lpAdapter =
new ContactAdapter;
446 else if(strType ==
"PROPERTYCONTROLADAPTER")
447 lpAdapter =
new PropertyControlAdapter;
452 THROW_PARAM_ERROR(Al_Err_lInvalidAdapterType, Al_Err_strInvalidAdapterType,
"AdapterType", strType);
457 catch(CStdErrorInfo oError)
459 if(lpAdapter)
delete lpAdapter;
465 if(lpAdapter)
delete lpAdapter;
466 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
476 Gain *VsClassFactory::CreateGain(std::string strType,
bool bThrowError)
484 if(strType ==
"BELL")
485 lpGain =
new BellGain;
486 else if(strType ==
"EQUATION")
487 lpGain =
new EquationGain;
488 else if(strType ==
"POLYNOMIAL")
489 lpGain =
new PolynomialGain;
490 else if(strType ==
"SIGMOID")
491 lpGain =
new SigmoidGain;
496 THROW_PARAM_ERROR(Al_Err_lInvalidGainType, Al_Err_strInvalidGainType,
"GainType", strType);
501 catch(CStdErrorInfo oError)
503 if(lpGain)
delete lpGain;
509 if(lpGain)
delete lpGain;
510 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
520 ExternalStimulus *VsClassFactory::CreateExternalStimulus(std::string strType,
bool bThrowError)
528 if(strType ==
"MOTORVELOCITY" || strType ==
"MOTORPOSITION")
530 else if(strType ==
"FORCEINPUT")
532 else if(strType ==
"NODEINPUT")
533 lpStimulus =
new ExternalInputStimulus;
534 else if(strType ==
"RIGIDBODYINPUT")
535 lpStimulus =
new ExternalInputStimulus;
536 else if(strType ==
"JOINTINPUT")
537 lpStimulus =
new ExternalInputStimulus;
538 else if(strType ==
"ENABLERINPUT")
539 lpStimulus =
new EnablerStimulus;
540 else if(strType ==
"INVERSEMUSCLECURRENT")
541 lpStimulus =
new InverseMuscleCurrent;
542 else if(strType ==
"CURRENT")
544 else if(strType ==
"VOLTAGECLAMP")
546 else if(strType ==
"PROPERTYCONTROLSTIMULUS")
552 THROW_PARAM_ERROR(Al_Err_lInvalidExternalStimulusType, Al_Err_strInvalidExternalStimulusType,
"ExternalStimulusType", strType);
557 catch(CStdErrorInfo oError)
559 if(lpStimulus)
delete lpStimulus;
565 if(lpStimulus)
delete lpStimulus;
566 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
576 HudItem *VsClassFactory::CreateHudItem(std::string strType,
bool bThrowError)
578 HudItem *lpItem=NULL;
584 if(strType ==
"HUDTEXT")
590 THROW_PARAM_ERROR(Vs_Err_lInvalidHudItemType, Vs_Err_strInvalidHudItemType,
"HudItem", strType);
595 catch(CStdErrorInfo oError)
597 if(lpItem)
delete lpItem;
603 if(lpItem)
delete lpItem;
604 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
613 Hud *VsClassFactory::CreateHud(std::string strType,
bool bThrowError)
627 THROW_PARAM_ERROR(Vs_Err_lInvalidHudItemType, Vs_Err_strInvalidHudItemType,
"Hud", strType);
632 catch(CStdErrorInfo oError)
634 if(lpHud)
delete lpHud;
640 if(lpHud)
delete lpHud;
641 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
650 MaterialType *VsClassFactory::CreateMaterialItem(std::string strType,
bool bThrowError)
652 MaterialType *lpItem=NULL;
658 if(strType ==
"BASIC" || strType ==
"DEFAULT"|| strType ==
"VORTEX")
664 THROW_PARAM_ERROR(Vs_Err_lInvalidMaterialItemType, Vs_Err_strInvalidMaterialItemType,
"Material Pair", strType);
669 catch(CStdErrorInfo oError)
671 if(lpItem)
delete lpItem;
677 if(lpItem)
delete lpItem;
678 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
687 SimulationWindow *VsClassFactory::CreateWindowItem(std::string strType,
bool bThrowError)
689 SimulationWindow *lpItem=NULL;
695 if(strType ==
"BASIC" || strType ==
"DEFAULT")
697 else if(strType ==
"SCRIPTEDSIMWINDOW")
703 THROW_PARAM_ERROR(Vs_Err_lInvalidSimWindowType, Vs_Err_strInvalidSimWindowType,
"Simulation Window", strType);
708 catch(CStdErrorInfo oError)
710 if(lpItem)
delete lpItem;
716 if(lpItem)
delete lpItem;
717 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
726 Light *VsClassFactory::CreateLight(std::string strType,
bool bThrowError)
734 if(strType ==
"LIGHT")
740 THROW_PARAM_ERROR(Vs_Err_lInvalidLightType, Vs_Err_strInvalidLightType,
"Light Type", strType);
745 catch(CStdErrorInfo oError)
747 if(lpItem)
delete lpItem;
753 if(lpItem)
delete lpItem;
754 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
763 NeuralModule *VsClassFactory::CreateNeuralModule(std::string strType,
bool bThrowError)
765 NeuralModule *lpModule=NULL;
771 if(strType ==
"PHYSICSNEURALMODULE")
780 THROW_PARAM_ERROR(Al_Err_lInvalidNeuralModuleType, Al_Err_strInvalidNeuralModuleType,
"NeuralModule", strType);
785 catch(CStdErrorInfo oError)
787 if(lpModule)
delete lpModule;
793 if(lpModule)
delete lpModule;
794 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
804 ConstraintRelaxation *VsClassFactory::CreateConstraintRelaxation(std::string strType,
bool bThrowError)
806 ConstraintRelaxation *lpRelax=NULL;
812 if(strType ==
"CONSTRAINTRELAXATION" || strType ==
"DEFAULT")
820 THROW_PARAM_ERROR(Al_Err_lInvalidRelaxationType, Al_Err_strInvalidRelaxationType,
"Relaxation", strType);
825 catch(CStdErrorInfo oError)
827 if(lpRelax)
delete lpRelax;
833 if(lpRelax)
delete lpRelax;
834 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
844 ConstraintFriction *VsClassFactory::CreateConstraintFriction(std::string strType,
bool bThrowError)
846 ConstraintFriction *lpFriction=NULL;
852 if(strType ==
"CONSTRAINTRELAXATION" || strType ==
"DEFAULT")
860 THROW_PARAM_ERROR(Al_Err_lInvalidFrictionType, Al_Err_strInvalidFrictionType,
"Friction", strType);
865 catch(CStdErrorInfo oError)
867 if(lpFriction)
delete lpFriction;
873 if(lpFriction)
delete lpFriction;
874 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
884 RemoteControlLinkage *VsClassFactory::CreateRemoteControlLinkage(std::string strType,
bool bThrowError)
886 RemoteControlLinkage *lpLink=NULL;
892 if(strType ==
"PASSTHROUGHLINKAGE")
894 lpLink =
new PassThroughLinkage;
896 else if(strType ==
"PULSEDLINKAGE")
898 lpLink =
new PulsedLinkage;
904 THROW_PARAM_ERROR(Al_Err_lInvalidFrictionType, Al_Err_strInvalidFrictionType,
"Friction", strType);
909 catch(CStdErrorInfo oError)
911 if(lpLink)
delete lpLink;
917 if(lpLink)
delete lpLink;
918 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
929 CStdSerialize *VsClassFactory::CreateObject(std::string strClassType, std::string strObjectType,
bool bThrowError)
935 if(strClassType ==
"RIGIDBODY")
936 lpObject = CreateRigidBody(strObjectType, bThrowError);
937 else if(strClassType ==
"JOINT")
938 lpObject = CreateJoint(strObjectType, bThrowError);
939 else if(strClassType ==
"ORGANISM")
940 lpObject = CreateStructure(strObjectType, bThrowError);
941 else if(strClassType ==
"STRUCTURE")
942 lpObject = CreateStructure(strObjectType, bThrowError);
943 else if(strClassType ==
"SIMULATOR")
944 lpObject = CreateSimulator(strObjectType, bThrowError);
945 else if(strClassType ==
"KEYFRAME")
946 lpObject = CreateKeyFrame(strObjectType, bThrowError);
947 else if(strClassType ==
"DATACHART")
948 lpObject = CreateDataChart(strObjectType, bThrowError);
949 else if(strClassType ==
"DATACOLUMN")
950 lpObject = CreateDataColumn(strObjectType, bThrowError);
951 else if(strClassType ==
"EXTERNALSTIMULUS")
952 lpObject = CreateExternalStimulus(strObjectType, bThrowError);
953 else if(strClassType ==
"ADAPTER")
954 lpObject = CreateAdapter(strObjectType, bThrowError);
955 else if(strClassType ==
"GAIN")
956 lpObject = CreateGain(strObjectType, bThrowError);
957 else if(strClassType ==
"HUDITEM")
958 lpObject = CreateHudItem(strObjectType, bThrowError);
959 else if(strClassType ==
"HUD")
960 lpObject = CreateHud(strObjectType, bThrowError);
961 else if(strClassType ==
"MATERIAL")
962 lpObject = CreateMaterialItem(strObjectType, bThrowError);
963 else if(strClassType ==
"SIMULATIONWINDOW")
964 lpObject = CreateWindowItem(strObjectType, bThrowError);
965 else if(strClassType ==
"LIGHT")
966 lpObject = CreateLight(strObjectType, bThrowError);
967 else if(strClassType ==
"NEURALMODULE")
968 lpObject = CreateNeuralModule(strObjectType, bThrowError);
969 else if(strClassType ==
"CONSTRAINTRELAXATION")
970 lpObject = CreateConstraintRelaxation(strObjectType, bThrowError);
971 else if(strClassType ==
"CONSTRAINTFRICTION")
972 lpObject = CreateConstraintFriction(strObjectType, bThrowError);
973 else if(strClassType ==
"REMOTECONTROLLINKAGE")
974 lpObject = CreateRemoteControlLinkage(strObjectType, bThrowError);
979 THROW_PARAM_ERROR(Std_Err_lInvalidClassType, Std_Err_strInvalidClassType,
"ClassType", strClassType);
990 extern "C" __declspec(dllexport)
IStdClassFactory* __cdecl GetStdClassFactory()
996 extern "C" __declspec(dllexport) int __cdecl BootstrapRunLibrary(
int argc, const
char **argv)
998 Simulator *lpSim = NULL;
1002 Simulator *lpSim = Simulator::CreateSimulator(argc, argv);
1005 lpSim->Initialize(argc, argv);
1006 lpSim->VisualSelectionMode(SIMULATION_SELECTION_MODE);
1009 if(lpSim)
delete lpSim;
1013 catch(CStdErrorInfo oError)
1015 if(lpSim)
delete lpSim;
1016 printf(
"Error occurred: %s\n", oError.m_strError) ;
1017 return (
int) oError.m_lError;
1021 if(lpSim)
delete lpSim;
1022 printf(
"An Unknown Error occurred.\n") ;
Declares the vs prismatic class.
virtual IStdClassFactory * ClassFactory()
Gets the class factory.
Declares the vortex heads-up display class.
Vortex physical structure implementation.
Declares the vortex relative position, relative orientation class.
Declares the vortex Torus class.
Declares the vortex fluid plane class.
Declares the vortex heads-up display text class.
Vortex physical structure implementation.
Declares the vortex organism class.
Vortex ball-and-socket joint class.
std::string Std_Trim(std::string strVal)
Trims a string.
Declares the vortex mouth class.
Declares the vortex odor sensor class.
Declares the vortex plane class.
Declares the vs motor velocity stimulus class.
Vortex Organism implementation.
Declares the vs universal class.
Current stimulus for neural items.
This stimulus enables or disables a joint or body part for a specified period of time.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
Declares the vortex ellipsoid class.
Declares the vortex hinge class.
virtual bool IsContactSensor()
Query if this object is contact sensor.
Declares the vortex distance joint class.
Declares the vortex plane class.
Vortex relative position, relative orientation joint class.
Declares the vortex Light class.
Vortex hinge joint class.
Declares the vortex ball socket class.
std::string Std_ToUpper(std::string strVal)
Converts a string to upper case.
Declares the vortex structure class.