Content uploaded by Ahmad Hoirul Basori
Author content
All content in this area was uploaded by Ahmad Hoirul Basori on Nov 19, 2014
Content may be subject to copyright.
1
VIRTUAL REALITY GAME, GAME
ENGINE AND XNA FRAMEWORK
Ahmad Hoirul Basori, Abdullah Bade, Daut Daman,
Mohd Shahrizal Sunar
INTRODUCTION
Virtual reality (VR) has become the main consideration to simulate
real interaction into virtual environment. On the other hand, games
also hold important rules to handle military training, medical
systems and education known as Serious Game (Chen 2006). The
combination between virtual reality and game called Virtual
Reality Game (VRG) has given a new opportunity to merge
entertainment aspect with educational material (Virvou et al. 2006;
Rossou et al. 2004).
BACKGROUND
Capilla et al. (2004) classified the complexity of virtual reality into
several elements:
Using special hardware like: haptic device or head mounted
display devices, etc.
Complication of user interface and interaction
3D modeling
Collision, physics and deformation
Presence of user in virtual environment
2Ǧǣ
In addition, researchers on VR emphasize on game research
and development. Zyda (2005) defines serious game as
“serious game is competition of psychological, playing the
game using real rule that generated from human rules,
further more it also used for government or commercial
training, education, health, and public policy.…serious
game also use pedagogy to stimulate game instruction in
order to increase play experience”.
See Figure 1.1 for detail information.
Figure 1.1 The taxonomy of Serious Game (Zyda 2005)
Ǧǣ 3
Michael (2006) gives another definition for serious game,
“Serious game, game that educate, train and inform”
He focused on how games are able to transfer message and
influence the players with the game rules. Victor (2000) also stated
that virtual reality in the future needs to complement and
enhancement of image processing and realism.
GAME ENGINE AND XNA FRAMEWORK
Good quality of virtual reality game application should use game
engines to handle virtual reality elements such as collision
detection, physics and hardware communication. Currently, game
engines have advanced technology that can provide and facilitate
better visualization and communication between graphics
hardware, sound hardware and application (Marks 2007).Game
engines has already evolved and become more powerful and able
to handle all graphics and visualization computational process for
instance of loading highly complex primitive, terrain, constructions
of trees, stones, cloud, ocean, sky and loading thousand of textures.
Game engines are able to create a virtual reality game application
on desktop platform. Game engines like Torque, Half Life, Irrlicht,
even XNA Framework or DirectX Library have the facilities to
display 3D model from a variety of 3D file format.
A. Irrlicht
Irrlicht is an open source game engine built in C++
language (Figure 1.2). It is able to load several 3D model
like .3ds, .x, .md2 (quake file) and basic object file model
like .obj.
4Ǧǣ
Figure 1.2 SpecialFX sample (Screenshot from irrlicht game
engines).
The implementation of loading 3D models is shown in the
following fragment of the source code.
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
int main(){
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
//loading 3d model file(Quake File) from particular directory
device->getFileSystem()->addZipFileArchive("../../media/map-
20kdm2.pk3");
// The next Step is loading the mesh and play the animation inside the
mesh
scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* node = 0;
Ǧǣ 5
B. XNA Framework
XNA framework is a bundled library from Microsoft for
Xbox game platform which is generated from .Net
Compact framework 2.0. It has been launched on 2006 and
the current version is XNA 3.0 which is compatible with
Visual Studio .Net 2008. XNA is also free to be used as a
tool for developing virtual reality/game and serious game
application in Windows platform. XNA framework uses C#
programming language as a core language to develop an
application. Some of the included games are Racing Game,
Ship Game, Rocket Commander and etc (see Figure 1.3).
Figure 1.3 Game applications build using XNA Framework
(screenshot from http://creators.xna.com/en-
US/education/starterkits/)
6Ǧǣ
Unlike, Irrlicht XNA has a limitation on 3D models are
supported by XNA such as .fbx, .x, .md2 and collada file
format. The following code fragment can be used to load
and display 3D model on the screen.
Model myModel;
float aspectRatio;
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
myModel = Content.Load<Model>("Models\\ship");
aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;
}
Vector3 modelPosition = Vector3.Zero;
float modelRotation = 0.0f;
Vector3 cameraPosition = new Vector3(0.0f, 50.0f, 5000.0f);
protected override void Draw(GameTime gameTime)
{ graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
Matrix[] transforms = new Matrix[myModel.Bones.Count];
myModel.CopyAbsoluteBoneTransformsTo(transforms);
foreach (ModelMesh mesh in myModel.Meshes)
{
foreach (BasicEffect effect in mesh.Effects) {
effect.EnableDefaultLighting();
effect.World = transforms[mesh.ParentBone.Index] *
Matrix.CreateRotationY(modelRotation) *
Matrix.CreateTranslation(modelPosition);
effect.View = Matrix.CreateLookAt(cameraPosition, Vector3.Zero,
Vector3.Up);
effect.Projection =
Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
aspectRatio, 1.0f, 10000.0f);
}
mesh.Draw();
}
base.Draw(gameTime);
}
// Add this code to update method
modelRotation +=
(float)gameTime.ElapsedGameTime.TotalMilliseconds *
MathHelper.ToRadians(0.1f);
Ǧǣ 7
CONCLUSION
Virtual reality game development can be implemented using
several existing game engines such as Irrlicht and XNA
framework. However, to build a realistic virtual reality game
application, it needs more complex object model, communication
with devices such as haptic devices, HMD and human emotion as
part of the intelligence elements for virtual reality game characters.
REFERENCE
MICHAEL,S.CHEN, “Serious Game, game that educate, train, and
inform “, Thomson Johnson technology, Thomson Course
Technology PTR, Boston, USA, 2006.
M. ROSSOU, Learning by Doing and Learning through Play: An
Exploration of interactivity in Virtual Environments for
Children, "ACM Journal of Computers in Entertainment”,
Vol. 2, No.1, 2004,pp.1-23.
M. VIRVOU, AND G. KATSIONIS, On the Usability and likeability of
virtual reality games for education: The case VR-ENGAGE
"Journal of Computers and Education", 2006, Vol.50,
pp.154-178.
RAFAEL CAPILLA,MARGARITA MARTINEZ, “Software Architectures
for designing Virtual reality applications”,EWSA
2004,pp.135-147,Springer-Verlag Berlin Heidelberg 2004.
STEFAN MARKS,JOHN WINDSOR,BURKHARD WUNSCHE, Evaluation
of Game Engines for Simulated Surgical Training,"
Proceedings of the 5th International Conference on Computer
Graphics and Interactive Techniques in Australia and
Southeast Asia(GRAPHITE )",December 2007. pp.273-318.