Marine systems simulation
CVisualRB.h
1/*
2* Class CVisualRB (SimObject)
3* Author: Biao Su
4
5* This class enables visualization of a rigid body with triangular mesh.
6*/
7
12#ifndef CVisualRB_H
13#define CVisualRB_H
14
15#include <string>
16#include <Eigen/Eigen>
17#include <iostream>
18#include <iomanip>
19#include <fstream>
20#include <algorithm>
21#include <vector>
22#include <valarray>
23
24#include "SimObject.h"
25
26#include "sfh/text.h"
27#include "sfh/math/math.h"
28#include "sfh/sim/kinematics.h"
29#include "sfh/constants.h"
30
31
32namespace Visualization {
33
34typedef Eigen::Matrix<double, 3, 1> vec3;
35typedef Eigen::Matrix<int, 3, 1> vec3i;
36typedef Eigen::Quaternion<double> quat;
37
38class CVisualRB : public SimObject
39{
40public:
41 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
42
43 // Constructor
44 CVisualRB(std::string sSimObjectName, ISimObjectCreator* pCreator);
45 virtual ~CVisualRB() {};
46 virtual void InitialConditionSetup(const double T, const double* const X, double* const XDot, ISimObjectCreator* pCreator);
48 virtual void OdeFcn(const double T, const double* const X, double* const XDot, const bool bIsMajorTimeStep);
49
50#ifdef FH_VISUALIZATION
51 // Initial specification of the simObject geometry for rendering.
52 virtual void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const pCreator);
53
54 // Updating the simObject for rendering the next frame.
55 virtual void RenderUpdate(const double T, const double* const X);
56#endif
57
58protected:
59
60 // DOF
61 int m_DOFModes[6];
62 int m_DOFNum;
63 std::vector<int> m_DOFIndex;
64 double m_Scale;
65 vec3 m_RelPos;
66
67 // Input ports
68 ISignalPort* m_InPos;
69 bool m_InForce;
70 ISignalPort* m_ForceIn;
71
72 // Output ports
73 double m_DOFDirections[6];
74 double m_PosNED[3];
75 const double* PositionNED(const double T, const double* const X);
76 double m_QuatNED[4];
77 const double* QuaternionNED(const double T, const double* const X);
78 double m_ForceCoeffs[6];
79 double m_ForceOut[6];
80 const double* ForceOut(const double T, const double* const X);
81
82#ifdef FH_VISUALIZATION
83 Ogre::SceneNode* m_RenderNode;
84 Ogre::SceneManager* m_SceneMgr;
85#endif
86
87};
88
89};
90
91#endif
Definition: CVisualRB.h:39
virtual void OdeFcn(const double T, const double *const X, double *const XDot, const bool bIsMajorTimeStep)
Calculate the state derivatives.