Wednesday, May 6, 2009

Project 3: Boids, flocking, and colorful boxes!

So, for Project 3, I chose to implement Boids. Basically, the program implements the three rules of flocking behavior in 3-dimensional space. If one boid is near another, it will start to follow it, kind of like a herd. This program is based off of the algorithm developed by Craig Reynolds, .

Before I go into detail about how I undertook this project, here is the end result:
click me!


Now that you have all been thoroughly "wowed" by the flying boxes...
I first started by reading up everything that I could find about boids on Wikipedia. After putting together a rough setup of the program based off of Conrad Parker's psuedocode, I also read up on how to implement 3D in Processing. While the math seemed right, I still had issues actually getting it to display anything in the environment... So I referenced a Processing-based example that showed how to implement boids in 2D which helped me iron-out many of the issues I was left with. Bull-headed persistance and experimentation helped me develope the environment-wrap. After seeing what some of the other students had done for their projects, I decided mine was in dire need of spicing up... So, I added the color changing feature, just to make it stand out from the sea of other uncolored boids. While designing it, I implemented OpenGL graphics processing to display the boxes, and, unfortunately, that does not export as a clean, self-contained application. So instead of using OpenGL to provide you with what you see when you launch my boids application, I used Processing's 3D graphics generator, P3D; which for some reason, does some strange stuff to the boids as they fly off of the screen in the Z-axis.

Monday, April 6, 2009

Project 2: OpenGL OBJ reader

For this project, I had to implement a way of reading an .obj file into a window and displaying it's contents. An .obj file is basically a text document that has either a v (for vertex) followed by 3 values (an x, a y, and a z coordinates).

Below is a screenshot of the project on my desktop:

Tuesday, March 24, 2009

More homework for classwork

This week, my instructor had to take another leave of absence, and in his place he left us a few exercises. First, I was instructed to explore some OpenGL code examples, and just submit proof that I got the files running on my computer. Click on the following picture for a larger view of the screenshot I took of the simple reshaping program he provided us:




The next assignment was to alter or make some of code of my own that generates something that is rotated when the arrow keys of a keyboard are pressed. What I did, basically, was take some code from an example that drew a quarter of a wireframe globe and changed it so that it would instead draw the entire globe. I then added the functionality of it rotating on keypresses by referencing a previous example that demonstrated such functionality. After satisfying all my instructor's pre-requisits, I decided to go ahead and make it feel more my own, so I changed the color of the globe from white to red with a simple alteration of the code.
Click this link to run an executable file of what I made to see the effects yourself.

Monday, March 16, 2009

Homework to cover the classwork

The Friday before Spring Break, my instructor cancelled class and left a bit of homework to work on so we wouldn't miss him TOO much. Basically, he left several articles to read and comment on, and a few short OpenGL code exercises.

As for the articles, they were about OpenGL (a language that speaks to graphics cards across all computer platforms, be it a Windows, Linux or Mac box)some of the interesting applications of it, and some specifics of implementing it through coding in Processing and Python.

I think it's awesome how OpenGL is used in anything that makes use of a graphics card. It surprised me to learn that from cell phones to super computers to even gaming consoles, they all implement OpenGL in order to render the graphics for display. 2D or 3D alike, OpenGL can handle it all. It really does sound like the silver-bullet of computer graphics.
It can also be implemented with any programming language. The examples in the articles refer to use in either Processing, Python, or even C/C++. I'm kind of impressed that one single language can be implemented so genericly across multiple languages. I suppose that the languages themselves do deviate on how they implement certain aspects of OpenGL, but still, it's impressive to imagine completely different languages communicating so flawlessly with each other.
But the best part is that OpenGL is open source, which means that extensions are constantly being developed by individual programmers, and popular extensions actually become part of the code included in the entire OpenGL language. Evolution comes to it naturally.

Here's the first of two exercises: We had to download Dev C++, and compile a few pre-made programs from our book. After that, we had to altar the code so that it would draw a Bezier Curve (See Bezier Curves assignment below) instead of the default circle. Below is a screenshot of my computer while running the modified version of that code. In the background of the screenshot is the alterations that I made to the original code.





Tuesday, March 3, 2009

Project 1: Shrinking Circles

For project number 1, I decided to attempt to recreate Anthony Mattox's Cell Cluster Cirlces. Below are some screenshots of the pre-colored production process; As always, click on the pictures to see a full-sized version.




Here's what I came up with in terms of mimicing Mr. Mattox's design
Oddly enough, this is the color scheme that took me the longest to figure out how to calculate.



Here are some of the interesting color schemes I was able to come up with through assigning color values to circles based on their location.




These two schemes have got to be my personal favorites.




Now that I have displayed the screenshots I have taken of my program, I am going to provide a link so that anyone who feels like playing with it themselves can have that opportunity.
As a side note, be sure to experiment with pressing the mouse button in the application screen, as well as pressing buttons 1-4 to switch between the previously shown color schemes. And enjoy!

Sunday, February 15, 2009

Interesting Picture exercise

For the second part of the assignment, I had to make an interesting looking picture using various built-in transformation methods, as well as pushMatrix and popMatrix.
Below is a screenshot of the picture my project makes.



The source code is located here

Saturday, February 14, 2009

Transformation Matrices

For this assignment, we were to create our own functions to perform rotation and translation on values stored in a matrix. My program waits for a user to input 3 points on the screen by clicking on any location. Once the three points have been input, the user may hit Enter/Return to make the program show the steps it takes in rotating the triangle.


Basically, the initial triangle (the TAN colored one) is translated to the origin (that is drawn as the RED triangle). It is then rotated correctly (that is the GREEN triangle) and then translated back to the location of the original triangle (which is the BLUE triangle

But... That is not the only thing this program does. Should the user click the screen more than the initial three times, the program will do some pretty interesting stuff. You can try it out yourself here.
Please note that if you press the DELETE button, you can reset the screen and create a new masterpiece.

The source code is located here.