Problem whit character animation SOLVED (for the moment ;) )

feanor91

19-09-2008 07:53:27

Hello

I manage to find a free model of character on the net (there is few), but I have a very big problem : it's facing Z axis by default. under Max, I can't make it facing X axis because link between mesh and skeleton are broken. The probleme is tht when it pass under OGRE, it has always a rotation applied so when I get is quaternion for getting orientation, I get a bad quaternion because my character is not oriented in right way after rotation to put it in direction where I want it to go. I found a way by reseting it's position on every direction change then calculate new orientation then pitching and yawing to make it stand up on the ground but this method didn't work if I move it on Z axis (it's laying on the ground when advancing.

I'm very busy by the way, theres one week I look after a solution but didn' tmanage to find one....Please help me.

This is my Next Location Function :

Public Function NextLocation() As Boolean
If WalkList.Count = 0 Then Return False
Dim Redresse As Mogre.Degree = New Mogre.Degree(90)
Dim Recule As Mogre.Degree = New Mogre.Degree(180)
Dim quat As Quaternion
'Get next location from walk list
myDestination = WalkList.Dequeue

myDirection = myDestination - myNode.Position
MyDistance = myDirection.Normalise

'Change orientation to face new location
myNode.ResetOrientation()
Dim src As Vector3 = myNode.Orientation * Vector3.UNIT_Z
If 1 + src.DotProduct(myDirection) < 0.0001 Then
myNode.Yaw(New Degree(180))
Else
quat = src.GetRotationTo(myDirection)
myNode.Rotate(quat)
CVNode.ResetOrientation()
CVNode.Rotate(quat)
src = myNode.Orientation * New Mogre.Vector3(1, 100, -500) + myNode.Position
CVNode.Position = src
CVNode.Pitch(New Mogre.Degree(90))
CVNode.Yaw(New Mogre.Degree(-90))
myNode.Pitch(Redresse)
myNode.Roll(Recule)
End If


Return True
End Function

Here's some pictures. First move on X then circle, it's OK with my method :














And now move on Z, same method not same result :









And so on....AU SECOUR!

feanor91

19-09-2008 11:03:22

OK, I manage to solve the problem by myself. In fact, I Add hte rotation to the first part of the test (to see if 180° orientation) like this :

Public Function NextLocation() As Boolean
If WalkList.Count = 0 Then Return False
Dim Redresse As Mogre.Degree = New Mogre.Degree(90)
Dim Recule As Mogre.Degree = New Mogre.Degree(180)
Dim quat As Quaternion
'Get next location from walk list
myDestination = WalkList.Dequeue

myDirection = myDestination - myNode.Position
MyDistance = myDirection.Normalise

'Change orientation to face new location
myNode.ResetOrientation()
Dim src As Vector3 = myNode.Orientation * Vector3.UNIT_Z
If 1 + src.DotProduct(myDirection) < 0.0001 Then
myNode.Yaw(New Degree(180))
myNode.Pitch(Redresse)
myNode.Roll(Recule)
Else
quat = src.GetRotationTo(myDirection)
myNode.Rotate(quat)
myNode.Pitch(Redresse)
myNode.Roll(Recule)
End If


Return True
End Function


and, by the way, I get off animation relative to CV and put it on the AnimationFrame function, because if I let it in the NextLocation function, if I want to see my kite move when going 0 to 500 for example I must enqueue 50 value (for cv position is calculated for each location change). Moving it to animationframe made it's position calculate for each move of the pilot. So here the routine for kite :

Dim src As Mogre.Vector3
Dim quat As Quaternion = myNode.Orientation
CVNode.ResetOrientation()
CVNode.Rotate(quat)
src = myNode.Orientation * New Mogre.Vector3(1, 500, -100) + myNode.Position
CVNode.Position = src
CVNode.Yaw(New Mogre.Degree(180))
CVNode.Pitch(New Mogre.Degree(180))


For the moment, yaw and pitch of cv are fixed but in the future, they will depend of pilot movement (an more difficulties to come....)