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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Tutorial on Drawing 3D Shapes...}if(targetNode)camTarget = targetNode->getAbsolutePosition();// Get camera FOVAttribute* fovAttribute = camNode->getCamera(0)->getAttribute("xfov");if(fovAttribute && fovAttribute->getComponentCount() == 1)fovAttribute->getValue(time, &camFov);// Get camera aspectAttribute* aspectAttribute = camNode->getCamera(0)->getAttribute("aspect");if(aspectAttribute && aspectAttribute->getComponentCount() == 1)aspectAttribute->getValue(time, &camAspect);context->setUniform("CAMERA_POSITION", 3, 1, camPos);// Terminate on pressing key ESCAPEif(keyboard->getSpecialKeyState(Keyboard::KEY_ESCAPE))break;5. Example 4-56 shows the part of the draw loop that modifies the lighting:Example 4-56 Modifying the lighting...// For each lightfor(int i = 0; i < 3; i++){LightAsset* light = (LightAsset*)scene->getAsset(Asset::TYPE_LIGHT, i);if (light){Array nodes;scene->findAssetNodes(light, scene->getTree(0), nodes);NodeAsset* lightNode = nodes[0]->data;if (lightNode){vec3 lightPos = lightNode->getAbsolutePosition();char buffer[255];// Get and set attributes for light:for(unsigned int j = 0; j < light->getAttributeCount(); j++){// Check for the color attributeAttribute* attr = light->getAttribute(j);if(attr->name == "color"){float values[3];attr->getValue(time, values);sprintf(buffer, "LIGHT_COLOR[%i]", i);context->setUniform(buffer, 3, 1, values);}// Check for the far attenuation start attributeelse if(attr->name == "far_attenuation_start"){float value;attr->getValue(time, &value);sprintf(buffer, "LIGHT_FAR_ATTENUATION_START[%i]", i);context->setUniform(buffer, value);}// Check for the fat attenuation end attributeARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-44ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!