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.

Dark GDK / Rotate limb to camera angle?

Author
Message
_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 22nd Jun 2010 12:18
Hi folks,
I want to rotate a certain limb of a .x-model to the X & Y angles of the camera. But I don't know how...
The problem is, that the limb already has a rotation because of the current animation frame I guess (dbLimbDirectionX..Z has certain values right from the start). Since dbRotateLimb is relative to that direction/axis, the task to rotate the limb to world angles isn't as easy as it seems

Any hints or ideas?

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 23rd Jun 2010 11:47
You can try to make an object from the limb, and then use that object to perform any rotations.
Then hide the original limb if needed

_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 23rd Jun 2010 12:50
No, I think that doesn't work, because I need the bone hirarchie for animations...
There must be some way to calculate the desired angles!
I have the LimbDirection, Object and Camera angles - I have no clue how to put those together

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 23rd Jun 2010 12:55
i've never played with limbs, but shouldn't it just be
dbRotateLimb ( -LimbAngleX ( ) + CameraAngleX ( ), -LimbAngleY ( ) + CameraAngleY ( ), -LimbAngleZ ( ) + CameraAngleZ ( ) ); ? -limbangle will set the angle to 0 and then add the camera angle to it

Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 23rd Jun 2010 13:09
I had this same problem a while back, never solved it. They should have a dbSetWorldMatrix() command for limbs like they do for objects, but they dont(that I know of).

I'm not great with matrix math but that might be the way to go, you would then just convert to euler at the end I think.

_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 23rd Jun 2010 18:39 Edited at: 23rd Jun 2010 18:42
@Hassan:
The problem is that dbLimbAngleX..Z are always zero if no dbRotateLimb is applied to the limb, but dbLimbDirectionX..Z returns certain angles, because these commands relate to the world angles of the limb.

@matty halewood:
I thought about something along those lines, maybe do it with quaternions or something. The problem there is, that I'm not very good at this stuff Plus I don't know how to really search for this on the net.
I tried "limb to camera" or something on this forum, but the one thread it found didn't help.

The main issue is that a limb has its own X, Y, Z axis because of the way they are rotated in the current animation frame!

Example:
Rotate the limb to Camera angle y -> gives strange results, because the limbs axis differs from the Camera axis (=world angles)

Doing the rotation with dbLimbDirection - dbCameraAngle didn't do the trick either...

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 23rd Jun 2010 20:55 Edited at: 23rd Jun 2010 21:02
can you get the limb's direction? if so, then maybe i could help..

first off, i don't know how euler angles work, but i can extract the x/y (possibly z, but not sure i can do it without some additional info) around their axes from that direction

so here's how you extract the angle around the X axis and the angle around the Y axis from a direction


this is copied directly from my engine's code, once again, this might NOT be euler angles as i dont know how they work, those are the angles around the axes.

So yes, the variable look is a D3DXVECTOR3, which is the direction in your case, so you can set it to
D3DXVECTOR3 look ( limbDirectionX, limbDirectionY, limbDirectionZ );

now that you have the angles, you can do what i said in my previous post,
dbRotateLimb ( -GetAngleX ( ) + dbCameraAngleX ( ), -GetAngleY + dbCameraAngleY ( ), 0 );

also note that the above functions are not 100% accurate, for example, if the angle is 50 around one axis, it might return 49.79 or something

hope it helps

_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 24th Jun 2010 12:20
Ok, thanks for your effort Hassan!
I just tried your code. Unfortunatly it didn't work
The limb still rotates around a wrong axis and has some strange behavior too (like flipping around very fast and such).

There must be a way of calculating the angles!
Think about this: I have the dbLimbDirectionX..Z values which are the limbs angles in world angles. I think I have to offset these angles and then apply the Camera angles to it...
I'm gonna try a few things now...

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 24th Jun 2010 18:11 Edited at: 24th Jun 2010 18:12
oook this should work:
create a dummy camera
position it at 0,0,0
point it to the direction of the limb
get it's angles
rotate the limb using the negative of the previous step's angles
now limbs should be at 0,0,0 angle

this should work

_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 25th Jun 2010 13:30 Edited at: 25th Jun 2010 13:43
Quote: "point it to the direction of the limb"


Do you mean rotate it to the Limb Direction? Because the commands return angles not a vector (like normals).
Anyways, I tried something like this (but with a dummy object instead of a camera), but it didn't work either (or I just missed something...)

This is terrible. Rotating a certain limb (like for a torso or head) of an animated model to camera angles is VERY important for lots of 3rd person games I think! It's really giving me headaches
I wonder that nobody has ever done it before...

Even when I do this:



I get very strange results. The limbs starts flipping from one rotation to another so fast, that it looks like the limb is doubled - like when shaking your hand very fast, you know
But the purpose of the code above was just to 'equalize' the limbs rotation and set it to world angles 0, 0, 0.
No idea why it doesn't work!

Edit:
Ok the flipping around was a mistake of mine because of setting wrong frames. But it's still not working right. I have to experiment a bit more...

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 25th Jun 2010 14:46
no i actually meant point, because (obviously) the direction should be a vector....
if the limb direction is not a vector, nor angles, then the function is not working at all, because, what else would it be returning?...

_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 25th Jun 2010 15:09
No, it's definitly angles returned by dbLimbDirectionX..Z!
You can see that when making a dummy object and position it at the limb and rotate it to the limb direction. It's aligned exactly to the limb then.

But I think doing all this rotating by code is too much for me right now. I'm thinking about just changing the models bones in a modeler. I just need the desired bone (limb) to have the exact same axis as the world.

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.

Login to post a reply

Server time is: 2024-07-04 10:39:34
Your offset time is: 2024-07-04 10:39:34