3D 장면에서 객체를 회전하고 싶습니다. 아래의 코드에서 WorldMatrix를 단순히 돌렸다. 그러나 장면에 2 개의 물체가 포함되어 있다면 어떨까요? WorldMatrix를 회전 시키면 둘 다 회전합니다 (기묘한 방식으로). 다른 모델을 변경하지 않고 장면의 한 객체를 어떻게 회전해야합니까?3D 장면에서 단일 객체를 회전하는 방법은 무엇입니까?
// Clear the buffers to begin the scene.
m_OpenGL->BeginScene(0.0f, 0.0f, 0.0f, 1.0f);
// Generate the view matrix based on the camera's position.
m_Camera->Render();
// Get the world, view, and projection matrices from the opengl and camera objects.
m_OpenGL->GetWorldMatrix(worldMatrix);
m_Camera->GetViewMatrix(viewMatrix);
m_OpenGL->GetProjectionMatrix(projectionMatrix);
// Get the light properties.
m_Light->GetDirection(lightDirection);
m_Light->GetDiffuseColor(diffuseLightColor);
m_Light->GetAmbientLight(ambientLight);
// Rotate the world matrix by the rotation value so that the object will spin.
m_OpenGL->MatrixRotationY(worldMatrix, rotation);
// Set the light shader as the current shader program and set the matrices that it will use for rendering.
m_LightShader->SetShader(m_OpenGL);
m_LightShader->SetShaderParameters(m_OpenGL, worldMatrix, viewMatrix, projectionMatrix, 0, lightDirection, diffuseLightColor, ambientLight);
// Render the model using the light shader.
m_Model->Render(m_OpenGL);
// Present the rendered scene to the screen.
m_OpenGL->EndScene();
롤, 요우 및 피치는 Y 축의 회전 방향입니다. 그것들은 수레이며 십진수를 포함 할 수 있습니다. – MilanSxD