From 0cc3672c3336af937ddab970f6505e3864154ff3 Mon Sep 17 00:00:00 2001 From: ayachi3 <1592757525@qq.com> Date: Tue, 13 Dec 2022 09:43:43 +0800 Subject: [PATCH] update model to set LOADED --- FinalProject/FinalProject.vcxproj | 2 +- FinalProject/model.cpp | 2 ++ FinalProject/sceneviewer.cpp | 16 +++++++++++++--- git命令.txt | 3 +++ 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 git命令.txt diff --git a/FinalProject/FinalProject.vcxproj b/FinalProject/FinalProject.vcxproj index c5c2ac2..75e1a28 100644 --- a/FinalProject/FinalProject.vcxproj +++ b/FinalProject/FinalProject.vcxproj @@ -13,7 +13,7 @@ {BB1EFCBB-6CD7-4283-8C3F-69AE88470EED} QtVS_v304 - 10.0.22621.0 + 10.0 10.0.22621.0 $(MSBuildProjectDirectory)\QtMsBuild diff --git a/FinalProject/model.cpp b/FinalProject/model.cpp index 38ccca0..6e623df 100644 --- a/FinalProject/model.cpp +++ b/FinalProject/model.cpp @@ -13,6 +13,7 @@ Model::~Model() { // TODO: Maybe delete all meshes? } +// file path is ...\\...\\.obj, and processnode & processmesh have been called here void Model::loadModel(std::string path) { Assimp::Importer importer; const aiScene* scene = importer.ReadFile( @@ -26,6 +27,7 @@ void Model::loadModel(std::string path) { _directory = path.substr(0, path.find_last_of('/')); processNode(scene->mRootNode, scene); + _status = LOADED; } void Model::processNode(aiNode* node, const aiScene* scene) { diff --git a/FinalProject/sceneviewer.cpp b/FinalProject/sceneviewer.cpp index e308a16..598c1f2 100644 --- a/FinalProject/sceneviewer.cpp +++ b/FinalProject/sceneviewer.cpp @@ -7,6 +7,7 @@ #include "vao.h" #include "shader.h" #include "logger.h" +#include "model.h" using std::vector; @@ -39,6 +40,7 @@ void SceneViewer::resizeGL(int w, int h) { void SceneViewer::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + /* vector vertices = { { { -0.5f, -0.5f, 0.0f } }, { { 0.5f, -0.5f, 0.0f } }, @@ -47,11 +49,19 @@ void SceneViewer::paintGL() { VertexBufferObject vbo(vertices); VertexArrayObject vao(vbo); vao.setVertexAttributePointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0); + vao.enableVertexAttribute(0); - VertexShader vertexShader("E:\\Repositories\\CollegeProjects\\CGAssignments\\FinalProject\\FinalProject\\vertexshader.vs"); - FragmentShader fragmentShader("E:\\Repositories\\CollegeProjects\\CGAssignments\\FinalProject\\FinalProject\\fragmentshader.fs"); +*/ + + + VertexShader vertexShader("D:\\code\\ComputerGraphic\\SceneEditor\\FinalProject\\vertexshader.vs"); + FragmentShader fragmentShader("D:\\code\\ComputerGraphic\\SceneEditor\\FinalProject\\fragmentshader.fs"); ShaderProgram shaderProgram(vertexShader, fragmentShader); shaderProgram.setActive(); - vao.bind(); + + Model test_model("D:\\code\\ComputerGraphic\\SceneEditor\\obj\\nanosuit/nanosuit.obj"); + test_model.render(shaderProgram); + + //vao.bind(); glDrawArrays(GL_TRIANGLES, 0, 3); } \ No newline at end of file diff --git a/git命令.txt b/git命令.txt new file mode 100644 index 0000000..48e3cbd --- /dev/null +++ b/git命令.txt @@ -0,0 +1,3 @@ +D: & cd D:\code\ComputerGraphic\SceneEditor & git clone https://github.com/Linloir/SceneEditor.git + +D: & cd D:\code\ComputerGraphic\SceneEditor & git clone https://github.com/Linloir/SceneEditor.git \ No newline at end of file