Table of contents

Introduction

Design and implementation of a scene graph using OpenGL to render program features such as animation of objects, multiple light sources, and texture mapping.

2D Rendering of an application using OpenGL

Scene Graph

Phase 1

Phase 2

Add animation to the scene and introduce controls as described below.

For all the above, an appropriate scene graph is set up and manage all animations and rendering through traversal of the scene graph.

Phase 1 Implementation

No scene graph is used to implement the scene. The controls are as follows in the implementation of Phase-1.

2

3

-Once this light is turned off only the ambient color of the object is rendered. Otherwise the diffuse and specular color of the object is rendered. -Rotation of the scene can be done using the following keys which rotate in either of the x,y,z axes either in clockwise or anticlockwise direction. * I,J,O,K,P,L are the keys which help in rotation of the scene anticlockwise and clockwise in x,y,z axes respectively.

Phase 2 Implementation

  1. Scene Graph
    • A model graph node is created such that the position of the current model node would depend on the position of the parent model node.
    • Creating a dependency for each model with its parent through its local matrix and world matrix for each node.
    • The draw function of the root of the scene graph results in recursive function calls to the draw function of its children sending its current position as the parameters.
  2. Animation
    • Object ID is added to keep track of its motion in the scene or to procedurally animate it having less control over the object.
    • The draw function of a model uses \textbf{glfwGetTime()} as the variable to update the time elapsed of the scene graph node and update its position of itself according to the values.

4

In the above screenshot, all the lights are near the face of the model and they follow the models motion throughout the scene’s display.

In below two screenshots, a single light source is initialized in the world space which effects all the objects near to it. In this case the lights don’t follow the objects.

5

7

References