Basic RTS Camera / Problem

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
Guest

Basic RTS Camera / Problem

Post by Guest »

Hi!
ive programmed a basic RTS style camera that works so far.
but i have a problem:

is there a way to rotate the camera pan? otherwise the controls arent aligned correctly for the cameramovement-code. the camera pan should be -90 and the camera angle should be -60.

if someone of you could help me i´d be very glad :) iam posting the camera code, if is error is gone it is a fully working simple RTS camera, maybe someone of you have a use for it :o :

Code: Select all

// BASIC RTS CAM
// -------------
// you have to call this in the main function:
// cursor->device->getCursorControl();
// createCamera();
//
// and this in the main function´s while loop
// updateCamera();

position2d<s32> Cursor_Position;
position2d<s32> Camera_Position;
position2d<s32> ScreenResolution;
vector3df Camera_Position;
ICursorControl* cursor;
ICameraSceneNode* camera;

void createCamera()
{
    ScreenResolution.X = 1024;
    ScreenResolution.Y = 768;
	camera = smgr->addCameraSceneNode(0, vector3df(0,0,0), vector3df(0,0,0));
	camera->setPosition(vector3df(35000,2000,35000));
}

void updateCamera()
{
	Cursor_Position = cursor->getPosition();
	Camera_Position = camera->getPosition();
	float CameraSpeed = 2;

	if(Cursor_Position.X < 1)
		{
			Camera_Position.X -= CameraSpeed;
			camera->setPosition(Camera_Position);
		}
	if(Cursor_Position.X > ScreenResolution.X - 2)
		{
			Camera_Position.X += CameraSpeed;
			camera->setPosition(Camera_Position);
		}
	if(Cursor_Position.Y > ScreenResolution.Y - 2)
		{
			Camera_Position.Z -= CameraSpeed;
			camera->setPosition(Camera_Position);
		}
	if(Cursor_Position.Y < 1)
		{
			Camera_Position.Z += CameraSpeed;
			camera->setPosition(Camera_Position);
		}
}
at next i will add camera rotation and zooming :)
Guest

Post by Guest »

18 views and no response? common, please its very urgent :)
Guest

Post by Guest »

*bump*
Guest

Post by Guest »

could somebody tell me why it is so fu**in (!!) impossible to make a simply static camera that doesnt rotate to the target ?!! :evil: this makes me mad! if it would be a real hard problem but WHY IN THE WORLD DOES IRRLICHT HAVE NO SIMPLY EASY NORMAL CAMERA ???? thats a damn waste of time !! my progress could have been 3 times so far if this damn senseless problems would appear every few hours!

ps: sorry but after this camera sh** i got a freakin RAGE! :wink:
Guest

Post by Guest »

ok i got it to work BUT IT WAS SO DAMN COMPLICATED !! :)

1. i created a dummy "player"
2. i made a 3rd person cam that has the player as target and is behind the player, so it looks like a rts view.
3. i made the player invisible
4. i applied the cursor movement to the player so that the screen moves if you move the cursor on the screen like in an rts.

so now at the end it looks like an rts cam (and it even is one, though).
but if i think that i needed 5 minutes with A6 engine to create such a cam and now needed a few hours to get out how to do it, my view of irrlicht has changed a little bit ... but nothing to worry, i´ll stay here as long as i dont become completely crazy because of this complicated stuff :o
Flatline
Posts: 49
Joined: Fri Sep 03, 2004 7:46 am
Location: England

Post by Flatline »

Well, given that A6 is a GAME engine and Irrlicht is a GRAPHIC engine, I would hardly expect Irrlicht to be able to compete. I wish people would remember what they should expect from Irrlicht.
Guest

Post by Guest »

i know what i can expect from irrlicht, but hey its a simple camera, why does irrlicht have a FPS camera but no normal and simple camera without any specials... i guess that has nothing really to do if its a game engine or not.
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

The camera class is extendable for a reason, anyone can add their own camera type. If you have a FPS cam, a modeller view cam, then add a 3D RTS cam then why not 3rd person? The point is so that the engine doesn't have to cater to everyone and bloat it, they can add and exchange their own classes.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

I'm trying to extend a camera class from Irrlicht's but it's becoming a pain. How I want to do the rotation is based off of not only the UpVector, but a RightVector and a ForwardVector and the base camera class only stores the UpVector.
Post Reply