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


C# Primitive.AddVertex方法代码示例

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


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

示例1: Arrow

        public static void Arrow(Vector3 start, Vector3 end, float arrowSize, Color color)
        {
            if (mSingleton == null ||
                !mSingleton.IsEnabled) {
                return;
            }

            Primitive p = new Primitive(color);
            p.AddVertex(start);
            p.AddVertex(end);

            Vector3 dir = Vector3.Normalize(end - start);
            Vector3 right;

            float dot = Vector3.Dot(dir, Vector3.UnitY);
            if (dot > .99f || dot < -.99f)
                right = Vector3.Cross(dir, Vector3.UnitX);
            else
                right = Vector3.Cross(dir, Vector3.UnitY);

            Vector3 top = Vector3.Cross(right, dir);

            dir *= arrowSize;
            right *= arrowSize;
            top *= arrowSize;

            // added by pentium @13/5/25
            float slantSize = 50;
            dir *= slantSize;
            right *= slantSize;
            top *= slantSize;

            // Right slant.
            p.AddVertex(end);
            p.AddVertex(end + right - dir);

            // Left slant.
            p.AddVertex(end);
            p.AddVertex(end - right - dir);

            // Top slant.
            p.AddVertex(end);
            p.AddVertex(end + top - dir);

            // Bottom slant.
            p.AddVertex(end);
            p.AddVertex(end - top - dir);

            mSingleton.mLinePrimitives.Add(p);
        }
开发者ID:pentiumx,项目名称:HLSLTest,代码行数:50,代码来源:DebugOverlay.cs

示例2: Sphere

        public static void Sphere(Vector3 pos, float radius, Color color)
        {
            if (mSingleton == null ||
                !mSingleton.IsEnabled) {
                return;
            }

            Primitive p = new Primitive(color);

            // Decrease these angles to increase the complexity of the sphere.
            int dtheta = 35, dphi = 35;
            int theta, phi;
            const double DegToRads = System.Math.PI / 180;

            for (theta = -90; theta <= 90 - dtheta; theta += dtheta) {
                for (phi = 0; phi <= 360 - dphi; phi += dphi) {
                    p.AddVertex((pos + radius * new Vector3((float)(Math.Cos(theta * DegToRads) * Math.Cos(phi * DegToRads)),
                                                (float)(Math.Cos(theta * DegToRads) * Math.Sin(phi * DegToRads)),
                                                (float)(Math.Sin(theta * DegToRads)))));

                    p.AddVertex((pos + radius * new Vector3((float)(Math.Cos((theta + dtheta) * DegToRads) * Math.Cos(phi * DegToRads)),
                                                (float)(Math.Cos((theta + dtheta) * DegToRads) * Math.Sin(phi * DegToRads)),
                                                (float)(Math.Sin((theta + dtheta) * DegToRads)))));

                    p.AddVertex((pos + radius * new Vector3((float)(Math.Cos((theta + dtheta) * DegToRads) * Math.Cos((phi + dphi) * DegToRads)),
                                                (float)(Math.Cos((theta + dtheta) * DegToRads) * Math.Sin((phi + dphi) * DegToRads)),
                                                (float)(Math.Sin((theta + dtheta) * DegToRads)))));

                    if (theta > -90 && theta < 90) {
                        p.AddVertex((pos + radius * new Vector3((float)(Math.Cos(theta * DegToRads) * Math.Cos((phi + dphi) * DegToRads)),
                                                    (float)(Math.Cos(theta * DegToRads) * Math.Sin((phi + dphi) * DegToRads)),
                                                    (float)(Math.Sin(theta * DegToRads)))));
                    }
                }
            }

            mSingleton.mLinePrimitives.Add(p);
        }
开发者ID:pentiumx,项目名称:HLSLTest,代码行数:38,代码来源:DebugOverlay.cs

示例3: Line

        public static void Line(Vector3 start, Vector3 end, Color color)
        {
            if (mSingleton == null ||
                !mSingleton.IsEnabled) {
                return;
            }

            Primitive p = new Primitive(color);
            p.AddVertex(start);
            p.AddVertex(end);

            mSingleton.mLinePrimitives.Add(p);
        }
开发者ID:pentiumx,项目名称:HLSLTest,代码行数:13,代码来源:DebugOverlay.cs

示例4: Point

        public static void Point(Vector3 pos, Color color)
        {
            if (mSingleton == null ||
                !mSingleton.IsEnabled) {
                return;
            }

            foreach (Primitive p in mSingleton.mPointPrimitives) {
                // Re-use existing primitive w/ same color for batch rendering.
                if (p.mColor == color) {
                    p.AddVertex(pos);
                    return;
                }
            }

            Primitive primitive = new Primitive(color);
            primitive.AddVertex(pos);
            mSingleton.mPointPrimitives.Add(primitive);
        }
开发者ID:pentiumx,项目名称:HLSLTest,代码行数:19,代码来源:DebugOverlay.cs

示例5: BoundingBox

        public static void BoundingBox(BoundingBox boundingBox, Color color)
        {
            if (mSingleton == null ||
                !mSingleton.IsEnabled) {
                return;
            }

            Vector3 halfExtents = (boundingBox.Max - boundingBox.Min) * 0.5f;
            Vector3 center = (boundingBox.Max + boundingBox.Min) * 0.5f;

            Vector3 edgecoord = Vector3.One, pa, pb;

            Primitive primitive = new Primitive(color);

            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 3; j++) {
                    pa = new Vector3(edgecoord.X * halfExtents.X, edgecoord.Y * halfExtents.Y,
                        edgecoord.Z * halfExtents.Z);
                    pa += center;

                    int othercoord = j % 3;
                    SetElement(ref edgecoord, othercoord, GetElement(edgecoord, othercoord) * -1f);
                    pb = new Vector3(edgecoord.X * halfExtents.X, edgecoord.Y * halfExtents.Y,
                        edgecoord.Z * halfExtents.Z);
                    pb += center;

                    primitive.AddVertex(pa);
                    primitive.AddVertex(pb);
                }

                edgecoord = new Vector3(-1f, -1f, -1f);

                if (i < 3) SetElement(ref edgecoord, i, GetElement(edgecoord, i) * -1f);
            }

            mSingleton.mLinePrimitives.Add(primitive);
        }
开发者ID:pentiumx,项目名称:HLSLTest,代码行数:37,代码来源:DebugOverlay.cs


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