Minor Update - Object Rendering change
+ RenderPass (render object in a vector)
This commit is contained in:
parent
bce659e55d
commit
915c0cdd7f
@ -9,34 +9,28 @@ SystemClass::SystemClass()
|
|||||||
m_Input = 0;
|
m_Input = 0;
|
||||||
m_Application = 0;
|
m_Application = 0;
|
||||||
m_imguiManager = 0;
|
m_imguiManager = 0;
|
||||||
|
m_applicationName = 0;
|
||||||
|
m_hinstance = 0;
|
||||||
|
m_hwnd = 0;
|
||||||
|
m_initialWindowWidth = 0;
|
||||||
|
m_initialWindowHeight = 0;
|
||||||
|
m_isDirect3DInitialized = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemClass::SystemClass(const SystemClass& other)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SystemClass::~SystemClass()
|
SystemClass::~SystemClass()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemClass::Initialize()
|
bool SystemClass::Initialize()
|
||||||
{
|
{
|
||||||
int screenWidth, screenHeight;
|
int screenHeight, screenWidth = 0;
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
Logger::Get().Log("Initializing system class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
Logger::Get().Log("Initializing system class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Initialize the width and height of the screen to zero before sending the variables into the function.
|
|
||||||
screenWidth = 0;
|
|
||||||
screenHeight = 0;
|
|
||||||
|
|
||||||
m_initialWindowWidth = 0;
|
|
||||||
m_initialWindowHeight = 0;
|
|
||||||
m_isDirect3DInitialized = false;
|
|
||||||
|
|
||||||
// Initialize the windows api.
|
// Initialize the windows api.
|
||||||
InitializeWindows(screenWidth, screenHeight);
|
InitializeWindows(screenWidth, screenHeight);
|
||||||
|
|
||||||
@ -149,6 +143,10 @@ void SystemClass::Run()
|
|||||||
|
|
||||||
// Loop until there is a quit message from the window or the user.
|
// Loop until there is a quit message from the window or the user.
|
||||||
done = false;
|
done = false;
|
||||||
|
|
||||||
|
auto fixedUpdateInterval = std::chrono::milliseconds(16);
|
||||||
|
auto m_lastFixedUpdateTime = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
// Handle the windows messages.
|
// Handle the windows messages.
|
||||||
@ -180,6 +178,13 @@ void SystemClass::Run()
|
|||||||
Logger::Get().Log("Failed to process frame", __FILE__, __LINE__, Logger::LogLevel::Error);
|
Logger::Get().Log("Failed to process frame", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto now = std::chrono::steady_clock::now();
|
||||||
|
if (now - m_lastFixedUpdateTime >= fixedUpdateInterval)
|
||||||
|
{
|
||||||
|
FixedUpdate();
|
||||||
|
m_lastFixedUpdateTime = now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -266,6 +271,7 @@ LRESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam
|
|||||||
m_initialWindowWidth = newWidth;
|
m_initialWindowWidth = newWidth;
|
||||||
m_initialWindowHeight = newHeight;
|
m_initialWindowHeight = newHeight;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
case WM_ENTERSIZEMOVE:
|
case WM_ENTERSIZEMOVE:
|
||||||
{
|
{
|
||||||
@ -470,4 +476,9 @@ void SystemClass::SendPath(wchar_t* path, std::filesystem::path WFolder)
|
|||||||
{
|
{
|
||||||
m_Application->SetPath(path);
|
m_Application->SetPath(path);
|
||||||
m_Application->SetWFolder(WFolder);
|
m_Application->SetWFolder(WFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SystemClass::FixedUpdate()
|
||||||
|
{
|
||||||
|
m_Application->GetPhysics()->Update();
|
||||||
}
|
}
|
@ -27,12 +27,6 @@ ApplicationClass::ApplicationClass() : m_ShouldQuit(false)
|
|||||||
m_Physics = 0;
|
m_Physics = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ApplicationClass::ApplicationClass(const ApplicationClass& other)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ApplicationClass::~ApplicationClass()
|
ApplicationClass::~ApplicationClass()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -725,7 +719,7 @@ bool ApplicationClass::Frame(InputClass* Input)
|
|||||||
m_Camera->SetRotation(rotationX, rotationY, 0.0f);
|
m_Camera->SetRotation(rotationX, rotationY, 0.0f);
|
||||||
m_Camera->Render();
|
m_Camera->Render();
|
||||||
|
|
||||||
// Render the graphics scene.
|
// Render the static graphics scene.
|
||||||
result = Render(rotation, x, y, z, textureTranslation);
|
result = Render(rotation, x, y, z, textureTranslation);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
@ -851,7 +845,7 @@ bool ApplicationClass::Frame(InputClass* Input)
|
|||||||
position = position + object->GetVelocity() * frameTime;
|
position = position + object->GetVelocity() * frameTime;
|
||||||
object->SetPosition(position);
|
object->SetPosition(position);
|
||||||
|
|
||||||
m_Physics->ApplyGravity(object, 1.0f, frameTime);
|
m_Physics->ApplyGravity(object, 1.0f);
|
||||||
|
|
||||||
// Check if the object has fallen below a certain position
|
// Check if the object has fallen below a certain position
|
||||||
if (XMVectorGetY(object->GetPosition()) < -30.0f)
|
if (XMVectorGetY(object->GetPosition()) < -30.0f)
|
||||||
@ -1074,134 +1068,15 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
|||||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0),
|
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0),
|
||||||
diffuseColor, lightPosition, ambientColor);
|
diffuseColor, lightPosition, ambientColor);
|
||||||
|
|
||||||
for (auto cube : m_cubes)
|
|
||||||
|
// -------------------------------------------------------- //
|
||||||
|
// ------------ Render the object in the queue ------------ //
|
||||||
|
// -------------------------------------------------------- //
|
||||||
|
result = RenderPass(m_terrainChunk, diffuseColor, lightPosition, ambientColor, viewMatrix, projectionMatrix);
|
||||||
|
if (!result)
|
||||||
{
|
{
|
||||||
|
Logger::Get().Log("Could not render the model using any shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
scaleMatrix = cube->GetScaleMatrix();
|
return false;
|
||||||
|
|
||||||
if (cube->m_demoSpinning)
|
|
||||||
rotateMatrix = XMMatrixRotationY(rotation);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rotateMatrix = cube->GetRotateMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
translateMatrix = cube->GetTranslateMatrix();
|
|
||||||
srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix);
|
|
||||||
worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix);
|
|
||||||
|
|
||||||
cube->Render(m_Direct3D->GetDeviceContext());
|
|
||||||
|
|
||||||
|
|
||||||
if (!m_enableCelShading) {
|
|
||||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), cube->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, cube->GetTexture(0),
|
|
||||||
diffuseColor, lightPosition, ambientColor);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
Logger::Get().Log("Could not render the cube model using the light shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render cel shading globally to the scene using the cel shader if the checkbox is checked.
|
|
||||||
if (m_enableCelShading) {
|
|
||||||
result = m_ShaderManager->RenderCelShadingShader(m_Direct3D->GetDeviceContext(), cube->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, cube->GetTexture(0),
|
|
||||||
m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor(), TrueLightPosition);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
Logger::Get().Log("Could not render the model using the cel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& object : m_object)
|
|
||||||
{
|
|
||||||
scaleMatrix = object->GetScaleMatrix();
|
|
||||||
if (object->m_demoSpinning)
|
|
||||||
rotateMatrix = XMMatrixRotationY(rotation);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rotateMatrix = object->GetRotateMatrix();
|
|
||||||
}
|
|
||||||
translateMatrix = object->GetTranslateMatrix();
|
|
||||||
srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix);
|
|
||||||
worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix);
|
|
||||||
|
|
||||||
|
|
||||||
object->Render(m_Direct3D->GetDeviceContext());
|
|
||||||
|
|
||||||
if (!m_enableCelShading) {
|
|
||||||
|
|
||||||
// check if m_object is null or not
|
|
||||||
if (object == nullptr) {
|
|
||||||
|
|
||||||
Logger::Get().Log("Object is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
|
|
||||||
object->GetTexture(0), diffuseColor, lightPosition, ambientColor);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
Logger::Get().Log("Could not render the object model using the light shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render cel shading globally to the scene using the cel shader if the checkbox is checked.
|
|
||||||
if (m_enableCelShading) {
|
|
||||||
result = m_ShaderManager->RenderCelShadingShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, object->GetTexture(0),
|
|
||||||
m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor(), TrueLightPosition);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
Logger::Get().Log("Could not render the model using the cel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render terrain
|
|
||||||
for (auto& chunk : m_terrainChunk)
|
|
||||||
{
|
|
||||||
|
|
||||||
scaleMatrix = chunk->GetScaleMatrix();
|
|
||||||
rotateMatrix = chunk->GetRotateMatrix();
|
|
||||||
translateMatrix = chunk->GetTranslateMatrix();
|
|
||||||
|
|
||||||
srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix);
|
|
||||||
worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix);
|
|
||||||
|
|
||||||
chunk->Render(m_Direct3D->GetDeviceContext());
|
|
||||||
if (!m_enableCelShading) {
|
|
||||||
if (chunk->GetTexture(0) == nullptr)
|
|
||||||
{
|
|
||||||
|
|
||||||
Logger::Get().Log("Could not render the terrain model using the light shader, texture is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), chunk->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, chunk->GetTexture(0), diffuseColor, lightPosition, ambientColor );
|
|
||||||
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
Logger::Get().Log("Could not render the terrain model using the light shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Render cel shading globally to the scene using the cel shader if the checkbox is checked.
|
|
||||||
if (m_enableCelShading) {
|
|
||||||
result = m_ShaderManager->RenderCelShadingShader(m_Direct3D->GetDeviceContext(), chunk->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, chunk->GetTexture(0),
|
|
||||||
m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor(), TrueLightPosition);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
Logger::Get().Log("Could not render the model using the cel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translate to where the bath model will be rendered.
|
// Translate to where the bath model will be rendered.
|
||||||
@ -1720,6 +1595,7 @@ void ApplicationClass::AddKobject(WCHAR* filepath)
|
|||||||
|
|
||||||
m_object.push_back(newObject);
|
m_object.push_back(newObject);
|
||||||
|
|
||||||
|
|
||||||
// Vérifiez que l'objet a bien reçu les textures
|
// Vérifiez que l'objet a bien reçu les textures
|
||||||
if (newObject->GetTexture(0) == nullptr)
|
if (newObject->GetTexture(0) == nullptr)
|
||||||
{
|
{
|
||||||
@ -2026,4 +1902,83 @@ void ApplicationClass::SetScreenWidth(int width)
|
|||||||
// log the new screen width
|
// log the new screen width
|
||||||
Logger::Get().Log("Setting screen width to " + std::to_string(width), __FILE__, __LINE__);
|
Logger::Get().Log("Setting screen width to " + std::to_string(width), __FILE__, __LINE__);
|
||||||
m_screenWidth = width;
|
m_screenWidth = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ApplicationClass::RenderPass(std::vector<Object*> RenderQueue, XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection)
|
||||||
|
{
|
||||||
|
XMMATRIX worldMatrix, scaleMatrix, rotateMatrix, translateMatrix, srMatrix;
|
||||||
|
bool result;
|
||||||
|
|
||||||
|
for (auto& object : RenderQueue)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (object == nullptr)
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Object is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
scaleMatrix = object->GetScaleMatrix();
|
||||||
|
rotateMatrix = object->GetRotateMatrix();
|
||||||
|
translateMatrix = object->GetTranslateMatrix();
|
||||||
|
|
||||||
|
srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix);
|
||||||
|
worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix);
|
||||||
|
|
||||||
|
object->Render(m_Direct3D->GetDeviceContext());
|
||||||
|
|
||||||
|
// Render cel shading.
|
||||||
|
if (object->GetCelShading()) {
|
||||||
|
result = m_ShaderManager->RenderCelShadingShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, view, projection, object->GetTexture(0),
|
||||||
|
m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor(), TrueLightPosition);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Could not render the model using the cel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render normal mapping.
|
||||||
|
if (object->GetNormalMappingEnabled()) {
|
||||||
|
|
||||||
|
result = m_ShaderManager->RenderNormalMapShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, view, projection, object->GetTexture(0), object->GetTexture(1), m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor());
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Could not render the model using the normal map shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render Specular mapping.
|
||||||
|
if (object->GetSpecularMappingEnabled()) {
|
||||||
|
result = m_ShaderManager->RenderSpecMapShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, view, projection, object->GetTexture(0), object->GetTexture(1), object->GetTexture(2), m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor(), m_Camera->GetPosition(), m_Lights[0]->GetSpecularColor(), m_Lights[0]->GetSpecularPower());
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Could not render the model using the specular map shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// By default, render the object using the light shader.
|
||||||
|
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, view, projection,
|
||||||
|
object->GetTexture(0) ,diffuse, position, ambient);
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Could not render the object model using the light shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
@ -102,14 +102,18 @@ public:
|
|||||||
bool IsWindowed() const;
|
bool IsWindowed() const;
|
||||||
void SetWindowed(bool windowed);
|
void SetWindowed(bool windowed);
|
||||||
|
|
||||||
|
Physics* GetPhysics() const { return m_Physics; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool Render(float, float, float, float, float);
|
bool Render(float, float, float, float, float);
|
||||||
|
bool RenderPhysics(float x, float y, float z);
|
||||||
bool UpdateMouseStrings(int, int, bool);
|
bool UpdateMouseStrings(int, int, bool);
|
||||||
bool UpdateFps();
|
bool UpdateFps();
|
||||||
bool UpdateRenderCountString(int);
|
bool UpdateRenderCountString(int);
|
||||||
bool RenderSceneToTexture(float);
|
bool RenderSceneToTexture(float);
|
||||||
bool RenderRefractionToTexture();
|
bool RenderRefractionToTexture();
|
||||||
bool RenderReflectionToTexture();
|
bool RenderReflectionToTexture();
|
||||||
|
bool RenderPass(std::vector<Object*> RenderQueue, XMFLOAT4* diffuse,XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX proijection);
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ Size=457,294
|
|||||||
[Window][Terrain]
|
[Window][Terrain]
|
||||||
Pos=60,60
|
Pos=60,60
|
||||||
Size=342,82
|
Size=342,82
|
||||||
Collapsed=1
|
|
||||||
|
|
||||||
[Window][Light]
|
[Window][Light]
|
||||||
Pos=1548,17
|
Pos=1548,17
|
||||||
@ -24,6 +23,6 @@ Pos=471,90
|
|||||||
Size=180,79
|
Size=180,79
|
||||||
|
|
||||||
[Window][Engine Settings]
|
[Window][Engine Settings]
|
||||||
Pos=561,352
|
Pos=106,213
|
||||||
Size=168,77
|
Size=168,77
|
||||||
|
|
||||||
|
@ -225,3 +225,72 @@ int Object::GetId() const
|
|||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Object::IsPhysicsEnabled() const
|
||||||
|
{
|
||||||
|
return m_isPhysicsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::SetPhysicsEnabled(bool state)
|
||||||
|
{
|
||||||
|
m_isPhysicsEnabled = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::SetCelShading(bool state)
|
||||||
|
{
|
||||||
|
isCelShading = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Object::GetCelShading() const
|
||||||
|
{
|
||||||
|
return isCelShading;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::SetLightingEnabled(bool state)
|
||||||
|
{
|
||||||
|
isLightingEnabled = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Object::GetLightingEnabled() const
|
||||||
|
{
|
||||||
|
return isLightingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::SetNormalMappingEnabled(bool state)
|
||||||
|
{
|
||||||
|
isNormalMappingEnabled = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Object::GetNormalMappingEnabled() const
|
||||||
|
{
|
||||||
|
return isNormalMappingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::SetSpecularMappingEnabled(bool state)
|
||||||
|
{
|
||||||
|
isSpecularMappingEnabled = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Object::GetSpecularMappingEnabled() const
|
||||||
|
{
|
||||||
|
return isSpecularMappingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::SetReflectionEnabled(bool state)
|
||||||
|
{
|
||||||
|
isReflectionEnabled = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Object::GetReflectionEnabled() const
|
||||||
|
{
|
||||||
|
return isReflectionEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::SetRefractionEnabled(bool state)
|
||||||
|
{
|
||||||
|
isRefractionEnabled = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Object::GetRefractionEnabled() const
|
||||||
|
{
|
||||||
|
return isRefractionEnabled;
|
||||||
|
}
|
@ -38,6 +38,9 @@ public:
|
|||||||
float GetMass() const;
|
float GetMass() const;
|
||||||
void SetGrounded(bool);
|
void SetGrounded(bool);
|
||||||
bool IsGrounded() const;
|
bool IsGrounded() const;
|
||||||
|
bool IsPhysicsEnabled() const;
|
||||||
|
void SetPhysicsEnabled(bool state);
|
||||||
|
|
||||||
|
|
||||||
void UpdateWorldMatrix();
|
void UpdateWorldMatrix();
|
||||||
void UpdateSRMatrix();
|
void UpdateSRMatrix();
|
||||||
@ -54,6 +57,20 @@ public:
|
|||||||
|
|
||||||
bool LoadTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, const std::wstring& filename);
|
bool LoadTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, const std::wstring& filename);
|
||||||
|
|
||||||
|
// Setters and getters for the shader to use
|
||||||
|
void SetCelShading(bool state);
|
||||||
|
bool GetCelShading() const;
|
||||||
|
void SetLightingEnabled(bool state);
|
||||||
|
bool GetLightingEnabled() const;
|
||||||
|
void SetNormalMappingEnabled(bool state);
|
||||||
|
bool GetNormalMappingEnabled() const;
|
||||||
|
void SetSpecularMappingEnabled(bool state);
|
||||||
|
bool GetSpecularMappingEnabled() const;
|
||||||
|
void SetReflectionEnabled(bool state);
|
||||||
|
bool GetReflectionEnabled() const;
|
||||||
|
void SetRefractionEnabled(bool state);
|
||||||
|
bool GetRefractionEnabled() const;
|
||||||
|
|
||||||
public :
|
public :
|
||||||
bool m_demoSpinning = false;
|
bool m_demoSpinning = false;
|
||||||
XMVECTOR m_previousPosition;
|
XMVECTOR m_previousPosition;
|
||||||
@ -70,6 +87,15 @@ private:
|
|||||||
XMVECTOR m_acceleration;
|
XMVECTOR m_acceleration;
|
||||||
float m_mass;
|
float m_mass;
|
||||||
bool m_isGrounded;
|
bool m_isGrounded;
|
||||||
|
bool m_isPhysicsEnabled;
|
||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
|
|
||||||
|
// Shader to use for rendering
|
||||||
|
bool isCelShading = false;
|
||||||
|
bool isLightingEnabled = true;
|
||||||
|
bool isNormalMappingEnabled = false;
|
||||||
|
bool isSpecularMappingEnabled = false;
|
||||||
|
bool isReflectionEnabled = false;
|
||||||
|
bool isRefractionEnabled = false;
|
||||||
};
|
};
|
||||||
|
@ -28,7 +28,7 @@ void Physics::SetGravity(XMVECTOR gravity)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply gravity to an object
|
// Apply gravity to an object
|
||||||
void Physics::ApplyGravity(Object* object, float dragValue, float frameTime)
|
void Physics::ApplyGravity(Object* object, float dragValue)
|
||||||
{
|
{
|
||||||
if (object == nullptr) // Verify if the object is not null
|
if (object == nullptr) // Verify if the object is not null
|
||||||
{
|
{
|
||||||
@ -53,7 +53,7 @@ void Physics::ApplyGravity(Object* object, float dragValue, float frameTime)
|
|||||||
XMVECTOR velocity = object->GetVelocity();
|
XMVECTOR velocity = object->GetVelocity();
|
||||||
|
|
||||||
// Update the velocity with the object's acceleration
|
// Update the velocity with the object's acceleration
|
||||||
velocity += object->GetAcceleration() * frameTime;
|
velocity += object->GetAcceleration();
|
||||||
|
|
||||||
// Set the new velocity
|
// Set the new velocity
|
||||||
object->SetVelocity(velocity);
|
object->SetVelocity(velocity);
|
||||||
@ -174,5 +174,4 @@ bool Physics::SphereCubeOverlap(Object* cube, Object* sphere)
|
|||||||
float radius = XMVectorGetX(XMVector3Length(scale2));
|
float radius = XMVectorGetX(XMVector3Length(scale2));
|
||||||
|
|
||||||
return distance < radius;
|
return distance < radius;
|
||||||
}
|
}
|
||||||
|
|
@ -13,7 +13,7 @@ public:
|
|||||||
|
|
||||||
XMVECTOR GetGravity() const; // Get the gravity value
|
XMVECTOR GetGravity() const; // Get the gravity value
|
||||||
void SetGravity(XMVECTOR gravity); // Define the gravity value
|
void SetGravity(XMVECTOR gravity); // Define the gravity value
|
||||||
void ApplyGravity(Object*, float, float); // Apply gravity to an object
|
void ApplyGravity(Object*, float); // Apply gravity to an object
|
||||||
void AddForce(Object*, XMVECTOR);
|
void AddForce(Object*, XMVECTOR);
|
||||||
bool IsColliding(Object*, Object*);
|
bool IsColliding(Object*, Object*);
|
||||||
bool CubesOverlap(Object*, Object*);
|
bool CubesOverlap(Object*, Object*);
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "imguiManager.h"
|
#include "imguiManager.h"
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
class SystemClass
|
class SystemClass
|
||||||
{
|
{
|
||||||
@ -21,6 +22,7 @@ public:
|
|||||||
bool Initialize();
|
bool Initialize();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
void Run();
|
void Run();
|
||||||
|
void FixedUpdate();
|
||||||
|
|
||||||
LRESULT CALLBACK MessageHandler(HWND, UINT, WPARAM, LPARAM);
|
LRESULT CALLBACK MessageHandler(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user