IrrlichtNETCP.Quaternion.fromAngleAxis C# (CSharp) Method

fromAngleAxis() public method

public fromAngleAxis ( float angle, IrrlichtNETCP.Vector3D axis ) : void
angle float
axis IrrlichtNETCP.Vector3D
return void
        public void fromAngleAxis(float angle, Vector3D axis)
        {
            float fHalfAngle = 0.5f * angle;
            float fSin = (float)Math.Sin(fHalfAngle);
            m_w = (float)Math.Cos(fHalfAngle);
            m_x = fSin * axis.X;
            m_y = fSin * axis.Y;
            m_z = fSin * axis.Z;
        }

Usage Example

Example #1
0
        public override void Update(ApplicationTime time)
        {
            IOxRenderPluginAvatar avatar = (IOxRenderPluginAvatar)Ox.Service.Get(typeof(IOxRenderPluginAvatar));
            SceneNode sn = avatar.GetAvatarScneNode(Ox.DataStore.World.Agent.ID);
            if (sn == null || node == null)
                return;

            node.Target = sn.Position + Render.RenderData.AgentHeadPosition;

            Matrix4 rot = new Matrix4();
            //rot.RotationDegrees = Util.ToRotationRH(new float[] {
            //    0,
            //    0,
            //    (float)(Ox.DataStore.World.Agent.Head * NewMath.RADTODEG) + Util.ROTATION_AND_3DS_OFFSET.Z });

            Quaternion q0 = new Quaternion();
            Quaternion q1 = new Quaternion();
            q0.fromAngleAxis(Ox.DataStore.Camera.Angle[0] + NewMath.DEGTORAD * Util.ROTATION_AND_3DS_OFFSET.Z, new Vector3D(0, 0, 1));
            q1.fromAngleAxis(Ox.DataStore.Camera.Angle[1], new Vector3D(1, 0, 0));
            q1 = q1 * q0;
            Vector3D vec = new Vector3D(0, -Ox.DataStore.Camera.Distance, 0);
            node.Position = node.Target + q1.Matrix.RotateVect(ref vec);

            if (Ox.DataStore.Camera.Angle[1] < -MathHelper.PIOver2 || MathHelper.PIOver2 < Ox.DataStore.Camera.Angle[1])
                node.UpVector = new Vector3D(0, 0, -1);
            else
                node.UpVector = new Vector3D(0, 0, 1);

            base.Update(time);
        }