void RageDisplay::PreMultMatrix( const RageMatrix &m ) { g_WorldStack.MultMatrixLocal( m ); }
void RageDisplay::SkewX( float fAmount ) { g_WorldStack.SkewX( fAmount ); }
void RageDisplay::PostMultMatrix( const RageMatrix &m ) { g_WorldStack.MultMatrix( m ); }
void RageDisplay::Scale( float x, float y, float z ) { g_WorldStack.ScaleLocal(x, y, z); }
void RageDisplay::RotateZ( float deg ) { g_WorldStack.RotateZLocal( deg ); }
void RageDisplay::PopMatrix() { g_WorldStack.Pop(); }
void RageDisplay::TranslateWorld( float x, float y, float z ) { g_WorldStack.Translate(x, y, z); }
const RageMatrix* RageDisplay::GetTextureTop() { return g_TextureStack.GetTop(); }
void RageDisplay::PushMatrix() { g_WorldStack.Push(); }
const RageMatrix* RageDisplay::GetWorldTop() { return g_WorldStack.GetTop(); }
const RageMatrix* RageDisplay::GetViewTop() { return g_ViewStack.GetTop(); }
const RageMatrix* RageDisplay::GetProjectionTop() { return g_ProjectionStack.GetTop(); }
void DrawFingers(MatrixStack &modelToCameraStack) { //Draw left finger modelToCameraStack.Push(); modelToCameraStack.Translate(posLeftFinger); modelToCameraStack.RotateY(angFingerOpen); modelToCameraStack.Push(); modelToCameraStack.Translate(glm::vec3(0.0f, 0.0f, lenFinger / 2.0f)); modelToCameraStack.Scale(glm::vec3(widthFinger / 2.0f, widthFinger/ 2.0f, lenFinger / 2.0f)); glUniformMatrix4fv(modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelToCameraStack.Top())); glDrawElements(GL_TRIANGLES, ARRAY_COUNT(indexData), GL_UNSIGNED_SHORT, 0); modelToCameraStack.Pop(); { //Draw left lower finger modelToCameraStack.Push(); modelToCameraStack.Translate(glm::vec3(0.0f, 0.0f, lenFinger)); modelToCameraStack.RotateY(-angLowerFinger); modelToCameraStack.Push(); modelToCameraStack.Translate(glm::vec3(0.0f, 0.0f, lenFinger / 2.0f)); modelToCameraStack.Scale(glm::vec3(widthFinger / 2.0f, widthFinger/ 2.0f, lenFinger / 2.0f)); glUniformMatrix4fv(modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelToCameraStack.Top())); glDrawElements(GL_TRIANGLES, ARRAY_COUNT(indexData), GL_UNSIGNED_SHORT, 0); modelToCameraStack.Pop(); modelToCameraStack.Pop(); } modelToCameraStack.Pop(); //Draw right finger modelToCameraStack.Push(); modelToCameraStack.Translate(posRightFinger); modelToCameraStack.RotateY(-angFingerOpen); modelToCameraStack.Push(); modelToCameraStack.Translate(glm::vec3(0.0f, 0.0f, lenFinger / 2.0f)); modelToCameraStack.Scale(glm::vec3(widthFinger / 2.0f, widthFinger/ 2.0f, lenFinger / 2.0f)); glUniformMatrix4fv(modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelToCameraStack.Top())); glDrawElements(GL_TRIANGLES, ARRAY_COUNT(indexData), GL_UNSIGNED_SHORT, 0); modelToCameraStack.Pop(); { //Draw right lower finger modelToCameraStack.Push(); modelToCameraStack.Translate(glm::vec3(0.0f, 0.0f, lenFinger)); modelToCameraStack.RotateY(angLowerFinger); modelToCameraStack.Push(); modelToCameraStack.Translate(glm::vec3(0.0f, 0.0f, lenFinger / 2.0f)); modelToCameraStack.Scale(glm::vec3(widthFinger / 2.0f, widthFinger/ 2.0f, lenFinger / 2.0f)); glUniformMatrix4fv(modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelToCameraStack.Top())); glDrawElements(GL_TRIANGLES, ARRAY_COUNT(indexData), GL_UNSIGNED_SHORT, 0); modelToCameraStack.Pop(); modelToCameraStack.Pop(); } modelToCameraStack.Pop(); }
void Draw() { MatrixStack modelToCameraStack; glUseProgram(theProgram); glBindVertexArray(vao); modelToCameraStack.Translate(posBase); modelToCameraStack.RotateY(angBase); //Draw left base. { modelToCameraStack.Push(); modelToCameraStack.Translate(posBaseLeft); modelToCameraStack.Scale(glm::vec3(1.0f, 1.0f, scaleBaseZ)); glUniformMatrix4fv(modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelToCameraStack.Top())); glDrawElements(GL_TRIANGLES, ARRAY_COUNT(indexData), GL_UNSIGNED_SHORT, 0); modelToCameraStack.Pop(); } //Draw right base. { modelToCameraStack.Push(); modelToCameraStack.Translate(posBaseRight); modelToCameraStack.Scale(glm::vec3(1.0f, 1.0f, scaleBaseZ)); glUniformMatrix4fv(modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelToCameraStack.Top())); glDrawElements(GL_TRIANGLES, ARRAY_COUNT(indexData), GL_UNSIGNED_SHORT, 0); modelToCameraStack.Pop(); } //Draw main arm. DrawUpperArm(modelToCameraStack); glBindVertexArray(0); glUseProgram(0); }