Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing a nice main.cpp example? #21

Open
taiya opened this issue Jan 7, 2017 · 8 comments
Open

Missing a nice main.cpp example? #21

taiya opened this issue Jan 7, 2017 · 8 comments

Comments

@taiya
Copy link

taiya commented Jan 7, 2017

No description provided.

@CedricGuillemet
Copy link
Owner

I'm working on it :)

@PicosePablo
Copy link

Yes, and can u make better comments? There are functions without any help (ex: SetRect). Im not sure about how to use this....

@w1th0utnam3
Copy link

I would really appreciate a small example that works on its own. I currently cannot get ImGuizmo to draw anything and I'm not sure whether it is because of the view/projection matrices or because I call the functions in the wrong order.
At the moment I call

ImGuizmo::BeginFrame();
ImGuizmo::Enable(true);

ImGuiIO& io = ImGui::GetIO();
ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y);

glm::fmat4 view = m_camera->modelViewMatrix();
glm::fmat4 projection = m_camera->projectionMatrix();

ImGuizmo::DrawCube(&view[0][0], &projection[0][0], &matrix[0][0]);
ImGuizmo::Manipulate(&view[0][0], &projection[0][0], ImGuizmo::ROTATE, ImGuizmo::WORLD, &matrix[0][0]);

right after ImGuiGlfw3NewFrame() in the render loop but nothing is drawn. The matrix variable is initialized to the identity matrix and I tried to supply my real view and projection matrices as well as identity matrices. Standard ImGui windows are drawn correctly btw. Do you have any advice?

@CedricGuillemet
Copy link
Owner

CedricGuillemet commented May 27, 2017 via email

@w1th0utnam3
Copy link

Thanks for the reply, I use the following code to compute the matrices:

void Camera::updateModelViewMatrix()
{
	m_modelView = glm::scale(glm::dmat4(), m_scaling);
	m_modelView = glm::rotate(m_modelView, glm::angle(m_rotation), glm::axis(m_rotation));
}

void Camera::updateProjectionMatrix()
{	
	const double diag = std::hypot(m_viewportSize.x, m_viewportSize.y);
	m_projection = glm::ortho<double>(-0.5*m_viewportSize.x*m_zoom, 0.5*m_viewportSize.x*m_zoom, -0.5*m_viewportSize.y*m_zoom, 0.5*m_viewportSize.y*m_zoom, -diag, diag);
}

@edselmalasig
Copy link

please add a main.cpp

@edselmalasig
Copy link

added mine with object picker http://www.github.com/edselmalasig/ImGuizmo_pick_and_choose

@w1th0utnam3
Copy link

@CedricGuillemet, I found the problem why nothing was drawn: In my call

ImGuizmo::Manipulate(&view[0][0], &projection[0][0], ImGuizmo::ROTATE, ImGuizmo::WORLD, &matrix[0][0]);

I forgot to initialize matrix to anything meaningful (e.g. identity matrix). facepalm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants