The game object.
More...
#include <Object.h>
|
|
eObject | m_eObjectType = eObject::Unknown |
| | Object type.
|
| |
|
eMesh | m_eMeshType = eMesh::Unknown |
| | Mesh type.
|
| |
|
eModel | m_eModelType = eModel::Unknown |
| | Model type.
|
| |
|
float | m_fScale = 1.0f |
| | Scale (used for models).
|
| |
|
UINT | m_nShapeIndex = 0 |
| | Shape index.
|
| |
|
UINT | m_nEffectIndex = 0 |
| | Effect index.
|
| |
|
Quaternion | m_qOrientation |
| | Initial orientation.
|
| |
|
btRigidBody * | m_pBody = nullptr |
| | Pointer to physics body.
|
| |
|
std::map< CObject *, CContactDesc > | m_mapContact [2] |
| | Contact lists.
|
| |
|
UINT | m_nContactIndex = 0 |
| | Contact index.
|
| |
|
|
const float | m_fFloorHt = 1.0f |
| | Floor height.
|
| |
| const Vector3 | m_vPlanePos |
| | Plane position.
|
| |
| const Vector3 | m_vPlaneSize |
| | Plane size.
|
| |
|
const bool | m_bWireFrame = false |
| | Draw in wireframe.
|
| |
|
const float | m_fMoonRadius = 25.0f |
| | Moon radius.
|
| |
|
const float | m_fBallRadius = 2.0f |
| | Ball radius.
|
| |
|
const Vector3 | m_vBoxSize = Vector3(9.0f, 6.0f, 6.0f) |
| | Box size.
|
| |
|
const float | m_fTetrahedronSize = 16.0f |
| | Tetrahedron size.
|
| |
|
const float | m_fIcosahedronSize = 16.0f |
| | Icosahedron size.
|
| |
|
const float | m_fDodecahedronSize = 16.0f |
| | Dodecahedron size.
|
| |
|
const float | m_fTeapotSize = 8.0f |
| | Teapot size.
|
| |
|
static CRenderer * | m_pRenderer = nullptr |
| | Pointer to the renderer.
|
| |
|
static Sage::CCamera * | m_pCamera = nullptr |
| | Pointer to the camera.
|
| |
|
static CObjectManager * | m_pObjectManager = nullptr |
| | Pointer to object manager.
|
| |
|
static btDiscreteDynamicsWorld * | m_pPhysicsWorld = nullptr |
| | Pointer to physics engine.
|
| |
|
static btDefaultCollisionConfiguration * | m_pConfig = nullptr |
| | Bullet physics configuration.
|
| |
|
static btCollisionDispatcher * | m_pDispatcher = nullptr |
| | Bullet physics dispatcher.
|
| |
|
static btBroadphaseInterface * | m_pBroadphase = nullptr |
| | Bullet physics broadphase.
|
| |
|
static btSequentialImpulseConstraintSolver * | m_pSolver = nullptr |
| | Bullet physics constraint solver.
|
| |
|
static btAlignedObjectArray< btCollisionShape * > | m_btCollisionShapes |
| | Collision shapes.
|
| |
|
static bool | m_bCollisionSoundsMuted = false |
| | Mute collision sounds.
|
| |
CObject is the abstract representation of an object.
◆ CObject()
Make an instance of a geometric primitive or triangle mesh model object with a shape for collision detection and response. Add a rigid body to the physics world with user pointer pointing to this so that we can later map collisions between physics bodies to the corresponding objects.
- Parameters
-
| t | Object type. |
| d | Instance descriptor. |
◆ ~CObject()
Destructor. This is mainly just cleaning up after Bullet Physics by deleting the physics body, motion state, and collision object.
◆ AddContact()
Add a contact to the current contact map. This function is called by a callback function myTickCallback(), which is called from Bullet Physics whenever a contact between two bodies is detected.
- Parameters
-
| pObj | Pointer to object in contact. |
| d | Contact descriptor for the contact. |
◆ ApplyImpulse()
| void CObject::ApplyImpulse |
( |
const Vector3 & | force, |
|
|
const Vector3 & | pos ) |
Apply an impulse through a point.
- Parameters
-
| force | Direction and magnitude of impulse. |
| pos | Point through which the impulse is applied. |
◆ ComputeConvexHull()
| btConvexHullShape * CObject::ComputeConvexHull |
( |
| ) |
|
|
private |
Compute the convex hull for a primitive of type m_eMeshType. A convex hull is a triangle mesh that fits closely to the original mesh but is convex. Bullet Physics has the ability to compute a convex hull from the vertices of a mesh and use it as a collision shape. Append a pointer to it to m_btCollisionShapes.
- Returns
- Pointer to the convex hull created.
◆ ContactType() [1/2]
Determine whether this object and another object have the right types, ignoring the order of the type parameters.
- Parameters
-
| p | Pointer to an object. |
| t | Object type. |
- Returns
- true if this object or *p has types t.
◆ ContactType() [2/2]
Determine whether this object and another object have the right types, ignoring the order of the type parameters.
- Parameters
-
| p | Pointer to an object. |
| t0 | First object type. |
| t1 | Second object type. |
- Returns
- true if this object and *p have types t0 and t1 in any order.
◆ GetObjectType()
| const eObject CObject::GetObjectType |
( |
| ) |
const |
Reader function for the object type.
- Returns
- Object type.
◆ GetOrientation()
| const Quaternion CObject::GetOrientation |
( |
| ) |
const |
Get the object orientation. If it has a physics body, then get it from the physics engine, otherwise from m_qOrientation.
- Returns
- The object orientation quaternion.
◆ GetPosition()
| const Vector3 CObject::GetPosition |
( |
| ) |
const |
Get position.
Get the position of the object center. If it has a physics body, then get it from the physics engine, otherwise return the zero vector.
- Returns
- The position of the object center.
◆ PlayCollisionSounds()
| void CObject::PlayCollisionSounds |
( |
| ) |
|
Play collision sounds, which are managed as follows. There are two contact maps, m_mapContact[0] and m_mapContact[1], which map a pointer to the object that this object is in contact with to a contact descriptor for the contact. The current contact map is m_mapContact[m_nContactIndex], where m_nContactIndex flips from zero to one each time this function is called. The other contact map m_mapContact[m_nContactIndex^1] is the contact map from the previous frame. Entries are place in the current contact map by a callback function myTickCallback() calling function AddContact() above. This function is then called at the end of the frame to play the appropriate sound when either (1) there is an entry in the current contact map for an object that does not have an entry in the previous contact map, or, (2) the entry for an object in the current contact map has more points of contact than the one in the previous contact map.