13.07.2015 Views

Mali GPU User Interface Engine Application Development Guide

Mali GPU User Interface Engine Application Development Guide

Mali GPU User Interface Engine Application Development Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Tutorial on Drawing 3D Shapes// scale the cube to 30% and move it right, up, and backmat4 wvpMatrix_cube = wvpMatrix *mat4::translation(12.0, 12.0, 12.0)* mat4::scale(0.3, 0.3, 0.30);context->setUniformMatrix("WORLD_VIEW_PROJECTION", wvpMatrix_cube);cube->draw();}while ( context->update() );5. Rebuild the project and run it. Figure 4-7 now shows a cube shape and a teapot:Figure 4-7 The lighting example with a cube and teapot6. Use the arrow keys to rotate the objects and the camera. Because both objects are in thesame world, they keep the same relationship and move together.7. Create separate world matrices for the objects shown in Example 4-30:Example 4-30 Independent worlds for the teapot and cube......// Set up the view, projection and world matrices and multiply them to get the// modelviewprojection and modelview matrices.mat4 view = mat4::lookAt(camPos, camTarget, upVector);mat4 proj = mat4::perspective(60.0f, 4.0f/3.0f, 1.0f, 500.0f);mat4 world_teapot = mat4::scale(0.7, 0.7, 0.7) *mat4::rotation(90.0f, vec3(0.0f, 0.0f, 1.0f));mat4 world_cube = mat4::scale(0.3, 0.3, 0.30) *mat4::rotation(50.0f, vec3(0.0f, 0.0f, 1.0f));mat4 wvpMatrix_teapot = proj * view * world_teapot;mat4 wvpMatrix_cube = proj * view * world_cube;8. Modify the code that rotates the world so that the left arrow moves the teapot and the rightarrow rotates the cube as shown in Example 4-31:Example 4-31 Independent worlds for the teapot and cube...// Rotate object or cameraif (keyboard->getSpecialKeyState(Keyboard::KEY_SPACE)){// rotate camera}}elseARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-23ID070710Non-Confidential - Draft - Beta

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!