Archive for the ‘Game Programming’ Category

Finally, my post after 3 months long. I’ve been really busy lately :(

Advertisements




Right now i’m experimenting with Kinect to animate a 3D model or model skinning by using Kinect. To calculate the joint orientation, first i need to obtain the three orthonormal axes (X, Y, and Z) and create Quaternion to change every bone orientation. By this way, the noise produces by Kinect can be reduced and character movement can look smoother and independent from position. Another advantage of using joint orientation, character movement isn’t depended to body posture and model scaling.

More info and source code: http://code.google.com/p/ogrekinect/

Hi, it’s been long time since my last post. I’ve just finished a project titled “Launch Launch Launch Saturn V”.  I made this using OGRE 3D and Bullet Physics. Oh yeah, if you want to look at the code you can get it from google code: http://code.google.com/p/azbullet/

To get ray intersect on worldGeometry is can be read here (http://www.ogre3d.org/tikiwiki/Intermediate+Tutorial+2&structure=Tutorials), but if Terrain or TerrainGroup is used, the code will be slightly different:

Ogre::Vector3 camPos = mCamera->getPosition();
Ogre::Terrain* pTerrain = mTerrainGroup->getTerrain(0, 0);
Ogre::Ray mouseRay(Ogre::Vector3(camPos.x, 5000.0f, camPos.z), Ogre::Vector3::NEGATIVE_UNIT_Y);
std::pair <bool, Ogre::Vector3> test;
test = pTerrain->rayIntersects(mouseRay, true, 0);

if (test.first)
{
    // do something
}

On the code above, instead RaySceneQUery, RayIntersect is used, a variable std::pair <bool, Ogre::Vector3> is used to store value of RayIntersects function, use test.fisrt to check if the Ray intersect with terrain, and test.second to get intersection point of Vector3.

This article is small tips that can be used to debug Ogre Project. By using this std::cout can be used.

Open your project Properties, then on Configuration Properties -> Linker -> System, change value of SubSystem to Console (/SUBSYSTEM:CONSOLE).

Then on your source code change

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )

to this

int main()

The last step, add #include<iostream>

Precompiled header is used to boost build time since an OGRE project will take quite long time when it is compiled. A complete tutorial to build precompiled header can be found here. But additional configurations will be needed when Visual Studio 2010 is used.

Right click project -> Properties -> Configuration -> All Configuration, C/C++ -> Precompiled Headers, the configurations will be like this :

Try to build the project and errors will appear:

Right click project (again) -> Configuration -> Active (Debug), C/C++ -> Command Line, add “-Zm134” to Additional Options.

In this article i want to share a simple way to use accelerometer on AIR SDK. Since we’re using AIR SDK, you can deploy your application in Anroid or IPhone. But the code that i want to share is actually intended to be deployed on Android (since i don’t have IPhone device) :p

First we need to import several libraries :

import flash.events.AccelerometerEvent;
import flash.sensors.Accelerometer;

This is the MovieClip that will be moved by accelerometer

private var haro:HaroSymbol;

An variable of accelerometer

private var accel:Accelerometer;

Two variables that will store tilt factor in x an y axis

private var targetX:Number = 0;
private var targetY:Number = 0;

(more…)

Developing Flash Application to run on smartphone such Android can be very interesting. My intention is to port my flash game into android platform and finally, after some configurations on my computer, i can create a simple flash application that runs in Android. Don’t expect much to my application, it  just displays images of android and air logo :)

Here’s the tools:

  1. AIR SDK
  2. Flex SDK
  3. Android SDK
  4. Flash Develop

Note: Thanks to Guave Studio Blog for creating Air Android AS3 template project :)

Region Growing Algorithm is one of pathfinding solutions and it is simple to implement.  For example,  in a game you have a map of two-dimensional-array and you want to move a character from start point to end point. The advantages if you use Region Growing are you don’t have to check every tiles and effective if your map is not perfect maze.

Here’s the preudocode :
1. Create a list of the four adjacent cells (right left up down), with a counter variable of the current element’s counter variable + 1
2. Check all cells in each list for the following two conditions:
– If the cell is a wall, remove it from the list
– If there is an element in the main list with the same coordinate and an equal or lower counter, remove it from the list
3. Add all remaining cells in the list to the end of the main list
4. Go to the next item in the list
5. Stop if :
– You find the goal
– All adjacent cells are invalid and you still can’t find the goal (impossible)
6. If you found the goal, track solution path in reversed way.

Here’s the example, a character (start) and a goal. the obstacles are trees (we will ignore them). In images below, we need 5 iterations before we find the goal, and once the goal is found, we’ll built the solution in reversed way ( starting from 5 to 0; 5-4-3-2-1-0 )

F# With XNA Game Studio

Posted: April 5, 2011 in F#, Game Programming, Programming, XNA
Tags: ,

xna_logo

I’m currenly trying how to create XNA game with F# and the result is quite interesting :)  This experiment  was using Windows 7 x64, .NET 4.0, and XNA Game Studio 4.0

First step is creating F# Application using Visual Studio 2010

Then in your project expoler add references to XNA 4.0 libraries

Write code below in your Program.fs

open System
open Microsoft.Xna.Framework
open Microsoft.Xna.Framework.Graphics
open Microsoft.Xna.Framework.Input

type Game1() as this =
    inherit Game()
    let graphics = new GraphicsDeviceManager(this)

    let mutable spriteBatch = null
    let mutable texture = null

    override Game.LoadContent() =
        spriteBatch <- new SpriteBatch(this.GraphicsDevice)

    override Game.Update gameTime =
        base.Update gameTime

    override Game.Draw gameTime =
        this.GraphicsDevice.Clear(Color.CornflowerBlue)
        base.Draw gameTime

let g = new Game1()
try g.Run()
finally g.Dispose()

Already finished? Here’s the result when you run the program :

And… the result is ugly weird blue window :) since code above is just basic of XNA implementation in F# :)