mirror of
https://github.com/theclub654/ProjectCane.git
synced 2024-11-23 06:19:53 +00:00
can now render collision
This commit is contained in:
parent
06d16f8669
commit
143ee75332
@ -415,6 +415,8 @@
|
||||
<ItemGroup>
|
||||
<None Include="..\.gitignore" />
|
||||
<None Include="..\README.md" />
|
||||
<None Include="collision.frag" />
|
||||
<None Include="collision.vert" />
|
||||
<None Include="glob.frag" />
|
||||
<None Include="glob.vert" />
|
||||
</ItemGroup>
|
||||
|
@ -841,6 +841,12 @@
|
||||
<None Include="glob.vert">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="collision.frag">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="collision.vert">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Sly1.rc">
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "alo.h"
|
||||
std::vector <GEOM> allcollisionModels;
|
||||
|
||||
void* NewAlo()
|
||||
{
|
||||
@ -275,6 +276,12 @@ void DeleteModel(ALO *palo)
|
||||
glDeleteTextures(1, &palo->globset.aglob[i].asubglob[a].gl_texture);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < allcollisionModels.size(); i++)
|
||||
{
|
||||
glDeleteVertexArrays(1, &allcollisionModels[i].VAO);
|
||||
glDeleteBuffers(1, &allcollisionModels[i].VBO);
|
||||
}
|
||||
}
|
||||
|
||||
void DeleteAlo(LO* palo)
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "bis.h"
|
||||
|
||||
std::vector <GEOM*> allcollisionModels;
|
||||
|
||||
CBinaryInputStream::CBinaryInputStream(std::string filePath)
|
||||
{
|
||||
file.open(filePath, std::ios::binary);
|
||||
@ -129,6 +131,12 @@ void CBinaryInputStream::ReadGeom(GEOM *pgeom)
|
||||
U16Read();
|
||||
}
|
||||
}
|
||||
|
||||
if (pgeom->cpos != 0)
|
||||
{
|
||||
allcollisionModels.push_back(pgeom);
|
||||
MakeCollisionGLBuffers(pgeom);
|
||||
}
|
||||
}
|
||||
|
||||
void CBinaryInputStream::ReadBspc()
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
void MakeCollisionGLBuffers(GEOM* pgeom);
|
||||
|
||||
class CBinaryInputStream
|
||||
{
|
||||
public:
|
||||
|
8
Sly1/collision.frag
Normal file
8
Sly1/collision.frag
Normal file
@ -0,0 +1,8 @@
|
||||
#version 330 core
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = vec4(0.76, 0.76, 0.76, 1.0);
|
||||
}
|
12
Sly1/collision.vert
Normal file
12
Sly1/collision.vert
Normal file
@ -0,0 +1,12 @@
|
||||
#version 330 core
|
||||
|
||||
layout (location = 0) in vec3 pos;
|
||||
|
||||
uniform mat4 proj;
|
||||
uniform mat4 view;
|
||||
uniform mat4 model;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = proj * view * model * vec4(pos.y, pos.x, pos.z, 1.0);
|
||||
}
|
@ -1,39 +1,48 @@
|
||||
#include "debug.h"
|
||||
|
||||
void RenderOpenFileGui()
|
||||
void RenderMenuGui(SW* psw)
|
||||
{
|
||||
ImGui::Begin("ProjectCane");
|
||||
|
||||
// open Dialog Simple
|
||||
ImGuiFileDialog instance_a;
|
||||
|
||||
if (ImGui::Button("Open World"))
|
||||
instance_a.Instance()->OpenDialog("ChooseFileDlgKey", "Choose File", ".brx", ".");
|
||||
|
||||
// display
|
||||
if (instance_a.Instance()->Display("ChooseFileDlgKey"))
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
{
|
||||
// action if OK
|
||||
if (instance_a.Instance()->IsOk())
|
||||
if (ImGui::BeginMenu("File"))
|
||||
{
|
||||
file = ImGuiFileDialog::Instance()->GetFilePathName();
|
||||
std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath();
|
||||
/*std::cout << file << "\n";
|
||||
std::cout << filePath << "\n";*/
|
||||
g_transition.m_fPending = 1;
|
||||
// action
|
||||
if (ImGui::MenuItem("Open World"))
|
||||
instance_a.Instance()->OpenDialog("ChooseFileDlgKey", "Choose File", ".brx", ".");
|
||||
|
||||
if (ImGui::MenuItem("Close World"))
|
||||
DeleteSw(psw);
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
// close
|
||||
instance_a.Instance()->Close();
|
||||
}
|
||||
}
|
||||
if (ImGui::BeginMenu("Render"))
|
||||
{
|
||||
if (fRenderModels == ImGui::MenuItem("Map", "", &fRenderModels))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RenderCloseWorldGui(SW* psw)
|
||||
{
|
||||
if (ImGui::Button("Close World"))
|
||||
{
|
||||
glFlush;
|
||||
DeleteSw(psw);
|
||||
if (fRenderCollision == ImGui::MenuItem("Collision", "", &fRenderCollision))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (instance_a.Instance()->Display("ChooseFileDlgKey"))
|
||||
{
|
||||
if (instance_a.Instance()->IsOk() == true)
|
||||
{
|
||||
file = ImGuiFileDialog::Instance()->GetFilePathName();
|
||||
std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath();
|
||||
g_transition.m_fPending = 1;
|
||||
}
|
||||
|
||||
instance_a.Instance()->Close();
|
||||
}
|
||||
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
}
|
||||
}
|
@ -8,5 +8,8 @@
|
||||
extern std::string file;
|
||||
void DeleteWorld(SW* psw);
|
||||
|
||||
void RenderOpenFileGui();
|
||||
void RenderCloseWorldGui(SW* psw);
|
||||
static ImGuiFileDialog instance_a;
|
||||
extern inline bool fRenderModels = true;
|
||||
extern inline bool fRenderCollision = false;
|
||||
|
||||
void RenderMenuGui(SW* psw);
|
@ -71,7 +71,7 @@ void FREECAMERA::UpdateCameraFov(double dy)
|
||||
fov = 45.0f;
|
||||
}
|
||||
|
||||
void FREECAMERA::UpdateViewProjMatrix(int height, int width)
|
||||
void FREECAMERA::UpdateViewProjMatrix(int height, int width, GLSHADER shader)
|
||||
{
|
||||
glm::mat4 proj{ 1.0 };
|
||||
glm::mat4 view{ 1.0 };
|
||||
@ -81,7 +81,12 @@ void FREECAMERA::UpdateViewProjMatrix(int height, int width)
|
||||
// Transform coordinates from world space to camera space
|
||||
view = glm::lookAt(cameraPos, cameraPos + cameraDirection, cameraUp);
|
||||
|
||||
glShader.Use();
|
||||
SendViewProjShader(proj, view, shader);
|
||||
}
|
||||
|
||||
void FREECAMERA::SendViewProjShader(glm::mat4 proj, glm::mat4 view, GLSHADER shader)
|
||||
{
|
||||
shader.Use();
|
||||
|
||||
// Sends view matrix to GPU shader
|
||||
int viewUniformLocation = glGetUniformLocation(glShader.ID, "view");
|
||||
|
@ -38,7 +38,8 @@ public:
|
||||
void UpdateCameraDirection(double dx, double dy);
|
||||
void UpdateCameraPos(CAMERADIRECTION direction, double dt);
|
||||
void UpdateCameraFov(double dy);
|
||||
void UpdateViewProjMatrix(int height, int width);
|
||||
void UpdateViewProjMatrix(int height, int width, GLSHADER shader);
|
||||
void SendViewProjShader(glm::mat4 proj, glm::mat4 view, GLSHADER shader);
|
||||
void UpdateCameraVectors();
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
#include "vec.h"
|
||||
#include <glad/glad.h>
|
||||
|
||||
// Collision related
|
||||
|
||||
struct EDGE
|
||||
{
|
||||
@ -21,6 +24,10 @@ struct SURF
|
||||
|
||||
struct GEOM
|
||||
{
|
||||
GLuint VAO;
|
||||
GLuint VBO;
|
||||
GLuint VNO;
|
||||
|
||||
float sRadius;
|
||||
int cpos;
|
||||
std::vector <glm::vec3> apos;
|
||||
|
@ -188,6 +188,14 @@ void LoadGlobsetFromBrx(GLOBSET* pglobset, CBinaryInputStream* pbis, ALO* palo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pglobset->aglob[i].asubglob[a].pshd->shdk == 1)
|
||||
BuildSubGlobSinglePass(pglobset, pglobset->aglob[i].asubglob[a].pshd, pglobset->aglob[i].asubglob[a].vertexes, pglobset->aglob[i].asubglob[a].normals,
|
||||
pglobset->aglob[i].asubglob[a].vertexColors, pglobset->aglob[i].asubglob[a].texcoords, pglobset->aglob[i].asubglob[a].indexes);
|
||||
|
||||
else if (pglobset->aglob[i].asubglob[a].pshd->shdk == 0)
|
||||
BuildSubGlobThreeWay(pglobset, pglobset->aglob[i].asubglob[a].pshd, pglobset->aglob[i].asubglob[a].vertexes, pglobset->aglob[i].asubglob[a].normals,
|
||||
pglobset->aglob[i].asubglob[a].vertexColors, pglobset->aglob[i].asubglob[a].texcoords, pglobset->aglob[i].asubglob[a].indexes);
|
||||
}
|
||||
|
||||
uint16_t numSubMesh1 = pbis->U16Read();
|
||||
@ -242,6 +250,16 @@ void LoadGlobsetFromBrx(GLOBSET* pglobset, CBinaryInputStream* pbis, ALO* palo)
|
||||
}
|
||||
}
|
||||
|
||||
void BuildSubGlobSinglePass(GLOBSET* pglobset, SHD* pshd, std::vector<glm::vec3>& vertexes, std::vector<glm::vec3>& normals, std::vector<RGBA>& vertexColors, std::vector<glm::vec2>& texcoords, std::vector<VTXFLG>& indexes)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BuildSubGlobThreeWay(GLOBSET* pglobset, SHD* pshd, std::vector<glm::vec3>& vertexes, std::vector<glm::vec3>& normals, std::vector<RGBA>& vertexColors, std::vector<glm::vec2>& texcoords, std::vector<VTXFLG>& indexes)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ConvertStripsToTriLists(std::vector <VTXFLG> &indexes, std::vector <uint16_t> &indices)
|
||||
{
|
||||
uint32_t idx = 0;
|
||||
@ -315,8 +333,6 @@ void DrawGlob(GLOBSET *pglobset)
|
||||
{
|
||||
for (int a = 0; a < pglobset->aglob[i].csubglob; a++)
|
||||
{
|
||||
glShader.Use();
|
||||
|
||||
int modelUniformLocation = glGetUniformLocation(glShader.ID, "model");
|
||||
glUniformMatrix4fv(modelUniformLocation, 1, GL_FALSE, glm::value_ptr(pglobset->aglob[i].pdmat));
|
||||
|
||||
|
@ -114,6 +114,8 @@ struct GLOBSET // NOT DONE
|
||||
|
||||
// Loads 3D models from binary file
|
||||
void LoadGlobsetFromBrx(GLOBSET* pglobset, CBinaryInputStream* pbis, ALO* palo); // NOT FINISHED
|
||||
void BuildSubGlobSinglePass(GLOBSET *pglobset, SHD* pshd, std::vector <glm::vec3> &vertexes, std::vector <glm::vec3> &normals, std::vector <RGBA> &vertexColors, std::vector <glm::vec2> &texcoords, std::vector <VTXFLG> &indexes);
|
||||
void BuildSubGlobThreeWay(GLOBSET* pglobset, SHD* pshd, std::vector <glm::vec3> &vertexes, std::vector <glm::vec3> &normals, std::vector <RGBA> &vertexColors, std::vector <glm::vec2> &texcoords, std::vector <VTXFLG> &indexes);
|
||||
// Converts tri strips to tri list
|
||||
void ConvertStripsToTriLists(std::vector <VTXFLG>& indexes, std::vector <uint16_t>& indices);
|
||||
// Storing 3D models in VRAM
|
||||
|
@ -24,5 +24,5 @@ class GLSHADER
|
||||
|
||||
std::string get_file_contents(const char* filename);
|
||||
|
||||
// Global OPENGL shader used for rendering
|
||||
extern GLSHADER glShader;
|
||||
extern GLSHADER glShader;
|
||||
extern GLSHADER glShaderCollision;
|
293
Sly1/imgui.ini
293
Sly1/imgui.ini
@ -16,13 +16,42 @@ Pos=1,2
|
||||
Size=232,54
|
||||
|
||||
[Window][ProjectCane]
|
||||
Pos=-2,0
|
||||
Pos=-3,19
|
||||
Size=1929,78
|
||||
Collapsed=1
|
||||
|
||||
[Window][Choose File##ChooseFileDlgKey]
|
||||
Pos=78,159
|
||||
Pos=74,106
|
||||
Size=652,398
|
||||
|
||||
[Window][Dear ImGui Demo]
|
||||
Pos=115,51
|
||||
Size=550,680
|
||||
|
||||
[Window][Example: Console]
|
||||
Pos=60,60
|
||||
Size=520,600
|
||||
|
||||
[Window][Dear ImGui Metrics/Debugger]
|
||||
Pos=60,60
|
||||
Size=339,341
|
||||
|
||||
[Window][Dear ImGui Debug Log]
|
||||
Pos=60,60
|
||||
Size=456,156
|
||||
|
||||
[Window][Dear ImGui ID Stack Tool]
|
||||
Pos=60,60
|
||||
Size=354,104
|
||||
|
||||
[Window][Dear ImGui Style Editor]
|
||||
Pos=60,60
|
||||
Size=353,775
|
||||
|
||||
[Window][About Dear ImGui]
|
||||
Pos=60,60
|
||||
Size=570,126
|
||||
|
||||
[Table][0xA0160ED0,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
@ -1223,3 +1252,263 @@ Column 0 Sort=0v
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x45A3A224,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x479C5A19,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x7B69D10A,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xD17C84E5,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x3EB4D4BC,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xA6215665,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x02066E6B,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xF71AD4C1,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x183D7C3C,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x8637D7AA,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x6A1B5BDB,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x064E4462,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xF3F8A4B0,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xB6126359,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xE038E1B2,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xD9593917,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x35EE6B04,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x4D76887B,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xD32006A6,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x3E5888D0,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xBEFFC97D,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xEE3A13A6,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xBE4A52D7,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xD9F718E9,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xEF3234EA,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x2805E84F,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x3FAF7A15,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x176172F3,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x2DF83F5B,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x585AED10,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x73691092,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x1755662E,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xA74C4D12,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x59D73EAD,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xFA404909,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x82C7C57F,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xCB09D15D,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x6287E925,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xFABBE706,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x7D59EE6B,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xF5E03687,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x4045BD2E,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xEB84202B,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x2E1BE0AC,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x9102925E,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x0475B593,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x1A495329,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x119B15CD,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x36AEEAEA,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x756A4ABB,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xB3826756,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xE8446B28,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x86031FE6,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xDAAC8D88,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xAE1D6C00,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xBB072075,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xD59782BF,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x94F29476,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x8F62FF74,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x81035B21,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x460429E1,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xB8637F77,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xBE83495C,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0xB24DF2F4,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
[Table][0x1FEA7BA9,4]
|
||||
RefScale=13
|
||||
Column 0 Sort=0v
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
bool loadEmitMesh = 0;
|
||||
GL g_gl;
|
||||
GLSHADER glShader;
|
||||
GLSHADER glShaderCollision;
|
||||
std::string file;
|
||||
CTransition g_transition;
|
||||
FREECAMERA g_freecamera(glm::vec3{0.0});
|
||||
@ -33,22 +34,26 @@ int main(int cphzArgs, char* aphzArgs[])
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
RenderMenuGui(g_psw);
|
||||
|
||||
if (g_psw != nullptr)
|
||||
{
|
||||
double currentTime = glfwGetTime();
|
||||
deltaTime = currentTime - lastFrame;
|
||||
lastFrame = currentTime;
|
||||
|
||||
//std::cout << glm::to_string(g_freecamera.cameraDirection) << "\n";
|
||||
|
||||
ProcessInput(g_gl.window, deltaTime);
|
||||
g_freecamera.UpdateViewProjMatrix(g_gl.height, g_gl.width);
|
||||
DrawSwAll();
|
||||
|
||||
g_freecamera.UpdateViewProjMatrix(g_gl.height, g_gl.width, glShader);
|
||||
g_freecamera.UpdateViewProjMatrix(g_gl.height, g_gl.width, glShaderCollision);
|
||||
|
||||
if(fRenderModels != 0)
|
||||
DrawSwAll();
|
||||
|
||||
if (fRenderCollision != 0)
|
||||
DrawSwCollisionAll();
|
||||
}
|
||||
|
||||
RenderOpenFileGui();
|
||||
RenderCloseWorldGui(g_psw);
|
||||
|
||||
ImGui::End();
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
|
||||
@ -70,6 +75,7 @@ void Startup()
|
||||
StartupBrx();
|
||||
g_gl.InitGL();
|
||||
glShader.Init("glob.vert", "glob.frag");
|
||||
glShaderCollision.Init("collision.vert", "collision.frag");
|
||||
}
|
||||
|
||||
void ProcessInput(GLFWwindow* window, double dt)
|
||||
@ -92,12 +98,10 @@ void ProcessInput(GLFWwindow* window, double dt)
|
||||
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
|
||||
g_freecamera.UpdateCameraPos(CAMERADIRECTION::DOWN, dt);
|
||||
|
||||
double dx = MOUSE::GetDX() , dy = MOUSE::GetDY();
|
||||
|
||||
if (glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS)
|
||||
{
|
||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||
g_freecamera.UpdateCameraDirection(dx, dy);
|
||||
g_freecamera.UpdateCameraDirection(MOUSE::GetDX(), MOUSE::GetDY());
|
||||
}
|
||||
|
||||
double scrollDy = MOUSE::GetScrollDY();
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
void RenderSw(SW* psw, CM* pcm);
|
||||
void DrawSwAll();
|
||||
void DrawSwCollisionAll();
|
||||
void DeleteSw(SW* psw);
|
||||
|
||||
// Game loop
|
||||
|
@ -39,4 +39,19 @@ void DrawSwAll()
|
||||
{
|
||||
for (int i = 0; i < allSWAloObjs.size(); i++)
|
||||
DrawAlo(allSWAloObjs[i]);
|
||||
}
|
||||
|
||||
void DrawSwCollisionAll()
|
||||
{
|
||||
for (int i = 0; i < allcollisionModels.size(); i++)
|
||||
{
|
||||
glShaderCollision.Use();
|
||||
|
||||
int modelUniformLocation = glGetUniformLocation(glShaderCollision.ID, "model");
|
||||
glUniformMatrix4fv(modelUniformLocation, 1, GL_FALSE, glm::value_ptr(glm::mat4{1.0}));
|
||||
|
||||
glBindVertexArray(allcollisionModels[i]->VAO);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, allcollisionModels[i]->apos.size());
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
}
|
@ -2,11 +2,14 @@
|
||||
#include "sw.h"
|
||||
|
||||
extern std::vector<ALO*> allSWAloObjs;
|
||||
extern std::vector <GEOM*> allcollisionModels;
|
||||
|
||||
// Loops through all objects in a level to see which object is in camera view and stores all objects
|
||||
// in camera view in a render list
|
||||
void RenderSw(SW* psw, CM* pcm);
|
||||
// Loops through that render list of objects to be rendered on the screen
|
||||
void DrawSw(SW* psw, CM* pcm);
|
||||
// Draws all objects in SW
|
||||
void DrawSwAll();
|
||||
// Draws all 3D objects in SW
|
||||
void DrawSwAll();
|
||||
// Draws all collision models in SW
|
||||
void DrawSwCollisionAll();
|
13
Sly1/so.cpp
13
Sly1/so.cpp
@ -67,6 +67,19 @@ void LoadSoFromBrx(SO* pso, CBinaryInputStream* pbis)
|
||||
LoadAloFromBrx(pso, pbis);
|
||||
}
|
||||
|
||||
void MakeCollisionGLBuffers(GEOM *pgeom)
|
||||
{
|
||||
glGenVertexArrays(1, &pgeom->VAO);
|
||||
glBindVertexArray(pgeom->VAO);
|
||||
|
||||
glGenBuffers(1, &pgeom->VBO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, pgeom->VBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, pgeom->apos.size() * sizeof(glm::vec3), pgeom->apos.data(), GL_STATIC_DRAW);
|
||||
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(glm::vec3), (void*)0);
|
||||
glEnableVertexAttribArray(0);
|
||||
}
|
||||
|
||||
void UpdateSo(SO* pso, float dt)
|
||||
{
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "alo.h"
|
||||
extern std::vector <GEOM*> allcollisionModels;
|
||||
|
||||
enum ZPK
|
||||
{
|
||||
@ -87,6 +88,7 @@ void* NewSo();
|
||||
void InitSo(SO *pso); // NOT FINISHED
|
||||
void OnSoAdd(SO *pso); // NOT FINISHED
|
||||
void LoadSoFromBrx(SO* pso, CBinaryInputStream* pbis); // NOT FINISHED
|
||||
void MakeCollisionGLBuffers(GEOM* pgeom);
|
||||
void UpdateSo(SO *pso, float dt); // NOT FINISHED
|
||||
void RenderSoSelf(SO* pso, CM* pcm, RO* pro);
|
||||
void DeleteSo(LO* plo);
|
@ -1,8 +1,10 @@
|
||||
#include "sw.h"
|
||||
#include "debug.h"
|
||||
|
||||
std::vector<LO*> allWorldObjs;
|
||||
std::vector<ALO*> allSWAloObjs;
|
||||
extern std::vector<void*> allSwLights;
|
||||
extern std::vector <GEOM> allcollisionModels;
|
||||
|
||||
void* NewSw()
|
||||
{
|
||||
@ -121,6 +123,8 @@ void DeleteWorld(SW* psw)
|
||||
allWorldObjs.shrink_to_fit();
|
||||
allSwLights.clear();
|
||||
allSwLights.shrink_to_fit();
|
||||
allcollisionModels.clear();
|
||||
allcollisionModels.shrink_to_fit();
|
||||
|
||||
g_psw = nullptr;
|
||||
std::cout << "World Deleted\n";
|
||||
|
Loading…
Reference in New Issue
Block a user