IVehiclePart

Vehicle Part interface

C++
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;
  };
};
File

IVehicleSystem.h

Description

Interface used to implement parts of a vehicle.

IVehiclePart::EVehiclePartEvent Enumeration

Part event values

C++
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
};
File

IVehicleSystem.h

Members
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
Description

Values used by the type variable in SVehiclePartEvent.

IVehiclePart::EVehiclePartState Enumeration
C++
enum EVehiclePartState {
  eVGS_Default = 0,
  eVGS_Damaged1,
  eVGS_Destroyed,
  eVGS_Last
};
File

IVehicleSystem.h

IVehiclePart::EVehiclePartStateFlags Enumeration
C++
enum EVehiclePartStateFlags {
  eVPSF_Physicalize = 1<<0,
  eVPSF_Force = 1<<1
};
File

IVehicleSystem.h

IVehiclePart::EVehiclePartType Enumeration
C++
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
};
File

IVehicleSystem.h

IVehiclePart::SVehiclePartEvent Structure

Part event structure

C++
struct SVehiclePartEvent {
  EVehiclePartEvent type;
  const char* sparam;
  float fparam;
  bool bparam;
  void* pData;
};
File

IVehicleSystem.h

Description

This structure is used by the OnEvent function to pass message to vehicle parts.

IVehiclePart::SVehiclePartEvent::bparam Data Member
C++
bool bparam;
IVehiclePart::SVehiclePartEvent::fparam Data Member
C++
float fparam;
Description

float parameter (optional)

IVehiclePart::SVehiclePartEvent::pData Data Member
C++
void* pData;
IVehiclePart::SVehiclePartEvent::sparam Data Member
C++
const char* sparam;
Description

c string parameter (optional)

IVehiclePart::SVehiclePartEvent::type Data Member
C++
Description

message type value, usually defined in EVehiclePartEvent

IVehiclePart::SVehiclePartEvent::SVehiclePartEvent Constructor
C++
SVehiclePartEvent();
IVehiclePart::AddChildPart Method

Add part to child list

C++
virtual void AddChildPart(IVehiclePart* pPart) = 0;
Description

Used for part implementations that needs to keep track of their children

IVehiclePart::ChangeState Method

Loads the geometry/character needed by the vehicle part

C++
virtual bool ChangeState(EVehiclePartState state, int flags = 0) = 0;
IVehiclePart::GetDetachBaseForce Method
C++
virtual const Vec3& GetDetachBaseForce() = 0;
IVehiclePart::GetEntity Method

Retrieves the entity which hold the vehicle part

C++
virtual IEntity* GetEntity() = 0;
Description

In most of the cases, the entity holding the vehicle part will be the vehicle entity itself.

IVehiclePart::GetId Method

Returns the id of the vehicle object

C++
virtual TVehicleObjectId GetId() = 0;
IVehiclePart::GetIndex Method
C++
virtual int GetIndex() const = 0;
IVehiclePart::GetIWheel Method

Retrieve IVehicleWheel interface, or NULL

C++
virtual IVehicleWheel* GetIWheel() = 0;
IVehiclePart::GetLocalBaseTM Method

Gets the local base transform matrix

C++
virtual const Matrix34& GetLocalBaseTM() = 0;
Description

Will return the local BASE transform matrix (without recoil etc) relative to parent part

IVehiclePart::GetLocalBounds Method

Gets a local bounding box

C++
virtual const AABB& GetLocalBounds() = 0;
Returns

a 3x4 matrix

Description

Will return a local transform matrix relative to the vehicle space.

IVehiclePart::GetLocalInitialTM Method

Gets the initial base transform matrix

C++
virtual const Matrix34& GetLocalInitialTM() = 0;
Description

Will return the local transform matrix from the initial state of the model as relative to parent part

IVehiclePart::GetLocalTM Method

Gets final local transform matrix

C++
virtual const Matrix34& GetLocalTM(bool relativeToParentPart, bool forced = false) = 0;
Returns

a 3x4 matrix

Description

Will return the FINAL local transform matrix (with recoil etc) relative to parent part or vehicle space

IVehiclePart::GetMass Method
C++
virtual float GetMass() = 0;
IVehiclePart::GetMemoryUsage Method
C++
virtual void GetMemoryUsage(ICrySizer * pSizer) const = 0;
IVehiclePart::GetName Method

Retrieves the name of the part

C++
virtual const char* GetName() = 0;
IVehiclePart::GetParent Method

Retrieves a pointer of the parent part

C++
virtual IVehiclePart* GetParent(bool root = false) = 0;
Returns

A pointer to the parent part, or NULL if there isn't any.

IVehiclePart::GetPhysId Method
C++
virtual int GetPhysId() = 0;
IVehiclePart::GetSlot Method
C++
virtual int GetSlot() = 0;
IVehiclePart::GetState Method

Query the current state of the vehicle part

C++
virtual EVehiclePartState GetState() const = 0;
IVehiclePart::GetType Method

Retrieve type id

C++
virtual int GetType() = 0;
IVehiclePart::GetWorldTM Method

Gets a world transform matrix

C++
virtual const Matrix34& GetWorldTM() = 0;
Returns

a 3x4 matrix

Description

Will return a transform matrix world space.

IVehiclePart::InvalidateTM Method

Invalidate local transformation matrix

C++
virtual void InvalidateTM(bool invalidate) = 0;
IVehiclePart::OnEvent Method

Sends an event message to the vehicle part

C++
virtual void OnEvent(const SVehiclePartEvent& event) = 0;
Parameters
Parameters
Description
const SVehiclePartEvent& event
event to be passed to the part
Description

Used to send different events to the vehicle part implementation. The EVehiclePartEvent enum lists several usual vehicle part events.

IVehiclePart::Physicalize Method

Query the current state of the vehicle part

C++
virtual void Physicalize() = 0;
Description

Obsolete. Will be changed soon in favor of an event passed by OnEvent.

IVehiclePart::PostInit Method

Initializes the vehicle part

C++
virtual void PostInit() = 0;
Parameters
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
Returns

A boolean which indicate if the function succeeded virtual bool Init(IVehicle* pVehicle, const SmartScriptTable &table, IVehiclePart* pParent = NULL) = 0;

Description

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.

IVehiclePart::PostSerialize Method
C++
virtual void PostSerialize() = 0;
IVehiclePart::RegisterSerializer Method

Obsolete function

C++
virtual void RegisterSerializer(IGameObjectExtension* gameObjectExt) = 0;
Description

Obsolete. Will be changed soon.

IVehiclePart::Release Method

Releases the vehicle part

C++
virtual void Release() = 0;
Description

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;".

IVehiclePart::Reset Method

Resets the vehicle part

C++
virtual void Reset() = 0;
Description

Used to reset a vehicle part to its initial state. Is usually being called when the Editor enter and exit the game mode.

IVehiclePart::Serialize Method

Serialize the vehicle object

C++
virtual void Serialize(TSerialize ser, EEntityAspects aspects) = 0;
IVehiclePart::SetLocalBaseTM Method

Sets local base transformation matrix relative to parent part

C++
virtual void SetLocalBaseTM(const Matrix34& localTM) = 0;
Description

This sets the local base tm.

IVehiclePart::SetLocalTM Method

Sets local transformation matrix relative to parent part

C++
virtual void SetLocalTM(const Matrix34& localTM) = 0;
Description

This sets the FINAL local tm only. Usually you'll want to use SetLocalBaseTM

IVehiclePart::SetMaterial Method

Sets material on the part

C++
virtual void SetMaterial(IMaterial* pMaterial) = 0;
IVehiclePart::SetMoveable Method

Sets part as being moveable and/or rotateable

C++
virtual void SetMoveable(bool allowTranslationMovement = false) = 0;
IVehiclePart::Update Method

Update the vehicle object

C++
virtual void Update(const float deltaTime) = 0;
Parameters
Parameters
Description
const float deltaTime
total time for the update, in seconds
Description

Used to handle any time sensitive updates. In example, rotation for turret parts is implemented in this function.