Day7: Quick overview

Just quick overview for end of day 7.

  • Input handler gets mouse position and escape button
  • Drawing 3D maya objects
  • Sound player
  • drawing 2D over 3d object
  • Font engine – well subsystem but..
  • High precision timing
  • FPS
  • CPU usage
  • Lighting

Still loads left to do but as for one week it is fairly enough!

Maya Converter Created v 0.1

I made this!

I have developed simple file that converts .obj file format exported from Maya to format that can be in easy way imported to my framework, processed and displayed! current version allows to import whole object with texture! This simple but really flexible script allows me to import any model exported to .Obj to the framework/engine.. how cool is that?!

some code below:

loading file and counts
[cc lang=”cpp”]
ifstream fin;
char input;

// counts.
vertexCount = 0;
textureCount = 0;
normalCount = 0;
faceCount = 0;

// open the file.
fin.open(filename);

// was successful in opening the file?
if(fin.fail() == true)
{
return false;
}

// beginning of the vertices section.
fin.get(input);
while(input != ‘v’)
{
// remainder of the line.
while(input != ‘\n’)
{
fin.get(input);
}

// start reading next line.
fin.get(input);
}

// vertices, texture coord, and normals counts
while(input == ‘v’)
{
fin.get(input);

if(input == ‘ ‘) { vertexCount++; }
if(input == ‘t’) { textureCount++; }
if(input == ‘n’) { normalCount++; }

// the line.
while(input != ‘\n’)
{
fin.get(input);
}

fin.get(input);
}

// number faces.
while(!fin.eof())
{
if(input == ‘f’) { faceCount++; }

// the line.
while(input != ‘\n’)
{
fin.get(input);
}

fin.get(input);
}

// Close the file.
fin.close();
[/cc]

now file processor:
[cc lang=”cpp”]
VertexType *vertices, *texcoords, *normals;
FaceType *faces;
ifstream fin;
int vertexIndex, texcoordIndex, normalIndex, faceIndex, vIndex, tIndex, nIndex;
char input, input2;
ofstream fout;

// Init the data structures.
vertices = new VertexType[vertexCount];
if(!vertices)
{
return false;
}

texcoords = new VertexType[textureCount];
if(!texcoords)
{
return false;
}

normals = new VertexType[normalCount];
if(!normals)
{
return false;
}

faces = new FaceType[faceCount];
if(!faces)
{
return false;
}

// the indexes.
vertexIndex = 0;
texcoordIndex = 0;
normalIndex = 0;
faceIndex = 0;

// open the file.
fin.open(filename);

// opened?
if(fin.fail() == true)
{
return false;
}

// parse of the vertices section.
fin.get(input);
while(input != ‘v’)
{
// the line.
while(input != ‘\n’)
{
fin.get(input);
}

// read the next line.
fin.get(input);
}

// Read vertices, texture coordinates, and normals into the data structures.
// + convert to left hand coordinate system.
while(input == ‘v’)
{
fin.get(input);

// read in the vertices.
if(input == ‘ ‘)
{
fin >> vertices[vertexIndex].x >> vertices[vertexIndex].y >> vertices[vertexIndex].z;

// Invert the Z vertex to left hand system.
vertices[vertexIndex].z = vertices[vertexIndex].z * -1.0f;

vertexIndex++;
}

// Read texture coords.
if(input == ‘t’)
{
fin >> texcoords[texcoordIndex].x >> texcoords[texcoordIndex].y;

// change the V texture coordinates to left hand system.
texcoords[texcoordIndex].y = 1.0f – texcoords[texcoordIndex].y;

texcoordIndex++;
}

// read normals.
if(input == ‘n’)
{
fin >> normals[normalIndex].x >> normals[normalIndex].y >> normals[normalIndex].z;

// normal to left hand system.
normals[normalIndex].z = normals[normalIndex].z * -1.0f;

normalIndex++;
}

// read line.
while(input != ‘\n’)
{
fin.get(input);
}

// next line.
fin.get(input);
}

//number of face indexes.
while(!fin.eof())
{
if(input == ‘f’)
{
// Read backwards – to a left hand system.
fin >> faces[faceIndex].vIndex3 >> input2 >> faces[faceIndex].tIndex3 >> input2 >> faces[faceIndex].nIndex3
>> faces[faceIndex].vIndex2 >> input2 >> faces[faceIndex].tIndex2 >> input2 >> faces[faceIndex].nIndex2
>> faces[faceIndex].vIndex1 >> input2 >> faces[faceIndex].tIndex1 >> input2 >> faces[faceIndex].nIndex1;
faceIndex++;
}

// the line.
while(input != ‘\n’)
{
fin.get(input);
}

// next line.
fin.get(input);
}

// close.
fin.close();

// output file.
fout.open(“model.txt”);

// header.
fout << "Vertex Count: " << (faceCount * 3) << endl; fout << endl; fout << "Data:" << endl; fout << endl; for(int i=0; i

Vortex Terrain Model

First of all: My class that loads objects from file is working now! v0.6 is able to load vertexes and put them into buffer! Great success!

I was thinking about topic for Games Engineering module. There are plenty ideas in my head of what I can create,

but last idea seems to be a challenge – Simple Vortex Terrain model (little bit similar to the one in minecraft) that will allow player to have ultimate power to change things on it – not sure what that will be exactly but, I am pretty sure player will be able to make “holes” in a ground, caves, flood, destroy object and create craters,

well I see the future for that kind of map for RTS games..

I need to make research and design data structure for vortex terrain – but I am sure that’s “doable”

Game Engine C++ – Overview

Lately I have started developing Game Engine for my Game Architecture Module at University.
It is C++/DirectX (at the moment it is directX 10 with HLSL but in the future it will be kinda smart and will detect what DirectX can be lunched on PC in future maybe OpenGL as well – we’ll see.)

Target for this project is to create basic but flexible and easy to extend RTS game  engine.

To present features of engine on every milestone I’ll publish release, and a code for it because I guess putting code in a post may be kinda messy. However some simple methods or smart ideas I ll post ;).

The engine is designed in a way that extending should be fairly easy.

Current features:

  • Starting Windows’ window
  • Creation DirectX device
  • Loading/Processing Vertex and Pixel shader file
  • very simple camera
  • very basic  input handler
  • model class
  • simple shader debuger
  • error handling

Milestone 1 (01/02/2011)

Working 3D environment – Terrain

  • height map – loaded from file
  • lighting
  • sky box
  • multi-textures
  • blending
  • water
  • loading object from graphics programs

    Milestone 2 (01/03/2011)

    Object system

    • Collision Detection
    • Picking elements and movement
    • Basic AI
    • Placing object on the map
    • Simple Game Logic – building units, balance

    Interface

    • Simple 2D interface

    Milestone 3 (01/04/2011)

    Working Scripting System

    • LUA scripting language implementation

    Milestone 4 (01/05/2011)

    • networking?
    • I bet I ll find something

    Release (02/05/2011)

    • Well documentation and tutorial
    • Party!

    This is just draft probably this days will change eventually however I will be aiming in release date which is be totally accident a day of my birthday 🙂

    Today I am putting a Debug release of Engine – it is really deep alpha and it works only on pc’s with DirectX 10 or later. (Vista or 7)

    Version 0.2 – this version is rendering green triangle on a screen to make that it uses shaders, basic input class manage to close program when escape button is being pressed.