Day 4 - OBJ From Code


Hello from Kansas State University Game Development Club,

Kansas State will be hosting our 5th annual Game Jam this upcoming February 8th-10th and we are looking for students from other universities who would be interested in coming to participate. Students participate for free and will have fun, food, and a great learning experience. Sign ups for our game jam and information can be found at:! If you would be able to pass the information on to students or relevant clubs, we would love to see students from as many universities as are able to come! If you or any students have questions, please let me know!

Thank you,

Nathan McClain

Junior | Computer Science President of Hack K-State | Engineering Ambassador Kansas State University 816.213.7180

See it

One of the first CGI created models seen in film that wasn't supposed to be thought of as computer generated model was in 1992's Stark Trek II: The Wrath of Khan. You can see it at the end of the trailer on YouTube.


Let's make something more interesting that a triangle from code. Let's make a sphere.

Let's start by making a circle out of the bottom lines of a series of triangles.

To do that, we'll need to review some trigonometry.

If we have a line with a given length that is rotated at a certain angle, we can find the x and y positions of the rotated end. The equations are as follows:

x = cos (angle) * length


y = sin(angle) * length

We may use the term radius instead of length. It means the same thing.


Remember that trig functions may expect radians or degrees. Generally, in code you are going to use radians, but always double check.

Code from class

Here is the code from class.

Here is the completed code with comments and minor bug fixes.

Graduate Students

Start looking at papers (or videos) of academic graphics papers. A great place to start looking is on this website that catalogs graphics papers. Look under the SIGGRAPH papers section.