RTS Camera

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.
Jumach
Posts: 32
Joined: Sun Mar 14, 2010 9:42 pm
Location: Oregon

Post by Jumach »

I'm using Vista (don't say it, I know) with Code Blocks. If I comment the line out it works but it is very difficult to find a mesh in the scene. Edge scrolling is waaaaaay to fast. Any way to slow that down without slowing anything else down? I would also like to know how I might change the rotation pivot for the camera for example: to rotate the camera around a selected unit. This might help minimize distortion that I get from the generalized rotation.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Jumach wrote:I added the rtscamera.cpp to my project but when I compile my main.cpp I get an error on line 134:

if ( core::equals ( fabs ( dp ), 1.f ) )

No idea why I can't get this to work...
yes, I don't know why, but you'll have to change this line(s) to:

Code: Select all

   f32 dp = fabs(tgtv.dotProduct(up));

   if ( core::equals ( dp, 1.f ) )
IIRC there are two or three places with this line... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
xirtamatrix
Posts: 219
Joined: Fri Feb 19, 2010 4:03 pm
Location: Estonia

Post by xirtamatrix »

Jumach wrote:If I comment the line out it works
Now that's strange.. if you comment out

Code: Select all

RTSCamera* camera = new RTSCamera(device,smgr->getRootSceneNode(),smgr,-1,100.0f,10.0f,10.0f); 
then you should see nothing at all, since there's no camera.

Are you sure you're not creating two cameras? In any case, if you post your main.cpp I could try to look through it and help.
to live, is natural; to die, is not!
Jumach
Posts: 32
Joined: Sun Mar 14, 2010 9:42 pm
Location: Oregon

Post by Jumach »

I commented out the line that Acki mentioned. Everything seems to work fine except that I cannot figure out how to change the start position of the camera or the starting target. All I have in my scene is a small square landscape similar to the ones in Final Fantasy Tactics. I want to know how I can get the RTS camera to start from a nice 45 degree isometric view. Of course I don't it fixed here so no using default cameras.

BTW now that I got this camera working (I think it's working properly) I'm really loving it. Excellent work.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Jumach wrote:I commented out the line that Acki mentioned.
you should not comment them out, but change them like I described... ;)
Jumach wrote:Everything seems to work fine except that I cannot figure out how to change the start position of the camera or the starting target.
you can't do that at creation, instead use setPosition and setTarget afterwards...
or you change the constructor so it takes a position and target vector and set it to the node inside the constructor... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Jumach
Posts: 32
Joined: Sun Mar 14, 2010 9:42 pm
Location: Oregon

Post by Jumach »

Thanks! That should have been obvious, right? Well that's why I'm here. That worked wonders, now I need to figure out why the perspective feels so distorted... When I rotate the camera in-game, my mesh appears to be turning on its side. Would setting max and min values for rotation and translation help solve this?

Also when I change those lines, the program terminates immediately upon execution. I don't know why but commenting that one line out makes it work...
Jumach
Posts: 32
Joined: Sun Mar 14, 2010 9:42 pm
Location: Oregon

Post by Jumach »

Sorry to double post but now the program is completely broken. Whenever I press compile and run in Code Blocks it tells me the program needs to be built and asks me If I want to do this now. It never used to ask me that before. Even if I revert to the way it was I'm still getting the same problem and the program just closes instantly. Here's what is tells me:

Linking console executable: bin\Debug\test.exe
/mingw/lib/libstdc++.a: file not recognized: Not enough space
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Jumach wrote:Also when I change those lines, the program terminates immediately upon execution. I don't know why but commenting that one line out makes it work...
for me it works when changing the lines (I'm also using C::B)...
Jumach wrote:/mingw/lib/libstdc++.a: file not recognized: Not enough space
huh, I never saw this error until now... :shock:
but it sounds like your hard drive is full !?!?! :lol:
Last edited by Acki on Thu Mar 18, 2010 11:41 pm, edited 1 time in total.
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

I've gotten that error before. I was coding from a flash drive though.
multum in parvo
Jumach
Posts: 32
Joined: Sun Mar 14, 2010 9:42 pm
Location: Oregon

Post by Jumach »

Hard drive has 260gb of free space. This is some serious BS because it was working until, literally, 10 minutes ago. I made the suggested changes to my code. When that failed I reverted to an older save that didn't have the change. I cannot stress enough that NOTHING in this file is any different than it was when it worked. Now Code Blocks is telling me that "The file needs to be built. Would you like to build it now?" Of course I do! That's why I clicked F9 (Build and Run)!!! Even after a restart it will not work...

UPDATE: Re-Install doesn't help.
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

Did you try to rebuild(ctrl+F11)?
multum in parvo
Jumach
Posts: 32
Joined: Sun Mar 14, 2010 9:42 pm
Location: Oregon

Post by Jumach »

It only took 9 re-installs and 3 restarts but I got it working...I think. The funny thing is that I still didn't change anything and I re-installed the same version.
Vermillion
Posts: 1
Joined: Fri Jun 18, 2010 11:11 am

Post by Vermillion »

Hi,

The code on the first page works (except collision detection but tha'ts not so important for me) but now if i try to add user interface elements it doesn't work.

Code: Select all

env->addStaticText(L"This is a Text", rect<s32>(50,110,250,130), true);
Is there an other way to do this?

EDIT:

Just copy & paste without having a closer look wasn't a good idea. if there is no env->drawAll(); it can't work.
rayden
Posts: 1
Joined: Mon Aug 02, 2010 7:09 pm

Post by rayden »

Well, english is not my main language but i will try to express!

I have used this RTS camera with the modifications provided by xirmatrix(sorry if i miswrited it), but i found one odd thing, that is if you rotate one object by 180 degrees around the xaxis, when you press A the object will rotate around Z by 180 degrees!

I'm starting now at irrlicht but i do understand very well the equations that must be behind it (as physicist)! If anyone can help me or point me some tutorials on how irrlicht does the projections transforms, it will be mutch apreciated!!!

Regards rayden! :D
alalai
Posts: 2
Joined: Mon Aug 30, 2010 3:25 pm

how to realize a orthogonal projection with RTS camera

Post by alalai »

The code in the first page runs well, but it seems as a perspective projection. how to use RTSCamera with Orthogonal projection? A common fixed camera with orthogonal projection uses the follow few lines
//matrix4 orthoMatrix;
//ICameraSceneNode * camera = smgr->addCameraSceneNode();
//orthoMatrix.buildProjectionMatrixOrthoLH(700, 130, -10, 1024);
//camera->setProjectionMatrix(orthoMatrix,true);
Post Reply