3D Graphics

February 25th, 2014

In class today we started our unit on 3 dimensional graphics and animations using the Alice 2 Software created by Carnegie Mellon university.

This software is similar to Scratch in that you drag and drop "blocks" of code to form your program.

I wouldn't say Alice is my favorite programming software that we've used so far, simply because there are so many steps to do the smallest things and there aren't blocks for many of the things I wanted to do. Aside from that though, it was nice to do some "asthetic" sort of programming for a change.

1. My first program that I wrote using Alice was a program that had a chicken on a beach (yes I know, a very odd combination) that spun in circles and then rolled around.

To do this, I had to import whats called an "instance" of a class called chicken into my program in addition to an instance of the beach scene.

It was extremely frustrating at first because I lost my chicken in the ocean! It took me about 10 minutes of panning the screen to try to find it until I finally saw the "Get Good Look at Object" button.

Turns out, my chicken was drowning under the water :-(

Here's a picture of my chicken once I got it out of the water.

Here's a video of the chicken going through a program that I wrote. This was officially my first Alice program!

2. Since one of my other interests other than Computer Science is ballet, I wanted to write a program having a ballerina perform a series of steps.

In this program, I made the ballerina do a pirouette, or turn (in French). Here's how I did it...

I dragged and dropped this code for the ballerina and then I put this all into a command that I would call by pressing a letter key.

From here I ran the program, but as you will see, it didn't work EXACTLY like planned...

3. Finally, I used conditionals to control a 3D car.

To do this, I programmed each key I would use to do what I wanted when press. For example, when I pressed the up key, the car would move forward, etc.

This is a peek into my program...

This is what happened when I "played" it...

February 26th, 2014

Today we used a different 3D software called "Google Scetchup". Apparently, this software is often used by architects and is a free alternative to expensive 3D software.

I didn't really like this software because it was really hard to navigate and also everything that I did that I thought would be the answer to my problems actually made the problems worse. Not intuitive at all.

The key to making anything was keeping track of the axes. In all 3D programs, there is an X, Y, and Z axis. This is important when forming, editing, and rotating shapes the way you want them. Anyway, I managed to make a couple shapes and some of them were my original design :). Enjoy!

1. Sphere

I started out making a sphere, which was very confusing. I first made 2 2-D perpendicular circles. After this I used a tool called "Follow Me", which lets me guide the tool to cover a surface.

At first this was way harder than it seems. The circles were not of the same shape and size, so the final product turned out like this (a big crack)....

After a while of editing and testing different things, I finally made it look like this...

2. Smily Face

I came up with this shape using what I learned with the sphere shape.

First, I made one big circle as the face. After that, I made two spheres the way I did for the sphere shape that I stuck in the face for the eyes.

Next I drew a mouth with the arch and pen tools. To make the face and the mouth 3D, I used the lifting tool to lift them up.

For finishing touches, I colored the shapes and also smoothed out the face so it looked more like a real face. Unfortunately, it came out looking more like a cake than a face.

There was also something a little wrong with the pupils that I couldn't really figure out how to fix. When I tried, the entire eyeball would come with it...

3. Teacup

To make this, I used one cylinder and shrunk the bottom to look more like a cup.

From there I formed two circles on the side of the cup and used the arch tool to connect them. From there, I used the Follow Me tool to connect them.

This is the end product....

4. Last but definitely not least........... the Heart

This was my biggest achievement, not to mention my own original design.

The video will illustrate how I made it, but to explain it in words, I connected two circles and a triangle together to form somewhat of a heart. Then I used the move tool to adjust it to my liking. Finally, I used the lift tool to make it 3D and I colored it in using the paint bucket.

February 27th, 2014

Today was probably my favorite day out of the week so far because we programmed in Visual Python! This was really fun because we simulated real-life situations using our programs. It was also much easier to use for me than Alice and Scetchup.

These activities were directly linked to physics because it involved formulas for gravity and concepts thought of by Newton and other scientists.

We also used vectors to control the velocity and force of gravity acting on the objects.

Below are some details about the projects we did in class...

1. Bouncing Ball

In this project, we made a "ball" (really just a sphere) bounce on the screen. Gradually the ball bounces less and less because we defined gravitational force.

I also have a "floor" which is just a rectangular prism, but here it doesn't serve any purpose right now.

The video is below. What's going on is we have defined the velocity and gravity of the ball. We have told it to bounce in the opposite direction when it reaches a certain y value.

This is why you see the ball bouncing and not fall infinity.

2. Bouncing against a wall

This time, the rectangular prisms serve a bigger purpose. I added two more to the scene to create "walls".

From here, I told the ball to bounce off the wall in the other direction when it reaches a certain x point. I did this for both walls in addition to doing it for the floor.

This was challenging because I had to make sure the ball did not go through the walls and floor but also not freeze because the point I picked for the ball to stop was too high.

Often it would freeze and I didn't know what was going on, but then I figured it out and adjusted it to my liking.

First, here's a video of the problems I faced when I was first working with this.

Here is a video of when I got it to work finally...

3. Earth and Sun Simulation

To me, this one is the most fascinating and cool. I simulated the way the earth moves around the sun in the Solar System.

I liked this because like many other computer science projects, I was able to build on other projects that I did before, namely the bouncing ball.

I kept the gravity and velocity parts but I replaced the balls and walls with two balls, the earth and sun.

After that, I programmed the earth ball to make an ellipse around the sun and also rotate at the same time.

One of the things I'm most proud of is the lighting feature. To make the scene more realistic, I put what's called a "lamp" where the sun is and made it look like the light was coming from the sun.

So, when the earth moves around the sun, the light moves around the face of the earth accordingly.

Take a look!