3D Graphics Projects

The History of Computer Graphics

Computers were used originally for crunching numbers but they could handle "vector graphics," which we know as pixel art. In the figure below, it takes hundreds of tiny squares (pixels) to fool our mind into thinking it's a face.


The Utah Teapot

Then processors got advanced enough in the 1970s to be able to store a bunch of points in 3D models. A team at the University of Utah created a 3D figure of a teapot and released the list of points publicly so other computer programmers could create the same image. This became known as "The Utah Teapot," a kind of in-joke in computer graphics.



The Math Behind 3D Graphics

The question we looked into before starting any actual graphics programming was "How do 3D graphics look so real?" It actually requires some complicated mathematics to get 3D shapes to look real on a 2D surface. Here's a figure representing the "viewing frustum" and camera position of a 3D environment:



To project a 3D object onto a 2D surface was a centuries-old problem for artists and mathematicians. It was in the field of cartography (mapmaking) that the complicated mathematics now known as "Projective Geometry" was worked out. In the figure below, the 3D sphere of the Earth is projected onto different 2D shapes such as a cone and a cylinder.

Graphics in Python

It's very complicated to program 3D figures on the screen, but over the years people have written "Graphics Libraries" to simplify the process. To use a graphics library like OpenGL it used to be necessary to program in C or C++, but somebody wrote a package called PyOpenGL so you can interact with the Graphics Library using Python. Here's a tutorial on making a simple rotating cube using Pygame and PyOpenGL.



Like with the Utah Teapot, you have to tell the program the location of every point ("vertex") on your object. Luckily there are only 8 points ("vertices") on a cube. The video then shows how to declare segments ("edges") between the vertices and finally the square faces, the flat surfaces defined by four edges.

Rendering

Rendering is the process of generating an image. A 3D scene in a computer is made of objects only. Colors, textures, shading information are all stored as properties of the object. The rendering program gives the objects their final appearance. To make rendering look realistic, it's important to have an understanding of the physics of light (Optics) and human perception.

Alice

We learned how to create 3D worlds in a program called Alice. You drag and drop code like in Scratch, but you can zoom in and out or make the "camera" move throughout the scene.

Classes

I found out that the angel I used in my Alice world is only an instance of the Class "Angel."

Island Scene

I made an ocean scene which opened with a shot from a canoe:

Then the camera panned around and zoomed in to an island where the goddess Pele was hanging out:

School Scene

You'll have to take my word for it, because Alice froze up and that file wouldn't work again! So I created a high school scene with a jock, a girl and a cheerleader:

Then I set the camera to follow the jock's POV (point of view) and walked him around:

I needed a forever loop to make the camera stay with the jock. Otherwise it would have gone to his POV once and if he moved the camera would stay there. Good thing Alice has a "While true" conditional block that is always true:

Home

Camera Angles

Next I learned to use "dummy objects" to save the position of the camera when we wanted to change camera angles. For example, we can start at a certain angle, in front of our characters:

Then we can move to another angle.

Then click "add dummy object at camera" to save that camera angle:

Then you have to add this to your code:

Sketchup

On Wednesday we learned how to create 3D worlds in a program called Sketchup. You draw rectangles and pull them out to form boxes and buildings.

First Shed

This is how a Sketchup file opens, with the three axes and a person there for perspective

Then I drew a rectangle, pulled it out to form a box, pulled up the roof and added a door and window.

The Utah Teapot

At the Computer History Museum, we saw an exhibit on 3D graphics featuring a teapot that held a place in the evolution of computer graphics. The "Utah Teapot" was modeled and copied by graphical programmers to test their software and their skills.

I tried to create a teapot in Sketchup, but it's not as simple as it looks! The Follow-Me tool was useful for making spheres and cones by extending a solid along a line or curve. The first teapot wasn't very good.

So I watched a few video tutorials on Sketchup and my second try was much better!

I used the "Follow Me" Tool to make a circle follow an arc to create the teapot's handle.

Visual Python

Visual Python is a graphics library that lets you put 3D objects on the screen and move them around using Python. I made an ice cream cone using a cone and two spheres:



The Return of the Rotating Cube

On Monday we made a rotating cube in Visual Python. The only hard part was keeping the x,y, and z coordinates straight.



I made a square like this:



Then I just added more cylinders and rotated them.

Here's an animated gif of the cube I did first:



Home