From abbdc23c3fe67b1e72b83c46490dd53460dd21d8 Mon Sep 17 00:00:00 2001 From: amschuberth Date: Fri, 18 Aug 2023 18:34:02 -0600 Subject: [PATCH 01/12] + Project plan --- .gitignore | 7 ++----- doc/pages/ProjectPlan.md | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 doc/pages/ProjectPlan.md diff --git a/.gitignore b/.gitignore index a9f0cc4..a7acaa1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ *.sln *.vcx* /imgui -<<<<<<< HEAD /packages /Cadera shaders/compile.bat @@ -16,8 +15,6 @@ imgui.ini build/ .vscode/ *.spv -doc/ +doc/Doxyfile +doc/html *.code-workspace -======= -/Cadera ->>>>>>> master diff --git a/doc/pages/ProjectPlan.md b/doc/pages/ProjectPlan.md new file mode 100644 index 0000000..f75f4d1 --- /dev/null +++ b/doc/pages/ProjectPlan.md @@ -0,0 +1,25 @@ +# Project Plan + + +## 0.0.1 + +### Grid + +[X] Resize +[] Major/Minor Axis +[] Works on any plane + +## 0.0.2 + +### Points + +[] Movable +[] Table (Debug) + +### Lines + +[] Line Tool +[] Add +[] Delete +[] Selection +[] Movable From 301a47ce93232cfc756e6ea08a2de68a76633c5f Mon Sep 17 00:00:00 2001 From: amschuberth Date: Fri, 18 Aug 2023 18:52:10 -0600 Subject: [PATCH 02/12] Added to project ProjectPlan --- doc/pages/ProjectPlan.md | 68 +++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 12 deletions(-) diff --git a/doc/pages/ProjectPlan.md b/doc/pages/ProjectPlan.md index f75f4d1..c01e76a 100644 --- a/doc/pages/ProjectPlan.md +++ b/doc/pages/ProjectPlan.md @@ -1,25 +1,69 @@ # Project Plan +## Version 0.1 Sketch Tooling -## 0.0.1 +- [ ] 0.0.1 +- [ ] 0.0.2 +- [ ] 0.0.3 +- [ ] 0.0.4 +- [ ] 0.0.5 +- [ ] 0.0.6 + +## Version 0.0.1 Grids + +### Sketch + +- [ ] Create a sketch on any 3 base planes (x/y, y/z, x/z) ### Grid -[X] Resize -[] Major/Minor Axis -[] Works on any plane +- [x] Resize +- [ ] Major/Minor Axis +- [ ] Works on any plane -## 0.0.2 +## Version 0.0.2 Points/Lines/Rectangles ### Points -[] Movable -[] Table (Debug) +- [ ] Movable +- [ ] Table (Debug) ### Lines -[] Line Tool -[] Add -[] Delete -[] Selection -[] Movable +- [ ] Line Tool +- [ ] Add +- [ ] Delete +- [ ] Selection +- [ ] Movable +- [ ] Debug + +### Rectangles +- [ ] Rectangle Tool + + +## Version 0.0.3 Rounds + +### Circles + +- [ ] Circle Tool +- [ ] Selection + +### Arcs + +- [ ] Arc Tool (3 pt) +- [ ] Selection + + +## Version 0.0.4 Notes + +### Text + +- [ ] Font Size +- [ ] Selection + - [ ] Bounding Box +- [ ] Return +- [ ] Tabs + + +# History +None \ No newline at end of file From 116009cb1bb219a9a8faa629851f1c82ff48168f Mon Sep 17 00:00:00 2001 From: amschuberth Date: Sat, 19 Aug 2023 11:19:49 -0600 Subject: [PATCH 03/12] + TOC to ProjectPlan + grid.py for manim visuals --- .gitignore | 3 +++ doc/pages/ProjectPlan.md | 17 +++++++++++++++++ doc/visuals/grid/grid.py | 33 +++++++++++++++++++++++++++++++++ src/CADRender.cpp | 1 - 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 doc/visuals/grid/grid.py diff --git a/.gitignore b/.gitignore index a7acaa1..e9f4910 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ build/ doc/Doxyfile doc/html *.code-workspace +doc/visuals/**/media/ +doc/visuals/**/__pycache__/ + diff --git a/doc/pages/ProjectPlan.md b/doc/pages/ProjectPlan.md index c01e76a..1725eae 100644 --- a/doc/pages/ProjectPlan.md +++ b/doc/pages/ProjectPlan.md @@ -1,5 +1,22 @@ # Project Plan +- [Project Plan](#project-plan) + - [Version 0.1 Sketch Tooling](#version-01-sketch-tooling) + - [Version 0.0.1 Grids](#version-001-grids) + - [Sketch](#sketch) + - [Grid](#grid) + - [Version 0.0.2 Points/Lines/Rectangles](#version-002-pointslinesrectangles) + - [Points](#points) + - [Lines](#lines) + - [Rectangles](#rectangles) + - [Version 0.0.3 Rounds](#version-003-rounds) + - [Circles](#circles) + - [Arcs](#arcs) + - [Version 0.0.4 Notes](#version-004-notes) + - [Text](#text) +- [History](#history) + + ## Version 0.1 Sketch Tooling - [ ] 0.0.1 diff --git a/doc/visuals/grid/grid.py b/doc/visuals/grid/grid.py new file mode 100644 index 0000000..5185bcc --- /dev/null +++ b/doc/visuals/grid/grid.py @@ -0,0 +1,33 @@ +from manim import * + + +class CreateCircle(Scene): + def construct(self): + circle = Circle() + circle.set_fill(PINK, opacity=0.5) + self.play(Create(circle)) + +class CreateGrid(Scene): + + def construct(self): + + line = Line() + line.set_length(2) + line.set_color(WHITE) + line.set_angle(-PI/2) + #line.shift(LEFT * .2) + + + line2 = Line() + line2.set_length(2) + line2.set_color(WHITE) + line2.set_angle(0) + #line2.shift(UP) + + self.play(Create(line)) + #self.play(Rotate(line,-PI/2, about_point=ORIGIN)) + self.play(Create(line2)) + self.play(FadeOut(line)) + self.play(FadeOut(line2)) + + diff --git a/src/CADRender.cpp b/src/CADRender.cpp index 6bb72ee..67516cb 100644 --- a/src/CADRender.cpp +++ b/src/CADRender.cpp @@ -1571,7 +1571,6 @@ void CADRender::createSwapChain() mCommandBuffers[i].bindVertexBuffers(0, 1, &mBuffers[BUF_SKETCH_GRID_LINE].mBuffer, offsets); mCommandBuffers[i].bindVertexBuffers(1, 1, &mBuffers[BUF_SKETCH_GRID_AXII].mBuffer, offsets); mCommandBuffers[i].draw(2, mBuffers[BUF_SKETCH_GRID_AXII].mPointSize, 0, 0); - //mCommandBuffers[i].draw(2, 4, 0, 0); } // Text From f7f0bd49a12b358163891333ec0bd1828677936b Mon Sep 17 00:00:00 2001 From: amschuberth Date: Sat, 19 Aug 2023 13:59:08 -0600 Subject: [PATCH 04/12] Camera + setXYView() + setYZView() + setZXView() + pan() now works in any of the 3 sketch planes + up and cross 3-vec member variables Selection + select() now takes in camera cross vector as input + select() now can select a point in any of the 3 sketch planes CadRender + model and view of the ubo now takes the up vector of the Camera GUI + Start Menu now has radio buttons for Sketch/Part and Sketch View. Callbacks + Point tool mouse click now sends the cameraVec of Camera to Selection::select() --- doc/pages/ProjectPlan.md | 2 +- include/Camera.hpp | 16 ++++++++-- include/Selection.hpp | 2 +- src/CADRender.cpp | 7 +++-- src/Camera.cpp | 54 +++++++++++++++++++++++++++++---- src/Selection.cpp | 12 +++++--- src/callbacks.cpp | 4 +-- src/gui.cpp | 65 +++++++++++++++++++++++++++++++++++----- 8 files changed, 136 insertions(+), 26 deletions(-) diff --git a/doc/pages/ProjectPlan.md b/doc/pages/ProjectPlan.md index 1725eae..b566f18 100644 --- a/doc/pages/ProjectPlan.md +++ b/doc/pages/ProjectPlan.md @@ -30,7 +30,7 @@ ### Sketch -- [ ] Create a sketch on any 3 base planes (x/y, y/z, x/z) +- [x] Create a sketch on any 3 base planes (x/y, z/x, y/z) ### Grid diff --git a/include/Camera.hpp b/include/Camera.hpp index c2785c1..eac835c 100644 --- a/include/Camera.hpp +++ b/include/Camera.hpp @@ -38,6 +38,12 @@ namespace cam { /// The length of the cameraVec vector float camDistance; + /// Up direction of Camera + glm::vec3 up; + + /// Direction to move Camera to the side, for panning + glm::vec3 cross; + // Ortho view float left; @@ -49,9 +55,15 @@ namespace cam { double xpos; double ypos; - void update(); + void setXYView(); + + void setYZView(); + + void setZXView(); + + void update(); - /** + /** * @brief * * @param yoffset diff --git a/include/Selection.hpp b/include/Selection.hpp index 95a8141..9a5cff8 100644 --- a/include/Selection.hpp +++ b/include/Selection.hpp @@ -44,7 +44,7 @@ namespace sel { void setActiveSketch(sketch::Sketch* pSketch); - void select(glm::vec3 mouseRay, glm::vec3 origin, glm::vec3 normal, glm::vec3 pos, bool isOrtho); + void select(glm::vec3 mouseRay, glm::vec3 origin, glm::vec3 normal, glm::vec3 pos, glm::vec3 cross, bool isOrtho); static int selectPoint(glm::vec3 pointToAdd, std::map &points, float skScale); diff --git a/src/CADRender.cpp b/src/CADRender.cpp index 67516cb..33ebc74 100644 --- a/src/CADRender.cpp +++ b/src/CADRender.cpp @@ -1598,8 +1598,11 @@ void CADRender::createSwapChain() void CADRender::updateUniformBuffer(uint32_t currentImage) { - u.model = glm::rotate(glm::mat4(1.0f), glm::radians(0.0f), glm::vec3(0.0f, 1.0f, 0.0f)); - u.view = glm::lookAt(Cam.pos, Cam.focus, glm::vec3(0.0f, 1.0f, 0.0f)); + //u.model = glm::rotate(glm::mat4(1.0f), glm::radians(0.0f), glm::vec3(0.0f, 1.0f, 0.0f)); + // u.view = glm::lookAt(Cam.pos, Cam.focus, glm::vec3(0.0f, 1.0f, 0.0f)); + u.model = glm::rotate(glm::mat4(1.0f), glm::radians(0.0f), Cam.up); + u.view = glm::lookAt(Cam.pos, Cam.focus, Cam.up); + if (Cam.flags.test(cam::ortho)) { diff --git a/src/Camera.cpp b/src/Camera.cpp index edd4e82..1044878 100644 --- a/src/Camera.cpp +++ b/src/Camera.cpp @@ -8,17 +8,57 @@ namespace cam { Camera::Camera() { - pos = { -20.0f, 0.0f, 0.0f }; + pos = { 0.0f, 0.0f, 20.0f }; focus = { 0.0f, 0.0f, 0.0f }; - cameraVec = { 1.0f, 0.0f, 0.0f }; + cameraVec = { 0.0f, 0.0f, -1.0f }; xpos = 0.0; ypos = 0.0; mouseRay = { 0.0f, 0.0f, 0.0f }; left = -10.0f; camDistance = 0.0f; + up = {0.0f, 1.0f, 0.0f}; + + cross = glm::cross(cameraVec, up); + } + + void Camera::setXYView() { + + pos = { 0.0f, 0.0f, 20.0f }; + focus = { 0.0f, 0.0f, 0.0f }; + cameraVec = { 0.0f, 0.0f, -1.0f }; + + up = {0.0f, 1.0f, 0.0f}; + cross = glm::cross(cameraVec, up); + + } + + void Camera::setYZView() { + + pos = { 20.0f, 0.0f, 0.0f }; + focus = { 0.0f, 0.0f, 0.0f }; + cameraVec = { -1.0f, 0.0f, 0.0f }; + + up = {0.0f, 0.0f, 1.0f}; + cross = glm::cross(cameraVec, up); + + } + + void Camera::setZXView() { + + pos = { 0.0f, 20.0f, 0.0f }; + focus = { 0.0f, 0.0f, 0.0f }; + cameraVec = { 0.0f, -1.0f, 0.0f }; + + up = {1.0f, 0.0f, 0.0f}; + cross = glm::cross(cameraVec, up); + + } + + + void Camera::update() { camDistance = glm::length(pos - focus); @@ -88,10 +128,12 @@ namespace cam { diff = mouseRay - prevMouseRay; - pos.y -= diff.y; - pos.z -= diff.x; - focus.y -= diff.y; - focus.z -= diff.x; + + + pos -= diff.y * up; + pos -= diff.x * cross; + focus -= diff.y * up; + focus -= diff.x * cross; } else { diff --git a/src/Selection.cpp b/src/Selection.cpp index f7748c1..0e01a7e 100644 --- a/src/Selection.cpp +++ b/src/Selection.cpp @@ -109,12 +109,16 @@ namespace sel { } - void Selector::select(glm::vec3 mouseRay, glm::vec3 origin, glm::vec3 normal, glm::vec3 pos, bool isOrtho) { + void Selector::select(glm::vec3 mouseRay, glm::vec3 origin, glm::vec3 normal, glm::vec3 pos, glm::vec3 cross, bool isOrtho) { if (isOrtho) { - point.x = 0.0f; - point.y = mouseRay.y + pos.y; - point.z = mouseRay.x + pos.z; + glm::vec3 up = glm::cross(cross, normal); + + glm::vec3 x = mouseRay.x * cross; + glm::vec3 y = mouseRay.y * up; + + glm::vec3 posOnPlane = origin + ( up + cross) * pos; + point = posOnPlane + x + y; } else { point = calcPOnPlane(mouseRay, origin, normal, pos); diff --git a/src/callbacks.cpp b/src/callbacks.cpp index 4d71517..63f8a62 100644 --- a/src/callbacks.cpp +++ b/src/callbacks.cpp @@ -18,7 +18,7 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) app->Sketch.flags.test(CADERA_APP_NAMESPACE::sketch::skt_tool_active)) { app->Render.Sel.select(app->Render.Cam.mouseRay, glm::vec3(0.0f, 0.0f, 0.0f), - glm::vec3(1.0f, 0.0f, 0.0f), app->Render.Cam.pos, + app->Render.Cam.cameraVec, app->Render.Cam.pos, app->Render.Cam.cross, app->Render.Cam.flags.test(cad::cam::ortho)); if (!app->Render.Sel.existingPoint(app->Render.Sel.point)) @@ -30,7 +30,7 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) else if (!ImGui::IsWindowHovered(ImGuiHoveredFlags_::ImGuiHoveredFlags_AnyWindow)) { app->Render.Sel.select(app->Render.Cam.mouseRay, glm::vec3(0.0f, 0.0f, 0.0f), - glm::vec3(1.0f, 0.0f, 0.0f), app->Render.Cam.pos, + app->Render.Cam.cameraVec, app->Render.Cam.pos, app->Render.Cam.cross, app->Render.Cam.flags.test(cad::cam::ortho)); int id = app->Render.Sel.add(app->Render.Sel.point, app->Sketch.Points, app->Render.Cam.camDistance); diff --git a/src/gui.cpp b/src/gui.cpp index 3fb872b..49b296a 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -62,17 +62,44 @@ namespace gui { ImGui::Begin("Start Screen"); - if (ImGui::Button("New Sketch")) { + + + static int modelTypeInt; + ImGui::RadioButton("Sketch", &modelTypeInt, 0); ImGui::SameLine(); + ImGui::RadioButton("Part", &modelTypeInt, 1); + + if (modelTypeInt == 0) { - flags.set(gui_sketch_menu); + ImGui::Text("Sketch Plane:"); - Sketch.setType(cad_sketch); - Sketch.setCameraDistance(&Render.Cam.camDistance); - Sel.setActiveSketch(&Sketch); + static int sketchViewInt; + ImGui::RadioButton("XY", &sketchViewInt, 0); ImGui::SameLine(); + ImGui::RadioButton("ZX", &sketchViewInt, 1); ImGui::SameLine(); + ImGui::RadioButton("YZ", &sketchViewInt, 2); - Render.flags.set(render_update_sketch); + if (ImGui::Button("New Sketch")) { + + flags.set(gui_sketch_menu); + + if (sketchViewInt == 0) { + Render.Cam.setXYView(); + } + else if (sketchViewInt == 1) { + Render.Cam.setZXView(); + } + else { + Render.Cam.setYZView(); + } + + + Sketch.setType(cad_sketch); + Sketch.setCameraDistance(&Render.Cam.camDistance); + Sel.setActiveSketch(&Sketch); - flags.reset(gui_start_menu); + Render.flags.set(render_update_sketch); + + flags.reset(gui_start_menu); + } } ImGui::End(); @@ -220,6 +247,16 @@ namespace gui { Render.Cam.flags.reset(cam::ortho); } + + if (ImGui::Button("Set XY View")) { + Render.Cam.setXYView(); + } + if (ImGui::Button("Set ZX View")) { + Render.Cam.setZXView(); + } + if (ImGui::Button("Set YZ View")) { + Render.Cam.setYZView(); + } ImGui::Text("Left: %f", Render.Cam.left); @@ -250,7 +287,19 @@ namespace gui { ImGui::Text("Camera Distance"); ImGui::Text("Distance: %f", Render.Cam.camDistance); - + ImGui::NewLine(); + + ImGui::Text("Up"); + ImGui::Text("x: %f", Render.Cam.up.x); + ImGui::Text("y: %f", Render.Cam.up.y); + ImGui::Text("z: %f", Render.Cam.up.z); + + ImGui::NewLine(); + + ImGui::Text("Cross"); + ImGui::Text("x: %f", Render.Cam.cross.x); + ImGui::Text("y: %f", Render.Cam.cross.y); + ImGui::Text("z: %f", Render.Cam.cross.z); } From 60ef0002215b99aa7f478e17c24680d296c2cd25 Mon Sep 17 00:00:00 2001 From: amschuberth Date: Sat, 19 Aug 2023 15:30:20 -0600 Subject: [PATCH 05/12] + Added tester.cpp --- CMakeLists.txt | 4 +++- test/tester.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/tester.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b39c90..4c11272 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,8 +27,10 @@ add_executable(Cadera src/Cadera.cpp ) - + +add_executable(tester test/tester.cpp) +add_test(tester tester) target_precompile_headers(Cadera PRIVATE include/pch.hpp) target_include_directories(Cadera PRIVATE include/) diff --git a/test/tester.cpp b/test/tester.cpp new file mode 100644 index 0000000..93bec98 --- /dev/null +++ b/test/tester.cpp @@ -0,0 +1,6 @@ + + + +int main() { + return 0; +} \ No newline at end of file From ef7630344bb15543ecb2c6eee2c1ac44df8f301b Mon Sep 17 00:00:00 2001 From: Austin Date: Sat, 19 Aug 2023 15:32:19 -0600 Subject: [PATCH 06/12] Create Test.yml --- .github/workflows/Test.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/Test.yml diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml new file mode 100644 index 0000000..ec57a0b --- /dev/null +++ b/.github/workflows/Test.yml @@ -0,0 +1,23 @@ +name: C/C++ CI + +on: + push: + branches: [ "exp" ] + pull_request: + branches: [ "exp" ] + +jobs: + build: + + runs-on: windows + + steps: + - uses: actions/checkout@v3 + - name: configure + run: ./configure + - name: make + run: make + - name: make check + run: make check + - name: make distcheck + run: make distcheck From 868db26a29575e8c43016c0456fe54eb0f9a04e5 Mon Sep 17 00:00:00 2001 From: amschuberth Date: Sat, 19 Aug 2023 15:35:18 -0600 Subject: [PATCH 07/12] test commit --- .github/workflows/Test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index ec57a0b..12c6ed8 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -6,6 +6,7 @@ on: pull_request: branches: [ "exp" ] + jobs: build: From c926980d239ba8b9000b26279a6a27a1869b9681 Mon Sep 17 00:00:00 2001 From: amschuberth Date: Sat, 19 Aug 2023 15:42:13 -0600 Subject: [PATCH 08/12] testing github actions --- .github/workflows/Test.yml | 4 ++-- CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index 12c6ed8..f1c1c6b 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -6,11 +6,11 @@ on: pull_request: branches: [ "exp" ] - + jobs: build: - runs-on: windows + runs-on: windows-latest steps: - uses: actions/checkout@v3 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c11272..2546ec1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.0.0) set(CMAKE_TOOLCHAIN_FILE "C:\\vcpkg\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" ) -project(Cadera VERSION 0.1.0) +project(Cadera VERSION 0.0.1) include(CTest) enable_testing() From ef0d15486a446dfe08e42a020b330d0bcc864846 Mon Sep 17 00:00:00 2001 From: amschuberth Date: Sat, 19 Aug 2023 15:44:43 -0600 Subject: [PATCH 09/12] testing github actions --- .github/workflows/Test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index f1c1c6b..5717c48 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -10,7 +10,7 @@ on: jobs: build: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 50bda275bf573a3b706a7f356e57c43f5ed59828 Mon Sep 17 00:00:00 2001 From: amschuberth Date: Sat, 19 Aug 2023 21:40:05 -0600 Subject: [PATCH 10/12] Grid + Made the grid work on the 3 base planes + setGridOrientation Gui + Calls Grid.setGridOrientation() on sketch creation --- doc/pages/ProjectPlan.md | 3 +-- include/grid.hpp | 10 +++++++++- src/grid.cpp | 18 ++++++++++++++---- src/gui.cpp | 3 +++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/doc/pages/ProjectPlan.md b/doc/pages/ProjectPlan.md index b566f18..31dec02 100644 --- a/doc/pages/ProjectPlan.md +++ b/doc/pages/ProjectPlan.md @@ -35,8 +35,7 @@ ### Grid - [x] Resize -- [ ] Major/Minor Axis -- [ ] Works on any plane +- [x] Works on any plane ## Version 0.0.2 Points/Lines/Rectangles diff --git a/include/grid.hpp b/include/grid.hpp index bfd687a..886cafd 100644 --- a/include/grid.hpp +++ b/include/grid.hpp @@ -17,7 +17,11 @@ class Grid { Grid(); - + + void setGridOrientation(glm::vec3 normal, glm::vec3 up, glm::vec3 cross); + + + /// @brief To generate the values needed to instance each grid line from the base line /// @return Vector to be used for rendering the instances std::vector createGridInstanceAxii(); @@ -25,6 +29,10 @@ class Grid { Vertex p1; Vertex p2; + glm::vec3 gNormal; + glm::vec3 gUp; + glm::vec3 gCross; + /// @brief The container for rendering the base line std::vector line; diff --git a/src/grid.cpp b/src/grid.cpp index 5b0a7e9..a8d0222 100644 --- a/src/grid.cpp +++ b/src/grid.cpp @@ -13,6 +13,16 @@ Grid::Grid() { p2 = { {0.0f, size, 0.0f}, {.0f, .0f, .0f} }; line = { p1, p2 }; + + gUp = {0.0f, 1.0f, 0.0f}; + gCross = {1.0f, 0.0f, 0.0f}; + gNormal = {0.0f, 0.0f, 1.0f}; +} + +void Grid::setGridOrientation(glm::vec3 normal, glm::vec3 up, glm::vec3 cross) { + gNormal = normal; + gUp = up; + gCross = cross; } std::vector Grid::createGridInstanceAxii() { @@ -20,8 +30,8 @@ std::vector Grid::createGridInstanceAxii() { std::vector axii; - p1 = { {0.0f, -size * spacing, 0.0f}, {.0f, .0f, .0f} }; - p2 = { {0.0f, size * spacing, 0.0f}, {.0f, .0f, .0f} }; + p1 = {(-size*spacing) * gUp, {.0f, .0f, .0f}};//{ {0.0f, -size * spacing, 0.0f}, {.0f, .0f, .0f} }; + p2 = {(size*spacing) * gUp, {.0f, .0f, .0f}};// { {0.0f, size * spacing, 0.0f}, {.0f, .0f, .0f} }; line = { p1, p2 }; @@ -29,8 +39,8 @@ std::vector Grid::createGridInstanceAxii() { for (int i = 0; i < 2*size+1 ; i++) { GridRotationAxis axis = { - {0.0f, 0.0f, position}, - {1.0f, 0.0f, 0.0f}, + position*gCross, + gNormal, {0.0f, 0.0f, 0.0f}, 0.0f }; diff --git a/src/gui.cpp b/src/gui.cpp index 49b296a..ed8410d 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -83,12 +83,15 @@ namespace gui { if (sketchViewInt == 0) { Render.Cam.setXYView(); + Sketch.mGrid.setGridOrientation(Render.Cam.cameraVec, Render.Cam.up, Render.Cam.cross); } else if (sketchViewInt == 1) { Render.Cam.setZXView(); + Sketch.mGrid.setGridOrientation(Render.Cam.cameraVec, Render.Cam.up, Render.Cam.cross); } else { Render.Cam.setYZView(); + Sketch.mGrid.setGridOrientation(Render.Cam.cameraVec, Render.Cam.up, Render.Cam.cross); } From c4a33a5097537d150ed51a4bd2b3e5a72e708aeb Mon Sep 17 00:00:00 2001 From: amschuberth Date: Sat, 19 Aug 2023 21:40:49 -0600 Subject: [PATCH 11/12] Updated project plan --- doc/pages/ProjectPlan.md | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/doc/pages/ProjectPlan.md b/doc/pages/ProjectPlan.md index 31dec02..6861135 100644 --- a/doc/pages/ProjectPlan.md +++ b/doc/pages/ProjectPlan.md @@ -2,9 +2,6 @@ - [Project Plan](#project-plan) - [Version 0.1 Sketch Tooling](#version-01-sketch-tooling) - - [Version 0.0.1 Grids](#version-001-grids) - - [Sketch](#sketch) - - [Grid](#grid) - [Version 0.0.2 Points/Lines/Rectangles](#version-002-pointslinesrectangles) - [Points](#points) - [Lines](#lines) @@ -15,27 +12,21 @@ - [Version 0.0.4 Notes](#version-004-notes) - [Text](#text) - [History](#history) + - [Version 0.0.1 Grids](#version-001-grids) + - [Sketch](#sketch) + - [Grid](#grid) ## Version 0.1 Sketch Tooling -- [ ] 0.0.1 +- [x] 0.0.1 - [ ] 0.0.2 - [ ] 0.0.3 - [ ] 0.0.4 - [ ] 0.0.5 - [ ] 0.0.6 -## Version 0.0.1 Grids -### Sketch - -- [x] Create a sketch on any 3 base planes (x/y, z/x, y/z) - -### Grid - -- [x] Resize -- [x] Works on any plane ## Version 0.0.2 Points/Lines/Rectangles @@ -82,4 +73,15 @@ # History -None \ No newline at end of file + + +## Version 0.0.1 Grids + +### Sketch + +- [x] Create a sketch on any 3 base planes (x/y, z/x, y/z) + +### Grid + +- [x] Resize +- [x] Works on any plane \ No newline at end of file From 1f209b54dbdedffc1e3bd2b11a7e63dfda38d9d5 Mon Sep 17 00:00:00 2001 From: Austin Date: Sat, 19 Aug 2023 21:45:35 -0600 Subject: [PATCH 12/12] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 65050a0..29bbea4 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ Open Source Cad Program ## About A work in progress 3D CAD Program +[Project Plan](doc/pages/ProjectPlan.md) + ## Dependencies Vulkan 1.2.154