Ouch my head - 3D Movement

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
LordNyson
Posts: 31
Joined: Tue Nov 11, 2008 12:02 pm
Location: Perth, Australia

Ouch my head - 3D Movement

Post by LordNyson »

Basically I am attempting to make a "space sim" sort of thing just to test, see if I can do it, unfortunately I am running into some minor niggles. I am not very maths based, I am translating my camera behind my ship like so:

Code: Select all

	vector3df hi = swordNode->getPosition();
	aabbox3d<f32> oO = swordNode->getBoundingBox();

	vector3df* r = new vector3df[8];
	oO.getEdges(r);
	hi = r[1];
	hi += (r[5] / 2);
	camera->setPosition(hi);
	camera->setTarget(swordNode->getPosition());

	delete r;
and then I am translating it based on changes in ship rotation with euler stuff..specifically:

Code: Select all

vector2df calcMatrix(vector2df inputs,f32 change)//inputs are X and Y
{
	vector2df outputs = vector2df(0,0);
	change *= ((f32)PI / (f32) 180.0);
	f32 cosRes = cos(change);
	f32 sinRes = sin(change);

	if(change < 0)
	{
		outputs.X = (cosRes * inputs.X) - (sinRes * inputs.Y);
		outputs.Y = (sinRes * inputs.X) + (cosRes * inputs.Y);
	}
	else
	{
		if(change == 0)return outputs;
		outputs.X = (cosRes * inputs.X) + (sinRes * inputs.Y);
		outputs.Y = -(sinRes * inputs.X) + (cosRes * inputs.Y);
	}
	return outputs;
}
Now as I said, I am not very maths based and as such have probably screwed up in some if not all of this. Butttt what I am wondering, in this environment what is the best way to create movement in a 3D environment in peoples opinions? Is it best to use say a physics engine and forces (Which I tried to do and failed miserably with irrOde irrNewt and many many others... Have been stuck for a while now :) or to actually do it yourself for the movement. or alternatively can someone give me some example code or logical progression of how I might accomplish 3d movement? (and yes I have looked at multiple maths sites, and books in a vain attempt to grasp exactly what is going on)

Just to add. What I am trying to do is take rotation aka D key rotates one degree right, now I want to move in that direction when W key is pressed.
But the cage only had "Warning: Vicious Lions" on it! Im a programmer! I only listen to errors!
d3jake
Posts: 198
Joined: Sat Mar 22, 2008 7:49 pm
Location: United States of America

Post by d3jake »

The Open Descent Foundation is always looking for programmers! http://www.odf-online.org
"I'll find out if what I deleted was vital here shortly..." -d3jake
Post Reply