From: <sv...@ww...> - 2004-08-07 02:14:08
|
Author: mkrose Date: 2004-08-06 19:14:02 -0700 (Fri, 06 Aug 2004) New Revision: 1204 Modified: trunk/CSP/CSPSim/CHANGES.current trunk/CSP/CSPSim/Include/CSPSim.i Log: Minor cleanup of the swig extensions to CSPSim for creating test objects. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1204 Modified: trunk/CSP/CSPSim/CHANGES.current =================================================================== --- trunk/CSP/CSPSim/CHANGES.current 2004-08-07 02:12:18 UTC (rev 1203) +++ trunk/CSP/CSPSim/CHANGES.current 2004-08-07 02:14:02 UTC (rev 1204) @@ -72,6 +72,8 @@ uniform across all parts (some where set to zero). Also increased the overall ambient lighting a bit. + * Minor cleanup of the swig extensions to CSPSim for creating test objects. + 2004-07-29: onsight * Removed a couple obsolete files from the Makefile, and added InputEvent. Modified: trunk/CSP/CSPSim/Include/CSPSim.i =================================================================== --- trunk/CSP/CSPSim/Include/CSPSim.i 2004-08-07 02:12:18 UTC (rev 1203) +++ trunk/CSP/CSPSim/Include/CSPSim.i 2004-08-07 02:14:02 UTC (rev 1204) @@ -23,9 +23,26 @@ #include "Projection.h" #include "Shell.h" #include <SimData/Math.h> -%} +void _createVehicleHelper(CSPSim *self, const char *path, simdata::Vector3 position, + simdata::Vector3 velocity, simdata::Vector3 attitude) { + simdata::Ref<DynamicObject> obj = self->getDataManager().getObject(path); + if (!obj) { + std::cout << "WARNING: Failed to create object '" << path << "'\n"; + return; + } + obj->setGlobalPosition(position); + obj->setVelocity(velocity); + simdata::Quat q_attitude; + attitude *= 3.1416 / 180.0; + q_attitude.makeRotate(attitude.x(), attitude.y(), -attitude.z()); + obj->setAttitude(q_attitude); + self->getBattlefield()->addUnit(obj); + if (!self->getActiveObject()) self->setActiveObject(obj); +} +%} + class CSPSim { public: @@ -68,38 +85,14 @@ %extend CSPSim { void createVehicle(const char *path, simdata::Vector3 position, - simdata::Vector3 velocity, simdata::Vector3 attitude) { - simdata::Ref<DynamicObject> obj = self->getDataManager().getObject(path); - if (!obj) { - std::cout << "WARNING: Failed to create object '" << path << "'\n"; - return; - } - obj->setGlobalPosition(position); - obj->setVelocity(velocity); - simdata::Quat q_attitude; - attitude *= 3.1416 / 180.0; - q_attitude.makeRotate(attitude.x(), attitude.y(), -attitude.z()); - obj->setAttitude(q_attitude); - self->getBattlefield()->addUnit(obj); - if (!self->getActiveObject()) self->setActiveObject(obj); + simdata::Vector3 velocity, simdata::Vector3 attitude) { + _createVehicleHelper(self, path, position, velocity, attitude); } void createVehicle(const char *path, simdata::LLA lla, simdata::Vector3 velocity, simdata::Vector3 attitude) { - simdata::Ref<DynamicObject> obj = self->getDataManager().getObject(path); - if (!obj) { - std::cout << "WARNING: Failed to create object '" << path << "'\n"; - return; - } Projection const &map = CSPSim::theSim->getTheater()->getTerrain()->getProjection(); simdata::Vector3 position = map.convert(lla); - obj->setGlobalPosition(position); - obj->setVelocity(velocity); - simdata::Quat q_attitude; - attitude *= 3.1416 / 180.0; - q_attitude.makeRotate(attitude.x(), attitude.y(), -attitude.z()); - obj->setAttitude(q_attitude); - self->getBattlefield()->addUnit(obj); - if (!self->getActiveObject()) self->setActiveObject(obj); + _createVehicleHelper(self, path, position, velocity, attitude); } void setShell(PyObject *shell) { self->getShell()->bind(shell); } std::string const &getTerrainName() { return self->getTheater()->getTerrain()->getName(); } |