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

C# Vec3F类代码示例

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

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



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

示例1: KeyDown

        /// <summary>
        /// Handles key-down 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 KeyDown(object sender, KeyEventArgs e)
        {
            m_keyMap[e.KeyValue] = true;

            ControlScheme controlSchm = InputScheme.ActiveControlScheme;
            // W A S D for forward, strafe left, backward, strafe right, is the default
            Vec3F dir = new Vec3F();
            if (m_keyMap[(int)controlSchm.Left1] ||
                m_keyMap[(int)controlSchm.Left2])
                dir = dir - Camera.Right;
            if (m_keyMap[(int)controlSchm.Right1] ||
                m_keyMap[(int)controlSchm.Right2])
                dir = dir + Camera.Right;
            if (m_keyMap[(int)controlSchm.Forward1] ||
                m_keyMap[(int)controlSchm.Forward2])
                dir = dir + Camera.LookAt;
            if (m_keyMap[(int)controlSchm.Back1] ||
                m_keyMap[(int)controlSchm.Back2])
                dir = dir - Camera.LookAt;

            bool handled = controlSchm.IsControllingCamera(Control.ModifierKeys, e);
            

            if (handled)
            {
                dir.Normalize();
                Camera.Set(Camera.Eye + dir * m_scale);
            }

            return handled;
        }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:36,代码来源:FlyCameraController.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 BezierSpline();
                var controlPoint1 = new Vec3F(1.1f, 2.2f, 3.3f);
                var controlPoint2 = new Vec3F(4.4f, 5.5f, 6.6f);
                var controlPoint3 = new Vec3F(7.7f, 8.8f, 9.9f);
                var incomingTangent = new Vec3F(-1.0f, -2.0f, -3.0f);
                var outgoingTangent = new Vec3F(1.0f, 2.0f, 3.0f);
                o.Add(new BezierPoint(controlPoint1, incomingTangent, outgoingTangent));
                o.Add(new BezierPoint(controlPoint2, incomingTangent, outgoingTangent));
                o.Add(new BezierPoint(controlPoint3, incomingTangent, outgoingTangent));

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

                string s2 = o.ToString();
                Assert.AreEqual(s, s2);

                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,代码行数:35,代码来源:TestBezierSpline.cs


示例3: Extend

        /// <summary>
        /// Extends sphere to enclose another sphere</summary>
        /// <param name="sphere">Sphere to enclose</param>
        /// <returns>Extended sphere</returns>
        public Sphere3F Extend(Sphere3F sphere)
        {
            if (!m_initialized)
            {
                Center = sphere.Center;
                Radius = sphere.Radius;
                m_initialized = true;
            }
            else if (!Contains(sphere))
            {
                if (Center == sphere.Center)
                {
                    Radius = sphere.Radius;
                }
                else
                {
                    Vec3F normal = Vec3F.Normalize(sphere.Center - Center);
                    Vec3F p1 = sphere.Center + (normal * sphere.Radius);
                    Vec3F p2 = Center - (normal * Radius);
                    Radius = (p2 - p1).Length / 2.0f;
                    Center = (p1 + p2) / 2.0f;
                }
            }

            return this;
        }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:30,代码来源:Sphere3F.cs


示例4: IntersectPlane

 /// <summary>
 /// Finds the intersection point of the ray with the given plane. Checks
 /// for the ray being parallel with the plane or the ray pointing away
 /// from the plane</summary>
 /// <param name="plane">Must be constructed "by the rules" of Plane3F</param>
 /// <param name="intersectionPoint">The resulting intersection point or
 /// the zero-point if there was no intersection</param>
 /// <returns>True if the ray points towards the plane and intersects it</returns>
 public bool IntersectPlane(Plane3F plane, out Vec3F intersectionPoint)
 {
     // both the normal and direction must be unit vectors.
     float cos = Vec3F.Dot(plane.Normal, Direction);
     if (Math.Abs(cos) > 0.0001f)
     {
         // dist > 0 means "on the same side as the normal", aka, "the front".
         float dist = plane.SignedDistance(Origin);
         // There are two cases for the ray shooting away from the plane:
         // 1. If the ray is in front of the plane and pointing away,
         //  then 'cos' and 'dist' are both > 0.
         // 2. If the ray is in back of the plane and pointing away,
         //  then 'cos' and 'dist' are both < 0.
         // So, if the signs are the same, then there's no intersection.
         // So, if 'cos' * 'dist' is positive, then there's no intersection.
         if (cos * dist < 0.0)
         {
             // There are two cases for the ray hitting the plane:
             // 1. Origin is behind the plane, so the ray and normal are aligned
             //  and 'dist' is < 0. We need to negate 'dist'.
             // 2. Origin is in front of the plane, so the ray needs to be negated
             //  so that cos(angle-180) is calculated. 'dist' is > 0.
             // Either way, we've got a -1 thrown into the mix. Tricky!
             float t = -dist / cos;
             intersectionPoint = Origin + (Direction * t);
             return true;
         }
     }
     intersectionPoint = new Vec3F(0, 0, 0);
     return false;
 }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:39,代码来源:Ray3F.cs


示例5: 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 corner1 = new Vec3F(1.1f, 2.2f, 3.3f);
                var corner2 = new Vec3F(4.4f, 5.5f, 6.6f);
                var o = new Box(corner1, corner2);

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

                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,代码行数:26,代码来源:TestBox.cs


示例6: 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 normal = new Vec3F(1.1f, 2.2f, 3.3f);
                normal.Normalize();
                var o = new Plane3F(normal, 4.4f);

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

                string s2 = o.ToString();
                Assert.AreEqual(s, s2);

                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,代码行数:29,代码来源:TestPlane3F.cs


示例7: KeyDown

        /// <summary>
        /// Handles key-down 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 KeyDown(object sender, KeyEventArgs e)
        {
            m_keyMap[e.KeyValue] = true;

            // W A S D for forward, strafe left, backward, strafe right, is the default
            Vec3F dir = new Vec3F();
            if (m_keyMap[(int)CanvasControl3D.ControlScheme.Left1] ||
                m_keyMap[(int)CanvasControl3D.ControlScheme.Left2])
                dir = dir - Camera.Right;
            if (m_keyMap[(int)CanvasControl3D.ControlScheme.Right1] ||
                m_keyMap[(int)CanvasControl3D.ControlScheme.Right2]) 
                dir = dir + Camera.Right;
            if (m_keyMap[(int)CanvasControl3D.ControlScheme.Forward1] ||
                m_keyMap[(int)CanvasControl3D.ControlScheme.Forward2])
                dir = dir + Camera.LookAt;
            if (m_keyMap[(int)CanvasControl3D.ControlScheme.Back1] ||
                m_keyMap[(int)CanvasControl3D.ControlScheme.Back2])
                dir = dir - Camera.LookAt;

            bool handled = CanvasControl3D.ControlScheme.IsControllingCamera(Control.ModifierKeys, e);

            if (handled)
            {
                dir.Normalize();
                Vec3F p = Camera.Eye;
                float y = p.Y;
                p += dir * m_scale;
                p.Y = y;
                Camera.Set(p);
            }

            return handled;
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:38,代码来源:WalkCameraController.cs


示例8: DrawLine

 /// <summary>
 /// Draws a colored line from point 1 to point 2</summary>
 /// <param name="p1">Point 1</param>
 /// <param name="p2">Point 2</param>        
 public static void DrawLine(Vec3F p1, Vec3F p2)
 {
     Gl.glBegin(Gl.GL_LINES);
     Gl.glVertex3d(p1.X, p1.Y, p1.Z);
     Gl.glVertex3d(p2.X, p2.Y, p2.Z);
     Gl.glEnd();
     Util3D.RenderStats.VertexCount += 2;
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:12,代码来源:Util3D.cs


示例9: Plane3F

 /// <summary>
 /// Constructs a plane from 3 non-linear points on the plane, such that
 /// Normal * p = Distance</summary>
 /// <param name="p1">First point</param>
 /// <param name="p2">Second point</param>
 /// <param name="p3">Third point</param>
 public Plane3F(Vec3F p1, Vec3F p2, Vec3F p3)
 {
     Vec3F d12 = p2 - p1;
     Vec3F d13 = p3 - p1;
     Vec3F normal = Vec3F.Cross(d12, d13);
     Normal = Vec3F.Normalize(normal);
     Distance = Vec3F.Dot(Normal, p1);
 }
开发者ID:vincenthamm,项目名称:ATF,代码行数:14,代码来源:Plane3F.cs


示例10: SnapPoint

 /// <summary>
 /// Snaps the given point to the nearest grid vertex</summary>
 /// <param name="pt">Point to snap, in world space</param>
 /// <returns>Point, from given point, snapped to grid, in world space</returns>
 public Vec3F SnapPoint(Vec3F pt)
 {
     float segment = Size / (float)Subdivisions;
     Vec3F snap = new Vec3F((int)(pt.X / segment), 0, (int)(pt.Z / segment));
     snap = snap * segment;
     snap.Y = Height;
     return snap;
 }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:12,代码来源:Grid.cs


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


示例12: Evaluate

        /// <summary>
        /// Evaluate the curve on parameter t [0,1]</summary>
        /// <param name="t">Parameter</param>
        /// <returns>Resulting 3D vector</returns>
        public Vec3F Evaluate(float t)
        {
            Vec3F result = new Vec3F();

            float tSquared = t * t;
            float tCubed = tSquared * t;

            result = (m_coefficients[0] * tCubed) + (m_coefficients[1] * tSquared) + (m_coefficients[2] * t) + m_ctrlPoints[0];
            return result;
        }
开发者ID:viniciusx,项目名称:ATF,代码行数:14,代码来源:BezierCurve.cs


示例13: BezierCurve

        /// <summary>
        /// Construct a Bezier curve from 4 control points</summary>
        /// <param name="controlPoints">Array of control points</param>
        public BezierCurve(Vec3F[] controlPoints)
        {
            m_ctrlPoints = controlPoints;

            // Calcualte coefficients
            m_coefficients = new Vec3F[3];

            m_coefficients[2] = 3.0f * (m_ctrlPoints[1] - m_ctrlPoints[0]);
            m_coefficients[1] = 3.0f * (m_ctrlPoints[2] - m_ctrlPoints[1]) - m_coefficients[2];
            m_coefficients[0] = m_ctrlPoints[3] - m_ctrlPoints[0] - m_coefficients[2] - m_coefficients[1];
        }
开发者ID:viniciusx,项目名称:ATF,代码行数:14,代码来源:BezierCurve.cs


示例14: CreateVertices

        // creates grid unit grid.
        public void CreateVertices()
        {
            DeleteVertexBuffer();

            IGrid grid = this.As<IGrid>();
            m_subDiv = grid.Subdivisions;
            float corner = 0.5f;                  // grid.Size / 2.0f;
            float step = 1.0f / (float)m_subDiv;   // grid.Size / (float)subDiv;

            int numLines = (m_subDiv + 1) * 2;
            int numVerts = numLines * 2;

            var vertices = new Vec3F[numVerts];

            int index = 0;
            float s = -corner;

            // Create vertical lines
            for (int i = 0; i <= m_subDiv; i++)
            {
                vertices[index] = new Vec3F(s, 0, corner);
                vertices[index + 1] = new Vec3F(s, 0, -corner);

                index += 2;
                s += step;
            }

            // Create horizontal lines
            s = -corner;
            for (int i = 0; i <= m_subDiv; i++)
            {
                vertices[index] = new Vec3F(corner, 0, s);
                vertices[index + 1] = new Vec3F(-corner, 0, s);

                index += 2;
                s += step;
            }

            m_gridVBId = GameEngine.CreateVertexBuffer(vertices);
            m_gridVertexCount = (uint)vertices.Length;

            {
                var vs = new VertexPC[6];
                vs[0] = new VertexPC(  0.0f,   0.0f,   0.0f, 0xff0000ff);
                vs[1] = new VertexPC(corner,   0.0f,   0.0f, 0xff0000ff);
                vs[2] = new VertexPC(  0.0f,   0.0f,   0.0f, 0xff00ff00);
                vs[3] = new VertexPC(  0.0f, corner,   0.0f, 0xff00ff00);
                vs[4] = new VertexPC(  0.0f,   0.0f,   0.0f, 0xffff0000);
                vs[5] = new VertexPC(  0.0f,   0.0f, corner, 0xffff0000);

                m_basisAxesVBId = GameEngine.CreateVertexBuffer(vs);
                m_basisAxesVertexCount = (uint)vs.Length;
            }
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:55,代码来源:GridRenderer.cs


示例15: GetVector

        /// <summary>
        /// Gets the DomNode attribute as a Vec3F and returns true, or returns false if the attribute
        /// doesn't exist</summary>
        /// <param name="domNode">DomNode holding the attribute</param>
        /// <param name="attribute">Attribute of the DomNode that contains the data</param>
        /// <param name="result">The resulting Vec3F. Is (0,0,0) if the attribute couldn't be found</param>
        /// <returns>True iff the attribute was found and was converted to a Vec3F</returns>
        public static bool GetVector(DomNode domNode, AttributeInfo attribute, out Vec3F result)
        {
            float[] floats = domNode.GetAttribute(attribute) as float[];
            if (floats != null)
            {
                result = new Vec3F(floats);
                return true;
            }

            result = new Vec3F();
            return false;
        }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:19,代码来源:DomNodeUtil.cs


示例16: WorldToSurfaceSpace

        public Point WorldToSurfaceSpace(Vec3F posW)
        {
            Point result = new Point();
            TerrainGob terrain = this.GetParentAs<TerrainGob>();
            ImageData hmImg = terrain.GetSurface();
            ImageData mpImg = GetSurface();
            Point posH = terrain.WorldToSurfaceSpace(posW);

            float dx = (float)mpImg.Width / (float)hmImg.Width;
            float dy = (float)mpImg.Height / (float)hmImg.Height;

            result.X = (int)Math.Round(posH.X * dx);
            result.Y = (int)Math.Round(posH.Y * dy);
            return result;
        }
开发者ID:arsaccol,项目名称:LevelEditor,代码行数:15,代码来源:LayerMap.cs


示例17: TestToStringResults

        private void TestToStringResults(Vec3F o, string s, string listSeparator, string decimalSeparator)
        {
            string[] results = s.Split(new[] { listSeparator }, StringSplitOptions.RemoveEmptyEntries);
            Assert.AreEqual(results.Length, 3);
            foreach (string oneFloatString in results)
                Assert.True(oneFloatString.Contains(decimalSeparator));
            Assert.AreEqual(float.Parse(results[0]), o.X);
            Assert.AreEqual(float.Parse(results[1]), o.Y);
            Assert.AreEqual(float.Parse(results[2]), o.Z);

            Vec3F roundTrip = Vec3F.Parse(s);
            Assert.AreEqual(roundTrip.X, o.X);
            Assert.AreEqual(roundTrip.Y, o.Y);
            Assert.AreEqual(roundTrip.Z, o.Z);
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:15,代码来源:TestVec3F.cs


示例18: DrawArrowDisplayList

        /// <summary>
        /// Draws a 3D arrow from point 1 to point 2 using an OpenGL display list for greatly improved
        /// performance. This method must not be called in between Gl.glNewList and Gl.glEndList.</summary>
        /// <param name="p1">Point 1</param>
        /// <param name="p2">Point 2</param>
        /// <param name="coneSize">Arrow head base diameter</param>
        public static void DrawArrowDisplayList(Vec3F p1, Vec3F p2, float coneSize)
        {
            Gl.glBegin(Gl.GL_LINES);
            Gl.glVertex3f(p1.X, p1.Y, p1.Z);
            Gl.glVertex3f(p2.X, p2.Y, p2.Z);
            Gl.glEnd();

            Gl.glPushMatrix();
            Gl.glTranslatef(p2.X, p2.Y, p2.Z);
            Gl.glPushMatrix();
            Util3D.glMultMatrixf(LookAtMatrix(p2 - p1));
            DrawConeDisplayList(coneSize, coneSize * 2, RenderStyle.Solid);
            Gl.glPopMatrix();
            Gl.glPopMatrix();
            Util3D.RenderStats.VertexCount += 2;
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:22,代码来源:Util3D.cs


示例19: SetPerspective

        /// <summary>
        /// Sets this frustum to frustum represented by the given values</summary>
        /// <param name="fovY">Y field-of-view</param>
        /// <param name="aspectRatio">Aspect ration of frustum cross section</param>
        /// <param name="near">Near plane distance</param>
        /// <param name="far">Far plane distance</param>
        public void SetPerspective(float fovY, float aspectRatio, float near, float far)
        {
            float tanY = (float)Math.Tan((double)fovY / 2.0);
            float tanX = tanY * aspectRatio;
            Vec3F xAxis = new Vec3F(-1, 0, -tanX);
            Vec3F yAxis = new Vec3F(0, -1, -tanY);
            float nX = xAxis.Length;
            float nY = yAxis.Length;

            // The view coordinate system has +y pointing up, +x to the right, +z out of the screen.
            m_planes[iRight].Set(new Vec3F(-1, 0, -tanX) / nX, 0.0f);
            m_planes[iLeft].Set(new Vec3F(1, 0, -tanX) / nX, 0.0f);
            m_planes[iTop].Set(new Vec3F(0, -1, -tanY) / nY, 0.0f);
            m_planes[iBottom].Set(new Vec3F(0, 1, -tanY) / nY, 0.0f);
            m_planes[iNear].Set(new Vec3F(0, 0, -1), near);
            m_planes[iFar].Set(new Vec3F(0, 0, 1), -far);
        }
开发者ID:vincenthamm,项目名称:ATF,代码行数:23,代码来源:Frustum.cs


示例20: Extend

        /// <summary>
        /// Extends box to contain the given point, or if this box is uninitialized, the box is
        /// initialized from the point</summary>
        /// <param name="p">Point</param>
        /// <returns>Extended box</returns>
        public void Extend(Vec3F p)
        {
            if (m_initialized == false)
            {
                Min = Max = p;
                m_initialized = true;
            }
            else
            {
                Min.X = Math.Min(Min.X, p.X);
                Min.Y = Math.Min(Min.Y, p.Y);
                Min.Z = Math.Min(Min.Z, p.Z);

                Max.X = Math.Max(Max.X, p.X);
                Max.Y = Math.Max(Max.Y, p.Y);
                Max.Z = Math.Max(Max.Z, p.Z);
            }
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:23,代码来源:AABB.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Vector类代码示例发布时间:2022-05-24
下一篇:
C# Vec3类代码示例发布时间: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