Blog

Raptr

Just started using Raptr, it’s similar to Xfire only that it’s cross platform supporting PSN, Steam,XBox Live, Xfire and more! Check out my profile here: http://raptr.com/liamrudel

Tags:

Monday, December 20th, 2010 Blog, Gaming View Comments

Slow Physics in my games

Slow Motion
So as you may or may not know, the games that I’ve been making have been suffering from what I can only describe as slow physics. The symptoms are that all the objects seem to move very slowly despite the frame rate and updates occurring at a high frequency. The physics engine is all set up correctly so I was stumped.

The logic that all the games follow is:
Setup the physics engine.
Load the 3D models.
Query the bounding box and scale.
Create the physics object based on the size of the 3D model.

During update:
Update physics.
Query physics engine for object positions and orientations and update the 3D models.

And shutdown nicely…..

So where was it going wrong?
Well technically it wasn’t going wrong, it was doing what it was supposed to do. The problem lay with the logic:
Create the physics object based on the size of the 3D model.

Turns out I wasn’t scaling my objects correctly so everything was in physics terms HUGE!!!!!!!! This gave the illusion of everything moving slowly when it fact it wasn’t.

Example: Think of standing a ruler upright on a table and watching it fall over. Happens quickly right? Now imagine looking at a 100 storey building falling over. In comparison the building seems to fall much slow, when in fact it’s just it has to travel a much bigger distance!

So by fixing my scaling my physics now seem fine… thank god! Unfortunately this leaves the massive task of updating ragCat and repositioning all the objects in the game world without an editor, and I don’t fancy that task right now! :P

Tags: , , ,

Saturday, November 13th, 2010 Blog View Comments

Job Offer

So after I went for my interview with ZoeMode I got offered a job and I happily accepted. I start on Tuesday as a Staff Programmer. I’m very excited and can’t wait to start. I’ll post my thoughts about it all later in the week!

Here’s the company website: www.zoemode.com

Tags: ,

Sunday, October 24th, 2010 Blog View Comments

What the …..? #2

Here’s another bit of madness I found in RagCat.

The current player update:

// update Graphics
UpdateGraphics();

//if the object is selected and has not been moved
if(objectSelected() && !mMovedObject)
{
// stop the object we are manipulating
Vector3 power(0,0,0);
mObjectManipulating->mRigidBody->setLinearVelocity(Conversions::getInstance()->Vector3TohkVector4(power));
}

mMovedObject = false;

And a snippet from the previous one:

// only do these updates when in 3rd person
//if(Input::Instance()->IsThirdPerson())
//{

//if(mInPrecisionAimMode)
//{
// PlayerCamera::getInstance()->SetInPrecisionMode(true);
//}
//else
//{
// PlayerCamera::getInstance()->SetInPrecisionMode(false);
//}

//// if we are trying to slect an object and we are in third person
//if(Input::Instance()->Selecting_object())
//{
// // we only do a ray cast if we are not manipulating an object already
// if(mObjectManipulating == 0)
// {

//// do ray cast which returns a pointer to a GameObject or 0(nothing)
//// store this pointer in a temporary variable
//// and then call Select(), passing a GameObject

////NOTE: you can only select an object if your not already selecting
//Vector3 castEndPosition = PlayerCamera::getInstance()->mCamera->getDirection();
//Vector3 castStartPosition = this->mTorsoNode->getPosition() + PlayerCamera::getInstance()->GetOffset();

//PhysicsManager::getInstance()->ray->setUpRay(Conversions::getInstance()->Vector3TohkVector4(castStartPosition),
Conversions::getInstance()->Vector3TohkVector4(castEndPosition),500);
//
////get the result from the raycast

////*********************************************************
//// NOTE: ALWAYS USE Select() TO SELECT OBJECTS,
//// DO NOT MANUALLY ASSIGN
////*********************************************************

//Select(PhysicsManager::getInstance()->ray->castForDynamic());
/* }
}
*/
// if we are manipulating a valid object
/* if(mObjectManipulating != 0)
{
*/
////*****************************************************************************************
////================== SWITCHING FROM PRECISION AIM TO NORMAL AIM============================
////*****************************************************************************************
////audio
//if(m_canPlayPickUpSound)
//{
// AudioSystem::GetInstance()->PlayPickUp();
// m_canPlayPickUpSound = false;
//}

// if we are hitting the precision aim key
//if(Input::Instance()->PrecisionAim() && m_canSwitchAimMode)
//{
//if(mInPrecisionAimMode)
//{
// mInPrecisionAimMode = false;
// PlayerCamera::getInstance()->SetTargetObject(this);
//}
//else
//{
// mInPrecisionAimMode = true;

//}
//// we just switched so now cant switch until set back to true
//m_canSwitchAimMode = false;
//}
//if(m_canSwitchAimMode == false)
//{
// if(m_currentPrecisionAimSwitchTime < m_precisionAimToggleTime)
// {
// m_currentPrecisionAimSwitchTime++;
// }
// else if(m_currentPrecisionAimSwitchTime >= m_precisionAimToggleTime)
// {
// m_canSwitchAimMode = true;
// m_currentPrecisionAimSwitchTime = 0;
// }
//}
//*****************************************************************************************
//===============END OF SWITCHING FROM PRECISION AIM TO NORMAL AIM=========================
//*****************************************************************************************

// if we are in precision mode then set our target object to the object we are controlling
//if(mInPrecisionAimMode)
//{
// PlayerCamera::getInstance()->SetTargetObject(mObjectManipulating);
//}
//else
//{
// PlayerCamera::getInstance()->mCamera->lookAt(mObjectManipulating->sceneNode->getPosition());
//}

//}
//else // we are not controlling an object
//{
// // we can now play the pick up sound
// m_canPlayPickUpSound = true;

// // if we are not manipulating an object then set the target to cat
// PlayerCamera::getInstance()->SetTargetObject(this);
//}

// // if we are trying to drop an object…
// if(Input::Instance()->DeSelecting_object())
// {
// //… then drop it
// DeSelect();
// }
//}// end of if in 3rd person

//else if(Input::Instance()->IsFreeRoam())
//{
// DeSelect();
//}

I’m not even going to pretend I have any idea whats going on, but I did have to go through all that to make the new one :) Fun times!!!!!

Tags: ,

Friday, September 17th, 2010 Blog, RagCat View Comments

What the…?

ragCat
So I’ve just been going through the code in RagCat tidying it up and I’ve stumbled across some really weird bits of code. It’s funny how at the time of writing the code it seems perfectly logical and simple. Then when you re-visit it you realise how akward and over complicated your logic was. One such example is this below.
It’s part of an object class. The data was read in from an xml file and had to be read in one value at a time. Then we passed each of these values to the graphics function. Data such as position, scale and colour were used. Which are typically stored as Vectors not single components. I don’t know for the life of me why we decided to pass everything separatly instead of creating vectors from the components and then passing it. But that is what it does now and it’s a lot easier to read and understand.
Before:
Reading the data from the XML file
pElem = hRoot->FirstChild("pos").Element();
float X,Y,Z;
pElem->QueryFloatAttribute("x",&X);
pElem->QueryFloatAttribute("y",&Y);
pElem->QueryFloatAttribute("z",&Z);

Calling the function
this->createGraphics(entityName,meshName,X,Y,Z,W,H,D,R1,G1,B1,R2,G2,B2,false);
Function declaration
void createGraphics(String meshName, float x, float y, float z,float scaleX, float scaleY,
float red1,float green1,float blue1,float red2,float green2,float blue2, float scaleZ,bool boundingBox);//Create the graphics representation of the object

After:
Reading the data from the XML file
pElem = hRoot->FirstChild("pos").Element();
float X,Y,Z;
pElem->QueryFloatAttribute("x",&X);
pElem->QueryFloatAttribute("y",&Y);
pElem->QueryFloatAttribute("z",&Z);
Vector3 pos = Vector3(X,Y,Z);

Calling the function:
this->createGraphics(meshName,pos,scale,colour1,colour2);
Function declaration
void createGraphics(String meshName, Vector3 position,Vector3 scale,Vector4 colour1, Vector4 colour2);//Create the graphics representation of the object

What were we thinking with the first one!!!!!!

Tags: ,

Thursday, September 16th, 2010 Blog, RagCat View Comments

RagCat Progress - Levels & New Feature!

So last night I finished up(I say the term loosely) the levels in RagCat. The game now has 4 levels. Levels 1-3 are puzzles where if the player does not do anything they will either not move or fail. Level 4 is an empty shell for anybody to modify themselves. All levels have been tested and can all be completed. While doing this creating and testing I found it inconvenient to have to exit to the main menu every time I failed, so I decided that I would add a reset button ‘R’ to the game. This was done by this simple piece of code:
if( e.key == OIS::KC_R)
{
exit();
enter();
}

You gotta love how functions wrap up things neat and tidy like that :)
I then proceeded to make it look nicer as that was an instantaneous reset and looked “jumpy”. To do this I added another state to my transitions ‘resetTransition’. At first I thought it would be more complicated then it was. I thought I would have to fade to black, reset and then fade back from black. However since I’m calling enter() which fades from black all I had to do was fade to black which made it very similar to the exitTransition.
exit:
else if(transitionState==exitTransition)
{
transition->setAlpha(transition->getAlpha()+0.05f);
if(transition->getAlpha()>1.0f)
changeState(MainMenu::getInstance());
}

reset:
else if(transitionState==resetTransition)
{
transition->setAlpha(transition->getAlpha()+0.05f);
if(transition->getAlpha()>1.0f)
reset();
}

So after I did this I just had to change my initial line of code to:
if( e.key == OIS::KC_R)
{
stateChange(resetTransition);
}

Piece of Pie! That has to be one of the quickest and easiest feature additions of RagCat :P

Tags: , ,

Wednesday, September 15th, 2010 Blog, Project Updates, RagCat View Comments

RagCat Version 2 Alpha Release

ragCat
I’m pleased to announce the release of the RagCat Alpha. I decided to release this to get some feedback and for the guys from Team Awesome to get a look at whats changed. It can be downloaded here: RagCat V2 Alpha.zip 9.05mb

Tags: ,

Tuesday, September 14th, 2010 Blog, Project Updates, RagCat View Comments

Applying for Jobs

So I’m currently applying for Jobs in the UK. It’s a long slow process but a necessary and worthwhile one. I’m using GameDev Map to locate game studios, and then emailing each one. I’ve already heard back from a few and they are currently not hiring but I’m remaining hopeful.

Tags:

Sunday, July 18th, 2010 Blog View Comments

I’ve been ill

So I was working over the weekend as usual, but also got a cold or flu and haven’t been able to get any work done, so thats why I haven’t had a post. I’m back to work again tonight which is good cause I need the money but bad because I won’t be programming. I will however be watching all the E3 videos I can get my hands on though! I might share my thought in a post, who knows?

Tags:

Thursday, June 17th, 2010 Blog View Comments

Fixes & Bugs

ragCat
So lately I’ve been trying to improve the performance of RagCat rather than add new features. I’ve fixed some bugs and I’m also making small changes to make future plans a lot easier. So heres some examples of what I’ve done.

Well yesterday I changed how buildings were placed in the world. The problem was that a buildings origin was in the center of the object. This meant that when you placed the object on the ground at y=0 it was actually half in the ground, because it’s origin was at y=0. Our fix at the time was to place the models by guessing a y co-ord for them. This was tricky and time consuming especially since the size of the models use a scalling factor and not a fixed size. Now obviously if we were still actively developing this I would have asked the artist to move the origin and the problem would have been solved. But because we’re not I had to come up with a fix myself. The solution was a simple one.

1. Get the objects bounding box
2. Get the size of the y component
3. Half it
4. Add this to the proposed y co-ordinate

rectangleHalfSize = Conversions::getInstance()->Vector3TohkVector4(mesh->getBoundingBox().getHalfSize() * sceneNode->getScale());
sceneNode->setPosition(x,y + (rectangleHalfSize(1)),z);

So if the building was 100 units tall, the y component halfed would be 50. So if I place the object at y=0, it is now actually placed at y=50, which results in the bottom of the model being at y=0.

ragcat-2010-05-17-23-22-24-68

Something that I did today was try improve the graphics and while looking through the code I noticed something I was doing wrong. Now in the new version of RagCat I use different states, each one then needs a pointer to the scene manager to be able to add to the scene and clear the scene. For whatever reason when I set up ogre in the GameManager::start() function I didn’t set the sceneManager I instead set it in the first state I entered, Splash1. Then when trying to save time(because I have 3 splash screens) I copied the whole first splash screen and renamed it splash2. This meant that I was now creating the sceneManager twice and doing no cleanup on the first! It even got so bad that I didn’t notice this when creating all my states, so I had 5 states each creating a new sceneManager and not cleaning up after them selves. So when I spotted this I decided to do it properly and put the sceneManager into the GameManger class, and put pointers to it in each state.

GameManager:

Ogre::SceneManager* mSceneManager;//Scene Manager
Ogre::SceneManager* sceneManager(){return mSceneManager;}//Scene Manager Accessor

GameStates:

mSceneMgr = GameManager::getSingletonPtr()->sceneManager();//Set the Scene Manager

This seemed to improve performance, and if anything else it is just a better way to do things.

I still have to try find a solution to the problem with scaling buildings and trying to place a new building on top to create skyscrapers for example. At the moment this still requires the use of guess work. Another thing I want to add is the auto creation of unique IDs for game objects as having to do it yourself is just a pain. I want to do this by taking the base object name such as crate and then using it’s memory address appended to it to create the ID.

Thats all for now,

Liam

Tags: , ,

Thursday, June 10th, 2010 Blog, RagCat View Comments