Google

Euler angles - current bugs + improved Euler Angle Class

Discussion regarding the Managed .Net Wrapper for Ogre, MOGRE (http://sourceforge.net/projects/mogre)

Moderators: OGRE Team, MOGRE Moderators

Euler angles - current bugs + improved Euler Angle Class

Postby Tubulii » Sun Jan 15, 2012 8:59 pm

:idea: Note:
The following posts were splitted from topic Is there a way to redefine a nodes roll and pitch axis?.



Beauty wrote:Also important:
When you read Euler Angles from quaternions, you will get different value combination by Mogre in comparison to Ogre (C++). Also there is a bug (Mogre only) that in special cases a returned value is null.
The reason is, that Mogre currently uses System.Math instead of Mogre.Math for math functions like Sin().
All needed knowledge I found out and reported it long time ago. Unfortunately this bug wasn't fixed until today.
As long as you know about this and add a null check, you don't need to care about.

Details I added to the Mogre bugtracker (including links to further details/solutions).

Very interesting. I ran exactly in the same issue on week ago. I had to check whether the value is NaN or not and if yes, "correct" it.
Last edited by Beauty on Tue Jan 17, 2012 1:43 pm, edited 2 times in total.
Reason: added topic SPLIT notes + improved the quote (added links + list points as in the original ;-)
User avatar
Tubulii
Goblin
 
Posts: 222
Kudos: 15
Joined: 24 Jan 2010
Location: Germany

Re: Is there a way to redefine a nodes roll and pitch axis?

Postby Beauty » Mon Jan 16, 2012 1:54 am

Also interesting to know that you found out this bug just one week ago.

Additionally I have to mention, that the Quaternion --> Euler Angle conversion returns values with different co-domains.
For example Quaternion.Yaw:
Co-domain in Ogre: -180 .. 180
Co-domain in Mogre: -90 .. 90
As written in my older post - the reason is an other Euler Angle combination which is mathematically correct, but different than we want to have.



In the paging topic I read that you modified something in the Mogre code and compiled it.
So I suppose you would have the technical knowledge to apply a bugfix.
Also it would be very useful to apply the bugfix in a special way, so that the modification will not be killed (overwritten) when the autowrapping tool re-wrapps Ogre again.
I hope you know what I mean.


For the bugfix we need to choose between 2 options:

1)
Use Mogre.MathFunction() instead of System.MathFunction()
. . . . . PRO: Easy to do. + Returns the same value as Ogre for shure.
. . . . . CON: Could be slower than pure C# code (because of wrapping layer). For heavy usage (multiple usage per each frame) maybe is causes lower FPS rates.

2)
Look to the special internal Ogre code of Sin(), Cos() etc. and port them to C#
. . . . . PRO: No CPU load by wrapping layer
. . . . . CON: Needs more work for searching/porting the related code (+1 hour??) and should be tested if it really returns the same values as Ogre[/list]


A testing code snippet for several rotation states I published here.
For each rotation state it converts Euler Angles --> Quaternion --> Euler Angles.
My test code was written for a co-domain check, but it also can be useful for testing/comparing after the bugfix.
For example run the code with Ogre (C++) and with Mogre. Print the result of each state and compare them (many lines) by a comparison tool (e.g. the great UltraCompare ... the free version would be good enough for this purpose)

If you are interested to fix the bugs, I would help you.
I would search for the related math functions and the C++ code snippets.
Then you could port them to C++ and embed them into the Mogre wrapper (in the correct way for long-term usage).
Nice would be a re-compilation of Mogre to have the bugfix in the binaries, too. But this is optional. More important is to have the bugfix in the souce code. Binaries can be done somewhen later.

What do you think about?
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1595
Kudos: 35
Joined: 09 May 2007
Location: Germany

Re: Is there a way to redefine a nodes roll and pitch axis?

Postby Beauty » Mon Jan 16, 2012 2:02 am

I found details in my older posts.
This is useful for people who want to write a workaround (as long as Mogre isn't bugfixed).

Beauty wrote:I found out that the function Quaternion::getYaw() returns a NaN (not defined) value for some special cases.

The special cases are:

Yaw = +/- 90 degree (positive 90 or negative 90)
Pitch = random
Roll = 0 degree


The reason of the problems:

Kojack wrote:Does Mogre use Ogre's math code for quaternions? I think it used it's own vector math instead of wrapping ogre's for performance.
If so, it might not have the same protection.
getYaw does an asin operation. This MUST be given a value between -1 to 1. Outside of that range will cause a nan. Even slight floating point errors like 1.000001 will fail. Ogre provides Math::ASin, which protects asin from being called with bad values. The Ogre getYaw function calls Math::ASin, but maybe the Mogre getYaw is doing asin directly.
That's the only operation in there that could cause a nan, assuming that the quaternion didn't contain a nan to start with.

There are problems with the getYaw and related functions though. I was testing them a few days ago (while making a new version of my Euler class) and I found that the returned values are wrong in many cases. Not just the usual thing where several different combination of eulers result in the same quaternion, this was giving results that were mirrored along the x or y axes. Converting the quaternion to a matrix3, then calling one of the toeuler methods gave the correct results.


More details are in this topic: Quaternion::getYaw() returns NaN (not defined)
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1595
Kudos: 35
Joined: 09 May 2007
Location: Germany

Re: Is there a way to redefine a nodes roll and pitch axis?

Postby Beauty » Mon Jan 16, 2012 7:09 pm

After I talked with Kojack on yesterday and today, he published and documented his improved Euler Angle class.
Details you find in the wiki:
http://www.ogre3d.org/tikiwiki/Euler+Angle+Class
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1595
Kudos: 35
Joined: 09 May 2007
Location: Germany

Re: Is there a way to redefine a nodes roll and pitch axis?

Postby Tubulii » Mon Jan 16, 2012 9:26 pm

Beauty wrote:Maybe somebody still created a C# clone.

Ahm, *looking for it*... there it is:
(the old version, i will it update in the next days)
(VB.Net)
Code: Select all
Imports Mogre
Public Class Euler
    ' ConstrucTor which takes yaw, pitch and roll values.
    Public Sub New()
        MyClass.New(New Radian(0.0F), New Radian(0.0F), New Radian(0.0F))
    End Sub
    Public Sub New(ByVal yaw As Radian)
        MyClass.New(yaw, New Radian(0.0F), New Radian(0.0F))

    End Sub
    Public Sub New(ByVal yaw As Radian, ByVal pitch As Radian)
        MyClass.New(yaw, pitch, New Radian(0.0F))

    End Sub
    Public Sub New(ByVal Oriantation As Quaternion)
        MyClass.New(Oriantation.Yaw, Oriantation.Pitch, Oriantation.Roll)
    End Sub
    Public Sub New(ByVal Euler As Euler)
        MyClass.New(Euler.m_yaw, Euler.m_pitch, Euler.m_roll)
    End Sub
    Public Sub New(ByVal yaw As Radian, ByVal pitch As Radian, ByVal roll As Radian)
        m_yaw = yaw
        m_pitch = pitch
        m_roll = roll
        m_changed = True
    End Sub
    ''' <summary>
    ''' Get the Yaw angle.
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetYaw() As Radian
        Return m_yaw
    End Function
    ''' <summary>
    ''' Get the Pitch angle.
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetPitch() As Radian
        Return m_pitch
    End Function

    ''' <summary>
    ''' Get the Roll angle.
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetRoll() As Radian
        Return m_roll
    End Function

    ''' <summary>
    '''  Apply a relative yaw. (Adds angle To current yaw)
    '''  Angles wrap around within the range 0 To 2*PI radians (0 To 360 degrees)
    ''' </summary>
    ''' <param name="y"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function yaw(ByVal y As Radian) As Euler
        m_yaw += y
        If m_yaw.ValueRadians() < 0.0F Then
            m_yaw = System.Math.IEEERemainder(m_yaw.ValueRadians(), Math.PI * 2.0F) + Math.PI * 2.0F
        ElseIf m_yaw.ValueRadians() > Math.PI Then
            m_yaw = System.Math.IEEERemainder(m_yaw.ValueRadians(), Math.PI * 2.0F)
        End If
        m_changed = True
        Return Me
    End Function
    ''' <summary>
    ''' Apply a relative pitch. (Adds angle To current pitch)
    ''' </summary>
    ''' <param name="p"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function pitch(ByVal p As Radian) As Euler
        m_pitch += p
        m_changed = True
        Return Me
    End Function
    ''' <summary>
    ''' Apply a relative roll. (Adds angle To current roll)
    ''' </summary>
    ''' <param name="r"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function roll(ByVal r As Radian) As Euler
        m_roll += r
        m_changed = True
        Return Me
    End Function
    ''' <summary>
    ''' Set the yaw.
    ''' </summary>
    ''' <param name="y"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function SetYaw(ByVal y As Radian) As Euler
        m_yaw = y
        m_changed = True
        Return Me
    End Function

    ''' <summary>
    '''   Set the pitch.
    ''' </summary>
    ''' <param name="p"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function SetPitch(ByVal p As Radian) As Euler
        m_pitch = p
        m_changed = True
        Return Me
    End Function

    ''' <summary>
    '''  Set the roll.
    ''' </summary>
    ''' <param name="r"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function SetRoll(ByVal r As Radian) As Euler
        m_roll = r
        m_changed = True
        Return Me
    End Function

    ''' <summary>
    '''  Get a vector pointing forwards.
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetForward() As Vector3
        Return ToQuaternion() * Vector3.NEGATIVE_UNIT_Z
    End Function
    ''' <summary>
    ''' Get a vector pointing To the right.
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetRight() As Vector3
        Return ToQuaternion() * Vector3.UNIT_X
    End Function

    ''' <summary>
    '''      Get a vector pointing up.
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetUp() As Vector3
        Return ToQuaternion() * Vector3.UNIT_Y
    End Function

    ''' <summary>
    ''' Calculate the quaternion of a euler object.
    ''' The result is cached, it is only recalculated when the component euler angles are changed.
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function ToQuaternion() As Quaternion
        If m_changed Then
            m_cachedQuaternion = New Quaternion(m_yaw, Vector3.NEGATIVE_UNIT_Y) * New Quaternion(m_pitch, Vector3.UNIT_X) * New Quaternion(m_roll, Vector3.NEGATIVE_UNIT_Z)
            m_changed = False
        End If
        Return m_cachedQuaternion
    End Function
    'Public Shared OperaTor Quaternion(ByVal ImpliedObject As Euler)
    '       Return ToQuaternion()
    '   End OperaTor
    ''' <summary>
    ''' Casting operaTor. This allows any ogre function that wants a Quaternion To accept a Euler instead
    ''' </summary>
    ''' <param name="ImpliedObject"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Widening Operator CType(ByVal ImpliedObject As Euler) As Quaternion
        Return ImpliedObject.ToQuaternion
    End Operator

    ''' <summary>
    '''  Set the yaw and pitch To face in the given direction.
    '''  The direction doesn't need To be normalised.
    '''  Roll is unaffected.
    ''' </summary>
    ''' <param name="v"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function SetDirection(ByVal v As Vector3) As Euler
        Dim d As Vector3 = v.NormalisedCopy
        m_pitch = Math.ASin(d.y)
        m_yaw = Math.ATan2(d.z, d.x) + New Radian((Math.PI / 2.0))
        m_changed = True

        Return Me
    End Function

    ''' <summary>
    '''  Get the angular difference between the current yaw and the specified yaw.
    '''  Only yaw is considered, pitch and roll are ignored.
    ''' </summary>
    ''' <param name="a"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetYawToDirection(ByVal a As Radian) As Radian
        Dim angle As Single = (a - m_yaw).ValueRadians()
        If angle > Math.PI Then
            angle = -Math.PI * 2.0F + angle
        ElseIf angle < -Math.PI Then
            angle = Math.PI * 2.0F + angle
        End If
        Return New Radian(angle)
    End Function

    ''' <summary>
    '''  Get the angular difference between the current yaw and the specified direction vector.
    '''  Only yaw is considered, pitch and roll are ignored.
    ''' </summary>
    ''' <param name="v"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetYawToDirection(ByVal v As Vector3) As Radian
        Return GetYawToDirection(New Radian(Math.ATan2(v.z, v.x) + New Radian(Math.PI / 2.0F)))
    End Function

    ''' <summary>
    '''  Get the angular difference between the current yaw and the specified euler object.
    '''  Only yaw is considered, pitch and roll are ignored.
    ''' </summary>
    ''' <param name="e"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetYawToDirection(ByVal e As Euler) As Radian
        Return GetYawToDirection(e.m_yaw)
    End Function


    ''' <summary>
    ''' Change the yaw To face in the direction of the vector.
    ''' Only yaw is changed, pitch and roll are ignored.
    ''' </summary>
    ''' <param name="v"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function yawToDirection(ByVal v As Vector3) As Euler
        m_yaw = GetYawToDirection(v)
        m_changed = True
        Return Me
    End Function



    ''' <summary>
    '''  Change the yaw To face in the direction of the euler object.
    '''  Only yaw is changed, pitch and roll are ignored.
    ''' </summary>
    ''' <param name="e"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function yawToDirection(ByVal e As Euler) As Euler
        'C++ TO VB CONVERTER WARNING: The following line was determined To be a copy construcTor call - this should be verified and a copy construcTor should be created if it does not yet exist:
        'ORIGINAL LINE: m_yaw = GetYawToDirection(e);
        m_yaw = GetYawToDirection(New Euler(e))
        m_changed = True
        Return Me
    End Function
    Public Function ToDisplayString() As String
        Return String.Format("X: {0:00}° Y: {1:00}° Z: {2:00}°", GetPitch.ValueDegrees, GetYaw.ValueDegrees, GetRoll.ValueDegrees)
    End Function
    Public Shared Function ParseDisplayString(ByVal str As String) As Euler
        Dim data = str.Split(" ")
        If data.Length = 6 Then
            Dim roll = Single.Parse(data(5))
            Dim pitch = Single.Parse(data(1))
            Dim yaw = Single.Parse(data(3))
            Return New Euler(New Degree(yaw), New Degree(pitch), New Degree(roll))
        Else
            Return Nothing
        End If
    End Function
    '' stream operaTor, for printing the euler component angles To a stream
    '   Public Shared OperaTor <<(ByVal o As IO.Stream, ByVal e As Euler) As IO.Stream
    '   o << "<Y:" << e.m_yaw << ", P:" << e.m_pitch << ", R:" << e.m_roll << ">"
    '       Return o
    '   End OperaTor
    Protected m_yaw As Radian = New Radian ' Rotation around the Y axis.
    Protected m_pitch As Radian = New Radian ' Rotation around the X axis.
    Protected m_roll As Radian = New Radian ' Rotation around the Z axis.
    Protected m_cachedQuaternion As Quaternion = New Quaternion() ' Cached quaternion equivalent of this euler object.
    Protected m_changed As Boolean ' Is the cached quaternion out of date?

End Class


Beauty wrote:What do you think about?

You are correct, but I am not a Mogre Developer... but it is possible.
User avatar
Tubulii
Goblin
 
Posts: 222
Kudos: 15
Joined: 24 Jan 2010
Location: Germany

Re: Is there a way to redefine a nodes roll and pitch axis?

Postby Beauty » Tue Jan 17, 2012 2:10 am

Beauty wrote:I looked to the source code of the class now.
It should work even with the unfixed Mogre bug, because the related functions (getYaw() etc.) are not used by the class.

Important:
This is only related to the OLD class.

By my motivation Kojack published his new improved class in the wiki today.
BUT: It seems so that his new class uses the methods/properties, which returns "buggy" values.
So I suppose we can't use the NEW class for Mogre as long as the Orientation bug is not fixed.

The link to the old Euler Angle Class you grabb from the history of the wiki page:
http://www.ogre3d.org/tikiwiki/tiki-pag ... &preview=4

Tubulii wrote:Ahm, *looking for it*... there it is

Nice.
I think it should be easy create C# code from it by usage of a VB-C# converter.
For example this one:
http://www.developerfusion.com/tools/co ... harp-to-vb
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1595
Kudos: 35
Joined: 09 May 2007
Location: Germany

Re: Is there a way to redefine a nodes roll and pitch axis?

Postby Beauty » Tue Jan 17, 2012 2:11 am

Tubulii wrote:
Beauty wrote:What do you think about?

You are correct, but I am not a Mogre Developer... but it is possible.

Since months there is nobody who maintains the Mogre core code.
(By exception of the improvements of Cygon. He published it, but it wasn't included to the official repository.)
So even if you are no senior hyper developer guru, I think it would be useful when you touch the official repository.
If I understood right, you improved the code of Cygon a little bit.
If you add this to the Mogre repository there would be important benifits, because
* your code is based on Cygons code,
* Cygons code is based on mstoykes terrain/paging branch of the official repository
* and the terrain/paging branch is an improved version of the current Mogre trunk.

So it would be a good step for the further development if you check it in there.

Well, perhaps the improvements contains bugs, but
* It's a good base for further development.
* Everybody find it quickly (instead of searching on less known private repositories)
* If a user has real problems, he still has the option to switch back to the previous Mogre 1.7 release.
* Bugs of the improved code can only be found and reported if people can test it.
* If somebody tries to autowrap Mogre agains Ogre 1.8, the improved code would be a better base than the current trunk.
* If somebody add improvements to the current trunk, then it's more hard to merge the different "forks".

This is my personal point of view.

If you have specific problems, I'm shure that some other people here will try to help you.

I don't want to force you to do anything you don't like to do.
It's just as a suggestion. :wink:


Related to the smaller challenge:
In the next days I want to search for the needed information/code again and will publish it here.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1595
Kudos: 35
Joined: 09 May 2007
Location: Germany

Re: Is there a way to redefine a nodes roll and pitch axis?

Postby Beauty » Tue Jan 17, 2012 2:30 am

Euler Angle Class - new improvements

I wanted to create a new Mogre topic to share this news.
While writing this text I regognized, that the new Euler Angle Class of user Kojack can't be used with Mogre, because of the Quaternion-To-EulerAngle bug.
So I just post it here as "hidden post".

____________________________________________


After I talked with Kojack on yesterday and today, he published and documented his improved Euler Angle class.

It's very useful if you like to work with Euler Angles for rotations (e.g. of scene nodes).

Details you find in the wiki:
http://www.ogre3d.org/tikiwiki/Euler+Angle+Class

Currently the code is only available in C++. If anybody port it to C#, please publish it.

Important:
Because of the current bug in More (related to reading out Euler Angles from quaternions), it's possible to get different results, of even a crash by a NaN value.
Details related to the bugs I postet here:
viewtopic.php?p=98017#p98017
....... Start to read at section "Also important"


The code of the old Euler Angle Class you can grabb from the history of the wiki page:
http://www.ogre3d.org/tikiwiki/tiki-pag ... &preview=4


Here are some details about the new class.
(They were posted in a very hidden topic in the developer forum section)

Kojack wrote:I actually have a new version of the euler class, much better, more tested and now compatible with ogre's angles (mine was a crazy combination of left handed and right handed angles, with some wrapping around and some unlimited. Now it's better). I haven't uploaded to the wiki yet, since I hacked one major function and haven't tested it yet.
I've got a cool test where the euler class controls the head of the sinbad model to do object tracking with angular limits and slow turning, regardless of the orientation of the original mesh. It's creepy watching him look at the camera. :)
I've also started working on a c# version for mogre.


Kojack wrote:Ok, I got off my ass and updated the wiki.

New euler class is up at http://www.ogre3d.org/tikiwiki/tiki-index.php?page_ref_id=1114
It's now fully compatible with Ogre::Matrix3::FromEulerAnglesYXZ and Ogre::Matrix3::ToEulerAnglesYXZ (note: only the YXZ versions, because my class is based purely on Yaw Pitch Roll ordering, which is most convenient for upright character controllers and cameras).

(My previous class was made to be easy, so I used clockwise for positive yaw to match compass headings. But the rest of ogre uses the standard anticlockwise right handed rotation for yaw. Now mine matches ogre).


More details are on the refreshed wiki page:
http://www.ogre3d.org/tikiwiki/tiki-ind ... ngle+Class
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1595
Kudos: 35
Joined: 09 May 2007
Location: Germany

Re: Is there a way to redefine a nodes roll and pitch axis?

Postby Beauty » Tue Jan 17, 2012 2:40 am

Perhaps I should move the last post to a new topic.
But not now. Today I spent several hours for forums and wiki. I'm just tired and in 6 hours I have to stand up again.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1595
Kudos: 35
Joined: 09 May 2007
Location: Germany

Re: Is there a way to redefine a nodes roll and pitch axis?

Postby Beauty » Tue Jan 17, 2012 1:01 pm

This Personal Message could be interesting for you, too.

Kojack wrote:I took a break from X3 Albion Prelude to do the Mogre port of the Euler class.
It all seems to be working. Although it's not tested as much (my mogre test app is tiny, my ogre one is a custom engine with 3d connexion control), and I've never written anything like this in c#. So it might suck horribly.

But it can do stuff like:
Code: Select all
e.AddYaw(new Radian(0.1));
e.Pitch = Radian(Math.PI / 4.0f);
sceneNode.Orientation = e;

to spin around a scene node while looking up at 45 degrees.
I got the operator overloading working so you can give the euler to any Mogre function that wants a quaternion.

It's not on the wiki yet, I need to make new example snippets and make sure the docs match, since I had to change things a bit from the c++ version (using Mogre's pascal case method names instead of Ogre's camel case, properties instead of get/set, etc). Should be up later today.

I need a break, C# hurts my head. :)
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1595
Kudos: 35
Joined: 09 May 2007
Location: Germany

Re: Is there a way to redefine a nodes roll and pitch axis?

Postby Beauty » Tue Jan 17, 2012 1:03 pm

Public answer to Kojack (quoted in last post).
_____________________________________________


Nice to see that you do so much useful work for the Ogre public.
Your old class was still ported. On yesterday somebody found it in the forums and postet it.
viewtopic.php?p=98037#p98037
It's VB, but can be converted to C# by online converters (e.g. this).


You are right, the Quaternion class APIs seems to miss some functionality.

I will add a task for that to the Mogre bugtracker.

Perhaps I found somebody who has the technical knowledge to bugfix/extend the related part of Mogre in the correct way. (The result should not be killed when the autowrapper wraps a newer version.)
I don't have the technical knowlede and have a very low knowledge about C++ and C++/CLI.

e.AddYaw(new Radian(0.1));
e.Pitch = Radian(Math.PI / 4.0f);
sceneNode.Orientation = e;


Until the Mogre API isn't extended, perhaps there is a workaround like this:

e = e * new Quaternion(new Radian(0.1)) or similar




it's not tested as much


Maybe my test code snippet is useful for you (after some modifications).
Beauty wrote:A testing code snippet for several rotation states I published here.
For each rotation state it converts Euler Angles --> Quaternion --> Euler Angles.
My test code was written for a co-domain check, but it also can be useful for testing/comparing after the bugfix.
For example run the code with Ogre (C++) and with Mogre. Print the result of each state and compare them (many lines) by a comparison tool (e.g. the great UltraCompare ... the free version would be good enough for this purpose)
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1595
Kudos: 35
Joined: 09 May 2007
Location: Germany

Re: Is there a way to redefine a nodes roll and pitch axis?

Postby Beauty » Tue Jan 17, 2012 1:24 pm

Kojack wrote:e.AddYaw(new Radian(0.1));
e.Pitch = Radian(Math.PI / 4.0f);
sceneNode.Orientation = e;


I can't find the related members in the current Ogre documentation of the Quaternion class.
Maybe it's only available for Ogre 1.8?

Beauty wrote:I will add a task for that to the Mogre bugtracker.

I added them as task for Mogre 1.8.
#16: Quaternion class - Yaw/Pitch/Roll - add setter (Mogre 1.8)
#17: Quaternion class - AddYaw, AddPitch, AddRoll (Mogre 1.8)
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1595
Kudos: 35
Joined: 09 May 2007
Location: Germany

Re: Is there a way to redefine a nodes roll and pitch axis?

Postby Beauty » Tue Jan 17, 2012 1:30 pm

It seems so that SceneNode.Yaw(...) should be similar to Quaternion.AddYaw(...)
Although I'm not shure. Maybe its functionality is equal to SetYaw(...) ??

The API description of SceneNode::yaw() is just
Rotate the node around the Y-axis.


I think the documentation should be more precise.
Do you like to improve it?
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1595
Kudos: 35
Joined: 09 May 2007
Location: Germany

Re: Euler angles - current bugs + improved Euler Angle Class

Postby kojack » Tue Jan 17, 2012 4:12 pm

Here's the C# version of the new euler class: http://www.ogre3d.org/tikiwiki/Euler+Angle+Class+Mogre
My C# skills are a bit rusty, I'm a C++ coder. Sorry if any of it sucks.


Beauty wrote:
Kojack wrote:e.AddYaw(new Radian(0.1));
e.Pitch = Radian(Math.PI / 4.0f);
sceneNode.Orientation = e;


I can't find the related members in the current Ogre documentation of the Quaternion class.
Maybe it's only available for Ogre 1.8?

Which members? There's no quaternion methods being called in that code. e is a Euler struct.

For this message the author kojack has received kudos
User avatar
kojack
Gnoblar
 
Posts: 17
Kudos: 2
Joined: 10 Feb 2006

Re: Euler angles - current bugs + improved Euler Angle Class

Postby Beauty » Tue Jan 17, 2012 4:57 pm

Kojack wrote:Here's the C# version of the new euler class

Great job - thank you very much !!

Kojack wrote:Which members?

In your code is the line sceneNode.Orientation = e;
So I suppose that e is a quaternion (because SceneNode.Orientation is a quaternion property).

As a result e.AddYaw(...); should be a member of the Quaternion class.

And the setter of property e.Pitch should be wrapped to a Quaternion::setPitch() function in Ogre.
(But in the current Quaternion class documentation I don't find a setter for pitch. So I supposed it's an other missing member.)

This is the way how I understand your code snippets. Am I wrong?


Kojack wrote:My C# skills are a bit rusty

On the other hand you told that you are even a C# teacher. 8)
Here a quote for the other users:
Kojack wrote:I use mogre around the middle of every year. I have a rapid app dev class which teaches c#, then we use mogre to make game level editors and stuff.
I thought it would be handy, and a bit of c# practice.


Kojack wrote:I knew there was an audience for a c# version of the new one

In the User Survey 2011 Report I saw that there are about 50 people who uses C# (Mogre) as favorite language for Ogre. (Perhaps some votes comes from the Ogre clone Axiom.)
So you know that there IS an audience. :wink:
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1595
Kudos: 35
Joined: 09 May 2007
Location: Germany

Next

Return to MOGRE

Who is online

Users browsing this forum: No registered users and 0 guests