Minor Update - Fix Warning + Add texture in the object inspector
Feat : + Show the texture of the object in the Object Window Fix : - No warning for now...
This commit is contained in:
parent
01acf46db8
commit
ca82f37127
@ -108,7 +108,7 @@ void PositionClass::TurnRight(bool keydown)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PositionClass::TurnMouse(float deltaX, float deltaY, bool rightMouseDown)
|
void PositionClass::TurnMouse(int deltaX, int deltaY, bool rightMouseDown)
|
||||||
{
|
{
|
||||||
float speed = 0.1f;
|
float speed = 0.1f;
|
||||||
// The turning speed is proportional to the horizontal mouse movement
|
// The turning speed is proportional to the horizontal mouse movement
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
|
|
||||||
void TurnLeft(bool);
|
void TurnLeft(bool);
|
||||||
void TurnRight(bool);
|
void TurnRight(bool);
|
||||||
void TurnMouse(float, float, bool);
|
void TurnMouse(int, int, bool);
|
||||||
void MoveCamera(bool, bool, bool, bool, bool, bool);
|
void MoveCamera(bool, bool, bool, bool, bool, bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -176,82 +176,85 @@ LRESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam
|
|||||||
switch (umsg)
|
switch (umsg)
|
||||||
{
|
{
|
||||||
// Check if a key has been pressed on the keyboard.
|
// Check if a key has been pressed on the keyboard.
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
{
|
|
||||||
// If a key is pressed send it to the input object so it can record that state.
|
|
||||||
m_Input->KeyDown((unsigned int)wparam);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if a key has been released on the keyboard.
|
|
||||||
case WM_KEYUP:
|
|
||||||
{
|
|
||||||
// If a key is released then send it to the input object so it can unset the state for that key.
|
|
||||||
m_Input->KeyUp((unsigned int)wparam);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
case WM_SIZE:
|
|
||||||
{
|
|
||||||
int newWidth = LOWORD(lparam);
|
|
||||||
int newHeight = HIWORD(lparam);
|
|
||||||
|
|
||||||
// If Direct3D is initialized, update the swap chain. Otherwise, store the window dimensions
|
|
||||||
if (m_isDirect3DInitialized && m_Application && m_Application->GetDirect3D())
|
|
||||||
{
|
{
|
||||||
m_Application->GetDirect3D()->ResizeSwapChain(newWidth, newHeight);
|
// If a key is pressed send it to the input object so it can record that state.
|
||||||
|
m_Input->KeyDown((unsigned int)wparam);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Check if a key has been released on the keyboard.
|
||||||
|
case WM_KEYUP:
|
||||||
{
|
{
|
||||||
m_initialWindowWidth = newWidth;
|
// If a key is released then send it to the input object so it can unset the state for that key.
|
||||||
m_initialWindowHeight = newHeight;
|
m_Input->KeyUp((unsigned int)wparam);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
case WM_SIZE:
|
||||||
case WM_ENTERSIZEMOVE:
|
{
|
||||||
{
|
int newWidth = LOWORD(lparam);
|
||||||
m_isResizing = true;
|
int newHeight = HIWORD(lparam);
|
||||||
break;
|
|
||||||
}
|
|
||||||
case WM_EXITSIZEMOVE:
|
|
||||||
{
|
|
||||||
m_isResizing = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case WM_DROPFILES:
|
|
||||||
{
|
|
||||||
HDROP hDrop = reinterpret_cast<HDROP>(wparam);
|
|
||||||
UINT numFiles = DragQueryFile(hDrop, 0xFFFFFFFF, nullptr, 0);
|
|
||||||
|
|
||||||
if (numFiles > 0) {
|
// If Direct3D is initialized, update the swap chain. Otherwise, store the window dimensions
|
||||||
for (UINT i = 0; i < numFiles; ++i) {
|
if (m_isDirect3DInitialized && m_Application && m_Application->GetDirect3D())
|
||||||
WCHAR filePath[MAX_PATH];
|
{
|
||||||
DragQueryFile(hDrop, i, filePath, MAX_PATH);
|
m_Application->GetDirect3D()->ResizeSwapChain(newWidth, newHeight);
|
||||||
|
}
|
||||||
// Get the file extension
|
else
|
||||||
std::wstring fileName = filePath;
|
{
|
||||||
std::wstring extension = fileName.substr(fileName.find_last_of(L".") + 1);
|
m_initialWindowWidth = newWidth;
|
||||||
|
m_initialWindowHeight = newHeight;
|
||||||
// Check if the file has a valid extension
|
|
||||||
if (extension == L"txt" || extension == L"kobj") {
|
|
||||||
// Handle dropped files with valid extensions
|
|
||||||
std::wcout << L"File dropped: " << filePath << std::endl;
|
|
||||||
m_Application->AddKobject(filePath);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Handle files with invalid extensions (optional)
|
|
||||||
std::wcout << L"Ignored file: " << filePath << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case WM_ENTERSIZEMOVE:
|
||||||
|
{
|
||||||
|
m_isResizing = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WM_EXITSIZEMOVE:
|
||||||
|
{
|
||||||
|
m_isResizing = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WM_DROPFILES:
|
||||||
|
{
|
||||||
|
HDROP hDrop = reinterpret_cast<HDROP>(wparam);
|
||||||
|
UINT numFiles = DragQueryFile(hDrop, 0xFFFFFFFF, nullptr, 0);
|
||||||
|
|
||||||
|
if (numFiles > 0) {
|
||||||
|
for (UINT i = 0; i < numFiles; ++i) {
|
||||||
|
WCHAR filePath[MAX_PATH];
|
||||||
|
DragQueryFile(hDrop, i, filePath, MAX_PATH);
|
||||||
|
|
||||||
|
// Get the file extension
|
||||||
|
std::wstring fileName = filePath;
|
||||||
|
std::wstring extension = fileName.substr(fileName.find_last_of(L".") + 1);
|
||||||
|
|
||||||
|
// Check if the file has a valid extension
|
||||||
|
if (extension == L"txt" || extension == L"kobj") {
|
||||||
|
// Handle dropped files with valid extensions
|
||||||
|
std::wcout << L"File dropped: " << filePath << std::endl;
|
||||||
|
m_Application->AddKobject(filePath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Handle files with invalid extensions (optional)
|
||||||
|
std::wcout << L"Ignored file: " << filePath << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DragFinish(hDrop);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Any other messages send to the default message handler as our application won't make use of them.
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return DefWindowProc(hwnd, umsg, wparam, lparam);
|
||||||
|
}
|
||||||
|
|
||||||
DragFinish(hDrop);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// Any other messages send to the default message handler as our application won't make use of them.
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
return DefWindowProc(hwnd, umsg, wparam, lparam);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemClass::InitializeWindows(int& screenWidth, int& screenHeight)
|
void SystemClass::InitializeWindows(int& screenWidth, int& screenHeight)
|
||||||
|
@ -43,7 +43,6 @@ ApplicationClass::~ApplicationClass()
|
|||||||
bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
|
bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
|
||||||
{
|
{
|
||||||
char mouseString1[32], mouseString2[32], mouseString3[32];
|
char mouseString1[32], mouseString2[32], mouseString3[32];
|
||||||
char testString1[32], testString2[32], testString3[32];
|
|
||||||
char modelFilename[128], textureFilename1[128], textureFilename2[128], textureFilename3[128], renderString[32];
|
char modelFilename[128], textureFilename1[128], textureFilename2[128], textureFilename3[128], renderString[32];
|
||||||
char bitmapFilename[128];
|
char bitmapFilename[128];
|
||||||
char spriteFilename[128];
|
char spriteFilename[128];
|
||||||
@ -598,12 +597,12 @@ bool ApplicationClass::Frame(InputClass* Input)
|
|||||||
|
|
||||||
currentMouseX = mouseX;
|
currentMouseX = mouseX;
|
||||||
|
|
||||||
float deltaX = currentMouseX - lastMouseX; // Calculez le d<>placement de la souris
|
int deltaX = currentMouseX - lastMouseX; // Calculez le d<>placement de la souris
|
||||||
lastMouseX = currentMouseX; // Mettez <20> jour la derni<6E>re position de la souris pour la prochaine image
|
lastMouseX = currentMouseX; // Mettez <20> jour la derni<6E>re position de la souris pour la prochaine image
|
||||||
|
|
||||||
currentMouseY = mouseY;
|
currentMouseY = mouseY;
|
||||||
|
|
||||||
float deltaY = currentMouseY - lastMouseY; // Calculez le d<>placement de la souris
|
int deltaY = currentMouseY - lastMouseY; // Calculez le d<>placement de la souris
|
||||||
lastMouseY = currentMouseY; // Mettez <20> jour la derni<6E>re position de la souris pour la prochaine image
|
lastMouseY = currentMouseY; // Mettez <20> jour la derni<6E>re position de la souris pour la prochaine image
|
||||||
|
|
||||||
// Set the frame time for calculating the updated position.
|
// Set the frame time for calculating the updated position.
|
||||||
@ -1080,7 +1079,7 @@ void ApplicationClass::GenerateTerrain()
|
|||||||
char textureFilename3[128];
|
char textureFilename3[128];
|
||||||
|
|
||||||
XMMATRIX scaleMatrix;
|
XMMATRIX scaleMatrix;
|
||||||
int scaleX, scaleY, scaleZ;
|
float scaleX, scaleY, scaleZ;
|
||||||
|
|
||||||
scaleX = 10.0f;
|
scaleX = 10.0f;
|
||||||
scaleY = 1.0f;
|
scaleY = 1.0f;
|
||||||
@ -1231,6 +1230,13 @@ bool ApplicationClass::UpdateMouseStrings(int mouseX, int mouseY, bool mouseDown
|
|||||||
|
|
||||||
// Update the sentence vertex buffer with the new string information.
|
// Update the sentence vertex buffer with the new string information.
|
||||||
result = m_MouseStrings[2].UpdateText(m_Direct3D->GetDeviceContext(), m_Font, finalString, 10, 100, 1.0f, 1.0f, 1.0f);
|
result = m_MouseStrings[2].UpdateText(m_Direct3D->GetDeviceContext(), m_Font, finalString, 10, 100, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ApplicationClass::UpdateFps()
|
bool ApplicationClass::UpdateFps()
|
||||||
|
@ -68,8 +68,8 @@ public:
|
|||||||
|
|
||||||
void AddCube();
|
void AddCube();
|
||||||
void DeleteKobject(int index);
|
void DeleteKobject(int index);
|
||||||
int GetCubeCount() const { return m_cubes.size(); };
|
size_t GetCubeCount() const { return m_cubes.size(); };
|
||||||
int GetTerrainCubeCount() const { return m_terrainChunk.size(); };
|
size_t GetTerrainCubeCount() const { return m_terrainChunk.size(); };
|
||||||
std::vector<Object*> GetCubes() const { return m_cubes; };
|
std::vector<Object*> GetCubes() const { return m_cubes; };
|
||||||
std::vector<Object*> GetTerrainCubes() const { return m_terrainChunk; };
|
std::vector<Object*> GetTerrainCubes() const { return m_terrainChunk; };
|
||||||
std::vector<Object*> GetKobjects() const { return m_object; };
|
std::vector<Object*> GetKobjects() const { return m_object; };
|
||||||
@ -113,7 +113,7 @@ private :
|
|||||||
XMMATRIX m_baseViewMatrix;
|
XMMATRIX m_baseViewMatrix;
|
||||||
RenderTextureClass* m_RenderTexture;
|
RenderTextureClass* m_RenderTexture;
|
||||||
DisplayPlaneClass* m_DisplayPlane;
|
DisplayPlaneClass* m_DisplayPlane;
|
||||||
float m_screenWidth, m_screenHeight;
|
int m_screenWidth, m_screenHeight;
|
||||||
CameraClass* m_Camera;
|
CameraClass* m_Camera;
|
||||||
PositionClass* m_Position;
|
PositionClass* m_Position;
|
||||||
FrustumClass* m_Frustum;
|
FrustumClass* m_Frustum;
|
||||||
|
@ -7,7 +7,7 @@ Pos=260,25
|
|||||||
Size=694,210
|
Size=694,210
|
||||||
|
|
||||||
[Window][Objects]
|
[Window][Objects]
|
||||||
Pos=1348,34
|
Pos=994,39
|
||||||
Size=492,353
|
Size=492,353
|
||||||
|
|
||||||
[Window][Terrain]
|
[Window][Terrain]
|
||||||
|
@ -106,6 +106,7 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
|||||||
{
|
{
|
||||||
ImGui::Begin("Objects", &showObjectWindow);
|
ImGui::Begin("Objects", &showObjectWindow);
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
int count = 0;
|
||||||
for (auto& object : app->GetKobjects())
|
for (auto& object : app->GetKobjects())
|
||||||
{
|
{
|
||||||
std::string headerName = object->GetName() + " " + std::to_string(index);
|
std::string headerName = object->GetName() + " " + std::to_string(index);
|
||||||
@ -139,6 +140,21 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
|||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
// Texture
|
||||||
|
std::string textureLabel = "Texture##" + std::to_string(index);
|
||||||
|
ID3D11ShaderResourceView* texture = object->GetTexture(0);
|
||||||
|
if (texture != nullptr)
|
||||||
|
{
|
||||||
|
if (ImGui::ImageButton((ImTextureID)texture, ImVec2(64, 64)))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::Text("Texture count: %d", count);
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
// Delete button
|
// Delete button
|
||||||
std::string deleteLabel = "Delete##" + std::to_string(index);
|
std::string deleteLabel = "Delete##" + std::to_string(index);
|
||||||
if (ImGui::Button(deleteLabel.c_str()))
|
if (ImGui::Button(deleteLabel.c_str()))
|
||||||
|
@ -20,7 +20,6 @@ TextureClass::~TextureClass()
|
|||||||
bool TextureClass::Initialize(ID3D11Device * device, ID3D11DeviceContext * deviceContext, char* filename)
|
bool TextureClass::Initialize(ID3D11Device * device, ID3D11DeviceContext * deviceContext, char* filename)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
int height, width;
|
|
||||||
D3D11_TEXTURE2D_DESC textureDesc;
|
D3D11_TEXTURE2D_DESC textureDesc;
|
||||||
HRESULT hResult;
|
HRESULT hResult;
|
||||||
unsigned int rowPitch;
|
unsigned int rowPitch;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user