Monday, April 21, 2014

Wind Energy - An animation

I presume this is the landing page of my blog. I am showcasing a project on wind energy. After that i have given links to a large set of projects with comments on each project and how it would be useful to you.
Wind mills have blades which rotate clockwise or anti-clockwise based on mouse input(menus). If you choose no wind the rotors stop turning. Electricity generated lights up the villages and homes can be seen glowing.
Snaps:




Here is the source for this project.

I have made an attempt to encourage bright students of CS branch of VTU to venture into a project solo. If you have not yet enrolled for CS branch but would do so in future or not yet into sixth semester where you will need to demonstrate your skills, consider yourself lucky to have visited this blog. Here you can learn a lot and I hope you have a lot of time for that. Bookmark this blog and I promise you will not return empty handed.
To repeat what I mentioned elsewhere, these student projects run in eclipse under Ubuntu platform. I am not sure that they will run in windows(may be a little tweaking here and there is needed). The files have been made public, so anyone on the net can find them and download. It is heartening to see the number of page views of this blog increasing tremendously. It gives me a lot of satisfaction to impact so many budding developers. My goal is to inspire the student community to take interest in their subjects and inspire confidence, they too can do projects on their own. Take some interest in having a look at the code of all these projects. I call it a cursory code inspection. I know you cannot understand all that you read. I know its an awful experience similar to reading greek and latin. But it gives you experience of going through other people's code and appreciating the work of art. With practical experience and after considerable coding yourself you will outgrow this blog I am sure.
Once you click and open in a new tab the source link of each project, you can have a look at the code. Don't postpone code inspection. If you download and keep for future reference you will never have the time to read. I am observing several sites have sprung up with a lot of projects and some language and sentences of mine. I cannot object to that but they cannot take out my passion towards the subject nor my ability to write on it.

Only 1-3% of these projects are my own. Several of them students own creation and many downloaded from elsewhere on the internet. Look at all the posts with a view to create something of your own.

You can borrow pieces of code from a project and use it in your own. I call it code transplantation. Most of these projects are non-object oriented and don't support code reuse. You need to be a surgeon(much higher difficulty than reuse of OO code). You need to know where to paste a particular piece of code(copy), what to modify and what to delete(cut). Only if you attain proficiency in understanding the code would you be able to do these things. The flowing fountain and the particles project have objects moving in a parabolic path. Shadow fun has a light source in simple harmonic motion(It is a sine wave) and has code which draws shadows. Robot movement has code which can be used to walk a human model. Many of the projects have code to use the mouse like the trackball to rotate the scene. Water ripples has code which draws waves on a water surface. Ray tracing has code which maps a scene image onto the sphere as a texture. Multi mirror has code to get mirror images of scenes. I have come across texture mapping in several of the projects. Fractals has breathtaking views of higher dimensional objects such as the mandelbrot set.

There are several projects on cars. You have the tata sumo type of car. The formula one racer type of car. An ambassador type of car. Only a top view(2D) type of car. You can use code from such projects. Believe me you, will get real advantage of reusing this code. In Jumping Dino there is code to update the orientation of the car or any object. It is simple trigonometry. There is code to draw trees in many projects esp the one on sea view. A realistic tree can be drawn using fractal techniques. I have written this JOGL program to use L-System for drawing a tree. Hope to make several changes to make it look realistic. There is code to draw a bus in one of the projects. The project on pac man has interesting code to move the devil which attacks the pac-man or runs away from it. The tic tac toe game played against the computer has code to make a move(best possible). I wanted something similar for the chess game. If someone could work out the code for making a move in the chess game it would be really great. Even some code to solve a given Rubik cube could be a really great achievement. You could get ready made code for such tasks and probably integrate into your project to draw the display.

Many of the techniques that are implemented in these projects are not that easy to understand.
Yes, Just like how complex mathematics is difficult to understand even programs making use of such mathematics are difficult to understand. To try and explain the water waves project has taken me to mathematics of wave equations.

So starting from my next post I would hopefully delve into specific programming techniques and insights that are shared by professional animators. Someday I wish I would write a game engine. Learning DirectX... Maya... and many more things are in the pipeline(dreaming). Its been a long time since I updated this page. My new goals are to learn to make use of existing game engines and not to reinvent the wheel. Also top on the wish list is learning to use Unity to make games. I have now got fair bit of exposure to Blender 3D.

I often advise students not to waste time playing video games. I appeal to the sadist(sic) in everyone and say them to write games that other people would waste their time on, so that you can steal a march. After all what happens when you play a game is just change in contents of bits in the memory. Nothing productive would ever come out of playing a video game. Read my personal experience of playing video games in the post if you have time (Indian audience would appreciate this more):- One rupee taught me a very big lesson.

Tower of Hanoi - An Animation

Tower of Hanoi a very popular program in computer science. Its working is demonstrated in this animation. The number of disks is the input. Then the disks move from one tower to the other and finally to the destination tower.

Snapshots:






The disks of different size are barely visible(at the bottom) in the snaps.

Here is the source.

Taj Mahal - A 3D view of the Taj

A few ellipsoids form the minars and polygons form the walls of the taj mahal. There is a gumbaz which is a part of the sphere. You can view a wireframe of the scene also by using right mouse button.

Snaps:


Here is the source.

Smileys - An animation

A round circular face with smiley type expressions of smile, sad, surprise and laugh which can be changed by a pop up which appears on right click. The smiling face rotates about the y axis.

This is a very simple project and can be implemented by the student on his own.

Snaps:





Here is the source.
On request i am posting the same file with comments here.
The modification that can be done is the face could be made to
1) rotate along x axis instead of y axis.
2) It is very difficult to rotate it along z axis as the eyes nose etc have to also rotate.
3) The face could be replaced with a hexagon.
4) There is flicker while rotation, it can be reduced somehow. Just don't understand what is causing it.

On another request i have modified slightly the code and now the background can be changed by the menu on right click. Smiley face is moving too. Here it is.

Shadow Fun - An animation

There is a light source in simple harmonic motion. There are two rings(torus) which rotate in an undefined axis. The moving light casts a shadow of the rings in the scene on to the walls which are texture mapped. Interesting project to learn and understand.

Snaps:





Here is the source.

Rings - An animation

As the name suggests three rings revolve one over the other and over an inverted cone. This is inside three large brown rings which themselves revolve over each other. The screen zooms out from the inner rings to the outer rings.

Snaps:







Here is the source.

Friday, April 11, 2014

Rigid Body Transformations

Several objects can be drawn on screen and rotated or translated.

Snapshots:



Here is the source.

Ray Tracing

This cannot be expected from a student. A project of this complexity is beyond the understanding of even the teacher.

Snapshots:



Here is the source.

Phases of the day - Animation

This is a project by Sharath H K and it is his own creation.(atleast i believe so). The day changes to night and a moon appears. Street lights glow. A car keeps moving on the road.

Snapshots:







Here is the source.

Path Finding - A game

This is a game in which there is a bhool bhulaiya or a maze. A large point enters the maze from one side and should find the path to the exit.

Snapshots:








Here is the source.

Particle Movement

This is an animation of a few particles looking like ping pong balls getting generated on top of a sphere and falling off its surface into the ground below.

Snapshots:



Here is the source.

Overtaking - A car race

This is a project on a top view of a road in which cars move.

Snapshots:



Here is the source.

Newtons Apple

Mangoes keep falling from trees and a basket collects them. Points increase when a mango is collected. The basket can be moved left and right.

Snapshots:



Here is the source.

Moving Bus - Animation

There is a bus stop where the bus picks up a girl and moves her to the college gates.

The problem here is that after moving the bus to the parking lot it does not end the animation. We need to close the window manually.

Snapshots:





Here is the source.

Memory Blocks - A game

A memory game in which a few blocks have objects with different colors hidden behind. Move the focus on to an object and press enter to uncover it. As soon as you move to another block this uncovered block gets covered. You have to uncover two blocks with same object hidden behind to clear both the blocks. This is a time based game. Faster the board is cleared the higher the points.

Snapshots:




Here is the source.
I frankly did not know this game was so engrossing and useful. I played it now and completely cleared the screen. I scored somewhere around 245 points. On special request of someone I have reduced the number of blocks to 4*4 ie 16. The display of blocks is reduced by commenting out certain code for last column. I am sure all blocks cannot be cleared now(since some blocks in the last column will have pairs in visible blocks). Will need more time to programmatically do the same. The goal being to draw variable number of blocks ie 4*3, 4*4 or 4*5. Here is the source for the modification.

Ludo - A game

The games in these posts are quite rare and interspersed with a lot of animation projects.

This game is well known to children. Ludo is a four player game and players take turns to toss a dice and move their pieces.

Finally found time to go through the code myself and found some instructions/rules. Here they are:
RULES:
At the start of the game, the player's four pieces are placed in
the start area of their colour.
Players take it in turn to throw a single die. A player must first
 throw a six
 to be able to move a piece from the starting area onto the starting
 square.In each subsequent
 turn the player moves a piece forward 1 to 6 squares as indicated by
 the die.When a player
 throws a 6 the player may bring a new piece onto the starting square,
 or may choose to move a
 piece already in play.Any throw of a six results in another turn. If
 a player cannot make a
 valid move they must pass the die to the next player. If a player's
 piece lands on a square
 containing an opponent's piece, the opponent's piece is captured and
 returns to the starting
area.A piece may not land on a square that already contains a piece of
 the same colour(unless
 playing doubling rules). Once a piece has completed a circuit of the
 board it moves up the
 home column of its own colour. The player must throw the exact number
 to advance to the home
 square.The winner is the first player to get all four of their pieces
 onto the home square.
 
I just love these kind of instructions and rules. I am hunting for more
 games to play them for
 sometime and mainly to learn their strategies.
Snapshots:


Here is the source.

Killing Machine

In this project a gun shoots bullets, three at a time. It needs to be reloaded by pressing right mouse button. Left mouse button to shoot.

Snapshots:





Here is the source.

Graphics Editor

This is the standard graphics editor a project that students used to do earlier.

Snapshots:





Here is the source.

Fluid Filteration - An animation

A simple project in which some fluid flows in pipes and fills a pipeline in an industry. The scene changes by the slow motion of the camera around the scene. I admit i do not understand this project much. Probably a cross section of the pipes in which fluid flows might have conveyed a better understanding. You can modify this project to do that i guess.

Snapshots:

Here is the source.

Client Server Communication

This is a computer network related project a subject i am allergic to as already mentioned elsewhere. So no details.

Snapshots:


Here is the source.

3D Car - Animation

This is a simple view of a car. It can be moved front and back using arrow keys. A road can be made to appear optionally. The car can be driven and fog and night mode can be activated. The body of the car has been made using cubes and tire spokes using GL_QUADS.
You can download the code, compile and execute once and then comment out individual function calls/pieces of code in the display function to see their effect.

Snapshots:



Here is the source. In this project lighting and shading is used. Enhancements that could be done include getting the camera move or change position to get different views. Also you could put this car in the car racer project and get it go round a racing track.