Discussion3S16

From Immersive Visualization Lab Wiki
Revision as of 22:44, 11 April 2016 by Kyl063 (Talk | contribs)

Jump to: navigation, search

Contents

Overview

Week 3 discussion recap (04/11/16)

Slides: download here

Object Centering

We can't expect our objects to be centered when we first parse our .OBJ files. The bear obj we parsed for Project1 are good examples. What can we do if we want to center our objects? How may we go about this?

Well the first job would be to find the center of our object right? Let's go through how we might accomplish that.

The Koan of Finding Your Center

This is going to be a slight modification to our parsing code so that we can find where the minimum point and the maximum point lie in our .OBJ file.

  • Loop and parse every vertex in the .OBJ file.
  • Loop through the vertices to find the minX, minY, minZ and maxX, maxY, maxZ.
    • Hint: You would want to use infinity and negative infinity in some way.
  • Find the average: avgX, avgY, avgZ
  • Loop through all vertices and subtract avgX, avgY, avgZ from all coordinates.

Try and draw a simple non-centered 2d rectangle to visualize what this would look like. Do you see how this would center our object?

Here we looped through the list of vertices three times to center our object. Can we do better and reduce the number of iterations?

The Zen of Filling The Room

Once we've centered our object, we can scale our object. Our goal is to fit the object into a standard cube(a 2x2x2 cube, with all vertices in the range [-1,1]) so that all objects start from the same size.

Here's an idea of how we might go about this.

  • Find the longest dimension between the axes x, y, or z.
  • Loop through every vertex and scale them(divide) by the longest axis.

Again, try drawing a simple centered 2d non-unit rectangle to visualize what this would look like. Do you see the positions fitting in the range [-1,1]?

Faces

In project 1, we parsed vertices and normals. What other lines were there in .OBJ files?

OpenGL Buffer Objects

GLSL Structure