Marine systems simulation
CVisualTrajectory.h
1/*
2* Class CVisualTrajectory (SimObject)
3* Author: Biao Su
4
5* This class enables visualization of a deformable body with triangular mesh.
6*/
7
8#ifndef CVisualTrajectory_H
9#define CVisualTrajectory_H
10
11#include <string>
12#include <Eigen/Eigen>
13#include <iostream>
14#include <iomanip>
15#include <fstream>
16#include <algorithm>
17#include <vector>
18#include <valarray>
19
20#include "SimObject.h"
21
22#include "sfh/text.h"
23#include "sfh/math/math.h"
24#include "sfh/sim/kinematics.h"
25#include "sfh/constants.h"
26
27#ifdef FH_VISUALIZATION
28#include "sfh/ogre/C3DLine.h"
29#endif
30
31namespace Visualization {
32
37typedef Eigen::Matrix<double, 3, 1> vec3;
38typedef Eigen::Matrix<int, 3, 1> vec3i;
39typedef Eigen::Matrix<int, 2, 1> vec2i;
40typedef Eigen::Quaternion<double> quat;
41
42class CVisualTrajectory : public SimObject
43{
44public:
45 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
46
47 // Constructor
48 CVisualTrajectory(std::string sSimObjectName, ISimObjectCreator* pCreator);
49 virtual ~CVisualTrajectory();
51 virtual void OdeFcn(const double dT, const double* const adX, double* const adXDot, const bool bIsMajorTimeStep) {};
52
53#ifdef FH_VISUALIZATION
54 // Initial specification of the simObject geometry for rendering.
55 virtual void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const pCreator);
56
57 // Updating the simObject for rendering the next frame.
58 virtual void RenderUpdate(const double dT, const double* const adX);
59#endif
60
61protected:
62 // Node
63 int m_NodeNum;
64 std::vector<vec3> m_NodePos;
65
66 // Time
67 int m_TNum;
68 double m_UpdateT;
69 double m_TStart;
70
71 // Input ports
72 ISignalPort* m_InPos;
73
74 // Output ports
75 bool m_Output;
76 vec3 m_OutputSta;
77 double m_OutputDis;
78 double m_InputPar[3];
79 double m_OutputPar;
80 virtual const double* OutputPar(const double dT, const double* const adX);
81
82#ifdef FH_VISUALIZATION
83 Ogre::SceneNode* m_RenderNode;
84 Ogre::SceneManager* m_SceneMgr;
85 Ogre::ManualObject* m_Manual;
86 string m_Material;
87 double m_Color[4];
88 C3DLine* m_Line;
89#endif
90
91};
92
93};
94
95#endif
Definition: CVisualTrajectory.h:43
virtual void OdeFcn(const double dT, const double *const adX, double *const adXDot, const bool bIsMajorTimeStep)
Calculate the state derivatives.
Definition: CVisualTrajectory.h:51