3D Programming


Alice




This is what the Alice interface looks like:



While a different program, you use Alice in a similar ways in which you would use Scratch. The entire premise is to drag and drop blocks onto the bottom rectangle in order to make the hand selected characters or objects move a certain way.
Duke University has many Alice tutorial on one of their websites and I completed one with an astronaut and drivable humvee. To make this work, I needed to first put both an astronaut and humvee down into the scene so I could work with them.



One of the first things that the tutorial showed was how to make the astronaut wave his right arm. To do this I needed to make the right arm lift up, and move back and forth.
These are the blocks needed to do this:

This is just a simple wave, nothing too complicated.

The humvee and driving part was the fun part though. Using the arrow keys, the humvee could be maneuvered after a new event is created in the top right corner of the program.

After the wave and driving were done, you needed to get the astronaut to ride in the humvee and that could be done by telling the astronaut to move into the truck and stay there with the vehicle property.
The final code:

This is the compilement of all of the other small blocks of code into one neat pile that is activated by hitting the play button.

SketchUp


Not so much a programming based program, SketchUp is a program in which you can model objects in 3D.


Here is a little bird house made from a hollow rectangular prism and a roof


This is a small top hat shaped thing that I also made.


One of the challenges was to make a cone.

The way to make one is to make a triangle perpendicular to a smaller circle like this:


The next thing to do is use the "follow me" button to make the triangle wrap around, following the circle until it make a cone like this:


A second challenge using the "follow me" button is to make a full sphere.

To do this I made two intersecting circles like this:


Then using the "follow me" button the two circles can be made into a sphere like this:


Visual Python


On Thursday, the class used Vidle Python or Visual Idle python to make a bouncing ball and an earth rotating around the sun. Both of these were definitely challenging to accomplish because I had never done anything of the sort except the the time we made a sphere a while back.

The first step towards making a ball bounce was making the ball and the platform that it was going to bounce off of.



This is just the code for spawning the sphere and the rectangular prism and setting the size of both the objects. In these lines of code the color for both of the objects is also set, the sphere being orange and the floor being blue. I later on changed them both so in upcoming screen shots they will be different then what they are here. The next thing was to add more walls and make the ball bounce back and forth between them. I added two walls on each side so the ball would be contained in them and keep bouncing until the bounce was killed off by the simulated gravity.



Here is the code for the final bouncing program:



From the top down to where it says "while True" is where the look of objects, starting velocity, and gravity rule are held. From there down it is the actual code that is carried out when the module is run. This includes the condition statements that tell the ball to bounce when it gets close enough to x=0 or close to either of the sides. Without these the ball would not bounce but instead just go straight through the floor and walls and not bounce at all.

The next part of the day was dedicated to making a sphere orbit around another sphere like the Earth orbits around the sun.
Much like the bouncing ball program, the first step towards making one sphere rotate round another was to actually make the spheres. This is the code for the design of the earth sphere and the sun sphere:



Note that the size of the Earth sphere and the Sun sphere are nowhere near in proportion as they are in real life. This is because If I actually did make the Earth to Sun size ratio accurate, you could not see one when the other was in view.
The next and hardest part is getting the Earth to rotate around the sun. I had to adjust the value of the starting velocity of the Earth and the amount of gravity in effect. I never got the value exactly on the dot, but I get pretty close to making a perfect circle with the orbiting Earth. Here is a picture of the code in action:



Of course this was actually moving but motion can't exactly be captured very well with a single photo.
To make this work there was quite a bit of coding to be done. This is what it looks like collectively:



What I learned while using Visual Python is how to make a simulated gravity system, how to make and object appear as if it is bouncing, and how to make an object orbit.