### Archive

Archive for August, 2010

## 3D Water Bodies

This is a simple XNA project that simulates an ocean…
The idea first came to me when I was practicing on creating terrain using heightmaps! I was playing with the vertices of the terrain, giving them some motion on the Y Axis then I said to my self: “Wow! This looks like the sea wavy water! :D”

The principle is simple! examine this very simple example:

I have 9 vertices forming 4 quads
I also have an array of 9 integers to determine the direction of each vertex : up/down
when first initializing the WaterBody, a random value between -n,n is assigned to the Y component of each vertex. so each vertex should start with a random Y component… The direction of each vertex is also generated randomly!

Now all I have to do – every frame – is to move each vertex in its direction, if Position.Y<-n or Position.Y>n then fix Position.Y and change the direction of the vertex ( if up make it down, if down make it up! pretty simple huh? π )

If you apply the above to a larger number of vertices ( I used 70×70 in my project ) you’ll have a nice wavy water!
Adding some lighting and texture will make things better ;).
Adding sound effects will make things even better! π π

Here’s the final result!

You can control several things in the application like enabling/disabling lighting and texture, changing camera position…
You can change the max wave height,wind speed and the application will automatically randomize theΒ  waves!

WaterBodies Executable ( 144 KB ) – XNA Redistributable 3.1 Required ONLY if you don’t have XNA Game Studio 3.1 installed
WaterBodies Source Code ( 183 KB ) – XNA Game Studio 3.1 Required

Revisions:

rev. 1 : Position,Rotation,Scale properties are now available! the WaterBody class is now more flexible than before!

rev. 2 : Updated camera class, now it’s a free look camera. Code now is more tidy..

## Hanoi Towers

Hanoi Towers is a game where the objective is to move all discs from tower A To tower C BUT there are two simple rules :

1. you can’t place a disc over a smaller one
2. you can only move one disc at a time!

The problem can be solved using a recursive algorithm..
Actually my college partner Hashem Al-Rifai and I programmed this simulation for our college algorithms project
We used C++,OpenGL and SFML ( what a mixture π )
The reason we used SFML is because it makes working with windows,input and sound much easier, it saves you the trouble you might run into when using only OpenGL :D…

Here’s our application:

You can rotate the scene,add more discs
Press Tab for fast animation!
You

You can add up to 18 dics π , you don’t wanna do that since it will take forever to solve! don’t you believe me? go ahead and try it π

Hanoi Simulation Executable – SFML and OpenGL Required Dlls are included

Hanoi Simulation Source Code – SFML and OpenGL headers and libs are NOT included

## Gokigen Naname

Gokigen Naname is a japanese puzzle where you have a grid…
some nodes on the grid has numbers from 0-4
each square on the grid should contain only on diagonal line
The number on each node (n for example) means that this node should have precisely (n) lines connected to it. the grid shouldn’t contain any closed loops!
For more details please refer to Wikipedia!

This “Game” solves the puzzle supplied by the user..so actually it’s not a game since the player won’t do the solving..

Click on any node with the left/right mouse button to increase/decrease its number…

The game is programmed using C++ and SFML
SFML is a powerful 2D Library but since C++ is a headache (at least for me :)) I prefer using XNA with C#
There’s also a .Net SFML library but I never tried it!

You’ll have to forgive me for a bug in my program π¦
When you want to change the value of a node, don’t click on the node! See the picture below

You have to click where the red circle is π¦ , The code is old now and as I said before C++ is annoying, that’s why I didn’t fix this problem and I wont!

Gokigen Naname Executable (718 KB) – Required SFML Dlls are included

Gokigen Naname Source Code (99.7 KB) – SFML Headers & Libs not included

Categories: Games Programming

## Spinning Rings

Some spinning rings π

It’s cool especially when you see the original size GIF!

For each ring I used a Torus and modified the properties Slice From,Slice To….And then rotated each ring!
Unfortunately DirectX Files (.x) doesn’t support the Slice From,Slice To properties for objects π¦

#### The Files :

Spinning Rings 3DS Max 9

Spinning Rings 150×150 GIF

Categories: 3DS Max Tags:

## 3D Coin

Here’s a simple 3D coin, 3DS Max 9 π

of course the 3DS Max image and the video are much cooler than the DirectX file because in max you can use the pump method to make the model look engraved when rendered… unfortunately! pump isn’t supported in .x files π¦ OR I don’t know how to use it!

Coin 3DS Max 9

Categories: 3DS Max Tags: