Exemplo n.º 1
0
    void DrawWrist(MatrixStack &modelToCameraStack)
    {
        modelToCameraStack.Push();
        modelToCameraStack.Translate(posWrist);
        modelToCameraStack.RotateZ(angWristRoll);
        modelToCameraStack.RotateX(angWristPitch);

        modelToCameraStack.Push();
        modelToCameraStack.Scale(glm::vec3(widthWrist / 2.0f, widthWrist/ 2.0f, lenWrist / 2.0f));
        glUniformMatrix4fv(modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelToCameraStack.Top()));
        glDrawElements(GL_TRIANGLES, ARRAY_COUNT(indexData), GL_UNSIGNED_SHORT, 0);
        modelToCameraStack.Pop();

        DrawFingers(modelToCameraStack);

        modelToCameraStack.Pop();
    }
Exemplo n.º 2
0
    void DrawLowerArm(MatrixStack &modelToCameraStack)
    {
        modelToCameraStack.Push();
        modelToCameraStack.Translate(posLowerArm);
        modelToCameraStack.RotateX(angLowerArm);

        modelToCameraStack.Push();
        modelToCameraStack.Translate(glm::vec3(0.0f, 0.0f, lenLowerArm / 2.0f));
        modelToCameraStack.Scale(glm::vec3(widthLowerArm / 2.0f, widthLowerArm / 2.0f, lenLowerArm / 2.0f));
        glUniformMatrix4fv(modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelToCameraStack.Top()));
        glDrawElements(GL_TRIANGLES, ARRAY_COUNT(indexData), GL_UNSIGNED_SHORT, 0);
        modelToCameraStack.Pop();

        DrawWrist(modelToCameraStack);

        modelToCameraStack.Pop();
    }
Exemplo n.º 3
0
    void DrawUpperArm(MatrixStack &modelToCameraStack)
    {
        modelToCameraStack.Push();
        modelToCameraStack.RotateX(angUpperArm);

        {
            modelToCameraStack.Push();
            modelToCameraStack.Translate(glm::vec3(0.0f, 0.0f, (sizeUpperArm / 2.0f) - 1.0f));
            modelToCameraStack.Scale(glm::vec3(1.0f, 1.0f, sizeUpperArm / 2.0f));
            glUniformMatrix4fv(modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelToCameraStack.Top()));
            glDrawElements(GL_TRIANGLES, ARRAY_COUNT(indexData), GL_UNSIGNED_SHORT, 0);
            modelToCameraStack.Pop();
        }

        DrawLowerArm(modelToCameraStack);

        modelToCameraStack.Pop();
    }
Exemplo n.º 4
0
void GeometryTest::MatrixStackTest()
{
    MatrixStack matrixStack;
    CPPUNIT_ASSERT(matrixStack.stack.size() == 1);
    
    Matrix4f m1;
    m1 << 1.0f, 0.0f, 0.0f, 4.0f,
          0.0f, 1.0f, 0.0f, 4.0f,
          0.0f, 0.0f, 1.0f, 0.0f,
          0.0f, 0.0f, 0.0f, 1.0f;
    Matrix4f m2;
    m2 << 1.0f, 0.0f, 0.0f, 5.0f,
          0.0f, 1.0f, 0.0f, 5.0f,
          0.0f, 0.0f, 1.0f, 0.0f,
          0.0f, 0.0f, 0.0f, 1.0f;

    matrixStack.Push(m1);
    CPPUNIT_ASSERT(matrixStack.stack.size() == 2);
    CPPUNIT_ASSERT(matrixStack.GetTop() == m1);

    matrixStack.Push(m2);
    CPPUNIT_ASSERT(matrixStack.stack.size() == 3);
    CPPUNIT_ASSERT(matrixStack.GetTop() == m2);

    matrixStack.Push(m1);
    CPPUNIT_ASSERT(matrixStack.stack.size() == 4);
    CPPUNIT_ASSERT(matrixStack.GetTop() == m1);

    matrixStack.MultiplyWithTop(m2);
    CPPUNIT_ASSERT(matrixStack.stack.size() == 4);
    CPPUNIT_ASSERT(matrixStack.GetTop() == (m1 * m2));

    matrixStack.Pop();
    CPPUNIT_ASSERT(matrixStack.stack.size() == 3);

    matrixStack.Pop();
    CPPUNIT_ASSERT(matrixStack.stack.size() == 2);

    matrixStack.Pop();
    CPPUNIT_ASSERT(matrixStack.stack.size() == 1);

    matrixStack.Pop();
    CPPUNIT_ASSERT(matrixStack.stack.size() == 0);
}
Exemplo n.º 5
0
    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);
    }
Exemplo n.º 6
0
	/* Draw instances */
	void Map::Draw(MatrixStack& matrixStack, GLuint uniformLocation) const {
		GLfloat cubeSize = Cube::m_size;
		matrixStack.Push();
			matrixStack.Scale(glm::vec3(cubeSize));
			glUniformMatrix4fv(uniformLocation, 1, GL_FALSE, glm::value_ptr(matrixStack.Top()));
		matrixStack.Pop();
		
		for(size_t i=0; i<m_instanceDatas.size(); ++i) {
			glBindTexture(GL_TEXTURE_2D,std::get<1>(m_instanceDatas[i]));
			glBindVertexArray(std::get<0>(m_instanceDatas[i]));
			glDrawArraysInstanced(GL_TRIANGLES, 0, Cube::m_tmpNbVertices, std::get<2>(m_instanceDatas[i]));
			glBindVertexArray(0);
			glBindTexture(GL_TEXTURE_2D,0);
			//std::cout << "instance["<<i<<"] = " << std::get<2>(instanceDatas[i]);
		}
	}
Exemplo n.º 7
0
    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();
    }
Exemplo n.º 8
0
void RageDisplay::CameraPopMatrix()
{
	g_ProjectionStack.Pop();
	g_ViewStack.Pop();
}
Exemplo n.º 9
0
void RageDisplay::TexturePopMatrix() 
{ 
	g_TextureStack.Pop();
}
Exemplo n.º 10
0
void RageDisplay::PopMatrix() 
{ 
	g_WorldStack.Pop();
}