camState is not documented.
The role of each key is not obvious from their names.
Go edit http://spring.clan-sy.com/wiki/Lua_camState until I get some idea about the role of flipped, zscale, rx, ry, rz, height, oldHeight.
camState
Moderator: Moderators
Re: camState
you're lucky they have names at all, it used to
be that the returned table was of the form:
You can look at the spring/rts/Game/Camera/*.cpp
files (in the GetState() functions) to get a better
idea of what the names are.
p[xyz]: position
d[xyz]: direction
r[xyz]: rotation
etc...
be that the returned table was of the form:
Code: Select all
{
[1] = number,
[2] = number,
[3] = number,
etc...
} -- ;-)
files (in the GetState() functions) to get a better
idea of what the names are.
p[xyz]: position
d[xyz]: direction
r[xyz]: rotation
etc...
Re: camState
I understood the TA overhead (I think) now. Getting a bit confused about the rot vector:
there is:
void CFPSController::MouseMove(float3 move)
{
camera->rot.y -= mouseScale*move.x;
camera->rot.x -= mouseScale*move.y*move.z;
if(camera->rot.x>PI*0.4999f)
camera->rot.x=PI*0.4999f;
if(camera->rot.x<-PI*0.4999f)
camera->rot.x=-PI*0.4999f;
}
and:
float3 CFPSController::GetDir()
{
dir.x = (float)(cos(camera->rot.x) * sin(camera->rot.y));
dir.z = (float)(cos(camera->rot.x) * cos(camera->rot.y));
dir.y = (float)(sin(camera->rot.x));
dir.ANormalize();
return dir;
}
Appears rot.z is never set nor used.
Appears rot is read from mouse movement. I don't get why the mouse movement would have three axis and not just two though.
I guess rot is just a temp value to go from mouse position to camera direction. But if I want to change a camera angle, I have to understand it since dir is calculated from rot and not the other way around.
As far as I understand the bit with the cos and sin means:
How "vertical" is the camera depends from rot.x so from mouse.y*mouse.z
How "east-west-north-south" is the camera depends from rot.y so from mouse.x
Still, why is MouseMove argument three dimensionnal? And why allow to set and display rot.z if it's never used?
Can lua set the dir vector instead of the rot vector? Or how to convert a dir into a rot in lua?
there is:
void CFPSController::MouseMove(float3 move)
{
camera->rot.y -= mouseScale*move.x;
camera->rot.x -= mouseScale*move.y*move.z;
if(camera->rot.x>PI*0.4999f)
camera->rot.x=PI*0.4999f;
if(camera->rot.x<-PI*0.4999f)
camera->rot.x=-PI*0.4999f;
}
and:
float3 CFPSController::GetDir()
{
dir.x = (float)(cos(camera->rot.x) * sin(camera->rot.y));
dir.z = (float)(cos(camera->rot.x) * cos(camera->rot.y));
dir.y = (float)(sin(camera->rot.x));
dir.ANormalize();
return dir;
}
Appears rot.z is never set nor used.
Appears rot is read from mouse movement. I don't get why the mouse movement would have three axis and not just two though.
I guess rot is just a temp value to go from mouse position to camera direction. But if I want to change a camera angle, I have to understand it since dir is calculated from rot and not the other way around.
As far as I understand the bit with the cos and sin means:
How "vertical" is the camera depends from rot.x so from mouse.y*mouse.z
How "east-west-north-south" is the camera depends from rot.y so from mouse.x
Still, why is MouseMove argument three dimensionnal? And why allow to set and display rot.z if it's never used?
Can lua set the dir vector instead of the rot vector? Or how to convert a dir into a rot in lua?
Re: camState
This is not the post you are looking for.
Re: camState
Camera rotation is identical to piece rotation in bos. X rotates sideways, Y rotates up/down, and Z rotates around the axis the camera is pointing along. Z is never used because it is basically nonsensical to rotate around it...unless you want the camera to be upside down for some reason. Z is not included in GetDir() because the z-rotation of the camera would never change the direction vector of the camera. No clue why mouseMove() has a float3 as a param (and uses all 3 vars) though.zwzsg wrote: Appears rot.z is never set nor used.
Appears rot is read from mouse movement. I don't get why the mouse movement would have three axis and not just two though.
I guess rot is just a temp value to go from mouse position to camera direction. But if I want to change a camera angle, I have to understand it since dir is calculated from rot and not the other way around.
As far as I understand the bit with the cos and sin means:
How "vertical" is the camera depends from rot.x so from mouse.y*mouse.z
How "east-west-north-south" is the camera depends from rot.y so from mouse.x
Re: camState
Oooh, makes sense!Peet wrote:Z is not included in GetDir() because the z-rotation of the camera would never change the direction vector of the camera.
I just tried to change rz in FPS view, hoping to get some upside down camera effect, but it appears changing rz (to a random value in [-4,4]) doesn't do anything.
Bah anyway thanks trepan (and Peet), it's getting clearer now.
-
- Imperial Winter Developer
- Posts: 3742
- Joined: 24 Aug 2004, 08:59
Re: camState
zw make us a 3rd person camera with your french magic
Re: camState
Regret's fake unit camera is probably closer to your needs.
What I wanted to do was another idea of yours, WZ, it's to make a widget that automatically centers the camera on area of intense action.
My magic is feeble in this place, not that it worn out, but there are people of for greater power around.
What I wanted to do was another idea of yours, WZ, it's to make a widget that automatically centers the camera on area of intense action.
My magic is feeble in this place, not that it worn out, but there are people of for greater power around.