00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _RIGID_BODY_GROUP_OBSERVER_H__
00021 #define _RIGID_BODY_GROUP_OBSERVER_H__
00022 #include "mbsim/observer.h"
00023
00024 #ifdef HAVE_OPENMBVCPPINTERFACE
00025 #include <mbsim/utils/boost_parameters.h>
00026 #include <mbsim/utils/openmbv_utils.h>
00027
00028 namespace OpenMBV {
00029 class Frame;
00030 }
00031 #endif
00032
00033 namespace MBSim {
00034 class RigidBody;
00035 class Frame;
00036
00037 class RigidBodyGroupObserver : public Observer {
00038 private:
00039 std::vector<RigidBody*> body;
00040 Frame* ref;
00041 #ifdef HAVE_OPENMBVCPPINTERFACE
00042 boost::shared_ptr<OpenMBV::Arrow> openMBVPosition, openMBVVelocity, openMBVAcceleration, openMBVAngularVelocity, openMBVAngularAcceleration, openMBVWeight, openMBVMomentum, openMBVAngularMomentum, openMBVDerivativeOfMomentum, openMBVDerivativeOfAngularMomentum;
00043 #endif
00044
00045 public:
00046 RigidBodyGroupObserver(const std::string &name);
00047 void addBody(RigidBody *body_) { body.push_back(body_); }
00048 void setFrameOfReference(Frame* frame) { ref = frame; }
00049
00050 void init(InitStage stage);
00051 virtual void plot(double t, double dt);
00052
00053 #ifdef HAVE_OPENMBVCPPINTERFACE
00054 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVWeight, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::fromPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
00055 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
00056 openMBVWeight=ombv.createOpenMBV();
00057 }
00058
00059 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVMomentum, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::fromPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
00060 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
00061 openMBVMomentum=ombv.createOpenMBV();
00062 }
00063
00064 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVAngularMomentum, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::fromPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
00065 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toDoubleHead,referencePoint,scaleLength,scaleSize);
00066 openMBVAngularMomentum=ombv.createOpenMBV();
00067 }
00068
00069 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVDerivativeOfMomentum, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::fromPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
00070 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toHead,referencePoint,scaleLength,scaleSize);
00071 openMBVDerivativeOfMomentum=ombv.createOpenMBV();
00072 }
00073
00074 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVDerivativeOfAngularMomentum, tag, (optional (scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(OpenMBV::Arrow::ReferencePoint),OpenMBV::Arrow::fromPoint)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) {
00075 OpenMBVArrow ombv(diffuseColor,transparency,OpenMBV::Arrow::toDoubleHead,referencePoint,scaleLength,scaleSize);
00076 openMBVDerivativeOfAngularMomentum=ombv.createOpenMBV();
00077 }
00078 #endif
00079
00080 };
00081
00082 }
00083
00084 #endif
00085