Scene::Scene() { // Conceptual root object uses the index 0 objectBatch.used = 1; // Set root object world transform objectBatch.worldTransforms[Scene::Root] = Mat4x4f(); }
void PointLight::setupLight(unsigned int glLightId) { Transform & transform = *(object.getComponent<Transform>()); Mat4x4f localToWorld = Mat4x4f(transform.getLocalToWorld()); Vec4f position = localToWorld * Vec4f(0,0,0,1); GLfloat pos[] = { position[0], position[1], position[2], 1 }; glLightfv(glLightId, GL_POSITION, pos); GLfloat ambientLight[] = { 0.0f, 0.0f, 0.0f, 1.0f }; GLfloat diffuseLight[] = { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat specularLight[] = { 1.0f, 1.0f, 1.0f, 1.0f }; // Assign created components to GL_LIGHT_? glLightfv(glLightId, GL_AMBIENT, ambientLight); glLightfv(glLightId, GL_DIFFUSE, diffuseLight); glLightfv(glLightId, GL_SPECULAR, specularLight); }