🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
GfxCelestialBody.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24
25// OSG头文件
26#include <osg/Group>
27#include <osg/Node>
28#include <osg/PositionAttitudeTransform>
29#include <osg/ShapeDrawable>
30#include <osg/Material>
31#include <osg/Texture2D>
32#include <osg/Vec3>
33#include <osg/Vec4>
34
35namespace osg {
36 class Node;
37 class Group;
38 class PositionAttitudeTransform;
39 class Sphere;
40 class ShapeDrawable;
41 class Material;
42 class Texture2D;
43}
44
45AST_NAMESPACE_BEGIN
46
47class AST_GFX_API GfxCelestialBody {
48public:
53 GfxCelestialBody(const std::string& name, double radius, const osg::Vec4& color = osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
54
57
59 bool initialize();
60
62 const std::string& getName() const;
63
65 void setPosition(const osg::Vec3d& position);
66
68 osg::Vec3d getPosition() const;
69
71 void setAttitude(const osg::Quat& attitude);
72
74 osg::Quat getAttitude() const;
75
77 void setRadius(double radius);
78
80 double getRadius() const;
81
83 void setColor(const osg::Vec4& color);
84
86 osg::Vec4 getColor() const;
87
89 void setRotationSpeed(double speed);
90
92 double getRotationSpeed() const;
93
95 void setOrbitalSpeed(double speed);
96
98 double getOrbitalSpeed() const;
99
101 void setOrbitalRadius(double radius);
102
104 double getOrbitalRadius() const;
105
108 bool setTexture(const std::string& textureFile);
109
112 void update(double deltaTime);
113
115 osg::Node* getNode();
116
120 osg::Node* createOrbitLine(const osg::Vec4& color = osg::Vec4(0.5f, 0.5f, 0.5f, 1.0f), int segments = 100);
121
122private:
124 std::string m_name;
125
127 double m_radius;
128
130 osg::Vec4 m_color;
131
133 double m_rotationSpeed;
134
136 double m_orbitalSpeed;
137
139 double m_orbitalRadius;
140
142 double m_currentRotation;
143
145 double m_currentOrbit;
146
148 osg::PositionAttitudeTransform* m_pat;
149
151 osg::ShapeDrawable* m_shapeDrawable;
152
154 osg::Material* m_material;
155
157 osg::Texture2D* m_texture;
158
160 bool createModel();
161};
162
163AST_NAMESPACE_END
定义 GfxCelestialBody.hpp:47