Archive

Archive for December, 2010

Some unpublished projects…published

24/12/2010 1 comment

Well… I have a bunch of old projects that weren’t published for some reasons…It’s time for them to finally see the light đŸ™‚
Just a few notes:
-These are old, so many things are less professional than I would write now, many things have nothing to do with OOP…

-You’ll need the SFML dlls to run any SFML game.


Labyrinth Maze:

SFML, OpenGL, C++ (VisualStudoi2008)

Labyrinth Maze

Click on image to view animated full size version

A path finding application that finds a path in a 3D maze from one corner to the other..
The maze is generated randomly, can be moved, rotated, zoomed in/out with keyboard…
The console window contains more information..

Actually this application was Read more…

XNA Picking Tutorial Part III

16/12/2010 7 comments

Welcome to the third picking tutorial! đŸ˜€
1- Ray picking.
2- RTS style selection box (two approaches).
3- Projection and why you need it.

Introduction:

This tutorial is really short..It’s not actually about picking but somehow related to it, I wanted to write this in the same post as Part II but Part II was already long enough.. đŸ™‚

Another use for Viewport.Project:

In part II we used Viewport.Project to get the positions of 3D objects on the 2D screen, well.. that was useful for picking…Another excellent use of Viewport.Project is displaying 2D elements over 3D objects such as units names in a game or the health bar for example…

Generals Contruction Dozer

Read more…

XNA Picking Tutorial Part II

09/12/2010 4 comments

Introduction:

Hello & welcome to the second picking tutorial!
1- Ray picking.
2- RTS style selection box (two approaches).
3- Projection and why you need it.

In part I, I talked about picking single objects, In many cases such as RTS games that’s not enough…

You’ll need to select multiple units together using some sort of a rectangle or selection box that you make by clicking and dragging with your mouse.

Two approaches I know:
1- Unprojecting your selection box and check for collisions in 3D world space.
2- Projecting your 3D objects and perform simple 2D rectangle collision detection.

First approach, Unprojecting a rectangle ( A little tricky ) :

If you unproject a point the result should be a ray ( Part I discussed this issue in some detail) , If you unproject a rectangle the result depends on your projection matrix, We’ll assume it’s a perspective projection matrix, so the result of unprojecting a rectangle is a frustum (BoundingFrustum in XNA), in most cases this BoundingFrustum is not a scaled version of the view frustum, it’s some sort of irregular frustum, images are better than words:

SelectionFrustum

Click on image to see full size

Now how do we get this frustum? Read more…