Implementing started properly implementing Gizmo
Adding GetTransform to the transform component such that the proper view transform can be calculated for any scene camera
This commit is contained in:
		@ -34,16 +34,37 @@ void Viewport::Draw() {
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    ImGuizmo::Enable(true);
 | 
			
		||||
    ImGuizmo::SetRect(ScreenSpaceMin.x, ScreenSpaceMin.y, ContentRegionMax.x, ContentRegionMax.y);
 | 
			
		||||
    ImGuizmo::SetOrthographic(false);
 | 
			
		||||
    ImGuizmo::SetDrawlist();
 | 
			
		||||
 | 
			
		||||
    glm::mat4 transposed_view = glm::transpose(cam.ViewMatrix);
 | 
			
		||||
    isFocused = ImGui::IsWindowFocused();
 | 
			
		||||
    float windowWidth = (float)ImGui::GetWindowWidth();
 | 
			
		||||
    float windowHeight = (float)ImGui::GetWindowHeight();
 | 
			
		||||
    ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, windowWidth, windowHeight);
 | 
			
		||||
 | 
			
		||||
    //ImGuizmo::DrawGrid(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), glm::value_ptr(worldOrigin), 100.0f);
 | 
			
		||||
    //ImGuizmo::ViewManipulate(glm::value_ptr(cam.ViewMatrix), 1, { ScreenSpaceMin.x,ScreenSpaceMin.y }, { 90,90 }, 0x22CCCCCC);
 | 
			
		||||
    const auto& ProjMatrix = camera.projection;
 | 
			
		||||
    glm::mat4& cameraView = glm::mat4(1.0f);//glm::inverse(glm::translate(glm::mat4(1.0f) , cam.Position) * glm::toMat4(glm::quat(cam.Rotation)) );
 | 
			
		||||
 | 
			
		||||
    // Matrix is the model matrix we would want to manipulate
 | 
			
		||||
    //ImGuizmo::Manipulate(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(cam.ViewMatrix));
 | 
			
		||||
    ImGuizmo::DrawGrid(glm::value_ptr(cameraView), glm::value_ptr(ProjMatrix), glm::value_ptr(cameraDelta), 100.0f);
 | 
			
		||||
    ImGuizmo::ViewManipulate(glm::value_ptr(cameraView), 1, ImGui::GetWindowPos(), {90,90}, 0x22CCCCCC);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if (selected == nullptr)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    if (selected->isValid()) {
 | 
			
		||||
      
 | 
			
		||||
        auto& tc = selected->GetComponent<YoggieEngine::TransformComponent>();
 | 
			
		||||
        glm::mat4 transform = tc.GetTransform();
 | 
			
		||||
 | 
			
		||||
        ImGuizmo::Manipulate(
 | 
			
		||||
                    glm::value_ptr(cameraView),
 | 
			
		||||
            glm::value_ptr(ProjMatrix),
 | 
			
		||||
            ImGuizmo::TRANSLATE, ImGuizmo::LOCAL,
 | 
			
		||||
            glm::value_ptr(transform), nullptr, nullptr);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
   
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user