camState

camState

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

camState

Post by zwzsg »

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.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: camState

Post by trepan »

you're lucky they have names at all, it used to
be that the returned table was of the form:

Code: Select all

{
  [1] = number,
  [2] = number,
  [3] = number,
  etc...
}   --   ;-)
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...
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: camState

Post by zwzsg »

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?
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: camState

Post by Beherith »

This is not the post you are looking for.
User avatar
Peet
Malcontent
Posts: 4384
Joined: 27 Feb 2006, 22:04

Re: camState

Post by Peet »

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
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.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: camState

Post by zwzsg »

Peet wrote:Z is not included in GetDir() because the z-rotation of the camera would never change the direction vector of the camera.
Oooh, makes sense!

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.
Warlord Zsinj
Imperial Winter Developer
Posts: 3742
Joined: 24 Aug 2004, 08:59

Re: camState

Post by Warlord Zsinj »

zw make us a 3rd person camera with your french magic
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: camState

Post by zwzsg »

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.
Post Reply

Return to “Lua Scripts”