[Opal-commits] opal/src AccelerationSensor.cpp,NONE,1.1 AccelerationSensor.h,NONE,1.1 AccelerationSe
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-03-14 05:18:39
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23596/src Modified Files: RaycastSensor.h SConscript Simulator.cpp VolumeSensor.h opal.h Added Files: AccelerationSensor.cpp AccelerationSensor.h AccelerationSensorData.h VelocitySensor.cpp VelocitySensor.h VelocitySensorData.h Log Message: added VelocitySensor and AccelerationSensor --- NEW FILE: AccelerationSensor.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_ACCELERATION_SENSOR_H #define OPAL_ACCELERATION_SENSOR_H #include "Defines.h" #include "Sensor.h" #include "AccelerationSensorData.h" namespace opal { /// A Sensor that monitors the linear and angular acceleration of a /// Solid. Using its transform, it can be set to a desired offset from /// the attached Solid. This Sensor does nothing if it is not attached /// to a Solid (i.e. its returned values are always zero). class AccelerationSensor : public Sensor { public: AccelerationSensor(); virtual ~AccelerationSensor(); /// Initializes the Sensor with the given data structure. If the /// Solid pointer in the data is valid, the Sensor's offset will /// be relative to the Solid's transform instead of the global /// origin. virtual void OPAL_CALL init(const AccelerationSensorData& data); /// Returns all data describing the Sensor. virtual const AccelerationSensorData& OPAL_CALL getData()const; /// Returns the Sensor's global linear acceleration. virtual real OPAL_CALL getGlobalLinearAccel()const; /// Returns the Sensor's global angular acceleration. virtual real OPAL_CALL getGlobalAngularAccel()const; /// Returns the Sensor's local linear acceleration. virtual real OPAL_CALL getLocalLinearAccel()const; /// Returns the Sensor's local angular acceleration. virtual real OPAL_CALL getLocalAngularAccel()const; virtual void OPAL_CALL setEnabled(bool e); virtual bool OPAL_CALL isEnabled()const; virtual void OPAL_CALL setTransform(const Matrix44r& t); virtual const Matrix44r& OPAL_CALL getTransform()const; virtual SensorType OPAL_CALL getType()const; virtual void OPAL_CALL setName(const std::string& name); virtual const std::string& OPAL_CALL getName()const; virtual void OPAL_CALL internal_update(); virtual bool OPAL_CALL internal_dependsOn(Solid* solid); protected: /// Stores data describing the Sensor. AccelerationSensorData mData; private: }; } #endif --- NEW FILE: AccelerationSensor.cpp --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #include "AccelerationSensor.h" #include "Simulator.h" namespace opal { AccelerationSensor::AccelerationSensor() { // "mData" is initialized in its own constructor. } AccelerationSensor::~AccelerationSensor() { } void AccelerationSensor::init(const AccelerationSensorData& data) { Sensor::init(); mData = data; } const AccelerationSensorData& AccelerationSensor::getData()const { return mData; } real AccelerationSensor::getGlobalLinearAccel()const { if (!mData.solid) { return 0; } // TODO: use the Sensor's transform to find its actual position // in global coordinates. // TODO: get the acceleration of the Solid at the Sensor's position. return 0; // temporary } real AccelerationSensor::getGlobalAngularAccel()const { if (!mData.solid) { return 0; } // TODO: use the Sensor's transform to find its actual position // in global coordinates. // TODO: get the acceleration of the Solid at the Sensor's position. return 0; // temporary } real AccelerationSensor::getLocalLinearAccel()const { if (!mData.solid) { return 0; } // TODO: use the Sensor's transform to find its actual position // relative to the Solid. // TODO: get the acceleration of the Solid at the Sensor's position. return 0; // temporary } real AccelerationSensor::getLocalAngularAccel()const { if (!mData.solid) { return 0; } // TODO: use the Sensor's transform to find its actual position // relative to the Solid. // TODO: get the acceleration of the Solid at the Sensor's position. return 0; // temporary } void AccelerationSensor::setEnabled(bool e) { if (!mInitCalled) { return; } mData.enabled = e; } bool AccelerationSensor::isEnabled()const { return mData.enabled; } SensorType AccelerationSensor::getType()const { return mData.getType(); } void AccelerationSensor::setTransform(const Matrix44r& t) { mData.transform = t; } const Matrix44r& AccelerationSensor::getTransform()const { return mData.transform; } void AccelerationSensor::setName(const std::string& name) { mData.name = name; } const std::string& AccelerationSensor::getName()const { return mData.name; } void AccelerationSensor::internal_update() { if (mData.enabled) { // TODO: update acceleration calculations } } bool AccelerationSensor::internal_dependsOn(Solid* solid) { if (solid == mData.solid) { return true; } else { return false; } } } Index: opal.h =================================================================== RCS file: /cvsroot/opal/opal/src/opal.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** opal.h 12 Mar 2005 01:21:17 -0000 1.22 --- opal.h 14 Mar 2005 05:18:27 -0000 1.23 *************** *** 54,59 **** --- 54,63 ---- #include "Sensor.h" #include "SensorData.h" + #include "AccelerationSensor.h" + #include "AccelerationSensorData.h" #include "RaycastSensor.h" #include "RaycastSensorData.h" + #include "VelocitySensor.h" + #include "VelocitySensorData.h" #include "VolumeSensor.h" #include "VolumeSensorData.h" --- NEW FILE: VelocitySensor.cpp --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #include "VelocitySensor.h" #include "Simulator.h" namespace opal { VelocitySensor::VelocitySensor() { // "mData" is initialized in its own constructor. } VelocitySensor::~VelocitySensor() { } void VelocitySensor::init(const VelocitySensorData& data) { Sensor::init(); mData = data; } const VelocitySensorData& VelocitySensor::getData()const { return mData; } real VelocitySensor::getGlobalLinearVel()const { if (!mData.solid) { return 0; } // TODO: use the Sensor's transform to find its actual position // in global coordinates. // TODO: get the velocity of the Solid at the Sensor's position. return 0; // temporary } real VelocitySensor::getGlobalAngularVel()const { if (!mData.solid) { return 0; } // TODO: use the Sensor's transform to find its actual position // in global coordinates. // TODO: get the velocity of the Solid at the Sensor's position. return 0; // temporary } real VelocitySensor::getLocalLinearVel()const { if (!mData.solid) { return 0; } // TODO: use the Sensor's transform to find its actual position // relative to the Solid. // TODO: get the velocity of the Solid at the Sensor's position. return 0; // temporary } real VelocitySensor::getLocalAngularVel()const { if (!mData.solid) { return 0; } // TODO: use the Sensor's transform to find its actual position // relative to the Solid. // TODO: get the velocity of the Solid at the Sensor's position. return 0; // temporary } void VelocitySensor::setEnabled(bool e) { if (!mInitCalled) { return; } mData.enabled = e; } bool VelocitySensor::isEnabled()const { return mData.enabled; } SensorType VelocitySensor::getType()const { return mData.getType(); } void VelocitySensor::setTransform(const Matrix44r& t) { mData.transform = t; } const Matrix44r& VelocitySensor::getTransform()const { return mData.transform; } void VelocitySensor::setName(const std::string& name) { mData.name = name; } const std::string& VelocitySensor::getName()const { return mData.name; } void VelocitySensor::internal_update() { if (mData.enabled) { // Do nothing. } } bool VelocitySensor::internal_dependsOn(Solid* solid) { if (solid == mData.solid) { return true; } else { return false; } } } Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** Simulator.cpp 13 Mar 2005 23:07:10 -0000 1.46 --- Simulator.cpp 14 Mar 2005 05:18:27 -0000 1.47 *************** *** 38,41 **** --- 38,43 ---- #include "SpringMotor.h" #include "RaycastSensor.h" + #include "VelocitySensor.h" + #include "AccelerationSensor.h" #include "VolumeSensor.h" --- NEW FILE: VelocitySensor.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_VELOCITY_SENSOR_H #define OPAL_VELOCITY_SENSOR_H #include "Defines.h" #include "Sensor.h" #include "VelocitySensorData.h" namespace opal { /// A Sensor that monitors the linear and angular velocity of a Solid. /// Using its transform, it can be set to a desired offset from the /// attached Solid. This Sensor does nothing if it is not attached /// to a Solid (i.e. its returned values are always zero). Note that /// if you never need the velocity offset from a Solid, you can also /// use the Solid's get velocity functions. class VelocitySensor : public Sensor { public: VelocitySensor(); virtual ~VelocitySensor(); /// Initializes the Sensor with the given data structure. If the /// Solid pointer in the data is valid, the Sensor's offset will /// be relative to the Solid's transform instead of the global /// origin. virtual void OPAL_CALL init(const VelocitySensorData& data); /// Returns all data describing the Sensor. virtual const VelocitySensorData& OPAL_CALL getData()const; /// Returns the Sensor's global linear velocity. virtual real OPAL_CALL getGlobalLinearVel()const; /// Returns the Sensor's global angular velocity. virtual real OPAL_CALL getGlobalAngularVel()const; /// Returns the Sensor's local linear velocity. virtual real OPAL_CALL getLocalLinearVel()const; /// Returns the Sensor's local angular velocity. virtual real OPAL_CALL getLocalAngularVel()const; virtual void OPAL_CALL setEnabled(bool e); virtual bool OPAL_CALL isEnabled()const; virtual void OPAL_CALL setTransform(const Matrix44r& t); virtual const Matrix44r& OPAL_CALL getTransform()const; virtual SensorType OPAL_CALL getType()const; virtual void OPAL_CALL setName(const std::string& name); virtual const std::string& OPAL_CALL getName()const; virtual void OPAL_CALL internal_update(); virtual bool OPAL_CALL internal_dependsOn(Solid* solid); protected: /// Stores data describing the Sensor. VelocitySensorData mData; private: }; } #endif --- NEW FILE: VelocitySensorData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_VELOCITY_SENSOR_DATA_H #define OPAL_VELOCITY_SENSOR_DATA_H #include "Defines.h" #include "SensorData.h" namespace opal { /// A data structure describing a VelocitySensor. class VelocitySensorData : public SensorData { public: OPAL_DECL VelocitySensorData() : SensorData() { mType = VELOCITY_SENSOR; } /// Copy constructor. OPAL_DECL VelocitySensorData(const VelocitySensorData& data) { (*this) = data; } OPAL_DECL virtual ~VelocitySensorData() { } /// Makes a deep copy. OPAL_DECL virtual void OPAL_CALL operator=( const VelocitySensorData& data) { mType = data.mType; enabled = data.enabled; name = data.name; solid = data.solid; internal_solidIndex = data.internal_solidIndex; internal_solidName = data.internal_solidName; transform = data.transform; } protected: private: }; } #endif Index: RaycastSensor.h =================================================================== RCS file: /cvsroot/opal/opal/src/RaycastSensor.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RaycastSensor.h 12 Mar 2005 01:21:16 -0000 1.4 --- RaycastSensor.h 14 Mar 2005 05:18:27 -0000 1.5 *************** *** 85,89 **** /// A Sensor that fires a ray into a scene and returns data describing ! /// the intersection, if any. This Sensor does not fire a ray on /// every time step because that would be a waste of time in most /// cases; it must be "fired" manually. --- 85,89 ---- /// A Sensor that fires a ray into a scene and returns data describing ! /// the closest intersection, if any. This Sensor does not fire a ray /// every time step because that would be a waste of time in most /// cases; it must be "fired" manually. Index: VolumeSensor.h =================================================================== RCS file: /cvsroot/opal/opal/src/VolumeSensor.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VolumeSensor.h 14 Mar 2005 01:20:53 -0000 1.2 --- VolumeSensor.h 14 Mar 2005 05:18:27 -0000 1.3 *************** *** 114,118 **** /// a specified volume. Each volume query returns a data structure /// containing a list of those Solids. This Sensor does not do a volume ! /// query on every time step because that would be a waste of time in /// most cases; it must be queried manually. class VolumeSensor : public Sensor --- 114,118 ---- /// a specified volume. Each volume query returns a data structure /// containing a list of those Solids. This Sensor does not do a volume ! /// query every time step because that would be a waste of time in /// most cases; it must be queried manually. class VolumeSensor : public Sensor --- NEW FILE: AccelerationSensorData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_ACCELERATION_SENSOR_DATA_H #define OPAL_ACCELERATION_SENSOR_DATA_H #include "Defines.h" #include "SensorData.h" namespace opal { /// A data structure describing an AccelerationSensor. class AccelerationSensorData : public SensorData { public: OPAL_DECL AccelerationSensorData() : SensorData() { mType = ACCELERATION_SENSOR; } /// Copy constructor. OPAL_DECL AccelerationSensorData(const AccelerationSensorData& data) { (*this) = data; } OPAL_DECL virtual ~AccelerationSensorData() { } /// Makes a deep copy. OPAL_DECL virtual void OPAL_CALL operator=( const AccelerationSensorData& data) { mType = data.mType; enabled = data.enabled; name = data.name; solid = data.solid; internal_solidIndex = data.internal_solidIndex; internal_solidName = data.internal_solidName; transform = data.transform; } protected: private: }; } #endif Index: SConscript =================================================================== RCS file: /cvsroot/opal/opal/src/SConscript,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** SConscript 12 Mar 2005 01:21:16 -0000 1.14 --- SConscript 14 Mar 2005 05:18:27 -0000 1.15 *************** *** 4,7 **** --- 4,9 ---- # OPAL headers headers = Split(""" + AccelerationSensor.h + AccelerationSensorData.h AttractorMotor.h AttractorMotorData.h *************** *** 50,53 **** --- 52,57 ---- ThrusterMotorData.h Vec3r.h + VelocitySensor.h + VelocitySensorData.h VolumeSensor.h VolumeSensorData.h *************** *** 56,59 **** --- 60,64 ---- # OPAL sources sources = Split(""" + AccelerationSensor.cpp AttractorMotor.cpp Blueprint.cpp *************** *** 73,76 **** --- 78,82 ---- SpringMotor.cpp ThrusterMotor.cpp + VelocitySensor.cpp VolumeSensor.cpp """) |