Colobot
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CObject Class Referenceabstract

Base class for all 3D in-game objects. More...

#include <object.h>

Inheritance diagram for CObject:
Inheritance graph
[legend]

Public Member Functions

 CObject (const CObject &)=delete
 
CObjectoperator= (const CObject &)=delete
 
ObjectType GetType () const
 Returns object type. More...
 
int GetID () const
 Returns object's unique id. More...
 
virtual void Write (CLevelParserLine *line)=0
 Writes object properties to line in level file. More...
 
virtual void Read (CLevelParserLine *line)=0
 Reads object properties from line in level file. More...
 
virtual void UpdateInterface ()
 Updates all interface controls. More...
 
bool Implements (ObjectInterfaceType type) const
 Check if object implements the given type of interface. More...
 
virtual Math::Vector GetPosition () const
 Returns object's position. More...
 
virtual void SetPosition (const Math::Vector &pos)
 Sets object's position. More...
 
virtual Math::Vector GetRotation () const
 Returns object's rotation (Euler angles) More...
 
virtual void SetRotation (const Math::Vector &rotation)
 Sets object's rotation (Euler angles) More...
 
virtual Math::Vector GetScale () const
 Returns object's scale. More...
 
virtual void SetScale (const Math::Vector &scale)
 Sets objects's scale. More...
 
void SetScale (float scale)
 Sets objects's scale (uniform value) More...
 
void SetCrashSpheres (const std::vector< Gfx::ModelCrashSphere > &crashSpheres)
 Sets crash spheres for object. More...
 
void AddCrashSphere (const CrashSphere &crashSphere)
 Adds a new crash sphere. More...
 
int GetCrashSphereCount ()
 Returns total number of crash spheres. More...
 
CrashSphere GetFirstCrashSphere ()
 Returns the first crash sphere (assumes it exists) More...
 
std::vector< CrashSphereGetAllCrashSpheres ()
 Returns all crash spheres. More...
 
void DeleteAllCrashSpheres ()
 Removes all crash spheres. More...
 
bool CanCollideWith (CObject *other)
 Returns true if this object can collide with the other one. More...
 
Math::Sphere GetCameraCollisionSphere ()
 Returns sphere used to test for camera collisions. More...
 
void SetCameraCollisionSphere (const Math::Sphere &sphere)
 Sets sphere used to test for camera collisions. More...
 
virtual void SetTransparency (float value)=0
 Sets the transparency of object. More...
 
void SetAnimateOnReset (bool animateOnReset)
 Sets flag controlling animation effect on level reset. More...
 
bool GetAnimateOnReset ()
 Returns flag controlling animation effect on level reset. More...
 
void SetCollisions (bool collisions)
 Turns object collisions on/off. More...
 
bool GetCollisions ()
 Returns true if collisions are enabled. More...
 
void SetTeam (int team)
 Sets object team (shouldn't be called after creation because the model won't update!) More...
 
int GetTeam ()
 Returns object team. More...
 
void SetProxyActivate (bool activate)
 Enable object activation only after you come close. More...
 
bool GetProxyActivate ()
 Returns close activation mode. More...
 
void SetProxyDistance (float distance)
 Sets distance for close activation. More...
 
float GetProxyDistance ()
 Returns distance for close activation. More...
 
CBot::CBotVarGetBotVar ()
 Returns CBot "object" variable associated with this object. More...
 
std::string GetTooltipText ()
 Returns tooltip text for an object. More...
 
void SetLock (bool lock)
 Set "lock" mode of an object (for example, a robot while it's being factored, or a building while it's built) More...
 
bool GetLock ()
 Return "lock" mode of an object. More...
 
virtual bool GetActive ()
 Is this object active (not dead)? More...
 
virtual bool GetDetectable ()
 Is this object detectable (not dead and not underground)? More...
 
void SetRotationX (float angle)
 
void SetRotationY (float angle)
 
void SetRotationZ (float angle)
 
float GetRotationX ()
 
float GetRotationY ()
 
float GetRotationZ ()
 
void SetScaleX (float angle)
 
void SetScaleY (float angle)
 
void SetScaleZ (float angle)
 
float GetScaleX ()
 
float GetScaleY ()
 
float GetScaleZ ()
 
- Public Member Functions inherited from COldObjectInterface
virtual void Simplify ()
 
virtual void DeletePart (int part)
 
virtual void SetType (ObjectType type)
 
virtual int GetObjectRank (int part)
 
virtual int GetOption ()
 
virtual void SetDrawFront (bool bDraw)
 
virtual void FloorAdjust ()
 
virtual void SetLinVibration (Math::Vector dir)
 
virtual void SetCirVibration (Math::Vector dir)
 
virtual Math::Vector GetTilt ()
 
virtual void SetMasterParticle (int part, int parti)
 
virtual Math::MatrixGetWorldMatrix (int part)
 
virtual CharacterGetCharacter ()
 
virtual void FlatParent ()
 
virtual void SetVirusMode (bool bEnable)
 
virtual bool GetVirusMode ()
 
virtual CAutoGetAuto ()
 

Static Public Member Functions

static ObjectCreateParams ReadCreateParams (CLevelParserLine *line)
 Reads params required for object creation. More...
 

Protected Member Functions

 CObject (int id, ObjectType type)
 Constructor only accessible to subclasses. More...
 
virtual void TransformCrashSphere (Math::Sphere &crashSphere)=0
 Transform crash sphere by object's world matrix. More...
 
virtual void TransformCameraCollisionSphere (Math::Sphere &collisionSphere)=0
 Transform crash sphere by object's world matrix. More...
 

Protected Attributes

const int m_id
 unique identifier More...
 
ObjectType m_type
 object type More...
 
ObjectInterfaceTypes m_implementedInterfaces
 interfaces that the object implements More...
 
Math::Vector m_position
 
Math::Vector m_rotation
 
Math::Vector m_scale
 
std::vector< CrashSpherem_crashSpheres
 crash spheres More...
 
Math::Sphere m_cameraCollisionSphere
 
bool m_animateOnReset
 
bool m_collisions
 
int m_team
 
bool m_proxyActivate
 
float m_proxyDistance
 
CBot::CBotVarm_botVar
 
bool m_lock
 

Detailed Description

Base class for all 3D in-game objects.

CObject serves as a base class for all in-game objects, including:

As every object has its specific behavior, there are or will be separate subclasses for each of the specific objects. For the time being, old object interface is still present, but its functions will be moved to appropriate subclasses with time. The new CObject interface implemented here will feature only functions common to all objects.

Constructor & Destructor Documentation

CObject::CObject ( int  id,
ObjectType  type 
)
protected

Constructor only accessible to subclasses.

Member Function Documentation

ObjectType CObject::GetType ( ) const
inline

Returns object type.

int CObject::GetID ( ) const
inline

Returns object's unique id.

virtual void CObject::Write ( CLevelParserLine line)
pure virtual

Writes object properties to line in level file.

Implemented in COldObject, CExchangePost, CBaseAlien, CShielder, and CStaticObject.

virtual void CObject::Read ( CLevelParserLine line)
pure virtual

Reads object properties from line in level file.

Implemented in COldObject, CExchangePost, CBaseAlien, CShielder, and CStaticObject.

ObjectCreateParams CObject::ReadCreateParams ( CLevelParserLine line)
static

Reads params required for object creation.

virtual void CObject::UpdateInterface ( )
inlinevirtual

Updates all interface controls.

Reimplemented in COldObject.

bool CObject::Implements ( ObjectInterfaceType  type) const
inline

Check if object implements the given type of interface.

Math::Vector CObject::GetPosition ( ) const
virtual

Returns object's position.

Reimplemented in COldObject.

void CObject::SetPosition ( const Math::Vector pos)
virtual

Sets object's position.

Reimplemented in COldObject.

Math::Vector CObject::GetRotation ( ) const
virtual

Returns object's rotation (Euler angles)

Angles are given in radians

Reimplemented in COldObject.

void CObject::SetRotation ( const Math::Vector rotation)
virtual

Sets object's rotation (Euler angles)

Angles are given in radians

Reimplemented in COldObject.

void CObject::SetRotationX ( float  angle)

Shortcuts for rotation components

Math::Vector CObject::GetScale ( ) const
virtual

Returns object's scale.

Reimplemented in COldObject.

void CObject::SetScale ( const Math::Vector scale)
virtual

Sets objects's scale.

Reimplemented in COldObject.

void CObject::SetScale ( float  scale)

Sets objects's scale (uniform value)

void CObject::SetScaleX ( float  angle)

Shortcuts for scale components

void CObject::SetCrashSpheres ( const std::vector< Gfx::ModelCrashSphere > &  crashSpheres)

Sets crash spheres for object.

void CObject::AddCrashSphere ( const CrashSphere crashSphere)

Adds a new crash sphere.

Crash sphere position is given in object coordinates

int CObject::GetCrashSphereCount ( )

Returns total number of crash spheres.

CrashSphere CObject::GetFirstCrashSphere ( )

Returns the first crash sphere (assumes it exists)

Crash sphere position is returned in world coordinates

std::vector< CrashSphere > CObject::GetAllCrashSpheres ( )

Returns all crash spheres.

Crash sphere position is returned in world coordinates

void CObject::DeleteAllCrashSpheres ( )

Removes all crash spheres.

bool CObject::CanCollideWith ( CObject other)

Returns true if this object can collide with the other one.

Math::Sphere CObject::GetCameraCollisionSphere ( )

Returns sphere used to test for camera collisions.

void CObject::SetCameraCollisionSphere ( const Math::Sphere sphere)

Sets sphere used to test for camera collisions.

virtual void CObject::SetTransparency ( float  value)
pure virtual

Sets the transparency of object.

Implemented in COldObject, and CStaticObject.

void CObject::SetAnimateOnReset ( bool  animateOnReset)

Sets flag controlling animation effect on level reset.

bool CObject::GetAnimateOnReset ( )

Returns flag controlling animation effect on level reset.

void CObject::SetCollisions ( bool  collisions)

Turns object collisions on/off.

bool CObject::GetCollisions ( )

Returns true if collisions are enabled.

void CObject::SetTeam ( int  team)

Sets object team (shouldn't be called after creation because the model won't update!)

int CObject::GetTeam ( )

Returns object team.

void CObject::SetProxyActivate ( bool  activate)

Enable object activation only after you come close.

bool CObject::GetProxyActivate ( )

Returns close activation mode.

void CObject::SetProxyDistance ( float  distance)

Sets distance for close activation.

float CObject::GetProxyDistance ( )

Returns distance for close activation.

CBot::CBotVar * CObject::GetBotVar ( )

Returns CBot "object" variable associated with this object.

std::string CObject::GetTooltipText ( )

Returns tooltip text for an object.

void CObject::SetLock ( bool  lock)

Set "lock" mode of an object (for example, a robot while it's being factored, or a building while it's built)

bool CObject::GetLock ( )

Return "lock" mode of an object.

virtual bool CObject::GetActive ( )
inlinevirtual

Is this object active (not dead)?

Reimplemented in COldObject.

virtual bool CObject::GetDetectable ( )
inlinevirtual

Is this object detectable (not dead and not underground)?

Reimplemented in COldObject.

virtual void CObject::TransformCrashSphere ( Math::Sphere crashSphere)
protectedpure virtual

Transform crash sphere by object's world matrix.

Implemented in COldObject, and CStaticObject.

virtual void CObject::TransformCameraCollisionSphere ( Math::Sphere collisionSphere)
protectedpure virtual

Transform crash sphere by object's world matrix.

Implemented in COldObject, and CStaticObject.

Member Data Documentation

const int CObject::m_id
protected

unique identifier

ObjectType CObject::m_type
protected

object type

ObjectInterfaceTypes CObject::m_implementedInterfaces
protected

interfaces that the object implements

std::vector<CrashSphere> CObject::m_crashSpheres
protected

crash spheres


The documentation for this class was generated from the following files: