RTSCamera Position vs. Pitch Angle?
by Robert Brower · in RTS Starter Kit · 11/26/2007 (4:13 am) · 7 replies
I've purchased the RTS Kit. And it's really cool. I am currently working it into my project. So far I am using just the RTSCamera. I am having a problem with setting the position of the RTSCamera.
I get the position of an AIPlayer, e.g.
%pos = %obj.getPosition();
And I want to set the position of the RTSCamera to be 5 units away from the AIPlayer, e.g.
$RTSCamera.setCameraPosition(getWord(%pos, 0), getWord(%pos, 1) - 5);
However, I noticed that the resulting Y position of the RTSCamera is a lot further away than what I requested. I also noticed that if I pitch the RTSCamera to 90 degrees and perform the same calls, I get the requested position.
Some other information that might be useful...
TGE 1.4,
Changed RTSConnection to GameConnection as I would like only to use the camera itself, so far.
Perhaps the position of the camera is also depending on one of the classes I did not include in my project. Can anyone please help?
Thanks
Robert
I get the position of an AIPlayer, e.g.
%pos = %obj.getPosition();
And I want to set the position of the RTSCamera to be 5 units away from the AIPlayer, e.g.
$RTSCamera.setCameraPosition(getWord(%pos, 0), getWord(%pos, 1) - 5);
However, I noticed that the resulting Y position of the RTSCamera is a lot further away than what I requested. I also noticed that if I pitch the RTSCamera to 90 degrees and perform the same calls, I get the requested position.
Some other information that might be useful...
TGE 1.4,
Changed RTSConnection to GameConnection as I would like only to use the camera itself, so far.
Perhaps the position of the camera is also depending on one of the classes I did not include in my project. Can anyone please help?
Thanks
Robert
#2
Steps to reproduce are:
1. Enter the mission. You should see several units on the terrain.
2. Change the pitch angle so that it is at the minimum.
3. Open the console and type: echo($RTSCamera.getCameraPosition());
4. Type $RTSCamera.setCameraPosition(X, Y); (where X and Y are what were returned in step 3.)
5. Observe that the camera moved!!!
This is my problem and the one I need to solve.
Thank you!
Robert
11/26/2007 (5:14 am)
Thanks Novack. I confirmed what I am saying with the stock RTS Kit...Steps to reproduce are:
1. Enter the mission. You should see several units on the terrain.
2. Change the pitch angle so that it is at the minimum.
3. Open the console and type: echo($RTSCamera.getCameraPosition());
4. Type $RTSCamera.setCameraPosition(X, Y); (where X and Y are what were returned in step 3.)
5. Observe that the camera moved!!!
This is my problem and the one I need to solve.
Thank you!
Robert
#3
11/26/2007 (8:05 pm)
Ok just to report some movement here, tomorrow I'll be trying to test some of this, hope to mantain this at a simple level....
#4
Great to see you in this neck of the woods!
Sorry, I have no ideas on the issue, I just wanted to welcome Robert. :)
11/26/2007 (10:19 pm)
Robert!Great to see you in this neck of the woods!
Sorry, I have no ideas on the issue, I just wanted to welcome Robert. :)
#5
I noticed this a while ago Robert. It may actually be a good thing that it does not set it exactly. The position is always shifted back along the forward vector. I noticed that the extent of the shift back is affected by the height of the camera and the pitch angle. It actually helps you to get a better view!!! The only way to set the camera position exactly is via code. There is some info available in the forums on Restraining RTS camera within mission area this should give you some ideas on how the camera position is actually set in code.
11/27/2007 (6:37 am)
I posted the same response in the Bug section also.I noticed this a while ago Robert. It may actually be a good thing that it does not set it exactly. The position is always shifted back along the forward vector. I noticed that the extent of the shift back is affected by the height of the camera and the pitch angle. It actually helps you to get a better view!!! The only way to set the camera position exactly is via code. There is some info available in the forums on Restraining RTS camera within mission area this should give you some ideas on how the camera position is actually set in code.
#6
void RTSCamera::setCameraPosition(Point2F pos)
{
F32 realHeight = getTerrHeight(pos) + mCurrHeight;
Point3F dir;
Point3F startPos = Point3F(pos.x, pos.y, realHeight);
Point3F endPos;
// RFB ->
//mObjToWorld.getColumn(1, &dir);
//endPos = startPos - dir * mTargetHeight;
//endPos.z = getTerrHeight(Point2F(endPos.x, endPos.y)) + mCurrHeight;
endPos.x = pos.x;
endPos.y = pos.y;
endPos.z = realHeight;
// <- RFB
mTargetPos = mPrevPos = Point2F(endPos.x, endPos.y);
setPosition(endPos);
11/27/2007 (11:31 am)
This gives me what I need...void RTSCamera::setCameraPosition(Point2F pos)
{
F32 realHeight = getTerrHeight(pos) + mCurrHeight;
Point3F dir;
Point3F startPos = Point3F(pos.x, pos.y, realHeight);
Point3F endPos;
// RFB ->
//mObjToWorld.getColumn(1, &dir);
//endPos = startPos - dir * mTargetHeight;
//endPos.z = getTerrHeight(Point2F(endPos.x, endPos.y)) + mCurrHeight;
endPos.x = pos.x;
endPos.y = pos.y;
endPos.z = realHeight;
// <- RFB
mTargetPos = mPrevPos = Point2F(endPos.x, endPos.y);
setPosition(endPos);
Torque 3D Owner Novack
CyberianSoftware
I havent tested it deeply, but this:
works ike a charm (Even with your "-5" -better centered yet-)
So, Robert, you should check the context, because with the stock rts-sk it works. I f I found some time I'll try to see around a little more.
BTW, if you have some time, talk to us about your project here: Who's alive in this part of the world?