Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Frostrum camera rotation

Author
Message
Weave
AGK Bronze Backer
18
Years of Service
User Offline
Joined: 26th Sep 2006
Location:
Posted: 28th Jul 2013 20:36
Can anyone advise as to how I wrap an object into an angle of 0 to 360 in its xy and z axes?

I have a 3d spaceship with a cube behind and above it, my camera seeks to the cubes position but I am having difficulty making my camera roll to the same plane so as to see the ship the correct way up.

it is the rota# value here:-

setcameralookat(1,getobjectx(1),getobjecty(1),getobjectz(1),rota#)

I find it complex because of the angles that an object reports behave oddly once you have rotated the object beyond 90 in its x axis in that y and z flip to 180 and that is just simply rotating the x alone.

Is it that I have to define my objects rotation between 0 to 360 somehow with quaterions so it is easier to ascertain how much rota# needs to be whichever direction the ship points in 3d space?

Rotation advice needed Thx
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 28th Jul 2013 21:50
You can set the position of the camera and its rotation to the same as the object (ship) then move the camera using local movement rather than global.

1-position and rotate camera to same as object
2-move camera local z and local y

I can look up some code if you have trouble but that's how I've done it in AppGameKit 3D.


this.mess = abs(sin(times#))
Weave
AGK Bronze Backer
18
Years of Service
User Offline
Joined: 26th Sep 2006
Location:
Posted: 30th Jul 2013 22:59 Edited at: 30th Jul 2013 23:00
Thx baxslash, yes that`s how I position the cube that my camera is seeking the position of, but it will lead to a rigid camera I was hoping to have a slow integer follow in increments to the current rotation so as to allow for smoother viewing...but I am using the setcameratolookat command which generally rotates it and then I was trying to roll it to the x component of the ship.

Thinking about it, I notice that the cube doesn`t correctly rotate to the same orientation as the ship when I roll the x of the ship in(object 4 is my follower cube, 1 is the ship)

setobjectrotation(4,getobjectanglex(1),getobjectangley(1),(getobjectanglez(1)))
SetObjectPosition(4,getobjectx(1),getobjecty(1),getobjectz(1))
MoveObjectLocalX( 4, -20 )
MoveObjectLocaly( 4, 15 )

Should this be a `plus` 20 in the localX and I then need to re-export my ship drawn facing the other direction? ie down the x axis=forwards

From what you are saying I place my camera where my cube is and it will be ok as long as my cube has been moved in the correct direction, thx I`ll try it.

But all I need to do is be able to equate an actual 0 to 360 of my ship in its x axis relative to the screen orientation from its quats.
Is this not something like a sum of the quats.

1080*(quatx+quaty+quatz)/3 (`im guessing here)

Does anyone know how to return a 0-360 of an objects x rotation from its quaterions?
Weave
AGK Bronze Backer
18
Years of Service
User Offline
Joined: 26th Sep 2006
Location:
Posted: 31st Jul 2013 02:59
Actually..thx baxslash I realised my ship had to move along the z axis to match the coordintes of the camera, and I have managed to make a steady working camera that at least is on `elastic` when accelerating now, progress

Login to post a reply

Server time is: 2024-11-24 18:43:24
Your offset time is: 2024-11-24 18:43:24