6 #include "BlClassFactory.h"
8 #include "BlConstraintRelaxation.h"
9 #include "BlConstraintFriction.h"
11 #include "BlMotorizedJoint.h"
12 #include "BlRigidBody.h"
15 #include "BlCylinder.h"
21 #include "BlMeshBase.h"
23 #include "BlTerrain.h"
33 #include "BlLinearHillMuscle.h"
34 #include "BlLinearHillStretchReceptor.h"
37 #include "BlSimulator.h"
39 #include "BlMaterialType.h"
43 extern "C" __declspec(dllexport)
IStdClassFactory* __cdecl GetStdClassFactory()
53 extern "C" __declspec(dllexport) int __cdecl BootstrapRunLibrary(
int argc, const
char **argv)
55 extern "C" int BootstrapRunLibrary(
int argc,
const char **argv)
58 Simulator *lpSim = NULL;
62 Simulator *lpSim = Simulator::CreateSimulator(argc, argv);
65 lpSim->Initialize(argc, argv);
66 lpSim->VisualSelectionMode(SIMULATION_SELECTION_MODE);
69 if(lpSim)
delete lpSim;
73 catch(CStdErrorInfo oError)
75 if(lpSim)
delete lpSim;
76 printf(
"Error occurred: %s\n", oError.m_strError.c_str()) ;
77 return (
int) oError.m_lError;
81 if(lpSim)
delete lpSim;
82 printf(
"An Unknown Error occurred.\n") ;
96 BlClassFactory::BlClassFactory()
101 BlClassFactory::~BlClassFactory()
108 RigidBody *BlClassFactory::CreateRigidBody(std::string strType,
bool bThrowError)
110 RigidBody *lpPart=NULL;
118 else if(strType ==
"BOXCONTACTSENSOR")
123 else if(strType ==
"CYLINDER")
125 else if(strType ==
"CYLINDERCONTACTSENSOR")
130 else if(strType ==
"CONE")
132 else if(strType ==
"SPHERE")
134 else if(strType ==
"PLANE")
136 else if(strType ==
"ATTACHMENT")
138 else if(strType ==
"LINEARHILLMUSCLE")
140 else if(strType ==
"LINEARHILLSTRETCHRECEPTOR")
142 else if(strType ==
"SPRING")
144 else if(strType ==
"TORUS")
146 else if(strType ==
"ELLIPSOID")
148 else if(strType ==
"MOUTH")
150 else if(strType ==
"ODORSENSOR")
152 else if(strType ==
"FLUIDPLANE")
154 else if(strType ==
"TERRAIN")
156 else if(strType ==
"MESH")
158 else if(strType ==
"STOMACH")
159 lpPart =
new Stomach;
164 THROW_PARAM_ERROR(Al_Err_lInvalidPartType, Al_Err_strInvalidPartType,
"PartType", strType);
169 catch(CStdErrorInfo oError)
171 if(lpPart)
delete lpPart;
177 if(lpPart)
delete lpPart;
178 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
188 Joint *BlClassFactory::CreateJoint(std::string strType,
bool bThrowError)
196 if(strType ==
"HINGE")
198 else if(strType ==
"PRISMATIC")
200 else if(strType ==
"BALLSOCKET")
202 else if(strType ==
"RPRO")
204 else if(strType ==
"STATIC")
206 else if(strType ==
"UNIVERSAL")
208 else if(strType ==
"FREEJOINT")
210 else if(strType ==
"DISTANCE")
216 THROW_PARAM_ERROR(Al_Err_lInvalidJointType, Al_Err_strInvalidJointType,
"JointType", strType);
221 catch(CStdErrorInfo oError)
223 if(lpJoint)
delete lpJoint;
229 if(lpJoint)
delete lpJoint;
230 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
239 Structure *BlClassFactory::CreateStructure(std::string strType,
bool bThrowError)
241 Structure *lpStructure=NULL;
247 if(strType ==
"BASIC")
248 lpStructure =
new OsgOrganism;
249 else if(strType ==
"ORGANISM")
250 lpStructure =
new OsgOrganism;
251 else if(strType ==
"STRUCTURE")
252 lpStructure =
new OsgStructure;
257 THROW_PARAM_ERROR(Al_Err_lInvalidOrganismType, Al_Err_strInvalidOrganismType,
"OrganismType", strType);
262 catch(CStdErrorInfo oError)
264 if(lpStructure)
delete lpStructure;
270 if(lpStructure)
delete lpStructure;
271 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
281 Simulator *BlClassFactory::CreateSimulator(std::string strType,
bool bThrowError)
283 Simulator *lpSimulator=NULL;
289 if(strType ==
"VORTEXSIMULATOR" || strType ==
"BULLETSIMULATOR")
291 else if(strType ==
"")
297 THROW_PARAM_ERROR(Al_Err_lInvalidSimulatorType, Al_Err_strInvalidSimulatorType,
"SimulatorType", strType);
302 catch(CStdErrorInfo oError)
304 if(lpSimulator)
delete lpSimulator;
310 if(lpSimulator)
delete lpSimulator;
311 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
321 KeyFrame *BlClassFactory::CreateKeyFrame(std::string strType,
bool bThrowError)
323 KeyFrame *lpFrame=NULL;
342 catch(CStdErrorInfo oError)
344 if(lpFrame)
delete lpFrame;
350 if(lpFrame)
delete lpFrame;
351 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
361 DataChart *BlClassFactory::CreateDataChart(std::string strType,
bool bThrowError)
363 DataChart *lpChart=NULL;
369 if(strType ==
"TABFILE")
370 lpChart =
new FileChart;
371 else if(strType ==
"FILECHART")
372 lpChart =
new FileChart;
373 else if(strType ==
"MEMORYCHART")
374 lpChart =
new MemoryChart;
375 else if(strType ==
"ARRAYCHART")
376 lpChart =
new ArrayChart;
381 THROW_PARAM_ERROR(Al_Err_lInvalidDataChartType, Al_Err_strInvalidDataChartType,
"DataChartType", strType);
386 catch(CStdErrorInfo oError)
388 if(lpChart)
delete lpChart;
394 if(lpChart)
delete lpChart;
395 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
404 DataColumn *BlClassFactory::CreateDataColumn(std::string strType,
bool bThrowError)
406 DataColumn *lpColumn=NULL;
412 if(strType ==
"DATACOLUMN")
413 lpColumn =
new DataColumn;
418 THROW_PARAM_ERROR(Al_Err_lInvalidDataColumnType, Al_Err_strInvalidDataColumnType,
"DataColumnType", strType);
423 catch(CStdErrorInfo oError)
425 if(lpColumn)
delete lpColumn;
431 if(lpColumn)
delete lpColumn;
432 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
442 Adapter *BlClassFactory::CreateAdapter(std::string strType,
bool bThrowError)
444 Adapter *lpAdapter=NULL;
450 if(strType ==
"NODETONODE")
451 lpAdapter =
new Adapter;
452 else if(strType ==
"NODETOPHYSICAL")
453 lpAdapter =
new Adapter;
454 else if(strType ==
"PHYSICALTONODE")
455 lpAdapter =
new Adapter;
456 else if(strType ==
"CONTACT")
457 lpAdapter =
new ContactAdapter;
458 else if(strType ==
"PROPERTYCONTROLADAPTER")
459 lpAdapter =
new PropertyControlAdapter;
464 THROW_PARAM_ERROR(Al_Err_lInvalidAdapterType, Al_Err_strInvalidAdapterType,
"AdapterType", strType);
469 catch(CStdErrorInfo oError)
471 if(lpAdapter)
delete lpAdapter;
477 if(lpAdapter)
delete lpAdapter;
478 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
488 Gain *BlClassFactory::CreateGain(std::string strType,
bool bThrowError)
496 if(strType ==
"BELL")
497 lpGain =
new BellGain;
498 else if(strType ==
"EQUATION")
499 lpGain =
new EquationGain;
500 else if(strType ==
"POLYNOMIAL")
501 lpGain =
new PolynomialGain;
502 else if(strType ==
"SIGMOID")
503 lpGain =
new SigmoidGain;
508 THROW_PARAM_ERROR(Al_Err_lInvalidGainType, Al_Err_strInvalidGainType,
"GainType", strType);
513 catch(CStdErrorInfo oError)
515 if(lpGain)
delete lpGain;
521 if(lpGain)
delete lpGain;
522 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
532 ExternalStimulus *BlClassFactory::CreateExternalStimulus(std::string strType,
bool bThrowError)
540 if(strType ==
"MOTORVELOCITY" || strType ==
"MOTORPOSITION")
542 else if(strType ==
"FORCEINPUT")
544 else if(strType ==
"NODEINPUT")
545 lpStimulus =
new ExternalInputStimulus;
546 else if(strType ==
"RIGIDBODYINPUT")
547 lpStimulus =
new ExternalInputStimulus;
548 else if(strType ==
"JOINTINPUT")
549 lpStimulus =
new ExternalInputStimulus;
550 else if(strType ==
"ENABLERINPUT")
551 lpStimulus =
new EnablerStimulus;
552 else if(strType ==
"INVERSEMUSCLECURRENT")
553 lpStimulus =
new InverseMuscleCurrent;
554 else if(strType ==
"CURRENT")
556 else if(strType ==
"VOLTAGECLAMP")
558 else if(strType ==
"PROPERTYCONTROLSTIMULUS")
564 THROW_PARAM_ERROR(Al_Err_lInvalidExternalStimulusType, Al_Err_strInvalidExternalStimulusType,
"ExternalStimulusType", strType);
569 catch(CStdErrorInfo oError)
571 if(lpStimulus)
delete lpStimulus;
577 if(lpStimulus)
delete lpStimulus;
578 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
588 HudItem *BlClassFactory::CreateHudItem(std::string strType,
bool bThrowError)
590 HudItem *lpItem=NULL;
596 if(strType ==
"HUDTEXT")
597 lpItem =
new OsgHudText;
602 THROW_PARAM_ERROR(Bl_Err_lInvalidHudItemType, Bl_Err_strInvalidHudItemType,
"HudItem", strType);
607 catch(CStdErrorInfo oError)
609 if(lpItem)
delete lpItem;
615 if(lpItem)
delete lpItem;
616 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
625 Hud *BlClassFactory::CreateHud(std::string strType,
bool bThrowError)
639 THROW_PARAM_ERROR(Bl_Err_lInvalidHudItemType, Bl_Err_strInvalidHudItemType,
"Hud", strType);
644 catch(CStdErrorInfo oError)
646 if(lpHud)
delete lpHud;
652 if(lpHud)
delete lpHud;
653 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
662 MaterialType *BlClassFactory::CreateMaterialItem(std::string strType,
bool bThrowError)
664 MaterialType *lpItem=NULL;
670 if(strType ==
"BASIC" || strType ==
"DEFAULT" || strType ==
"BULLET")
676 THROW_PARAM_ERROR(Bl_Err_lInvalidMaterialItemType, Bl_Err_strInvalidMaterialItemType,
"Material Pair", strType);
681 catch(CStdErrorInfo oError)
683 if(lpItem)
delete lpItem;
689 if(lpItem)
delete lpItem;
690 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
699 SimulationWindow *BlClassFactory::CreateWindowItem(std::string strType,
bool bThrowError)
701 SimulationWindow *lpItem=NULL;
707 if(strType ==
"BASIC" || strType ==
"DEFAULT")
708 lpItem =
new OsgSimulationWindow;
709 else if(strType ==
"SCRIPTEDSIMWINDOW")
710 lpItem =
new OsgScriptedSimulationWindow;
715 THROW_PARAM_ERROR(Bl_Err_lInvalidSimWindowType, Bl_Err_strInvalidSimWindowType,
"Simulation Window", strType);
720 catch(CStdErrorInfo oError)
722 if(lpItem)
delete lpItem;
728 if(lpItem)
delete lpItem;
729 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
738 Light *BlClassFactory::CreateLight(std::string strType,
bool bThrowError)
746 if(strType ==
"LIGHT")
747 lpItem =
new OsgLight;
752 THROW_PARAM_ERROR(Bl_Err_lInvalidLightType, Bl_Err_strInvalidLightType,
"Light Type", strType);
757 catch(CStdErrorInfo oError)
759 if(lpItem)
delete lpItem;
765 if(lpItem)
delete lpItem;
766 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
775 NeuralModule *BlClassFactory::CreateNeuralModule(std::string strType,
bool bThrowError)
777 NeuralModule *lpModule=NULL;
783 if(strType ==
"PHYSICSNEURALMODULE")
792 THROW_PARAM_ERROR(Al_Err_lInvalidNeuralModuleType, Al_Err_strInvalidNeuralModuleType,
"NeuralModule", strType);
797 catch(CStdErrorInfo oError)
799 if(lpModule)
delete lpModule;
805 if(lpModule)
delete lpModule;
806 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
816 ConstraintRelaxation *BlClassFactory::CreateConstraintRelaxation(std::string strType,
bool bThrowError)
818 ConstraintRelaxation *lpRelax=NULL;
824 if(strType ==
"CONSTRAINTRELAXATION" || strType ==
"DEFAULT")
832 THROW_PARAM_ERROR(Al_Err_lInvalidRelaxationType, Al_Err_strInvalidRelaxationType,
"Relaxation", strType);
837 catch(CStdErrorInfo oError)
839 if(lpRelax)
delete lpRelax;
845 if(lpRelax)
delete lpRelax;
846 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
856 ConstraintFriction *BlClassFactory::CreateConstraintFriction(std::string strType,
bool bThrowError)
858 ConstraintFriction *lpFriction=NULL;
864 if(strType ==
"CONSTRAINTRELAXATION" || strType ==
"DEFAULT")
872 THROW_PARAM_ERROR(Al_Err_lInvalidFrictionType, Al_Err_strInvalidFrictionType,
"Friction", strType);
877 catch(CStdErrorInfo oError)
879 if(lpFriction)
delete lpFriction;
885 if(lpFriction)
delete lpFriction;
886 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
896 RemoteControlLinkage *BlClassFactory::CreateRemoteControlLinkage(std::string strType,
bool bThrowError)
898 RemoteControlLinkage *lpLink=NULL;
904 if(strType ==
"PASSTHROUGHLINKAGE")
906 lpLink =
new PassThroughLinkage;
908 else if(strType ==
"PULSEDLINKAGE")
910 lpLink =
new PulsedLinkage;
916 THROW_PARAM_ERROR(Al_Err_lInvalidFrictionType, Al_Err_strInvalidFrictionType,
"Friction", strType);
921 catch(CStdErrorInfo oError)
923 if(lpLink)
delete lpLink;
929 if(lpLink)
delete lpLink;
930 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
941 CStdSerialize *BlClassFactory::CreateObject(std::string strClassType, std::string strObjectType,
bool bThrowError)
947 if(strClassType ==
"RIGIDBODY")
948 lpObject = CreateRigidBody(strObjectType, bThrowError);
949 else if(strClassType ==
"JOINT")
950 lpObject = CreateJoint(strObjectType, bThrowError);
951 else if(strClassType ==
"ORGANISM")
952 lpObject = CreateStructure(strObjectType, bThrowError);
953 else if(strClassType ==
"STRUCTURE")
954 lpObject = CreateStructure(strObjectType, bThrowError);
955 else if(strClassType ==
"SIMULATOR")
956 lpObject = CreateSimulator(strObjectType, bThrowError);
957 else if(strClassType ==
"KEYFRAME")
958 lpObject = CreateKeyFrame(strObjectType, bThrowError);
959 else if(strClassType ==
"DATACHART")
960 lpObject = CreateDataChart(strObjectType, bThrowError);
961 else if(strClassType ==
"DATACOLUMN")
962 lpObject = CreateDataColumn(strObjectType, bThrowError);
963 else if(strClassType ==
"EXTERNALSTIMULUS")
964 lpObject = CreateExternalStimulus(strObjectType, bThrowError);
965 else if(strClassType ==
"ADAPTER")
966 lpObject = CreateAdapter(strObjectType, bThrowError);
967 else if(strClassType ==
"GAIN")
968 lpObject = CreateGain(strObjectType, bThrowError);
969 else if(strClassType ==
"HUDITEM")
970 lpObject = CreateHudItem(strObjectType, bThrowError);
971 else if(strClassType ==
"HUD")
972 lpObject = CreateHud(strObjectType, bThrowError);
973 else if(strClassType ==
"MATERIAL")
974 lpObject = CreateMaterialItem(strObjectType, bThrowError);
975 else if(strClassType ==
"SIMULATIONWINDOW")
976 lpObject = CreateWindowItem(strObjectType, bThrowError);
977 else if(strClassType ==
"LIGHT")
978 lpObject = CreateLight(strObjectType, bThrowError);
979 else if(strClassType ==
"NEURALMODULE")
980 lpObject = CreateNeuralModule(strObjectType, bThrowError);
981 else if(strClassType ==
"CONSTRAINTRELAXATION")
982 lpObject = CreateConstraintRelaxation(strObjectType, bThrowError);
983 else if(strClassType ==
"CONSTRAINTFRICTION")
984 lpObject = CreateConstraintFriction(strObjectType, bThrowError);
985 else if(strClassType ==
"REMOTECONTROLLINKAGE")
986 lpObject = CreateRemoteControlLinkage(strObjectType, bThrowError);
991 THROW_PARAM_ERROR(Std_Err_lInvalidClassType, Std_Err_strInvalidClassType,
"ClassType", strClassType);
999 void BULLET_PORT RunBootstrap(
int argc,
const char **argv)
1001 BootstrapRunLibrary(argc, argv);
Declares the vortex plane class.
Declares the vs prismatic class.
virtual IStdClassFactory * ClassFactory()
Gets the class factory.
Declares the vortex ball socket class.
Declares the vortex hinge class.
Vortex ball-and-socket joint class.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
std::string Std_Trim(std::string strVal)
Trims a string.
Vortex relative position, relative orientation joint class.
Declares the vortex distance joint class.
Vortex hinge joint class.
Current stimulus for neural items.
This stimulus enables or disables a joint or body part for a specified period of time.
Declares the vortex fluid plane class.
virtual bool IsContactSensor()
Query if this object is contact sensor.
Declares the vortex ellipsoid class.
Declares the vortex Torus class.
Declares the vs universal class.
std::string Std_ToUpper(std::string strVal)
Converts a string to upper case.
Declares the vortex relative position, relative orientation class.