Pages

Monday, August 29, 2011

Solid of revolution generator in C# with sources

This is a sample of a solid of revolution generator, it has some basics functions. Source code is very easy. Any question post it here. Here is the download link.

Tuesday, August 23, 2011

XNA battleship game


This is the classic battleship game written in XNA. Unfortunatelly I lost the last version when Megaupload closed, and this one is completed by 70%, but it can be played. In this game I cover a lot of 3D techniques that I have learned over the years. This is a ported version of my first game. The first version was with opengl and c++ builder and it was less complex. here are the download links, Anonymous comments are allowed.

Monday, August 22, 2011

3D plaza with openGL and c#


This is an example of a 3D plaza, The waving flag was a code I borrowed from NEHE tutorials. The shadows are on the texture, they were rendered on 3D max studio. The sky-box and the grass outside are not models, they are hard coded. Collisions are implemented in the easiest way. That means that I am working on defining a 2D segment and calculating the distance to that segment, if that number is bellow a number I define there is a collision and therefore the camera wont move on that direction. Sources are in MVS 2008, I am using TAO Framework  and a small engine I made myself called Shadowengine.

Here is a list of what you will learn if you download(and leave a comment) this sample
  1. A small approach to simple camera collision
  2. You will learn how to implemente a simple FPS camera and to combine it with the collision class
  3. You will have the working code of a waving flag to use it to your convenience
  4. You will have a sky-box to use in your personal projects
  5. You will get an idea of what opengl Quadrics are, the stick of the flag is a quadric.
  6. If you wish you will learn how to use mi small opengl-engine, I develop this engine to teach my students the basis of 3D programming
Any comments on the blog will be useful, anonymous comments are enabled. Also I will answer all the questions about this project.

Ten things to achieve when starting 3D programming

Ten things to achieve when starting 3D programming
Starting 3D programming it is not an easy task to accomplish. There are a lot of new things that come into to play, and they vary from choosing a programming language to selecting the correct 3D modeling software.
These are the stuff that when they are done, no matter in what language and with what rendering engine, you can consider yourself a semi-expert on this matter.

Wednesday, August 17, 2011

3d house with sources


In this example I have loaded a 3ds file. Shadows are pre-rendered on the texture, so they run fast on video cards.

Tuesday, August 16, 2011

delaunay triangulation example in c#


This is an example demo of a Delaunay triangulation, it was invented by Boris Delaunay and  is used for making hull surfaces from single points. The downloadable .rar also has a java implementation and other stuff to study. The algorithm has a high degree order and has a few bugs when there are many points. It can be added points dynamically and circles that make triangles can be drawn as well.
Any questions post it here. Anonymous comments are enabled. this is the download link

3D laberinth with opengl and c++ builder


This is a sample of a 3D laberinth with binary collision, fog and other stuff, here is the download link of the project, any questions, post it here

Monday, August 15, 2011

3d asteroid game in with sources

A basic 3D asteroid game in openGL with C#
This article is intended for beginners that want to start in 3d game programming and don’t know where to start. It is programmed in Opengl using VS 2008 and a small graphic engine I made myself called Shadowengine. It has the basics of what a game should have: a Score, levels of difficulty and a life counter. All this is written a small amount of code lines, trying to be simple and understandable.

The first problem I had to achieve is the scene to look like outer space, for that issue I set the background color to black. In opengl is set this way
Gl.glClearColor(0, 0, 0, 1);//red green blue alpha
The other problem were the stars and I solve it by drawing random white points on the screen, the algorithm is more or less this way I generate a random point and measure the distance to the spaceship, and is if is less than a predefined number I discard it and repeat the process until are creates the desired stars look at the code:
public void CreateStars(int cantidad)
        {
            Random r = new Random();
            int count = 0;
            while (count != cantidad)
            {
                Position p = default(Position);
                p.x = (r.Next(110)) * (float)Math.Pow(-1, r.Next());
                p.z = (r.Next(110)) * (float)Math.Pow(-1, r.Next());
                p.y = (r.Next(110)) * (float)Math.Pow(-1, r.Next());
                if (Math.Pow(Math.Pow(p.x, 2) + Math.Pow(p.y, 2) +
    Math.Pow(p.z, 2), 1 / 3f) > 15)
                {
                    stars.Add(p);
                    count++;
                }
            }
        }
The score is a number which increases over time and it grows faster everytime I pass a level. The level increases every 450 frames.
The last issue I had to adress is the problem of asteroid collision. I make for the ship three positions(one for th ship and two for the wings) and everytime in a while I check the distance between all the asteroid and those trhee positions. If is under a predefinde value I execute the collission event.
The project has 6 classes
AsteroidGenerator.cs It handles the creation of asteroids in random places and with random sizes and speeds. It also have the method to query wether or not  It have been a collision between the spaceship and an asteroid
Asteroid.cs It handles all concerning an asteroid such as the movement, texture selection, drawing, among others
Star.cs It has a method to create random white points and to draw them. 
Camera.cs It handles the selection of the user camera and to set the right perspective view of the scene
SpaceShip.cs This class contains all methods and attributes regarding the spaceship, such as movement, drawing, etc.
Controller.cs This class manages the game creation, game logic and contains all the classes needed to run the game. Here is a portion of code
using System;
using System.Collections.Generic;
using System.Text;

namespace Naves
{
    public class Controller
    {
        Camera camara = new Camera();
        Star star = new Star();
        SpaceShip spaceShip = new SpaceShip();
        public SpaceShip Nave
        {
            get { return spaceShip; }set { spaceShip = value; }
        }
        public Camera Camara
        {
            get { return camara; }
        }
        public void BeginGame()
        {
            AsteroidGenerator.GenerateAsteroid(35, false);
        }
        public void ResetGame()
        {
            AsteroidGenerator.GenerateAsteroid(35, true);
            spaceShip.Reiniciar(); 
        }
        public void CreateObjects()
        {
            star.CreateStars(450);
            spaceShip.Create(); 
            Asteroid.Crear(); 
        }
        public void DrawScene()
        {
            star.Draw();
            AsteroidGenerator.DrawAsteroids();
            spaceShip.Dibujar(); 
        }
    }
}
  
Main.cs This is the form wich contains this visual components of the game. It contains the controller class and give the player information throught proper windows controls. It has a timer to draw perodically the scene and has the code for texture and object loading.
If you want to add sound to the project uncomment the commented lines and press ctrl+alt+E and under managed debuggin asistants uncheck the loaderlock exceptionI am hoping to receive feedback from this example. , Anonymous comments are enabled.
Here is the download link
http://filebeam.com/4219ffee44dcabb93daa30c61109b91a

Friday, August 12, 2011

The difficulty of deploying 3D applications

I began to develop 3D application by fun. It was at the 3rd year of university. I friend of mine had a few examples and I began to learn how to get into this word. First I started with C++ builder 6.0 with open GL. This was great until I started with MVS 2008 and I realized that that was the future. When you make a c++ 3D app with opengl there are a lot of chances that It will go very slow, because Microsoft don't install the openGL driver by default,. so if you deploy your 3D openGL application in a PC with windows there a chance that It will not be what you wanted. At the beginning that was not a problem because everyone installed the video drivers of the manufactures, but nowadays with W7 normal people let the OS to install the video driver they got by default and of course they do not have OPENGL driver. Another issue is with platforms if that if you use glut32, your application wont run on 64 bit OS. You may say that opengl will be the future but with windows dominating 90 % of the market I don't think so. When I started programming opengl with visual studio there was the problem of the .NET framework, your PC had to have it in order to run your application so your app will not be click and run in all windows versions. Later when I started programming in XNA I was amazed how fast you could make a 3D app but then I saw that in order to use XNA you had to have .NET, XNA redistributable and pixel shader 1.0 so if you want to make apps for developing countries that was not an option, also there is the problem of the license. Today I am beginning to make some stuff with directX SDK and  is very promising, it only needs .NET in order to run. If this doesn't work i will start with Ogre or Irlicht.

Solar system in 3D with opengl and C#


Here is an example using opengl with C#, this example uses a random function for creating stars, also uses quadrics for the planets. Any questions post it here. Anonymous comments are enabled

Thursday, August 11, 2011

3D field with opengl and c#


Here is a virtual exploration of a field, it uses a billboarding technique for displaying trees and sheeps and a simple collision algorithm. It also uses a FPS camera and some transparency blendings. here is the link to the source code, any kind of suggestions are acepted.
http://fbe.am/qqz

3D factory with opengl and C#


This is a virtual exploration of a factory, it contains a FPS(First Person Shooter) camera and loads a 3DS file, shadows are on the texture, this project uses a simply engine I made myself called shadowengine, if you want the source code ask it here, note it doesn't work on 64 bit systems because of glut32.dll issues, here is the download link

car race in 3D with C#

Yesterday I was looking at the demo I published in my last article, the asteroid demo, it had a good acceptance because it was made in a very simple way and today I will do the same. This article is a simple straightforward car race game trying to contain the minimum amount of lines of code (LOC). There are 3 cars that begin in a start line, they random change their speeds on the race and the race ends on an end line, quite simple. The user can follow the race with the keys W(forward) S(backward)  and can change the camera takes. At the end of the race a message is shown telling which car was the winner and you are able to reset the race and start over again. The car race is a simulation and the user can’t take control over any car.
Any suggestions to the code let me know, here is the download link

3D chess in openGL with C#


In this chess I use a technique called picking, Ive copied and ported some NEHE C code. Pieces are in STL format. This chess only has bishop pieces, it is not intended to be a real chess game. I have all the models of the pieces, if you want them post it here, anonymous comments are enabled. Here is the download link: