• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Matrix4F类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Render

        /// <summary>
        /// Renders the control</summary>
        /// <param name="action">Render action</param>
        /// <param name="camera">Camera</param>
        /// <param name="state">Render state</param>
        /// <param name="transform">Transform</param>
        public void Render(IRenderAction action, Camera camera, RenderState state, Matrix4F transform)
        {
            float s1, s2, s3;

            // apply xform
            Gl.glPushMatrix();
            Util3D.glMultMatrixf(transform);

            CalcAxisLengths(camera, transform, out s1, out s2, out s3);

            bool drawX, drawY, drawZ;
            DecideArrowDrawing(transform, camera, out drawX, out drawY, out drawZ);

            if (drawX)
            {
                RenderXArrow(s1);
                RenderXAxis(s1);
            }
            if (drawY)
            {
                RenderYArrow(s2);
                RenderYAxis(s2);
            }
            if (drawZ)
            {
                RenderZArrow(s3);
                RenderZAxis(s3);
            }

            RenderXYSquare(s1 * SquareLength, s2 * SquareLength, true);
            RenderYZSquare(s2 * SquareLength, s3 * SquareLength, true);
            RenderXZSquare(s1 * SquareLength, s3 * SquareLength, true);
            
            Gl.glPopMatrix();
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:41,代码来源:TranslatorControl.cs


示例2: TestToStringWithCulture

        private void TestToStringWithCulture(CultureInfo culture)
        {
            CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = culture;
            try
            {
                string listSeparator = culture.TextInfo.ListSeparator;
                string decimalSeparator = culture.NumberFormat.NumberDecimalSeparator;
                var o = new Matrix4F(
                    1.1f, 2.2f, 3.3f, 4.4f,
                    5.5f, 6.6f, 7.7f, 8.8f,
                    9.9f, 10.10f, 11.11f, 12.12f,
                    13.13f, 14.14f, 15.15f, 16.16f);

                string s = o.ToString(null, null);
                TestToStringResults(o, s, listSeparator, decimalSeparator);

                s = o.ToString();
                Assert.True(s.Contains(listSeparator));

                s = o.ToString("G", culture);
                TestToStringResults(o, s, listSeparator, decimalSeparator);

                s = o.ToString("R", culture);
                TestToStringResults(o, s, listSeparator, decimalSeparator);
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = originalCulture;
            }
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:31,代码来源:TestMatrix4F.cs


示例3: TraverseNode

 /// <summary>
 /// Constructor</summary>
 /// <param name="renderObject">RenderObject. A reference is held to this, so that IRenderObject.Dispatch
 /// can be called.</param>
 /// <param name="transform">Transform to use when dispatching the RenderObject; a reference is held</param>
 /// <param name="graphPath">Graph path leading to RenderObject; a reference is held</param>
 /// <param name="renderState">RenderState to use for RenderObject; is copied</param>
 public TraverseNode(
     IRenderObject renderObject,
     Matrix4F transform,
     Stack<SceneNode> graphPath,
     RenderState renderState)
 {
     Init(renderObject, transform, graphPath, renderState);
 }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:15,代码来源:TraverseNode.cs


示例4: DrawCircle

 public static void DrawCircle(GUILayer.SimpleRenderingContext context, Matrix4F xform, Color color)
 {
     GameEngine.DrawPrimitive(context, PrimitiveType.LineStrip,
        s_circleVerts,
        0,
        s_circleVertexCount,
        color,
        xform);
 }
开发者ID:coreafive,项目名称:XLE,代码行数:9,代码来源:Util3d.cs


示例5: DrawUnitSquare

 public static void DrawUnitSquare(GUILayer.SimpleRenderingContext context, Matrix4F xform, Color color)
 {
     GameEngine.DrawPrimitive(context, PrimitiveType.LineList,
         s_linesVertId,
         s_unitSquareStartVertex,
         s_unitSquareVertexCount,
         color,
         xform);
 }
开发者ID:coreafive,项目名称:XLE,代码行数:9,代码来源:Util3d.cs


示例6: SetTransform

 /// <summary>
 /// Decomposes the given matrix to translation, scale, 
 /// and rotation and set them to given Transformable node.        
 /// </summary>        
 public static void SetTransform(ITransformable xform, Matrix4F mtrx)
 {
     xform.Translation = mtrx.Translation;
     xform.Scale = mtrx.GetScale();
     Vec3F rot = new Vec3F();
     mtrx.GetEulerAngles(out rot.X, out rot.Y, out rot.Z);
     xform.Rotation = rot;
     xform.UpdateTransform();
 }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:13,代码来源:TransformUtils.cs


示例7: DrawPivot

 public static void DrawPivot(GUILayer.SimpleRenderingContext context, Matrix4F xform, Color c)
 {
     GameEngine.DrawPrimitive(context, PrimitiveType.LineStrip,
       s_pivotVerts,
       0,
       s_pivotVertexCount,
       c,
       xform);            
 }
开发者ID:coreafive,项目名称:XLE,代码行数:9,代码来源:Util3d.cs


示例8: Init

 /// <summary>
 /// Initializes instance</summary>
 /// <param name="renderObject">RenderObject. A reference is held to this, so that IRenderObject.Dispatch
 /// can be called.</param>
 /// <param name="transform">Transform to use when dispatching the RenderObject; a reference is held</param>
 /// <param name="graphPath">Graph path leading to RenderObject; a reference is held</param>
 /// <param name="renderState">RenderState to use for RenderObject; is copied</param>
 public void Init(
     IRenderObject renderObject,
     Matrix4F transform,
     Stack<SceneNode> graphPath,
     RenderState renderState)
 {
     m_renderObject = renderObject;
     m_transform = transform;
     m_renderState.Init(renderState);
     m_graphPath = graphPath.ToArray();//faster to create every time than to cache!
 }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:18,代码来源:TraverseNode.cs


示例9: DrawUnitSquare

 public static void DrawUnitSquare(Matrix4F xform, Color color)
 {
     GameEngine.DrawPrimitive(PrimitiveType.LineList,
         s_linesVertId,
         s_unitSquareStartVertex,
         s_unitSquareVertexCount,
         color,
         xform,
         RenderFlag
         );
 }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:11,代码来源:Util3d.cs


示例10: DrawCircle

 public static void DrawCircle(Matrix4F xform, Color color)
 {            
     GameEngine.DrawPrimitive(PrimitiveType.LineStrip,
        s_circleVerts,
        0,
        s_circleVertexCount,
        color,
        xform,
        RenderFlag
        );
 }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:11,代码来源:Util3d.cs


示例11: DrawPivot

 public static void DrawPivot(Matrix4F xform, Color c)
 {
     GameEngine.DrawPrimitive(PrimitiveType.LineStrip,
       s_pivotVerts,
       0,
       s_pivotVertexCount,
       c,
       xform,
       RenderFlag
       );            
 }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:11,代码来源:Util3d.cs


示例12: TestToStringResults

 private void TestToStringResults(Matrix4F o, string s, string listSeparator, string decimalSeparator)
 {
     string[] results = s.Split(new[] { listSeparator }, StringSplitOptions.RemoveEmptyEntries);
     Assert.AreEqual(results.Length, 16);
     for (int i = 0; i < 16; i++)
     {
         Assert.True(results[i].Contains(decimalSeparator));
         float result = float.Parse(results[i]);
         Assert.AreEqual(result, o[i]);
     }
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:11,代码来源:TestMatrix4F.cs


示例13: OnBeginDrag

        public override void OnBeginDrag()
        {
            if (m_hitRegion == HitRegion.None || !CanManipulate(m_node))
                return;
            var transactionContext = DesignView.Context.As<ITransactionContext>();
            transactionContext.Begin("Move".Localize());
            m_originalPivot = m_node.Pivot;

            Path<DomNode> path = new Path<DomNode>(m_node.Cast<DomNode>().GetPath());
            Matrix4F localToWorld = TransformUtils.CalcPathTransform(path, path.Count - 1);
            m_worldToLocal = new Matrix4F();
            m_worldToLocal.Invert(localToWorld);
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:13,代码来源:TranslatePivotManipulator.cs


示例14: ComputeWorldTransform

 /// <summary>
 /// Computes world transformation matrix for the given 
 /// Transformable node.</summary>        
 public static Matrix4F ComputeWorldTransform(ITransformable xform)
 {
     Matrix4F world = new Matrix4F();
     DomNode node = xform.As<DomNode>();
     foreach (DomNode n in node.Lineage)
     {
         ITransformable xformNode = n.As<ITransformable>();
         if (xformNode != null)
         {
             world.Mul(world, xformNode.Transform);
         }
     }
     return world;
 }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:17,代码来源:TransformUtils.cs


示例15: CalcPathTransform

        /// <summary>
        /// Calculates the world space matrix of the given path</summary>
        /// <param name="path">The path</param>
        /// <param name="start">Starting index</param>
        /// <param name="M">the world matrix</param>        
        public static void CalcPathTransform(Matrix4F M, Path<DomNode> path, int start)
        {
            for (int i = start; i >= 0; i--)
            {
                if (path[i] != null)
                {
                    ITransformable renderable =
                        path[i].As<ITransformable>();

                    if (renderable != null)
                    {
                        M.Mul(M, renderable.Transform);
                    }
                }
            }
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:21,代码来源:TransformUtils.cs


示例16: CalcPathTransform

        /// <summary>
        /// Calculates the world space matrix of the given SceneNode path, starting from a given index</summary>
        /// <param name="path">The SceneNode path</param>
        /// <param name="start">Starting index within the path</param>
        /// <returns>The world space matrix</returns>
        public static Matrix4F CalcPathTransform(SceneNode[] path, int start)
        {
            Matrix4F M = new Matrix4F();

            for (int i = start; i < path.Length; i++)
            {
                if (path[i].Source != null)
                {
                    ITransformable renderable =
                        path[i].Source.As<ITransformable>();

                    if (renderable != null)
                    {
                        M.Mul(M, renderable.Transform);
                    }
                }
            }

            return M;
        }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:25,代码来源:TransformUtils.cs


示例17: InsertPoint

        public IControlPoint InsertPoint(uint index, float x, float y, float z)
        {            
            IControlPoint cpt = CreateControlPoint();
            int numSteps = GetAttribute<int>(Schema.curveType.stepsAttribute);
            int interpolationType = GetAttribute<int>(Schema.curveType.interpolationTypeAttribute);            
            if (interpolationType != 0 && numSteps > 0)
            {
                index = index / (uint)numSteps;
            }


            Path<DomNode> path = new Path<DomNode>(DomNode.GetPath());
            Matrix4F toworld = TransformUtils.CalcPathTransform(path, path.Count - 1);
            Matrix4F worldToLocal = new Matrix4F();
            worldToLocal.Invert(toworld);
            Vec3F pos = new Vec3F(x, y, z);
            worldToLocal.Transform(ref pos);
            cpt.Translation = pos;
            ControlPoints.Insert((int)index + 1, cpt);
            return cpt;
        }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:21,代码来源:Curve.cs


示例18: Render

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

            Camera camera = vc.Camera;
            float s;
            Util.CalcAxisLengths(camera, normWorld.Translation, out s);
            m_translatorControl.Render(normWorld, s);        
            
            Matrix4F sc = new Matrix4F();
            Vec3F pos = normWorld.Translation;            
            s /= 12.0f;
            sc.Scale(s);

            Matrix4F bl = new Matrix4F();
            Util.CreateBillboard(bl, pos, camera.WorldEye, camera.Up, camera.LookAt);

            Matrix4F recXform = new Matrix4F();
            Matrix4F.Multiply(sc, bl, recXform);

            Util3D.DrawPivot(recXform, Color.Yellow);
        }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:23,代码来源:TranslatePivotManipulator.cs


示例19: Pick

        public override bool Pick(ViewControl vc, Point scrPt)
        {
            m_hitRegion = HitRegion.None;
            if (base.Pick(vc, scrPt) == false)
                return false;

            Camera camera = vc.Camera;
            
            Matrix4F view = camera.ViewMatrix;
            Matrix4F vp = view  * camera.ProjectionMatrix;
            Matrix4F wvp = HitMatrix * vp;
            
            Ray3F rayL = vc.GetRay(scrPt,wvp);

            float s = Util.CalcAxisScale(vc.Camera, HitMatrix.Translation, AxisLength, vc.Height);

                // There's only one hot-spot for this manipulator:
                //      a square at the manipulator origin.
            Vec3F min = new Vec3F(-0.5f, -0.5f, -0.5f);
            Vec3F max = new Vec3F(0.5f, 0.5f, 0.5f);
            AABB box = new AABB(min, max);

            float centerCubeScale = s * CenterCubeSize;
            Matrix4F centerCubeXform = new Matrix4F();
            centerCubeXform.Scale(centerCubeScale);
            centerCubeXform.Invert(centerCubeXform);
            Ray3F ray = rayL;
            ray.Transform(centerCubeXform);
            if (box.Intersect(ray))
            {
                m_hitRegion = HitRegion.XYSquare;
                return true;
            }

            m_hitRegion = HitRegion.None;
            return false;
        }
开发者ID:coreafive,项目名称:XLE,代码行数:37,代码来源:MoveAcrossTerrainManipulator.cs


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Matrix4x4类代码示例发布时间:2022-05-24
下一篇:
C# Matrix44类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap