IMS2
Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
|
A physical component of a spacecraft that can be added or removed at runtime. More...
Public Member Functions | |
virtual bool | InitModule (IMS_Orbiter_ModuleData *orbiter_data, IMS_General_ModuleData *module_data, IMS2 *mVessel) |
initialises the Module with static data from a config file More... | |
virtual void | PostLoad () |
A callback that is called when all data has been loaded, including data from a scenario state. More... | |
virtual void | PreStep (double simdt) |
Called at every clbkPreStep() of the containing vessel. More... | |
virtual void | SaveState (FILEHANDLE scn, UINT index) |
called from IMS2::clbkSaveState() to write the module state to scenario file More... | |
virtual bool | LoadState (FILEHANDLE scn) |
loads the modules saved state from scenario file More... | |
virtual void | RemoveModuleFromVessel () |
Called when this module is removed from a vessel. More... | |
virtual void | AddModuleToVessel (IMS2 *_vessel, bool rotatemesh=false, bool addMesh=true) |
Performs all actions necessary when adding the module to a vessel. More... | |
virtual double | GetMass () |
Returns the combined mass of the module and all its functions/components. | |
MATRIX3 | GetRotationMatrix () |
Returns a rotation matrix to transform from vessel-relative to the module-relative frame. | |
VECTOR3 | GetLocalCoordinates () |
Returns the modules position in orbiter local (vessel relative) coordinates. | |
UINT | GetMeshIndex () |
Returns the index the modules mesh has in the vessel. | |
IMS2 * | GetVessel () |
Returns the vessel containing this module. | |
string | getModulePosDescription () |
Returns a string describing the module by name and position. | |
virtual void | RemoveMeshFromVessel () |
Removes the module's mesh from the vessel. | |
void | SpawnNewVesselFromModule (string _name, VECTOR3 velocity) |
Spawns a new vessel that has the same position, orientation and class as this module. More... | |
void | RotateMesh () |
Rotates the module's mesh into the correct position relative to the vessel. | |
void | GetRot (VECTOR3 &mRot) |
Fills the passed reference with the module's rotational vector. More... | |
void | GetDir (VECTOR3 &mDir) |
Fills the passed reference with the module's directional vector. More... | |
void | GetPos (VECTOR3 &mPos) |
Fills the passed reference with the module's position. More... | |
IMS_General_ModuleData * | GetGeneralModuleData () |
Returns a pointer to the module's general static data. | |
void | SetRot (VECTOR3 &mRot) |
void | SetDir (VECTOR3 &mDir) |
Sets the vessel-relative direction of the module. More... | |
void | SetPos (VECTOR3 &mPos) |
Sets the vessel-relative position of the module. More... | |
void | GetAttachmentPoints (vector< IMSATTACHMENTPOINT * > &OUT_points) |
Fills the passed std::vector with the module's list of attachment points. More... | |
void | AddAttachmentPointsToList (vector< IMSATTACHMENTPOINT * > &IN_OUT_points) |
Appends this module's attachment points to the passed std::vector. More... | |
IMSATTACHMENTPOINT * | GetConnectingAttachmentPoint (VESSEL *_v) |
Returns the attachment point connecting to the passed vessel. More... | |
IMSATTACHMENTPOINT * | GetConnectingAttachmentPoint (IMS_Module *module) |
returns the attachment point that connects to the passed module More... | |
int | GetAttachmentPointIndex (IMSATTACHMENTPOINT *point) |
Returns the index of an attachment point on this module. More... | |
void | UpdateAttachmentPoints (bool redock=false) |
Updates state of attachment points and associated dockports as well as vessels docked to those ports. More... | |
void | GetPmi (VECTOR3 &OUT_pmi) |
Returns the modules principle moments of inertia ("inertia" parameter in cfg) in the passed VECTOR3. | |
void | CreatePhysicalAttachmentPoints () |
creates the actual physical attachment points of this vessel (i.e. the orbiter dockports). More... | |
void | TransformAttachmentPoints () |
Transforms attachment points to face the right way and be in the right place. | |
void | SetDockPortsToNull () |
Gets called after assimilating a module, because all DOCKHANDLEs in the module are now invalid. More... | |
void | RotateAttachmentPoint (IMSATTACHMENTPOINT *att, double angle) |
rotates an attachment point around its directional axis More... | |
void | RemoveAllAttachmentPoints () |
disconnects attachment points and deletes their docking ports. More... | |
void | SetOrientationRelativeTo (IMS_Module *module) |
transforms the module to preserve position and orientation relative to the passed module in its origin state. More... | |
GUIplugin * | GetGui () |
Returns the GUIplugin of this module, NULL if it doesn't have a GUI. | |
Public Member Functions inherited from EventHandler | |
void | ConnectToMyEventGenerator (EventSink *sink, EVENTPIPE pipe) |
connects an EventSink to the EventGenerator of this in the appropriate pipe. More... | |
void | ConnectToMyEventSink (EventSink *sink, EVENTPIPE pipe) |
Connects an EventSink on this to the passed event sink. More... | |
void | ConnectMySinkToYourNode (EventNode *node, EVENTPIPE pipe) |
Connects an EventSink on this to the passed EventNode, no matter whether generator or another sink. More... | |
EVENTHANDLERTYPE | GetEventHandlerType () |
Returns the EVENTHANDLERTYPE of this event handler. | |
UINT | GetUID () |
Returns the globaly unique identifier of this event handler. | |
Static Public Member Functions | |
static bool | X_ORDER (IMS_Module *a, IMS_Module *b) |
Comparator to sort modules by their position along the X axis. | |
static bool | Y_ORDER (IMS_Module *a, IMS_Module *b) |
Comparator to sort modules by their position along the Y axis. | |
static bool | Z_ORDER (IMS_Module *a, IMS_Module *b) |
Comparator to sort modules by their position along the Z axis. | |
static bool | X_SYMMETRIC_ORDER (IMS_Module *a, IMS_Module *b) |
Comparator to sort modules by their symmetric position along the X axis. | |
static bool | Y_SYMMETRIC_ORDER (IMS_Module *a, IMS_Module *b) |
Comparator to sort modules by their symmetric position along the Y axis. | |
static bool | Z_SYMMETRIC_ORDER (IMS_Module *a, IMS_Module *b) |
Comparator to sort modules by their symmetric position along the Z axis. | |
static bool | ATTACHMENT_POINTS_BY_POS (IMSATTACHMENTPOINT *a, IMSATTACHMENTPOINT *b) |
Comparator to sort attachment points by their overall position. More... | |
Protected Member Functions | |
void | resetAttachmentPoints () |
Resets attachment points to their original state. More... | |
void | SaveBaseAttributes (FILEHANDLE scn) |
Saves attributes common to all modules. More... | |
bool | LoadScenarioBaseAttributes (FILEHANDLE scn) |
Loads attributes common to all modules from a scenario file. More... | |
bool | AddMeshToVessel (bool rotateMesh=false) |
Adds the module's mesh to the meshes list of the vessel. More... | |
void | dockVessel (DOCKEDVESSEL *v, IMSATTACHMENTPOINT *p) |
docks a vessel wraped by a DOCKEDVESSEL struct to the intended attachment point on this module More... | |
virtual bool | ProcessEvent (Event_Base *e) |
Receives all events coming through this EventHandler. More... | |
virtual void | createGui () |
creates the module gui. Only called once in the lifetime of a module | |
Protected Member Functions inherited from EventHandler | |
EventGenerator * | createEventGenerator (EVENTPIPE pipe) |
Creates a new EventGenerator for this handler instance. More... | |
EventSink * | createEventSink (EVENTPIPE pipe) |
creates a new EventSink in this handler instance More... | |
void | disconnect (EventHandler *handler, bool bidirectional=true) |
Completely severs connections to and from the passed EventHandler, all sinks, all generators. More... | |
void | sendEvents () |
Tells all event generators in this event handler to advance their event cue. More... | |
void | processWaitingQueue () |
processes all events in the waiting queue. More... | |
void | addEvent (Event_Base *_event, EVENTPIPE _pipe=DEFAULT_PIPE) |
Adds an event to the eventcue of an eventpipe. More... | |
void | addEventToWaitingQueue (Event_Base *_event) |
Adds an event to this handlers waiting queue. More... | |
void | relayEvent (Event_Base *_event, EVENTPIPE _pipe) |
Relays an event to another event pipe. More... | |
EventSink * | getEventSink (EVENTPIPE pipe) |
returns the EventSink on this EventHandler that belongs to the passed event pipe More... | |
EventGenerator * | getEventGenerator (EVENTPIPE pipe) |
Returns the EventGenerator on this EventHandler that belongs to the passed event pipe. More... | |
Protected Attributes | |
vector< IMS_ModuleFunction_Base * > | functions |
A list containing all this module's ModuleFunction objects. | |
IMS2 * | vessel |
The vessel containing this module. | |
IMS_Orbiter_ModuleData * | _orbiter_data |
Orbiter related attributes of this module. | |
IMS_General_ModuleData * | _module_data |
General attributes of this module. | |
UINT | moduleIndex |
Index of the module in the modules list. | |
UINT | meshIndex |
Index of the module mesh in the vessel. | |
VECTOR3 | pos |
The module's current position in vessel-relative coordinates. | |
VECTOR3 | rot |
The module's current orientation ("up"-direction), vessel-relative. | |
VECTOR3 | dir |
The module's current directional vector, vessel-relative. | |
MATRIX3 | rotationmatrix |
Matrix for transformations into the module-relative frame. | |
vector< IMSATTACHMENTPOINT * > | attachmentPoints |
Vector containing all the attachment points of this module. | |
GUIplugin * | guiplugin = NULL |
pointer to the module's GUI. If NULL, this module doesn't have a GUI | |
Protected Attributes inherited from EventHandler | |
EVENTPIPE | defaultpipe = DEFAULT_PIPE |
Use this to set the defualt event pipe of this event handler. | |
EVENTHANDLERTYPE | eventhandlertype |
An identifier that offers a group identification. | |
Friends | |
class | GUI_Module |
A physical component of a spacecraft that can be added or removed at runtime.
The Module class is the heart of IMS2: It manages Attachment points and Mesh placement and transformation, and contains one or several ModuleFunction objects as required to adapt to the demanded functionality. However, while Modules can be added or removed to a vessel at will, a module instance itself is static in terms of capability for the duration of its lifetime, as defined by a config file. A Module is never destroyed, unless the containing vessel is destroyed. If a Module changes ownership, its overall state and the overall state of its functions are unaffected.
A Module is also an EventHandler that provides a throughput eventpipe from the vessel to the modulefunctions. The EventPipe back from a modulefunction however is passed to all other module functions INSIDE THIS MODULE, and are only passed down to the vessel if the module takes action to do so.
void IMS_Module::AddAttachmentPointsToList | ( | vector< IMSATTACHMENTPOINT * > & | IN_OUT_points | ) |
Appends this module's attachment points to the passed std::vector.
IN_OUT_points | An std::vector to receive the attachment points. Existing data will not be changed. |
|
protected |
Adds the module's mesh to the meshes list of the vessel.
rotateMesh | Whether the mesh needs to be newly transformed |
|
virtual |
Performs all actions necessary when adding the module to a vessel.
_vessel | The vessel the module is added to |
rotatemesh | Whether the mesh needs to be newly transformed |
addMesh | whether the mesh needs to be added |
|
static |
Comparator to sort attachment points by their overall position.
Sorting with this comparator has the effect that overlapping attachment points will be next to each other in the resulting list.
void IMS_Module::CreatePhysicalAttachmentPoints | ( | ) |
creates the actual physical attachment points of this vessel (i.e. the orbiter dockports).
|
protected |
docks a vessel wraped by a DOCKEDVESSEL struct to the intended attachment point on this module
v | The DOCKEDVESSEL that you want docked |
p | The attachment point v needs to dock to |
int IMS_Module::GetAttachmentPointIndex | ( | IMSATTACHMENTPOINT * | point | ) |
Returns the index of an attachment point on this module.
point | A pointer to the attachment point you need to know the index of |
void IMS_Module::GetAttachmentPoints | ( | vector< IMSATTACHMENTPOINT * > & | OUT_points | ) |
Fills the passed std::vector with the module's list of attachment points.
OUT_points | Reference to std::vector to receive the list. Will be overwritten! |
IMSATTACHMENTPOINT * IMS_Module::GetConnectingAttachmentPoint | ( | VESSEL * | _v | ) |
Returns the attachment point connecting to the passed vessel.
_v | the vessel for which you need to know to which attachment point on this module it is docked \ return A pointer to an IMSATTACHMENTPOINT object, or NULL if the vessel is not docked to this module |
IMSATTACHMENTPOINT * IMS_Module::GetConnectingAttachmentPoint | ( | IMS_Module * | module | ) |
returns the attachment point that connects to the passed module
module | The module for which you need to know to which attachment point on this module it is connected |
void IMS_Module::GetDir | ( | VECTOR3 & | mDir | ) |
Fills the passed reference with the module's directional vector.
mDir | Reference to receive the direction ("front"-direction) |
void IMS_Module::GetPos | ( | VECTOR3 & | mPos | ) |
Fills the passed reference with the module's position.
mPos | Reference to receive the position |
void IMS_Module::GetRot | ( | VECTOR3 & | mRot | ) |
Fills the passed reference with the module's rotational vector.
mRot | Reference to receive the rotation ("up"-direction) |
|
virtual |
initialises the Module with static data from a config file
orbiter_data | The orbiter api specific data for the module (like meshname, size etc) |
module_data | The general data for the module, like mass, module functions etc. |
mVessel | The vessel that will initially contain this module |
|
protected |
Loads attributes common to all modules from a scenario file.
scn | FILEHANDLE of the scenario file to read from |
|
virtual |
loads the modules saved state from scenario file
scn | the FILEHANDLE to the scenario file being loaded |
|
virtual |
A callback that is called when all data has been loaded, including data from a scenario state.
|
virtual |
Called at every clbkPreStep() of the containing vessel.
simdt | The time elapsed between this frame and the previous one |
|
protectedvirtual |
Receives all events coming through this EventHandler.
Overload to implement event handling in your inheriting class. The function will receive Events one by one as they are coming through your event sinks, regardless of which pipe they belong to. Return true to consume an event, but be sure it was only meant for you when you do that.
e | The event coming through the event pipe |
Implements EventHandler.
void IMS_Module::RemoveAllAttachmentPoints | ( | ) |
disconnects attachment points and deletes their docking ports.
This does NOT delete the attachment points themselves, merely their physical representation in Orbiter. it will also remove all DOCKEDVESSEL objects from the vessel without deallocating them. They remain in memory, and the attachment point stays connected to them, and will be redocked this MODULE if UpdateAttachmentPoints() is called with redock true. This enables the transfer of docked vessels from one vessel to another in the event of a split.
|
virtual |
Called when this module is removed from a vessel.
overload for module types that register things or need to modify the base vessel overloaded methods should ALWAYS invoke the base method because of attachment point and mesh handling!
|
protected |
Resets attachment points to their original state.
The original state is defined as the state of the attachment point on the newly created, unintegrated module. The state includes position, rotation, direction as well as connection state and dockport state
void IMS_Module::RotateAttachmentPoint | ( | IMSATTACHMENTPOINT * | att, |
double | angle | ||
) |
rotates an attachment point around its directional axis
att | Pointer to the attachment point to be rotated |
angle | The rotational angle in radians |
|
protected |
Saves attributes common to all modules.
scn | FILEHNDLE to the open scenario file to write to |
|
virtual |
called from IMS2::clbkSaveState() to write the module state to scenario file
scn | The FILEHANDLE to the Scenario file being written |
index | The current index of this module in the vessel. This is only needed as an identifier in the Scenario. |
void IMS_Module::SetDir | ( | VECTOR3 & | mDir | ) |
Sets the vessel-relative direction of the module.
mDir | The desired directional vector ("front"-direction) |
void IMS_Module::SetDockPortsToNull | ( | ) |
Gets called after assimilating a module, because all DOCKHANDLEs in the module are now invalid.
void IMS_Module::SetOrientationRelativeTo | ( | IMS_Module * | module | ) |
transforms the module to preserve position and orientation relative to the passed module in its origin state.
A module in its origin state means that its position/orientation is 0, 0, 1 / 0, 1, 0. This module is transformed so it has the same position and orientation relative to the passed module that it has now, after the other module is rotated from iuts current orientation to origin. This is used to preserve the relative orientation of modules in a subset of the vessel that is being split off.
module | A pointer to the module this module should keep its relative position and orientation to. |
void IMS_Module::SetPos | ( | VECTOR3 & | mPos | ) |
Sets the vessel-relative position of the module.
mPos | The desired position |
void IMS_Module::SetRot | ( | VECTOR3 & | mRot | ) |
Sets the vessel-relative rotation of the module
mRot | The desired rotational vector ("up"-direction, normalised) |
void IMS_Module::SpawnNewVesselFromModule | ( | string | _name, |
VECTOR3 | velocity | ||
) |
Spawns a new vessel that has the same position, orientation and class as this module.
_name | The name for the newly created vessel |
velocity | Direction and magnitude of velocity relative to separating vessel |
void IMS_Module::UpdateAttachmentPoints | ( | bool | redock = false | ) |
Updates state of attachment points and associated dockports as well as vessels docked to those ports.
redock | pass true if vessels formerly docked to this attachment point should be redocked instead of unregistered as docked vessels. |