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.

Saturday, February 7, 2009

Project Proposal

As far as projects go, trying to recreate and enhance this particle sphere would be interesting to undertake.

Particle Sphere

There is a ton of opportunity to enhance what is seen here. For one thing, it would be possible to have the particles repelled from or drawn to the mouse, and they could travel at different speeds because of their acceleration to/from the mouse. The particles themselves could probably change dynamically to give the impression of movement other than around the sphere.

Thursday, February 5, 2009

Line Clipping Exercise

This program was an exercise in calculating, and clipping lines if they did not fall within a boundary box. The basic instructions for this program was to have the program randomly draw up to 5 triangles on the screen, and if they were not located inside of the box, they would be "clipped."
I decided that instead of merely just not drawing the portions outside of the boundary box, I would instead draw them in a monochrome color. This both shows how the original triangle was laid out, and what sections of the triangle are located outside of the box.

Click this link to use the program. Click on the screen to make it draw one triangle at a time.

The source code is located here.

Multi-Triangles Project

For this exercise, I was instructed to create an interactive program that allows a user to draw a single triangle by clicking on three points anywhere on the screen. After that, the program is supposed to draw up to 5 more triangles randomly across the screen. I intentionally set it that the new, randomly generated triangles appear one at a time per every mouse-click after the initial triangle is created.

Since the posting of my last entry, I have researched how to link to an executable .jar file, and will see about going back and adding links to the programs from previously.
Click this link to see this program in action.

The source code is located here.

Thursday, January 22, 2009

Bezier Curves assignment

This was an interesting assignment; we were assigned to redo our makeLine() method from a previous homework, so that it took a single parameter (t). From that, we had to make it draw a linear, quadratic, and cubic line.

Below are some animated screenshots of two different outputs that I experimented with. Below those pictures is my actual source code.
The program itself lets you click on the screen to select your points. I recommend clicking on the image to see a larger version of the picture, which also has a higher quality.
To access the application, click on this link and select yes when prompted to open the bezier.jar file.






The source code is located here

Monday, January 12, 2009

Web excersize

So, for this assignment, I needed to make a method to draw a line, without using a pre-made method to make a line. The only thing I had to make use of was the ability to change a single pixle given a coordinate. So, after making the line, I made the web in the bottom left corner. After that, I made the circle. The actual program itself flashes colors, and is seizure-enducing to watch. Upload the script to see for yourself! :P

Or, click this link to see what I'm talking about

Here's the screenshot.


The source code is located here

Thursday, January 8, 2009

First Assignment

Well, our first assignment was basically an introduction to a programming/sketching language called Processing which can be used to make simple graphics. Our actual assignment was to create a "simple but interesting and recognizable drawing" using Processing. So, here's what I was able to come up with. As of right now, this is only a screenshot and the source code.

Here's the program.


The source code is located here.

Wednesday, January 7, 2009

First Blog Post

Well, this is the start of a new blog, one that I will use to upload and share any work that I do for my CSC 370, Computer Graphics, class. Check back often to see what new and interesting things I've learned during the course.