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


C# Matrix4F.RotY方法代码示例

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


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

示例1: MouseMove

        /// <summary>
        /// Handles mouse-move events</summary>
        /// <param name="sender">Control that raised original event</param>
        /// <param name="e">Event args</param>
        /// <returns>true, if controller handled the event</returns>
        public override bool MouseMove(object sender, MouseEventArgs e)
        {
            if (m_dragging &&
                InputScheme.ActiveControlScheme.IsControllingCamera(Control.ModifierKeys, e))
            {
                float dx = (float)(e.X - m_lastMousePoint.X) / 150.0f;
                float dy = (float)(e.Y - m_lastMousePoint.Y) / 150.0f;

                if (InputScheme.ActiveControlScheme.IsElevating(Control.ModifierKeys, e))
                {
                    // move camera up/down
                    Vec3F p = Camera.Eye;
                    p.Y += (dy < 0) ? m_scale : -m_scale;
                    Camera.Set(p);
                }
                else if (InputScheme.ActiveControlScheme.IsTurning(Control.ModifierKeys, e))
                {
                    // pitch and yaw camera
                    Matrix4F mat = Matrix4F.RotAxisRH(Camera.Right, -dy); // pitch along camera right
                    Matrix4F yaw = new Matrix4F();
                    yaw.RotY(-dx);
                    mat.Mul(yaw, mat);

                    Vec3F lookAt = Camera.LookAt;
                    Vec3F up = Camera.Up;
                    mat.Transform(ref lookAt);
                    mat.Transform(ref up);

                    Vec3F position = Camera.Eye;
                    float d = Camera.DistanceFromLookAt;
                    Camera.Set(position, position + lookAt * d, up);
                }

                m_lastMousePoint = e.Location;

                return true;
            }

            return base.MouseMove(sender, e);
        }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:45,代码来源:FlyCameraController.cs

示例2: Render

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

            Util3D.RenderFlag = BasicRendererFlags.WireFrame | BasicRendererFlags.DisableDepthTest;
            Color xcolor = (m_hitRegion == HitRegion.XAxis ) ? Color.LightSalmon : Color.Red;
            Color ycolor = (m_hitRegion == HitRegion.YAxis ) ? Color.LightGreen : Color.Green;
            Color Zcolor = (m_hitRegion == HitRegion.ZAxis ) ? Color.LightBlue : Color.Blue;

            float s;
            Util.CalcAxisLengths(vc.Camera, normWorld.Translation, out s);
            Vec3F axScale = new Vec3F(s, s, s);

            Matrix4F scale = new Matrix4F();
            scale.Scale(axScale);
            Matrix4F xform = scale*normWorld;
            Util3D.DrawCircle(xform, Zcolor);

            Matrix4F rot = new Matrix4F();
            rot.RotY(MathHelper.PiOver2);
            xform = scale * rot * normWorld;
            Util3D.DrawCircle(xform, xcolor);

            rot.RotX(MathHelper.PiOver2);
            xform = scale * rot * normWorld;
            Util3D.DrawCircle(xform,ycolor);

        }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:29,代码来源:RotateManipulator.cs

示例3: 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

示例4: 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

示例5: CreateTorus

        public static void CreateTorus(float innerRadius,
            float outerRadius,
            uint rings,
            uint sides,
            List<Vec3F> pos,
            List<Vec3F> nor,
            List<Vec2F> tex,
            List<uint> indices)
        {
            uint ringStride = rings + 1;
            uint sideStride = sides + 1;

            // radiusC: distance to center of the ring
            float radiusC = (innerRadius + outerRadius) * 0.5f;

            //radiusR: the radius of the ring
            float radiusR = (outerRadius - radiusC);

            for (uint i = 0; i <= rings; i++)
            {
                float u = (float)i / rings;

                float outerAngle = i * MathHelper.TwoPi / rings;

                // xform from ring space to torus space.
                Matrix4F trans = new Matrix4F();
                trans.Translation = new Vec3F(radiusC, 0, 0);
                Matrix4F roty = new Matrix4F();
                roty.RotY(outerAngle);
                Matrix4F transform = trans * roty;

                // create vertices for each ring.
                for (uint j = 0; j <= sides; j++)
                {
                    float v = (float)j / sides;

                    float innerAngle = j * MathHelper.TwoPi / sides + MathHelper.Pi;
                    float dx = (float)Math.Cos(innerAngle);
                    float dy = (float)Math.Sin(innerAngle);

                    // normal, position ,and texture coordinates
                    Vec3F n = new Vec3F(dx, dy, 0);
                    Vec3F p = n * radiusR;

                    if (tex != null)
                    {
                        Vec2F t = new Vec2F(u, v);
                        tex.Add(t);
                    }

                    transform.Transform(ref p);
                    transform.TransformVector(n, out n);

                    pos.Add(p);
                    nor.Add(n);

                    // And create indices for two triangles.
                    uint nextI = (i + 1) % ringStride;
                    uint nextJ = (j + 1) % sideStride;

                    indices.Add(nextI * sideStride + j);
                    indices.Add(i * sideStride + nextJ);
                    indices.Add(i * sideStride + j);

                    indices.Add(nextI * sideStride + j);
                    indices.Add(nextI * sideStride + nextJ);
                    indices.Add(i * sideStride + nextJ);
                }
            }
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:70,代码来源:Util3d.cs


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