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


C# Vector3.GetLength方法代码示例

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


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

示例1: findMaxPoints

        /// <summary>
        /// From min and max coords of the BB, project them according to the active view, for determining zooming scale
        /// </summary>
        /// <param name="min"> The min coord of BB </param>
        /// <param name="max"> The max coord of BB </param>
        /// <param name="activeView"> Active view to zoom </param>
        /// <returns> Returns an array of two vectos in screen space </returns>
        private Vector2[] findMaxPoints(Vector3 min, Vector3 max, Canguro.View.GraphicView activeView)
        {
            Vector3[] boundingVolume = new Vector3[8];

            Vector2[] screen = new Vector2[2];

            screen[0] = new Vector2(float.MaxValue, float.MaxValue);
            screen[1] = new Vector2(float.MinValue, float.MinValue);

            boundingVolume[0] = min;
            boundingVolume[1] = new Vector3(min.X, min.Y, max.Z);
            boundingVolume[2] = new Vector3(max.X, min.Y, max.Z);
            boundingVolume[3] = new Vector3(max.X, min.Y, min.Z);

            boundingVolume[4] = new Vector3(max.X, max.Y, min.Z);
            boundingVolume[5] = max;
            boundingVolume[6] = new Vector3(min.X, max.Y, max.Z);
            boundingVolume[7] = new Vector3(min.X, max.Y, min.Z);

            for (int i = 0; i < boundingVolume.GetLength(0); ++i)
            {
                activeView.Project(ref boundingVolume[i]);
                screen[0].X = (screen[0].X > boundingVolume[i].X) ? boundingVolume[i].X : screen[0].X;
                screen[0].Y = (screen[0].Y > boundingVolume[i].Y) ? boundingVolume[i].Y : screen[0].Y;

                screen[1].X = (screen[1].X < boundingVolume[i].X) ? boundingVolume[i].X : screen[1].X;
                screen[1].Y = (screen[1].Y < boundingVolume[i].Y) ? boundingVolume[i].Y : screen[1].Y;
            }

            return screen;
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:38,代码来源:ZoomAll.cs

示例2: Build

            /// <summary> Builds an extrusion from the shape along a curve </summary>
            /// <param name="shape"> An array indicating the shape points ordered counter_clockwise. First index is for vertex and second for normals. </param>
            /// <param name="axis"> The curve that must be followed. Array of vertixes. </param>
            /// <param name="axisDerivative"> The derivative at each vertex in the curve. </param>
            /// <param name="extrudedMesh"> A ref variable containing the extruded mesh. First index refers to vertices and the second to normals. </param>
            public static void Build(Vector2[][] shape, Vector3[] axis, Vector3[] axisDerivative, ref Vector3[,] extrudedMesh, ref int[] extrudedIndices, bool faceNormals, short[] cover, Vector3[] origAxes)
            {
                // Get the number of segments in the curve
                nPointSegments = axis.GetLength(0);
                // Get the number of vertices in the shape
                nShapeVertices = shape[0].GetLength(0);
                // Initialize some counters
                meshVertex = 0;
                //index = 0;

                // How many vertices in the mesh are we going to have?
                int coverSize = cover.Length;
                nMeshVertices = nShapeVertices * (nPointSegments - 1) * 6 + 2 * coverSize; // 6 vertices per face

                // Just get memory when necessary (vectors)
                if (extrudedMesh == null || nMeshVertices != extrudedMesh.GetLength(1))
                    extrudedMesh = new Vector3[2, nMeshVertices];
                // Just get memory when necessary (colors)
                if (extrudedIndices == null || nMeshVertices != extrudedIndices.GetLength(0))
                    extrudedIndices = new int[nMeshVertices];

                for (segment = 0; segment < nPointSegments - 1; ++segment)
                {
                    // Compute the plane at the current point in the curve
                    if (axisDerivative != null && axisDerivative[segment] != Vector3.Empty)
                        lineDir = axisDerivative[segment];
                    // When no derivatives are computed, use instead the line direction
                    else
                    {
                        if (segment == nPointSegments - 1)
                            lineDir = axis[nPointSegments - 1] - axis[nPointSegments - 2];
                        else
                            lineDir = axis[segment + 1] - axis[segment];

                        lineDir.Normalize();
                    }

                    // Check if we have a 'good' value
                    checkIntegrity(ref lineDir);

                    // and compute the local axes at the current curve point
                    currAxes = computeLocalSystem(lineDir, origAxes);

                    currDir = lineDir;

                    if (segment > 0)
                    {
                        temp1 = nextAxes[0];
                        temp2 = nextAxes[1];
                        temp3 = nextAxes[2];
                    }

                    int auxSegment = segment + 1;
                    // Compute the plane at the next point in the curve
                    if (axisDerivative != null && axisDerivative[auxSegment] != Vector3.Empty)
                        lineDir = axisDerivative[auxSegment];
                    // When no derivatives are computed, use instead the line direction
                    else
                    {
                        if (auxSegment == nPointSegments - 1)
                            lineDir = axis[nPointSegments - 1] - axis[nPointSegments - 2];
                        else
                            lineDir = axis[auxSegment + 1] - axis[auxSegment];

                        lineDir.Normalize();
                    }

                    lineDir += currDir;
                    lineDir.Normalize();

                    // Check if we have a 'good' value
                    checkIntegrity(ref lineDir);
                    nextAxes = computeLocalSystem(lineDir, origAxes);

                    if (segment > 0)
                    {
                        currAxes[0] = temp1;
                        currAxes[1] = temp2;
                        currAxes[2] = temp3;
                    }

                    // Make start cover
                    if (segment == 0)
                    {
                        for (int i = 0; i < coverSize; ++i)
                        {
                            extrudedMesh[0, meshVertex] = axis[segment] + shape[0][cover[i]].X * currAxes[0] + shape[0][cover[i]].Y * currAxes[1];
                            extrudedMesh[1, meshVertex] = -currAxes[2];
                            extrudedIndices[meshVertex] = cover[i];
                            ++meshVertex;
                        }
                    }
                    // Make end cover
                    else if (auxSegment == nPointSegments - 1)
                    {
//.........这里部分代码省略.........
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:101,代码来源:Extrusion.cs

示例3: Texture

        /// <summary>
        /// Constructs a 2D texture from a matrix of 3D data vectors.
        /// </summary>
        /// <param name="window">A reference to the Direct3D-capable window containing the rendering engine.</param>
        /// <param name="data">A matrix of 3D data vectors that will make up the texture on the GPU.</param>
        public Texture(Window3D window, Vector3[,] data)
            : this(window)
        {
            int h = data.GetLength(0);
            int w = data.GetLength(1);
            int szVector = SizeOf<Vector4>();

            ImageBuffer = Tag(new DataStream(szVector * h * w, true, true));
            foreach (Vector3 x in data) { ImageBuffer.Write((Vector4)x); }

            Image = Tag(new Texture2D
            (
                Device3D,
                CreateTextureDescription(h, w, Formats.Float4),
                new DataRectangle(ImageBuffer.DataPointer, w * szVector)
            ));

            SRV = Tag(new ShaderResourceView(Device3D, Image));
        }
开发者ID:JoshGrooms,项目名称:Tesseract,代码行数:24,代码来源:Texture.cs


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