Merge branch 'main' into ImGui-V2
This commit is contained in:
commit
f59f371c0c
24
README.md
24
README.md
@ -1,11 +1,29 @@
|
|||||||
[](https://classroom.github.com/a/Ki-dD_5X)
|
|
||||||
|
|
||||||
# Khaotic Engine
|
# Khaotic Engine - C++ Custom Engine
|
||||||
|
|
||||||
|
Khaotic Engine est un moteur de rendu fait en c++ réalisé par une petite équipe dans le but d'apprendre a utilisé les API de rendu (OpenGL,DirectX 11/12 et Vulkan).
|
||||||
|
|
||||||
|
Ce moteur est basé sur DirectX11 utilise ImGui avec une couche d'abstraction pour permetre son usage avec d'autre API.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Khaotic Engine is a rendering engine made in C++ by a small team with the aim of learning how to use rendering APIs (OpenGL, DirectX 11/12 and Vulkan).
|
||||||
|
|
||||||
|
This DirectX11-based engine uses ImGui with an abstraction layer to enable its use with other APIs.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Demo
|
||||||
|
|
||||||
|
Insert gif or link to demo
|
||||||
|
|
||||||
A custom engine build with chaos and DirectX11 in less than 5 weeks in C++.
|
|
||||||
|
|
||||||
## Engine Build by :
|
## Engine Build by :
|
||||||
|
|
||||||
- [@CatChow0](https://github.com/CatChow0)
|
- [@CatChow0](https://github.com/CatChow0)
|
||||||
- [@miragefr0st](https://github.com/miragefr0st)
|
- [@miragefr0st](https://github.com/miragefr0st)
|
||||||
- [@StratiX0](https://github.com/StratiX0)
|
- [@StratiX0](https://github.com/StratiX0)
|
||||||
- [@Kagutsuchi84](https://github.com/Mattys8423)
|
- [@Kagutsuchi84](https://github.com/Mattys8423)
|
||||||
|
- [@Harpie94](https://github.com/Harpie94)
|
||||||
|
- [@axelpicou](https://github.com/axelpicou)
|
||||||
|
- [@GolfOcean334](https://github.com/GolfOcean334)
|
||||||
|
@ -741,6 +741,103 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z)
|
|||||||
m_Direct3D->GetProjectionMatrix(projectionMatrix);
|
m_Direct3D->GetProjectionMatrix(projectionMatrix);
|
||||||
m_Direct3D->GetOrthoMatrix(orthoMatrix);
|
m_Direct3D->GetOrthoMatrix(orthoMatrix);
|
||||||
|
|
||||||
|
// Get the light properties.
|
||||||
|
for (i = 0; i < m_numLights; i++)
|
||||||
|
{
|
||||||
|
// Create the diffuse color array from the four light colors.
|
||||||
|
diffuseColor[i] = m_Lights[i]->GetDiffuseColor();
|
||||||
|
|
||||||
|
// Create the light position array from the four light positions.
|
||||||
|
lightPosition[i] = m_Lights[i]->GetPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
scaleMatrix = XMMatrixScaling(0.5f, 0.5f, 0.5f); // Build the scaling matrix.
|
||||||
|
rotateMatrix = XMMatrixRotationY(rotation); // Build the rotation matrix.
|
||||||
|
translateMatrix = XMMatrixTranslation(x, y, z); // Build the translation matrix.
|
||||||
|
|
||||||
|
// Multiply the scale, rotation, and translation matrices together to create the final world transformation matrix.
|
||||||
|
srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix);
|
||||||
|
worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix);
|
||||||
|
|
||||||
|
// Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing.
|
||||||
|
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||||
|
|
||||||
|
// Render the model using the light shader.
|
||||||
|
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0),
|
||||||
|
diffuseColor, lightPosition);
|
||||||
|
|
||||||
|
for (auto cube : m_cubes)
|
||||||
|
{
|
||||||
|
|
||||||
|
scaleMatrix = cube->GetScaleMatrix();
|
||||||
|
|
||||||
|
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());
|
||||||
|
|
||||||
|
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0),
|
||||||
|
diffuseColor, lightPosition);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
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());
|
||||||
|
|
||||||
|
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0),
|
||||||
|
diffuseColor, lightPosition);
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
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());
|
||||||
|
|
||||||
|
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), chunk->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, chunk->GetTexture(1),
|
||||||
|
diffuseColor, lightPosition);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Setup matrices - Top display plane.
|
// Setup matrices - Top display plane.
|
||||||
worldMatrix = XMMatrixTranslation(0.0f, 1.5f, 0.0f);
|
worldMatrix = XMMatrixTranslation(0.0f, 1.5f, 0.0f);
|
||||||
|
|
||||||
@ -777,16 +874,6 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the light properties.
|
|
||||||
for (i = 0; i < m_numLights; i++)
|
|
||||||
{
|
|
||||||
// Create the diffuse color array from the four light colors.
|
|
||||||
diffuseColor[i] = m_Lights[i]->GetDiffuseColor();
|
|
||||||
|
|
||||||
// Create the light position array from the four light positions.
|
|
||||||
lightPosition[i] = m_Lights[i]->GetPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Construct the frustum.
|
// Construct the frustum.
|
||||||
m_Frustum->ConstructFrustum(viewMatrix, projectionMatrix, SCREEN_DEPTH);
|
m_Frustum->ConstructFrustum(viewMatrix, projectionMatrix, SCREEN_DEPTH);
|
||||||
|
|
||||||
@ -919,92 +1006,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z)
|
|||||||
lightPosition[i] = m_Lights[i]->GetPosition();
|
lightPosition[i] = m_Lights[i]->GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
scaleMatrix = XMMatrixScaling(0.5f, 0.5f, 0.5f); // Build the scaling matrix.
|
|
||||||
rotateMatrix = XMMatrixRotationY(rotation); // Build the rotation matrix.
|
|
||||||
translateMatrix = XMMatrixTranslation(x, y, z); // Build the translation matrix.
|
|
||||||
|
|
||||||
// Multiply the scale, rotation, and translation matrices together to create the final world transformation matrix.
|
|
||||||
srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix);
|
|
||||||
worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix);
|
|
||||||
|
|
||||||
// Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing.
|
|
||||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
|
||||||
|
|
||||||
// Render the model using the light shader.
|
|
||||||
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0),
|
|
||||||
diffuseColor, lightPosition);
|
|
||||||
|
|
||||||
for (auto cube : m_cubes)
|
|
||||||
{
|
|
||||||
|
|
||||||
scaleMatrix = cube->GetScaleMatrix();
|
|
||||||
|
|
||||||
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());
|
|
||||||
|
|
||||||
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0),
|
|
||||||
diffuseColor, lightPosition);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
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());
|
|
||||||
|
|
||||||
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0),
|
|
||||||
diffuseColor, lightPosition);
|
|
||||||
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
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());
|
|
||||||
|
|
||||||
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0),
|
|
||||||
diffuseColor, lightPosition);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render the model using the multitexture shader.
|
// Render the model using the multitexture shader.
|
||||||
//result = m_MultiTextureShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
|
//result = m_MultiTextureShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
|
||||||
@ -1076,6 +1078,16 @@ void ApplicationClass::GenerateTerrain()
|
|||||||
char textureFilename[128];
|
char textureFilename[128];
|
||||||
char textureFilename2[128];
|
char textureFilename2[128];
|
||||||
char textureFilename3[128];
|
char textureFilename3[128];
|
||||||
|
|
||||||
|
XMMATRIX scaleMatrix;
|
||||||
|
int scaleX, scaleY, scaleZ;
|
||||||
|
|
||||||
|
scaleX = 10.0f;
|
||||||
|
scaleY = 1.0f;
|
||||||
|
scaleZ = 10.0f;
|
||||||
|
|
||||||
|
scaleMatrix = XMMatrixScaling(scaleX, scaleY, scaleZ);
|
||||||
|
|
||||||
// Set the file name of the model.
|
// Set the file name of the model.
|
||||||
strcpy_s(modelFilename, "plane.txt");
|
strcpy_s(modelFilename, "plane.txt");
|
||||||
strcpy_s(textureFilename, "stone01.tga");
|
strcpy_s(textureFilename, "stone01.tga");
|
||||||
@ -1083,14 +1095,16 @@ void ApplicationClass::GenerateTerrain()
|
|||||||
strcpy_s(textureFilename3, "alpha01.tga");
|
strcpy_s(textureFilename3, "alpha01.tga");
|
||||||
|
|
||||||
// for loop to generate terrain chunks for a 10x10 grid
|
// for loop to generate terrain chunks for a 10x10 grid
|
||||||
for (int i = -5; i < 5; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
for (int j = -5; j < 5; j++)
|
for (int j = 0; j < 10; j++)
|
||||||
{
|
{
|
||||||
Object* newTerrain = new Object();
|
Object* newTerrain = new Object();
|
||||||
newTerrain->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textureFilename, textureFilename2, textureFilename3);
|
newTerrain->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textureFilename, textureFilename2, textureFilename3);
|
||||||
|
|
||||||
newTerrain->SetTranslateMatrix(XMMatrixTranslation(i*10, -5.0f, j*10));
|
newTerrain->SetScaleMatrix(scaleMatrix);
|
||||||
|
|
||||||
|
newTerrain->SetTranslateMatrix(XMMatrixTranslation(i / 2 * (scaleX * 2), -5.0f, j * (scaleZ * 2)));
|
||||||
|
|
||||||
m_terrainChunk.push_back(newTerrain);
|
m_terrainChunk.push_back(newTerrain);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user