当前位置: 首页>>代码示例>>C#>>正文


C# Matrix4F.RotZ方法代码示例

本文整理汇总了C#中Matrix4F.RotZ方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4F.RotZ方法的具体用法?C# Matrix4F.RotZ怎么用?C# Matrix4F.RotZ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix4F的用法示例。


在下文中一共展示了Matrix4F.RotZ方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render

        public override void Render(object opaqueContext, ViewControl vc)
        {                                                                           
            Matrix4F normWorld = GetManipulatorMatrix();
            if (normWorld == null) return;

            var context = opaqueContext as GUILayer.SimpleRenderingContext;
            if (context == null) return;

            float RingDiameter = 2 * AxisLength;
            Color xcolor = (m_hitRegion == HitRegion.XAxis) ? Color.Gold : XAxisColor;
            Color ycolor = (m_hitRegion == HitRegion.YAxis ) ? Color.Gold : YAxisColor;
            Color Zcolor = (m_hitRegion == HitRegion.ZAxis ) ? Color.Gold : ZAxisColor;
            Color lColor = (m_hitRegion == HitRegion.LookAxis) ? Color.Gold : Color.Cyan;

            float s = Util.CalcAxisScale(vc.Camera, normWorld.Translation, RingDiameter, vc.Height);
            Vec3F axScale = new Vec3F(s, s, s);

            Matrix4F rot = new Matrix4F();
            Matrix4F scale = new Matrix4F();
            scale.Scale(axScale);
            rot.RotX(MathHelper.PiOver2);            
            Matrix4F xform = scale * rot * normWorld;
            Util3D.DrawRing(context, xform, Zcolor);

            rot.RotZ(-MathHelper.PiOver2);
            xform = scale * rot * normWorld;
            Util3D.DrawRing(context, xform, xcolor);
            
            xform = scale * normWorld;
            Util3D.DrawRing(context, xform, ycolor);

            Matrix4F billboard
                = Util.CreateBillboard(normWorld.Translation, vc.Camera.WorldEye, vc.Camera.Up, vc.Camera.LookAt);
            rot.RotX(MathHelper.PiOver2);
            scale.Scale(s * LookRingScale);
            xform = scale * rot * billboard;
            Util3D.DrawRing(context, xform, lColor);
        }
开发者ID:coreafive,项目名称:XLE,代码行数:38,代码来源:RotateManipulator.cs

示例2: Render

        public override void Render(ViewControl vc)
        {
            Matrix4F normWorld = GetManipulatorMatrix();
            if (normWorld == null) return;

            Vec3F pos = normWorld.Translation;
            float s = Util.CalcAxisScale(vc.Camera, pos, AxisLength, vc.Height);

            Color xcolor = (m_hitRegion == HitRegion.XAxis || m_hitRegion == HitRegion.CenterCube ) ? Color.Gold : XAxisColor;
            Color ycolor = (m_hitRegion == HitRegion.YAxis || m_hitRegion == HitRegion.CenterCube ) ? Color.Gold : YAxisColor;
            Color zcolor = (m_hitRegion == HitRegion.ZAxis || m_hitRegion == HitRegion.CenterCube ) ? Color.Gold : ZAxisColor;
            Color centerCubeColor = (m_hitRegion == HitRegion.CenterCube) ? Color.Gold : Color.White;

            Vec3F sv = new Vec3F(s, s, s);
            Vec3F axscale = new Vec3F(s * AxisThickness, s, s * AxisThickness);

            Matrix4F scale = new Matrix4F();
            axscale.Y = Math.Abs(s * m_scale.X);
            scale.Scale(axscale);
            Matrix4F rot = new Matrix4F();
            rot.RotZ(-MathHelper.PiOver2);
            Matrix4F xform = scale * rot * normWorld;
            Util3D.DrawCylinder(xform, xcolor);

            axscale.Y = Math.Abs(s * m_scale.Y);
            scale.Scale(axscale);
            xform = scale * normWorld;
            Util3D.DrawCylinder(xform, ycolor);
            rot.RotX(MathHelper.PiOver2);
            axscale.Y = Math.Abs(s * m_scale.Z);
            scale.Scale(axscale);
            xform = scale * rot * normWorld;
            Util3D.DrawCylinder(xform, zcolor);

            Vec3F centerCubeScale = sv * CenterCubeSize;
            scale.Scale(centerCubeScale);
            Matrix4F centerCubeXform = scale * normWorld;
            Util3D.DrawCube(centerCubeXform, centerCubeColor);

            Vec3F handleScale = new Vec3F(Math.Abs(s * m_scale.X), Math.Abs(s * m_scale.Y), Math.Abs(s * m_scale.Z));
            Vec3F handle = sv * AxisHandle;
            float handleWidth = handle.X / 2;
            scale.Scale(handle);
            Matrix4F trans = new Matrix4F();
            trans.Translation = new Vec3F(handleScale.X - handleWidth, 0, 0);
            xform = scale * trans * normWorld;

            Util3D.DrawCube(xform, xcolor);

            trans.Translation = new Vec3F(0, handleScale.Y - handleWidth, 0);
            xform = scale * trans * normWorld;
            Util3D.DrawCube(xform, ycolor);

            trans.Translation = new Vec3F(0, 0, handleScale.Z - handleWidth);
            xform = scale * trans * normWorld;
            Util3D.DrawCube(xform, zcolor);
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:57,代码来源:ScaleManipulator.cs

示例3: Render

        public override void Render(ViewControl vc)
        {
            Matrix4F normWorld = GetManipulatorMatrix();
            if (normWorld == null) return;

            int axis = (int)m_hitRegion;

            // axis colors
            Color saveColor = m_axisColor[axis];
            m_axisColor[axis] = m_highlightColor;
            Color xcolor  = m_axisColor[(int)HitRegion.XAxis];
            Color ycolor  = m_axisColor[(int)HitRegion.YAxis];
            Color zcolor  = m_axisColor[(int)HitRegion.ZAxis];
            Color nxcolor = m_axisColor[(int)HitRegion.NegXAxis];
            Color nycolor = m_axisColor[(int)HitRegion.NegYAxis];
            Color nzcolor = m_axisColor[(int)HitRegion.NegZAxis];
            m_axisColor[axis] = saveColor;

            if (m_hitRegion != HitRegion.None)
            {
                normWorld.Translation = HitMatrix.Translation;
            }

            Vec3F pos = normWorld.Translation;
            float s = Util.CalcAxisScale(vc.Camera, pos, AxisLength, vc.Height);

            Vec3F sv = new Vec3F(s, s, s);
            Vec3F axscale = new Vec3F(s*AxisThickness, s, s*AxisThickness);
            bool negativeAxis = m_hitRegion == HitRegion.NegXAxis || m_hitRegion == HitRegion.NegYAxis || m_hitRegion == HitRegion.NegZAxis;
            Vec3F dragScale = new Vec3F(Math.Abs(m_scale.X),
                Math.Abs(m_scale.Y), Math.Abs(m_scale.Z));

            Matrix4F rot = new Matrix4F();
            Matrix4F scale = new Matrix4F();
            axscale.Y = negativeAxis ? s : s * dragScale.X;
            scale.Scale(axscale);
            rot.RotZ(-MathHelper.PiOver2);
            Matrix4F xform = scale * rot * normWorld;
            Util3D.DrawCylinder(xform, xcolor);

            axscale.Y = negativeAxis ? s : s * dragScale.Y;
            scale.Scale(axscale);
            xform = scale * normWorld;
            Util3D.DrawCylinder(xform, ycolor);

            axscale.Y = negativeAxis ? s : s * dragScale.Z;
            scale.Scale(axscale);
            rot.RotX(MathHelper.PiOver2);
            xform = scale * rot * normWorld;
            Util3D.DrawCylinder(xform, zcolor);

            rot.RotZ(MathHelper.PiOver2);
            axscale.Y = negativeAxis ? s * dragScale.X : s;
            scale.Scale(axscale);
            xform = scale * rot * normWorld;
            Util3D.DrawCylinder(xform, nxcolor);

            rot.RotZ(MathHelper.Pi);
            axscale.Y = negativeAxis ? s * dragScale.Y : s;
            scale.Scale(axscale);
            xform = scale * rot * normWorld;
            Util3D.DrawCylinder(xform, nycolor);

            rot.RotX(-MathHelper.PiOver2);
            axscale.Y = negativeAxis ? s * dragScale.Z : s;
            scale.Scale(axscale);
            xform = scale * rot * normWorld;
            Util3D.DrawCylinder(xform, nzcolor);

            // draw center cube
            scale.Scale(s*(1.0f / 16.0f));
            xform = scale * normWorld;
            Util3D.DrawCube(xform, Color.White);

            Vec3F handle = sv*AxisHandle;
            float handleWidth = handle.X/2;
            scale.Scale(handle);
            Matrix4F trans = new Matrix4F();

            // X handle
            float drag = m_hitRegion == HitRegion.XAxis ? dragScale.X : 1.0f;
            trans.Translation = new Vec3F(drag * sv.X - handleWidth, 0, 0);
            xform = scale * trans * normWorld;
            Util3D.DrawCube(xform, xcolor);

            // y handle
            drag = m_hitRegion == HitRegion.YAxis ? dragScale.Y : 1.0f;
            trans.Translation = new Vec3F(0, drag * sv.Y - handleWidth, 0);
            xform = scale * trans * normWorld;
            Util3D.DrawCube(xform, ycolor);

            // z handle
            drag = m_hitRegion == HitRegion.ZAxis ? dragScale.Z : 1.0f;
            trans.Translation = new Vec3F(0, 0, drag * sv.Z - handleWidth);
            xform = scale * trans * normWorld;
            Util3D.DrawCube(xform, zcolor);

            // -x handle
            drag = m_hitRegion == HitRegion.NegXAxis ? dragScale.X : 1.0f;
            trans.Translation = new Vec3F(-sv.X * drag + handleWidth, 0, 0);
//.........这里部分代码省略.........
开发者ID:ldh9451,项目名称:XLE,代码行数:101,代码来源:ExtensionManipulator.cs

示例4: ComputeXhead

        private Matrix4F ComputeXhead(Matrix4F normWorld, float s)
        {
            Matrix4F headrot = new Matrix4F();
            headrot.RotZ(-MathHelper.PiOver2);

            Matrix4F trans = new Matrix4F();
            trans.Translation = new Vec3F(s * (1 - hr), 0, 0);
            Matrix4F scale = new Matrix4F();
            scale.Scale(new Vec3F(s * br, s * hr, s * br));
            Matrix4F xform = scale * headrot * trans * normWorld;
            return xform;
        }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:12,代码来源:TranslatorControl.cs

示例5: Render

        public void Render(ViewControl vc, Matrix4F normWorld)
        {
            float s = Util.CalcAxisScale(vc.Camera, normWorld.Translation, Manipulator.AxisLength, vc.Height);
            Color xcolor = (m_hitRegion == HitRegion.XAxis || m_hitRegion == HitRegion.XYSquare || m_hitRegion == HitRegion.XZSquare) ? Color.Gold : Manipulator.XAxisColor;
            Color ycolor = (m_hitRegion == HitRegion.YAxis || m_hitRegion == HitRegion.XYSquare || m_hitRegion == HitRegion.YZSquare) ? Color.Gold : Manipulator.YAxisColor;
            Color Zcolor = (m_hitRegion == HitRegion.ZAxis || m_hitRegion == HitRegion.XZSquare || m_hitRegion == HitRegion.YZSquare) ? Color.Gold : Manipulator.ZAxisColor;

            Color XYx = m_hitRegion == HitRegion.XYSquare ? Color.Gold : Manipulator.XAxisColor;
            Color XYy = m_hitRegion == HitRegion.XYSquare ? Color.Gold : Manipulator.YAxisColor;

            Color XZx = m_hitRegion == HitRegion.XZSquare ? Color.Gold : Manipulator.XAxisColor;
            Color XZz = m_hitRegion == HitRegion.XZSquare ? Color.Gold : Manipulator.ZAxisColor;

            Color YZy = m_hitRegion == HitRegion.YZSquare ? Color.Gold : Manipulator.YAxisColor;
            Color YZz = m_hitRegion == HitRegion.YZSquare ? Color.Gold : Manipulator.ZAxisColor;

            var axisScale = new Matrix4F();
            axisScale.Scale(new Vec3F(s * Manipulator.AxisThickness, s * (1 - ConeHeight), s * Manipulator.AxisThickness));
            var axisrot = new Matrix4F();

            // Draw X axis
            axisrot.RotZ(-MathHelper.PiOver2);
            Matrix4F scaleRot  = axisScale * axisrot;
            Matrix4F axisXform = scaleRot * normWorld;
            Util3D.DrawCylinder(axisXform, xcolor);

            // draw y
            axisXform = axisScale * normWorld;
            Util3D.DrawCylinder(axisXform, ycolor);

            // draw z
            axisrot.RotX(MathHelper.PiOver2);
            scaleRot = axisScale * axisrot;
            axisXform = scaleRot * normWorld;
            Util3D.DrawCylinder(axisXform, Zcolor);

            // draw center cube.
            Matrix4F cubeScale = new Matrix4F();
            cubeScale.Scale(CenterCube * s);
            var cubexform = cubeScale * normWorld;
            Util3D.DrawCube(cubexform, Color.White);

            Matrix4F arrowHead = ComputeXhead(normWorld, s);
            Util3D.DrawCone(arrowHead, xcolor);

            arrowHead = ComputeYhead(normWorld, s);
            Util3D.DrawCone(arrowHead, ycolor);

            arrowHead = ComputeZhead(normWorld, s);
            Util3D.DrawCone(arrowHead, Zcolor);

            // draw xy rect.
            Matrix4F scale = new Matrix4F();
            scale.Scale(s * Manipulator.AxisThickness, s * SquareLength, s * Manipulator.AxisThickness);
            Matrix4F trans = new Matrix4F();
            trans.Translation = new Vec3F(0, s * SquareLength, 0);
            Matrix4F rot = new Matrix4F();
            rot.RotZ(-MathHelper.PiOver2);
            Matrix4F squareXform = scale * rot * trans * normWorld;

            Util3D.DrawCylinder(squareXform, XYy);

            trans.Translation = new Vec3F(s * SquareLength, 0, 0);
            squareXform = scale * trans * normWorld;
            Util3D.DrawCylinder(squareXform, XYx);

            // draw xz rect.
            trans.Translation = new Vec3F(0, 0, s * SquareLength);
            rot.RotZ(-MathHelper.PiOver2);
            squareXform = scale * rot * trans * normWorld;
            Util3D.DrawCylinder(squareXform, XZz);

            trans.Translation = new Vec3F(s * SquareLength, 0, 0);
            rot.RotX(MathHelper.PiOver2);
            squareXform = scale * rot * trans * normWorld;
            Util3D.DrawCylinder(squareXform, XZx);

            // draw yz
            trans.Translation = new Vec3F(0, s * SquareLength, 0);
            rot.RotX(MathHelper.PiOver2);
            squareXform = scale * rot * trans * normWorld;
            Util3D.DrawCylinder(squareXform, YZy);

            trans.Translation = new Vec3F(0, 0, s * SquareLength);
            squareXform = scale * trans * normWorld;
            Util3D.DrawCylinder(squareXform, YZz);
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:87,代码来源:TranslatorControl.cs

示例6: CalcTransform

        /// <summary>
        /// Calculates the transformation matrix corresponding to the given transform components
        /// </summary>
        /// <param name="translation">Translation</param>
        /// <param name="rotation">Rotation</param>
        /// <param name="scale">Scale</param>
        /// <param name="scalePivot">Translation to origin of scaling</param>
        /// <param name="scalePivotTranslate">Translation after scaling</param>
        /// <param name="rotatePivot">Translation to origin of rotation</param>
        /// <param name="rotatePivotTranslate">Translation after rotation</param>
        /// <returns>transformation matrix corresponding to the given transform components</returns>
        public static Matrix4F CalcTransform(
            Vec3F translation,
            Vec3F rotation,
            Vec3F scale,
            Vec3F pivot)
        {
            Matrix4F M = new Matrix4F();
            Matrix4F temp = new Matrix4F();

            M.Set(-pivot);

            temp.Scale(scale);
            M.Mul(M, temp);

            if (rotation.X != 0)
            {
                temp.RotX(rotation.X);
                M.Mul(M, temp);
            }

            if (rotation.Y != 0)
            {
                temp.RotY(rotation.Y);
                M.Mul(M, temp);
            }

            if (rotation.Z != 0)
            {
                temp.RotZ(rotation.Z);
                M.Mul(M, temp);
            }

            temp.Set(pivot + translation);
            M.Mul(M, temp);

            return M;
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:48,代码来源:TransformUtils.cs

示例7: OnNodeSet

        /// <summary>
        /// Performs initialization when the adapter's node is set.
        /// This method is called each time the adapter is connected to its underlying node.
        /// Typically overridden by creators of DOM adapters.</summary>
        protected override void OnNodeSet()
        {
            base.OnNodeSet();

            // get trans, scale, and rot.
            foreach (DomNode domNode in this.DomNode.GetChildList(Schema.node.scaleChild))
            {
                m_scale = Tools.GetVector3(domNode, Schema.TargetableFloat3.Attribute);
                break;
            }

            foreach (DomNode domNode in this.DomNode.GetChildList(Schema.node.translateChild))
            {
                m_translation = Tools.GetVector3(domNode, Schema.TargetableFloat3.Attribute);
                break;
            }
                        
            const float PiOver180 = (float)(Math.PI / 180.0f);
            foreach (DomNode node in DomNode.GetChildList(Schema.node.rotateChild))
            {                
                double[] arr = (double[])node.GetAttribute(Schema.rotate.Attribute);
                float angle = (float)arr[3] * PiOver180;
                string sid = node.GetAttribute(Schema.rotate.sidAttribute) as string;
                if (string.IsNullOrEmpty(sid))
                    continue;
                if (sid == "rotateX")
                    m_rotation.X = angle;
                else if (sid == "rotateY")
                    m_rotation.Y = angle;
                else if (sid == "rotateZ")
                    m_rotation.Z = angle;
            }

            Matrix4F M = new Matrix4F();
            Matrix4F temp = new Matrix4F();

            temp.Scale(Scale);
            M.Mul(M, temp);

            if (m_rotation.X != 0)
            {
                temp.RotX(m_rotation.X);
                M.Mul(M, temp);
            }

            if (m_rotation.Y != 0)
            {
                temp.RotY(m_rotation.Y);
                M.Mul(M, temp);
            }

            if (m_rotation.Z != 0)
            {
                temp.RotZ(m_rotation.Z);
                M.Mul(M, temp);
            }

            temp.Set(Translation);
            M.Mul(M, temp);

            Transform = M;
            m_boundingBox = new Cached<Box>(CalculateBoundingBox);
            Visible = true;
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:68,代码来源:Node.cs

示例8: Render

        public void Render(Camera cam)
        {
            GameEngine.SetRendererFlag(BasicRendererFlags.WireFrame);
            IGrid grid = this.As<IGrid>();

            if (grid.Visible == false)
                return;

            float s = grid.Size;

            Matrix4F scale = new Matrix4F();
            scale.Scale(new Vec3F(s, s, s));

            Matrix4F gridXform = new Matrix4F();
            if (cam.Frustum.IsOrtho)
            {
                float dist = cam.ViewMatrix.Translation.Z;
                ViewTypes vt = cam.ViewType;
                if (vt == ViewTypes.Top)
                {
                    gridXform.Translation
                        = new Vec3F(0, dist, 0);
                }
                else if (vt == ViewTypes.Bottom)
                {
                    gridXform.Translation
                        = new Vec3F(0, -dist, 0);
                }
                else if (vt == ViewTypes.Right)
                {
                    gridXform.RotZ(MathHelper.PiOver2);
                    gridXform.Translation
                        = new Vec3F(dist, 0, 0);
                }
                else if (vt == ViewTypes.Left)
                {
                    gridXform.RotZ(MathHelper.PiOver2);
                    gridXform.Translation
                        = new Vec3F(-dist, 0, 0);

                }
                else if (vt == ViewTypes.Front)
                {
                    gridXform.RotX(MathHelper.PiOver2);
                    gridXform.Translation
                        = new Vec3F(0, 0, dist);

                }
                else if (vt == ViewTypes.Back)
                {
                    gridXform.RotX(MathHelper.PiOver2);
                    gridXform.Translation
                        = new Vec3F(0, 0, -dist);

                }
                gridXform.Mul(scale, gridXform);
            }
            else
            {
                Matrix4F trans = new Matrix4F();
                trans.Translation = new Vec3F(0, grid.Height, 0);
                gridXform = Matrix4F.Multiply(scale, trans);
            }

            GameEngine.DrawPrimitive(PrimitiveType.LineList, m_gridVBId, 0, m_gridVertexCount, Color.LightGray,
                                     Matrix4F.Multiply(gridXform, cam.AxisSystem));

            GameEngine.DrawPrimitive(PrimitiveType.LineList, m_basisAxesVBId, 0, m_basisAxesVertexCount, Color.White,
                                     gridXform);
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:70,代码来源:GridRenderer.cs


注:本文中的Matrix4F.RotZ方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。