Game Development Community

RTSCamera::setCameraPosition() vs Pitch Angle

by Robert Brower · in RTS Starter Kit · 11/26/2007 (6:15 am) · 2 replies

When the RTSCamera is pitched to it's minimum, and the RTSCamera::setCameraPosition() function is called, the camera position obtained is not the camera position requested. Steps to reproduce:

1. Using the stock RTS Kit .exe,
2. Enter the mission provided.
3. Using the mouse wheel, pitch the camera to it's minimum pitch angle.
4. Open the console and type: echo($RTSCamera.getCameraPosition());
5. In the console, type: $RTSCamera.setCameraPosition(X, Y); (where X and Y are what were returned in step 4.)
6. Observe that the camera moves to a position that was not requested.
7. Pitch the camera to it's maximum.
8. repeat steps 4 - 6.
9. Observe that the camera moves to the requested position.

I may be able to work around this but I thought I should be diligent enough to post what I may only be presuming is a bug.

Thank you.

With regards,

Robert Brower

#1
11/27/2007 (6:33 am)
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.
#2
11/27/2007 (11:32 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);