Skip to content

Commit

Permalink
Implement setting value in ModelSpinner
Browse files Browse the repository at this point in the history
  • Loading branch information
zonkmachine committed Jul 16, 2023
1 parent 2cce2c2 commit d9c5529
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pigui/ModelSpinner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ using namespace PiGui;

ModelSpinner::ModelSpinner() :
m_spinning(true),
m_middleMouseButton(false),
m_pauseTime(.0f),
m_rot(vector2f(DEG2RAD(-15.0), DEG2RAD(120.0))),
m_zoom(1.0f),
Expand Down Expand Up @@ -118,7 +119,8 @@ void ModelSpinner::DrawPiGui()

const ImGuiIO &io = ImGui::GetIO();
bool hovered = ImGui::IsItemHovered();
if (hovered && ImGui::IsMouseDown(SDL_BUTTON_MIDDLE)) {
const int mouseButton = (Pi::input->GetMouseMiddleButton() ? 0 : 2); // 0 : 2 = ImGui mouse button Left and Middle.
if (hovered && ImGui::IsMouseDown(mouseButton)) {
m_rot.x -= 0.005 * io.MouseDelta.y;
m_rot.y -= 0.005 * io.MouseDelta.x;
m_pauseTime = 1.0f;
Expand Down
4 changes: 4 additions & 0 deletions src/pigui/ModelSpinner.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Graphics {
#include "Shields.h"
#include "scenegraph/Model.h"
#include "scenegraph/ModelSkin.h"
#include "Input.h"

// TODO:
// - make this code reusable across multiple usecases (camera, rear-view mirror, UI preview, etc.)
Expand Down Expand Up @@ -71,6 +72,9 @@ namespace PiGui {
// Shoulde we spinne?
bool m_spinning;

// Is there a middle mouse button?
bool m_middleMouseButton;

// After the user manually rotates the model, hold that orientation for
// a second to let them look at it. Assumes Update() is called every
// frame while visible.
Expand Down

0 comments on commit d9c5529

Please sign in to comment.