Vehicle Part interface
struct IVehiclePart : public IVehicleObject { enum EVehiclePartEvent { eVPE_Damaged = 0, eVPE_Repair, eVPE_Physicalize, eVPE_PlayAnimation, eVPE_GotDirty, eVPE_Fade, eVPE_Hide, eVPE_DriverEntered, eVPE_DriverLeft, eVPE_StartUsing, eVPE_StopUsing, eVPE_BlockRotation, eVPE_FlippedOver, eVPE_OtherEvents }; enum EVehiclePartType { eVPT_Base = 0, eVPT_Animated, eVPT_AnimatedJoint, eVPT_Static, eVPT_SubPart, eVPT_Wheel, eVPT_Tread, eVPT_Massbox, eVPT_Light, eVPT_Attachment, eVPT_Entity, eVPT_Last }; enum EVehiclePartState { eVGS_Default = 0, eVGS_Damaged1, eVGS_Destroyed, eVGS_Last }; enum EVehiclePartStateFlags { eVPSF_Physicalize = 1<<0, eVPSF_Force = 1<<1 }; struct SVehiclePartEvent { EVehiclePartEvent type; const char* sparam; float fparam; bool bparam; void* pData; }; };
IVehicleSystem.h
Interface used to implement parts of a vehicle.
Part event values
enum EVehiclePartEvent { eVPE_Damaged = 0, eVPE_Repair, eVPE_Physicalize, eVPE_PlayAnimation, eVPE_GotDirty, eVPE_Fade, eVPE_Hide, eVPE_DriverEntered, eVPE_DriverLeft, eVPE_StartUsing, eVPE_StopUsing, eVPE_BlockRotation, eVPE_FlippedOver, eVPE_OtherEvents };
IVehicleSystem.h
Members |
Description |
eVPE_Damaged = 0 |
the part got damaged, fparam will hold the damage ratio |
eVPE_Repair |
part gets repaired, fparam also holds damage ratio |
eVPE_Physicalize |
currently unused |
eVPE_PlayAnimation |
currently unused |
eVPE_GotDirty |
used to notify that the part geometry got modified and would need to be reloaded next time the part is reset |
eVPE_Fade |
toggle hide the part, fparam specify the amount of time until the requested effect is fully completed |
eVPE_Hide |
toggle hide |
eVPE_DriverEntered |
sent when driver entered the vehicle |
eVPE_DriverLeft |
sent when driver left |
eVPE_StartUsing |
sent when part starts being used in turret (or similar) rotation |
eVPE_StopUsing |
sent when part starts being used in turret (or similar) rotation |
eVPE_BlockRotation |
sent when rotations need to be blocked |
eVPE_FlippedOver |
sent when vehicle flips over. bParam is true when flipping, false when returning to normal orientation |
eVPE_OtherEvents |
used as a starting index for project specific part events |
Values used by the type variable in SVehiclePartEvent.
enum EVehiclePartState { eVGS_Default = 0, eVGS_Damaged1, eVGS_Destroyed, eVGS_Last };
IVehicleSystem.h
enum EVehiclePartStateFlags { eVPSF_Physicalize = 1<<0, eVPSF_Force = 1<<1 };
IVehicleSystem.h
enum EVehiclePartType { eVPT_Base = 0, eVPT_Animated, eVPT_AnimatedJoint, eVPT_Static, eVPT_SubPart, eVPT_Wheel, eVPT_Tread, eVPT_Massbox, eVPT_Light, eVPT_Attachment, eVPT_Entity, eVPT_Last };
IVehicleSystem.h
Part event structure
IVehicleSystem.h
This structure is used by the OnEvent function to pass message to vehicle parts.
bool bparam;
float fparam;
float parameter (optional)
void* pData;
const char* sparam;
c string parameter (optional)
EVehiclePartEvent type;
message type value, usually defined in EVehiclePartEvent
SVehiclePartEvent();
Add part to child list
virtual void AddChildPart(IVehiclePart* pPart) = 0;
Used for part implementations that needs to keep track of their children
Loads the geometry/character needed by the vehicle part
virtual bool ChangeState(EVehiclePartState state, int flags = 0) = 0;
virtual const Vec3& GetDetachBaseForce() = 0;
Retrieves the entity which hold the vehicle part
virtual IEntity* GetEntity() = 0;
In most of the cases, the entity holding the vehicle part will be the vehicle entity itself.
Returns the id of the vehicle object
virtual TVehicleObjectId GetId() = 0;
virtual int GetIndex() const = 0;
Retrieve IVehicleWheel interface, or NULL
virtual IVehicleWheel* GetIWheel() = 0;
Gets the local base transform matrix
virtual const Matrix34& GetLocalBaseTM() = 0;
Will return the local BASE transform matrix (without recoil etc) relative to parent part
Gets a local bounding box
virtual const AABB& GetLocalBounds() = 0;
a 3x4 matrix
Will return a local transform matrix relative to the vehicle space.
Gets the initial base transform matrix
virtual const Matrix34& GetLocalInitialTM() = 0;
Will return the local transform matrix from the initial state of the model as relative to parent part
Gets final local transform matrix
virtual const Matrix34& GetLocalTM(bool relativeToParentPart, bool forced = false) = 0;
a 3x4 matrix
Will return the FINAL local transform matrix (with recoil etc) relative to parent part or vehicle space
virtual float GetMass() = 0;
virtual void GetMemoryUsage(ICrySizer * pSizer) const = 0;
Retrieves the name of the part
virtual const char* GetName() = 0;
Retrieves a pointer of the parent part
virtual IVehiclePart* GetParent(bool root = false) = 0;
A pointer to the parent part, or NULL if there isn't any.
virtual int GetPhysId() = 0;
virtual int GetSlot() = 0;
Query the current state of the vehicle part
virtual EVehiclePartState GetState() const = 0;
Retrieve type id
virtual int GetType() = 0;
Gets a world transform matrix
virtual const Matrix34& GetWorldTM() = 0;
a 3x4 matrix
Will return a transform matrix world space.
Invalidate local transformation matrix
virtual void InvalidateTM(bool invalidate) = 0;
Sends an event message to the vehicle part
virtual void OnEvent(const SVehiclePartEvent& event) = 0;
Parameters |
Description |
const SVehiclePartEvent& event |
event to be passed to the part |
Used to send different events to the vehicle part implementation. The EVehiclePartEvent enum lists several usual vehicle part events.
Query the current state of the vehicle part
virtual void Physicalize() = 0;
Obsolete. Will be changed soon in favor of an event passed by OnEvent.
Initializes the vehicle part
virtual void PostInit() = 0;
Parameters |
Description |
pVehicle |
pointer to the vehicle instance which will own this part |
table |
script table which hold all the part parameters |
pParent |
pointer to a parent part, or NULL if there isn't any parent part specified |
A boolean which indicate if the function succeeded virtual bool Init(IVehicle* pVehicle, const SmartScriptTable &table, IVehiclePart* pParent = NULL) = 0;
Will initialize a newly allocated instance of the vehicle part class according to the parameter table which is passed. This function should only be called once.
virtual void PostSerialize() = 0;
Obsolete function
virtual void RegisterSerializer(IGameObjectExtension* gameObjectExt) = 0;
Obsolete. Will be changed soon.
Releases the vehicle part
virtual void Release() = 0;
Used to release a vehicle part. A vehicle part implementation should then deallocate any memory or object that it dynamically allocated. In addition, the part implementation or its base class should include "delete this;".
Resets the vehicle part
virtual void Reset() = 0;
Used to reset a vehicle part to its initial state. Is usually being called when the Editor enter and exit the game mode.
Serialize the vehicle object
virtual void Serialize(TSerialize ser, EEntityAspects aspects) = 0;
Sets local base transformation matrix relative to parent part
virtual void SetLocalBaseTM(const Matrix34& localTM) = 0;
This sets the local base tm.
Sets local transformation matrix relative to parent part
virtual void SetLocalTM(const Matrix34& localTM) = 0;
This sets the FINAL local tm only. Usually you'll want to use SetLocalBaseTM
Sets material on the part
virtual void SetMaterial(IMaterial* pMaterial) = 0;
Sets part as being moveable and/or rotateable
virtual void SetMoveable(bool allowTranslationMovement = false) = 0;
Update the vehicle object
virtual void Update(const float deltaTime) = 0;
Parameters |
Description |
const float deltaTime |
total time for the update, in seconds |
Used to handle any time sensitive updates. In example, rotation for turret parts is implemented in this function.