72 lines
2.4 KiB
C++
72 lines
2.4 KiB
C++
#pragma once
|
|
#include <string>
|
|
#include <list>
|
|
#include "libs.h"
|
|
#include "star_system.h"
|
|
|
|
class Body;
|
|
class CollisionSpace;
|
|
class Geom;
|
|
|
|
/* Frame of reference. */
|
|
class Frame {
|
|
public:
|
|
Frame(void);
|
|
Frame(Frame* parent, const char* label);
|
|
Frame(Frame* parent, const char* label, unsigned int flags);
|
|
~Frame(void);
|
|
|
|
static void Serialize(Frame*);
|
|
static void PostUnserializeFixup(Frame* f);
|
|
static Frame* Unserialize(Frame* parent);
|
|
|
|
const char* GetLabel(void) const { return m_label.c_str(); }
|
|
void SetLabel(const char* label) { m_label = label; }
|
|
void SetPosition(const vector3d &pos) { m_pos = pos; }
|
|
vector3d GetPosition(void) const { return m_pos; }
|
|
void SetVelocity(const vector3d& vel) { m_vel = vel; }
|
|
vector3d GetVelocity(void) const { return m_vel; }
|
|
void SetAngVelocity(const vector3d& angvel) { m_angVel = angvel; }
|
|
vector3d GetAngVelocity(void) const { return m_angVel; }
|
|
const matrix4x4d& GetOrientation(void) const { return m_orient; }
|
|
void SetOrientation(const matrix4x4d& m) { m_orient = m; }
|
|
void SetRadius(double radius) { m_radius = radius; }
|
|
void RemoveChild(Frame* f);
|
|
void AddGeom(Geom*);
|
|
void RemoveGeom(Geom*);
|
|
void SetPlanetGeom(double radius, Body*);
|
|
CollisionSpace* GetCollisionSpace(void) const { return m_collisionSpace; }
|
|
void RotateInTimestep(double step);
|
|
|
|
|
|
void ApplyLeavingTransform(matrix4x4d& m) const;
|
|
void ApplyEnteringTransform(matrix4x4d& m) const;
|
|
|
|
static void GetFrameTransform(const Frame* fFrom, const Frame* fTo, matrix4x4d& m);
|
|
|
|
bool IsLocalPosInFrame(const vector3d& pos) {
|
|
return (pos.Length() < m_radius);
|
|
}
|
|
|
|
/* If parent is null then frame position is absolute. */
|
|
Frame* m_parent;
|
|
std::list<Frame*> m_children;
|
|
StarSystem::SBody* m_sbody; /* Points to SBodies in L3D::current_system. */
|
|
Body* m_astroBody; /* If frame contains a star or planet or something.. */
|
|
|
|
enum { TEMP_VIEWING=1 };
|
|
|
|
private:
|
|
void Init(Frame* parent, const char* label, unsigned int flags);
|
|
vector3d m_pos;
|
|
/* We don't use this to move frame, rather, orbital rails determine velocity. */
|
|
vector3d m_vel;
|
|
vector3d m_angVel; /* This however *is* directly applied (for rotating frames). */
|
|
matrix4x4d m_orient;
|
|
std::string m_label;
|
|
double m_radius;
|
|
int m_flags;
|
|
CollisionSpace* m_collisionSpace;
|
|
};
|
|
|