ShiVa3D
Rotation localTransform problem [SOLVED]
Windows DX9/OpenGL 2 Standalone AppsRotation localTransform problem
by rasq » 27 Dec 2010, 16:53
Hi, i have problem with kLocalSpace, when i trying rotate object on it.
Iam using OSV sample, to rotate, transform and zoom. But on this sample i can only rotate like this:
In data i have compute like this:
When i changed:
to
rotation cant stop, an if i change
Please help me with that.
Iam using OSV sample, to rotate, transform and zoom. But on this sample i can only rotate like this:
- Code: Select all
object.setRotation ( this.getObject ( ), 0, curAngleX, 0, object.kGlobalSpace )
object.rotate ( this.getObject ( ), curAngleY, 0, 0, object.kLocalSpace )
In data i have compute like this:
- Code: Select all
this.nDstAngleX ( this.nDstAngleX ( ) - nDeltaX * 90 )
this.nDstAngleY ( this.nDstAngleY ( ) + nDeltaY * 90 )
if ( this.bCameraRotationClamped ( ) )
then
this.nDstAngleY ( math.clamp ( this.nDstAngleY ( ), -80, -10 ) )
end
- Code: Select all
local curAngleX = math.interpolate ( this.nCurAngleX ( ), this.nDstAngleX ( ), 10 * dt )
local curAngleY = math.interpolate ( this.nCurAngleY ( ), this.nDstAngleY ( ), 10 * dt )
- Code: Select all
this.nCurAngleX ( curAngleX )
this.nCurAngleY ( curAngleY )
When i changed:
- Code: Select all
object.setRotation ( this.getObject ( ), 0, curAngleX, 0, object.kGlobalSpace )
to
- Code: Select all
object.setRotation ( this.getObject ( ), 0, curAngleX, 0, object.kLocalSpace )
rotation cant stop, an if i change
- Code: Select all
setRotation
- Code: Select all
rotate
- Code: Select all
kLocalSpace
Please help me with that.
- rasq
- Junior Boarder

- Posts: 37
Re: Rotation localTransform problem
by broozar » 27 Dec 2010, 23:20
why do you change from global to local space in the first place, what is your goal.
your rotation issue is easily explained. curAngleX will cause problems in local space - my understanding is this: in local space, the rotation is reset after each frame. so after one bit of rotation per frame, your object will have a rotation of 0,0,0 in local space. curAngleX is computed by math.interpolate ( this.nCurAngleX ( ), this.nDstAngleX ( ), 10 * dt ) while nDstAngleX is compused of this.nDstAngleX ( this.nDstAngleX ( ) - nDeltaX * 90 ) , nDeltaX being the value your onMouseMove handler sends object.sendEvent ( application.getCurrentUserActiveCamera ( ), "OSVCamera", "onRotateBy", nDeltaX, nDeltaY ). in other words, this.nDstAngleX ( ) - nDeltaX * 90 assumes a global inertial system and will deliver an abolute angle value, a value that can never be reached in a local system because the coordinate system will get reset after every frame.
correct me if i am wrong.
ps: there are two ai models, osvMain and OSVCamera. have a look at both, the real stuff happens in the camera. i should explain this sample on the wiki, it's one of the few i have not yet managed to write some guide to.
your rotation issue is easily explained. curAngleX will cause problems in local space - my understanding is this: in local space, the rotation is reset after each frame. so after one bit of rotation per frame, your object will have a rotation of 0,0,0 in local space. curAngleX is computed by math.interpolate ( this.nCurAngleX ( ), this.nDstAngleX ( ), 10 * dt ) while nDstAngleX is compused of this.nDstAngleX ( this.nDstAngleX ( ) - nDeltaX * 90 ) , nDeltaX being the value your onMouseMove handler sends object.sendEvent ( application.getCurrentUserActiveCamera ( ), "OSVCamera", "onRotateBy", nDeltaX, nDeltaY ). in other words, this.nDstAngleX ( ) - nDeltaX * 90 assumes a global inertial system and will deliver an abolute angle value, a value that can never be reached in a local system because the coordinate system will get reset after every frame.
correct me if i am wrong.
ps: there are two ai models, osvMain and OSVCamera. have a look at both, the real stuff happens in the camera. i should explain this sample on the wiki, it's one of the few i have not yet managed to write some guide to.
Re: Rotation localTransform problem
by rasq » 27 Dec 2010, 23:36
Now:
and i need to achive this:
as You see pan, zoom and other translations are Global, but rotations of object are local.
I need that rotation radius will be only for rotated object (rotation point) will be his pivot, not scene point (0,0,0).
- Now
- Untitled-1.png (29.57 KiB) Viewed 1626 times
and i need to achive this:
- My Goal
- Untitled-2.png (24.51 KiB) Viewed 1626 times
as You see pan, zoom and other translations are Global, but rotations of object are local.
I need that rotation radius will be only for rotated object (rotation point) will be his pivot, not scene point (0,0,0).
- rasq
- Junior Boarder

- Posts: 37
Re: Rotation localTransform problem
by broozar » 28 Dec 2010, 00:14
you can do both, actually. use object.lookAt() to aim the camera, object.rotateAround() to parent your camera to a pivot like the target object, and make one of the buttons switch camera modes to a "local rotation". "local rotation" works like the parented rotation (with .kGlobalSpace), you only have to fill in new (target) values and change the axis (you probably want to rotate around the y and x axis). have a look at FPVCamera.onEnterFrame ( ) and FPVCamera.onTurnHead ( nPointX, nPointY, nDeltaX, nDeltaY ) how it could be done.
Re: Rotation localTransform problem
by rasq » 28 Dec 2010, 00:16
Ok, thx, i will try this. But i need my camera looking at (0,0,0) all time, it will be problem??
- rasq
- Junior Boarder

- Posts: 37
Re: Rotation localTransform problem
by broozar » 28 Dec 2010, 00:35
How can it? Sounds impossible, from a Logic Point of View. The POS of the Cam and 0,0,0 Form a Straight line, if you are rotating the Cam While keeping 0,0,0 in View, you are bound to Change the Cam POS, which is exactly what the OSV has already.
Re: Rotation localTransform problem
by rasq » 28 Dec 2010, 00:47
And then im on start point of my problem.
I need camera looking all time in to (0,0,0).
Rotate object around its own pivot not a (0,0,0).
I need camera looking all time in to (0,0,0).
Rotate object around its own pivot not a (0,0,0).
- rasq
- Junior Boarder

- Posts: 37
Re: Rotation localTransform problem
by broozar » 28 Dec 2010, 00:58
It's like you want a Car to take a turn whithout moving the steering Wheel, how can it work?
Maybe in your Case, maybe it Would Be enough to Move the Cam up and down White Running .lookAt on onEnterFrame?
Maybe in your Case, maybe it Would Be enough to Move the Cam up and down White Running .lookAt on onEnterFrame?
Re: Rotation localTransform problem
by rasq » 28 Dec 2010, 01:25
Heare You have sample:
My goals:
1. When object is on (0,0,0) like now:
http://gorol.pl/1.ogg
2. When object is on other cordinates and camera look at (0,0,0)
http://gorol.pl/2.ogg
My goals:
1. When object is on (0,0,0) like now:
http://gorol.pl/1.ogg
2. When object is on other cordinates and camera look at (0,0,0)
http://gorol.pl/2.ogg
- rasq
- Junior Boarder

- Posts: 37
Re: Rotation localTransform problem
by rasq » 28 Dec 2010, 19:23
There are video files.
Maybe You must reneme ogg to ogv for Your player, but FF 3.5 play its.
Maybe You must reneme ogg to ogv for Your player, but FF 3.5 play its.
- rasq
- Junior Boarder

- Posts: 37
Re: Rotation localTransform problem
by broozar » 28 Dec 2010, 19:50
ogv worked.
in movie 2, you are not really looking at 0,0,0 all the time, your camera spins full 360 degrees.
you can achieve this, as i mentioned, with the camera ai code provided by the FPS sample, if that is really what you want.
in movie 2, you are not really looking at 0,0,0 all the time, your camera spins full 360 degrees.
you can achieve this, as i mentioned, with the camera ai code provided by the FPS sample, if that is really what you want.
Re: Rotation localTransform problem
by rasq » 28 Dec 2010, 20:08
Yes, but on this videos, i dont rendered a background. It is very important that camere looks at (0,0,0) beacause all background will be changed on its movment.
- rasq
- Junior Boarder

- Posts: 37
Re: Rotation localTransform problem
by rasq » 30 Dec 2010, 01:42
And:
on 2rd movie camera cant spin full 360 degrees, its not possible to achive this animation by this way. On 1st movie, yes. You can rotate object or spin camera.
on 2rd movie camera cant spin full 360 degrees, its not possible to achive this animation by this way. On 1st movie, yes. You can rotate object or spin camera.
- rasq
- Junior Boarder

- Posts: 37
22 posts
• Page 1 of 2 • 1, 2
