Bullet Physics 3D Block Toy
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CRenderer Class Reference

The renderer. More...

#include <Renderer.h>

Inheritance diagram for CRenderer:
CCommon

Public Member Functions

 CRenderer ()
 Constructor.
 
 ~CRenderer ()
 Destructor.
 
void Initialize ()
 Initialize. More...
 
void LoadGeometricPrimitives ()
 Load meshes. More...
 
void LoadModel (eModel, const std::wstring &)
 Load model from file. More...
 
void Render (CObject *)
 Render an object. More...
 
LBaseCamera * GetCameraPtr () const
 Get the camera pointer. More...
 
ID3D12Device * GetD3DDevice () const
 Get the D3D device pointer. More...
 
const Vector3 & GetExtents (const eModel) const
 Get model extents. More...
 
CMeshDescGetPrimitiveDesc (const eMesh) const
 Get mesh descriptor. More...
 

Private Member Functions

void BeginResourceUpload ()
 Begin resource upload.
 
void EndResourceUpload ()
 End resource upload. More...
 
void UploadTexture (char *, eMesh)
 Upload texture to GPU. More...
 
void UploadDefaultEffect (CMeshDesc *)
 Upload default effect to GPU. More...
 
void UploadSphereMesh (CMeshDesc *)
 Upload sphere mesh to GPU. More...
 
void UploadBoxMesh (CMeshDesc *)
 Upload box mesh to GPU. More...
 
void UploadPrimitiveMesh (CMeshDesc *)
 Upload geometric primitive mesh to GPU. More...
 

Private Attributes

CMeshDesc ** m_pPrimitive
 Array of primitive descriptors.
 
LTextureDesc * m_pTextureDesc = nullptr
 Array of texture descriptors.
 
size_t m_nNumTextures = 0
 Number of textures.
 
std::map< eModel, CModelDesc * > m_mapModelDesc
 Model descriptor map.
 

Additional Inherited Members

- Protected Attributes inherited from CCommon
const float m_fFloorHt = 0.5f
 Floor height.
 
const Vector3 m_vPlanePos = Vector3(0.0f, 0.0f, 100.0f)
 Plane position.
 
const Vector3 m_vPlaneSize = Vector3(600.0f, 2.0f*m_fFloorHt, 600.0f)
 Plane size.
 
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 Protected Attributes inherited from CCommon
static CRendererm_pRenderer = nullptr
 Pointer to the renderer.
 
static LBaseCamera * m_pCamera = nullptr
 Pointer to the camera.
 
static CObjectManagerm_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.
 

Detailed Description

CRenderer handles the game-specific rendering tasks, relying on the base class to do all of the actual API-specific rendering.

Member Function Documentation

◆ EndResourceUpload()

void CRenderer::EndResourceUpload ( )
private

Wait for the upload thread to terminate.

◆ GetCameraPtr()

LBaseCamera * CRenderer::GetCameraPtr ( ) const

Reader function for the camera pointer.

Returns
The camera pointer.

◆ GetD3DDevice()

ID3D12Device * CRenderer::GetD3DDevice ( ) const

Reader function for the D3D device pointer.

Returns
the D3D device pointer.

◆ GetExtents()

const Vector3 & CRenderer::GetExtents ( const eModel  t) const

Reader function for the model extents (half width, height, and depth).

Parameters
tModel type.
Returns
Const reference to the bounding box extents of a model of type t.

◆ GetPrimitiveDesc()

CMeshDesc * CRenderer::GetPrimitiveDesc ( const eMesh  t) const

Get a pointer to the geometric primitive descriptor for a mesh type.

Parameters
tMesh type.
Returns
Pointer to the geometric primitive descriptor for the mesh type.

◆ Initialize()

void CRenderer::Initialize ( )

Initialize the renderer, set the background color, and create a perspective camera.

◆ LoadGeometricPrimitives()

void CRenderer::LoadGeometricPrimitives ( )

Load meshes, textures, and effects for geometric primitives.

◆ LoadModel()

void CRenderer::LoadModel ( eModel  t,
const std::wstring &  strPath 
)

Load a model mesh and texture from a file to the GPU.

Parameters
tModel type.
strPathWide string containing path and file name.

◆ Render()

void CRenderer::Render ( CObject pObj)

Render an object.

Parameters
pObjPointer to the object to be rendered. May be nullptr.

◆ UploadBoxMesh()

void CRenderer::UploadBoxMesh ( CMeshDesc pDesc)
private

Upload box mesh to GPU. This gets its own function because we will be repeating the texture across each face.

Parameters
pDescPointer to geometric primitive descriptor.

◆ UploadDefaultEffect()

void CRenderer::UploadDefaultEffect ( CMeshDesc pDesc)
private

Upload default effect to GPU.

Parameters
pDescPointer to geometric primitive descriptor.

◆ UploadPrimitiveMesh()

void CRenderer::UploadPrimitiveMesh ( CMeshDesc pDesc)
private

General function for uploading a geometric primitive mesh. Creates a new primitive mesh descriptor and fills it with mesh information including a local copy of vertices, and stores a pointer to it in m_vecPrimitives[t] for later use, for example, in physics calculations such as collision detection and response.

Parameters
pDescPointer to geometric primitive descriptor.

◆ UploadSphereMesh()

void CRenderer::UploadSphereMesh ( CMeshDesc pDesc)
private

Upload sphere mesh to GPU. The sphere gets its own function because it has its own level of triangulation, which will be larger for large spheres.

Parameters
pDescPointer to geometric primitive descriptor.

◆ UploadTexture()

void CRenderer::UploadTexture ( char *  name,
eMesh  t 
)
private

Upload texture to GPU.

Parameters
nameName string found in gamesettings.xml.
tTexture type.