Make import work
This commit is contained in:
parent
f3bda5636e
commit
369577c8db
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -25,6 +25,6 @@
|
||||
[submodule "include/glad"]
|
||||
path = include/glad
|
||||
url = https://github.com/Dav1dde/glad.git
|
||||
[submodule "include/imGuIZMO.quat"]
|
||||
path = include/imGuIZMO.quat
|
||||
url = https://github.com/BrutPitt/imGuIZMO.quat.git
|
||||
[submodule "include/ImGuizmo"]
|
||||
path = include/ImGuizmo
|
||||
url = https://github.com/CedricGuillemet/ImGuizmo.git
|
||||
|
@ -55,15 +55,17 @@ add_library(
|
||||
include/imgui/backends/imgui_impl_opengl3.cpp)
|
||||
target_link_libraries(imgui glfw)
|
||||
|
||||
include_directories(include/imGuIZMO.quat)
|
||||
include_directories(include/ImGuizmo)
|
||||
add_library(
|
||||
imGuIZMO STATIC
|
||||
include/imGuIZMO.quat/imGuIZMO.quat/imGuIZMOquat.cpp
|
||||
imGuizmo STATIC
|
||||
include/ImGuizmo/GraphEditor.cpp
|
||||
include/ImGuizmo/ImCurveEdit.cpp
|
||||
include/ImGuizmo/ImGradient.cpp
|
||||
include/ImGuizmo/ImGuizmo.cpp
|
||||
include/ImGuizmo/ImSequencer.cpp
|
||||
)
|
||||
target_link_libraries(imGuIZMO imgui)
|
||||
target_compile_definitions(imGuIZMO PUBLIC -DIMGUIZMO_IMGUI_FOLDER=)
|
||||
target_link_libraries(imGuizmo imgui)
|
||||
|
||||
add_executable(fred engine.cpp shader.c)
|
||||
target_link_libraries(fred $<$<PLATFORM_ID:Linux>:-lm> glad_gl_core_33 glm glfw
|
||||
soil2 assimp imgui imGuIZMO clog)
|
||||
target_compile_definitions(fred PUBLIC -DIMGUIZMO_IMGUI_FOLDER=)
|
||||
soil2 assimp imgui imGuizmo clog)
|
||||
|
16
TODO.md
16
TODO.md
@ -1,7 +1,21 @@
|
||||
[ ] Destruct all at the end
|
||||
[ ] Make ImGuIZMO.quat work
|
||||
[x] Make ImGuIZMO~~.quat~~ work
|
||||
[ ] Finish modularization
|
||||
[ ] Make SOIL2 stop giving that smelly error message
|
||||
Wtf is this warning?
|
||||
CMake Warning (dev) at include/SOIL2/CMakeLists.txt:4 (option):
|
||||
Policy CMP0077 is not set: option() honors normal variables. Run "cmake
|
||||
--help-policy CMP0077" for policy details. Use the cmake_policy command to
|
||||
set the policy and suppress this warning.
|
||||
|
||||
For compatibility with older versions of CMake, option is clearing the
|
||||
normal variable 'SOIL2_BUILD_TESTS'.
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
|
||||
CMake Warning (dev) at include/SOIL2/CMakeLists.txt:67 (install):
|
||||
Target soil2 has PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
[ ] Overhaul asset debug screen
|
||||
[ ] Simple Lighting
|
||||
[ ] Lightmapped Lighting
|
||||
[x] Deuteronomy is the coolest word ever
|
||||
|
31
engine.cpp
31
engine.cpp
@ -16,8 +16,7 @@
|
||||
#include <backends/imgui_impl_glfw.h>
|
||||
#include <backends/imgui_impl_opengl3.h>
|
||||
#include <imgui.h>
|
||||
#define VGIZMO_USES_GLM
|
||||
#include <imGuIZMO.quat/imGuIZMOquat.h>
|
||||
#include <ImGuizmo.h>
|
||||
#include <clog/clog.h>
|
||||
|
||||
#include <SOIL2.h>
|
||||
@ -42,6 +41,7 @@ static bool loadModel(const char *path, std::vector<unsigned short> &indices,
|
||||
std::vector<glm::vec3> &vertices,
|
||||
std::vector<glm::vec2> &uvs,
|
||||
std::vector<glm::vec3> &normals) {
|
||||
clog_log(CLOG_LEVEL_DEBUG, "Loading model: %s", path);
|
||||
Assimp::Importer importer;
|
||||
|
||||
const aiScene *scene = importer.ReadFile(
|
||||
@ -76,6 +76,7 @@ static bool loadModel(const char *path, std::vector<unsigned short> &indices,
|
||||
}
|
||||
|
||||
GLuint loadTexture(const char *path) {
|
||||
clog_log(CLOG_LEVEL_DEBUG, "Loading texture: %s", path);
|
||||
GLuint texture = SOIL_load_OGL_texture(
|
||||
path, SOIL_LOAD_AUTO,
|
||||
SOIL_CREATE_NEW_ID,
|
||||
@ -321,6 +322,7 @@ void render(Scene scene) {
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
ImGuizmo::BeginFrame();
|
||||
|
||||
for (int i = 0; i < scene.assets.size(); i++) {
|
||||
Asset *currentAsset = scene.assets[i];
|
||||
@ -338,7 +340,30 @@ void render(Scene scene) {
|
||||
char assetName[] = "Asset: 00";
|
||||
sprintf(assetName, "Asset: %d", i);
|
||||
ImGui::Begin(assetName);
|
||||
ImGui::gizmo3D(assetName, currentAsset->rotation);
|
||||
static ImGuizmo::OPERATION mCurrentGizmoOperation(ImGuizmo::ROTATE);
|
||||
static ImGuizmo::MODE mCurrentGizmoMode(ImGuizmo::WORLD);
|
||||
if (ImGui::RadioButton("Translate", mCurrentGizmoOperation == ImGuizmo::TRANSLATE)) {
|
||||
mCurrentGizmoOperation = ImGuizmo::TRANSLATE;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton("Rotate", mCurrentGizmoOperation == ImGuizmo::TRANSLATE)) {
|
||||
mCurrentGizmoOperation = ImGuizmo::ROTATE;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton("Scale", mCurrentGizmoOperation == ImGuizmo::TRANSLATE)) {
|
||||
mCurrentGizmoOperation = ImGuizmo::SCALE;
|
||||
}
|
||||
glm::vec3 rotationEuler = eulerAngles(currentAsset->rotation);
|
||||
ImGui::DragFloat3("Translate", (float*)¤tAsset->position);
|
||||
ImGui::DragFloat3("Rotate", (float*)&rotationEuler);
|
||||
ImGui::DragFloat3("Scale", (float*)¤tAsset->scaling);
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y);
|
||||
ImGuizmo::Manipulate((const float*)&viewMatrix, (const float*)&projectionMatrix, mCurrentGizmoOperation, mCurrentGizmoMode, (float*)&modelMatrix, NULL, NULL);
|
||||
ImGuizmo::DecomposeMatrixToComponents((const float*)&modelMatrix, (float *)¤tAsset->position, (float *)&rotationEuler, (float *)¤tAsset->scaling);
|
||||
currentAsset->rotation = glm::quat(rotationEuler);
|
||||
|
||||
ImGui::End();
|
||||
|
||||
glUniformMatrix4fv(currentAsset->matrixID, 1, GL_FALSE, &mvp[0][0]);
|
||||
|
1
include/ImGuizmo
Submodule
1
include/ImGuizmo
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 6d588209f99b1324a608783d1f52faa518886c29
|
@ -1 +0,0 @@
|
||||
Subproject commit 6c038a90fdadae580b357fbaf26f83cafeb83a6a
|
Loading…
Reference in New Issue
Block a user