Right now each model is loaded in the main graphics class that does rendering calls. Functions inside the class are specific to each model.
load:
// Create the model object.
m_Model = new ModelClass;
if(!m_Model)
{
return false;
}
// Initialize the model object.
result = m_Model->Initialize(m_D3D->GetDevice(), "../Engine/Assets/SphereMesh.txt", L"../Engine/Assets/earthlights.dds");
if(!result)
{
MessageBox(hwnd, L"Could not initialize the model object.", L"Error", MB_OK);
return false;
}
function method:
m_BeaconModel->Render(m_D3D->GetDeviceContext());
m_testTexture->Render(m_D3D->GetDeviceContext(), m_BeaconModel->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
m_BeaconModel->GetTexture(), m_Light->GetDirection(), color);
......
if(m_Frustum->CheckSphere(x,y,z, 2.0f))
{
D3DXMatrixTranslation(&transMatrix, x, y, z);
worldMatrix = transMatrix;
m_BeaconModel->Render(m_D3D->GetDeviceContext());
m_testTexture->Render(m_D3D->GetDeviceContext(), m_BeaconModel->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
m_BeaconModel->GetTexture(), m_Light->GetDirection(), color);
}
As you can see its very hard coded. If I want to use another model with the function above I have to alter the function and not the call. I know this isn't right.
Do I use something like this->render( ... ) inside functions to make them work upon whatever i call them with as opposed to what Ive hard-coded?
Also right now the model loading bothers me. Hard coding in all the models and textures seems wrong if not impossible for anything with a significant number of meshes and textures. Is it possible to write a function or a manager class that will load and unload as needed given a lookup table or some such?
I dont necessarily need exact methods, but Im a little aimless in how to write my code in a more manageable way so any direction is very helpful right now. Thanks all.