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

C# Graphics.VertexPositionNormalTexture类代码示例

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

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



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

示例1: GetShapeMeshData

        public static void GetShapeMeshData(EntityCollidable collidable, List<VertexPositionNormalTexture> vertices, List<ushort> indices)
        {
            var convexHullShape = collidable.Shape as ConvexHullShape;
            if (convexHullShape == null)
                throw new ArgumentException("Wrong shape type.");

            var hullTriangleVertices = new List<Vector3>();
            var hullTriangleIndices = new List<int>();
            Toolbox.GetConvexHull(convexHullShape.Vertices, hullTriangleIndices, hullTriangleVertices);
            //The hull triangle vertices are used as a dummy to get the unnecessary hull vertices, which are cleared afterwards.
            hullTriangleVertices.Clear();
            foreach (int i in hullTriangleIndices)
            {
                hullTriangleVertices.Add(convexHullShape.Vertices[i]);
            }

            var toReturn = new VertexPositionNormalTexture[hullTriangleVertices.Count];
            Vector3 normal;
            for (ushort i = 0; i < hullTriangleVertices.Count; i += 3)
            {
                normal = Vector3.Normalize(Vector3.Cross(hullTriangleVertices[i + 2] - hullTriangleVertices[i], hullTriangleVertices[i + 1] - hullTriangleVertices[i]));
                vertices.Add(new VertexPositionNormalTexture(hullTriangleVertices[i], normal, new Vector2(0, 0)));
                vertices.Add(new VertexPositionNormalTexture(hullTriangleVertices[i + 1], normal, new Vector2(1, 0)));
                vertices.Add(new VertexPositionNormalTexture(hullTriangleVertices[i + 2], normal, new Vector2(0, 1)));
                indices.Add(i);
                indices.Add((ushort)(i + 1));
                indices.Add((ushort)(i + 2));
            }
        }
开发者ID:gpforde,项目名称:GPBrakes,代码行数:29,代码来源:DisplayConvexHull.cs


示例2: Plane

 /// <summary>
 /// Constructor to generate the plane geometry
 /// </summary>
 /// <param name="segments">The number of rows/columns</param>
 public Plane(int segments = 1)
 {
     int rowCount = segments + 1;
     float fSegments = segments;
     // Initialize the arrays
     Indices = new int[6 * segments * segments];
     Vertices = new VertexPositionNormalTexture[(rowCount) * (rowCount)];
     // Populate the vertices
     for(int i = 0; i <= segments; i++)
         for (int j = 0; j <= segments; j++)
         {
             Vertices[i * rowCount + j] = new VertexPositionNormalTexture(
                 new Vector3(-1 + 2 * j / fSegments, 0, -1 + 2 * i / fSegments), // Position
                 Vector3.Up, // Normal
                 new Vector2(j / fSegments, i / fSegments)); // Texture
         }
     // Populate the indices
     int index = 0;
     for(int i = 0; i < segments; i++)
         for (int j = 0; j < segments; j++)
         {
             Indices[index++] = i * rowCount + j;
             Indices[index++] = i * rowCount + j + 1;
             Indices[index++] = (i + 1) * rowCount + j + 1;
             Indices[index++] = i * rowCount + j;
             Indices[index++] = (i + 1) * rowCount + j + 1;
             Indices[index++] = (i + 1) * rowCount + j;
         }
 }
开发者ID:Vallalan,项目名称:CPI311,代码行数:33,代码来源:Plane.cs


示例3: GenerateStructures

        public void GenerateStructures()
        {
            vertices = new VertexPositionNormalTexture[(dimension + 1) * (dimension + 1)];
            indices = new int[dimension * dimension * 6];
            for (int i = 0; i < dimension + 1; i++)
            {
                for (int j = 0; j < dimension + 1; j++)
                {
                    VertexPositionNormalTexture vert = new VertexPositionNormalTexture();
                    vert.Position = new Vector3((i - dimension / 2.0f) * cellSize, 0, (j - dimension / 2.0f) * cellSize);
                    vert.Normal = Vector3.Up;
                    vert.TextureCoordinate = new Vector2((float)i / dimension, (float)j / dimension);
                    vertices[i * (dimension + 1) + j] = vert;

                }
            }

            for (int i = 0; i < dimension; i++)
            {
                for (int j = 0; j < dimension; j++)
                {
                    indices[6 * (i * dimension + j)] = (i * (dimension + 1) + j);
                    indices[6 * (i * dimension + j) + 1] = (i * (dimension + 1) + j + 1);
                    indices[6 * (i * dimension + j) + 2] = ((i + 1) * (dimension + 1) + j + 1);

                    indices[6 * (i * dimension + j) + 3] = (i * (dimension + 1) + j);
                    indices[6 * (i * dimension + j) + 4] = ((i + 1) * (dimension + 1) + j + 1);
                    indices[6 * (i * dimension + j) + 5] = ((i + 1) * (dimension + 1) + j);
                }

            }
        }
开发者ID:arturstaszczyk,项目名称:WaterErosion,代码行数:32,代码来源:Grid.cs


示例4: Clouds

        public Clouds(Vector2 orbit)
        {
            var size = new Vector2(9192, 4096);

            billboardVertices = new VertexPositionNormalTexture[6];
            Vector3 e = new Vector3(-size.X / 2, size.Y, 0);
            Vector3 f = new Vector3(size.X / 2, size.Y, 0);
            Vector3 g = new Vector3(size.X / 2, 0, 0);
            Vector3 h = new Vector3(-size.X / 2, 0, 0);

            Vector3 frontNormal = new Vector3(0.0f, 0.0f, 1.0f);
            billboardVertices[0] = new VertexPositionNormalTexture(h, frontNormal, new Vector2(0, 1));
            billboardVertices[1] = new VertexPositionNormalTexture(e, frontNormal, new Vector2(0, 0));
            billboardVertices[2] = new VertexPositionNormalTexture(f, frontNormal, new Vector2(1, 0));
            billboardVertices[3] = new VertexPositionNormalTexture(h, frontNormal, new Vector2(0, 1));
            billboardVertices[4] = new VertexPositionNormalTexture(f, frontNormal, new Vector2(1, 0));
            billboardVertices[5] = new VertexPositionNormalTexture(g, frontNormal, new Vector2(1, 1));

            offsetA = new Vector3(-orbit.X * 4, 0, -orbit.Y * 4);
            offsetB = new Vector3(-orbit.X * 3, 0, -orbit.Y * 3);
            offsetC = new Vector3(-orbit.X * 5f, 0, -orbit.Y * 5f);

            orbitA = new Vector3(orbit.X, 256, orbit.Y);
            orbitB = new Vector3(orbit.X, 5120, orbit.Y);
            orbitC = new Vector3(orbit.X, 2048, orbit.Y);

            degreesA = G.r.Next(360);
            degreesB = G.r.Next(360);
            degreesC = G.r.Next(360);

            CloudA = RM.GetTexture("cloud1");
            CloudB = RM.GetTexture("cloud2");
            CloudC = RM.GetTexture("cloud3");
        }
开发者ID:Frib,项目名称:LD24,代码行数:34,代码来源:Clouds.cs


示例5: BuildBoundingBox

        //See https://electronicmeteor.wordpress.com/2011/10/25/bounding-boxes-for-your-model-meshes/
        public static BoundingBox BuildBoundingBox(ModelMesh mesh, Matrix meshTransform)
        {
            // Create initial variables to hold min and max xyz values for the mesh
            Vector3 meshMax = new Vector3(float.MinValue);
            Vector3 meshMin = new Vector3(float.MaxValue);

            foreach (ModelMeshPart part in mesh.MeshParts)
            {
                // The stride is how big, in bytes, one vertex is in the vertex buffer
                // We have to use this as we do not know the make up of the vertex
                int stride = part.VertexBuffer.VertexDeclaration.VertexStride;

                VertexPositionNormalTexture[] vertexData = new VertexPositionNormalTexture[part.NumVertices];
                part.VertexBuffer.GetData(part.VertexOffset * stride, vertexData, 0, part.NumVertices, stride);

                // Find minimum and maximum xyz values for this mesh part
                Vector3 vertPosition = new Vector3();

                for (int i = 0; i < vertexData.Length; i++)
                {
                    vertPosition = vertexData[i].Position;

                    // update our values from this vertex
                    meshMin = Vector3.Min(meshMin, vertPosition);
                    meshMax = Vector3.Max(meshMax, vertPosition);
                }
            }

            // transform by mesh bone matrix
            meshMin = Vector3.Transform(meshMin, meshTransform);
            meshMax = Vector3.Transform(meshMax, meshTransform);

            // Create the bounding box
            return new BoundingBox(meshMin, meshMax);
        }
开发者ID:SongmanW,项目名称:Group-Project-2016-Team-Magia,代码行数:36,代码来源:CollisionUtility.cs


示例6: drawSquarre

        public void drawSquarre(VertexPositionNormalTexture[] vertexData, int[] indexData, Camera came, BasicEffect effect, GraphicsDevice graphicsDevice)
        {
            Texture2D texture = Tools.Quick.groundTexture[BiomeType.SubtropicalDesert];
            effect.Projection = projectionMatrix;
            effect.Texture = texture;
            effect.TextureEnabled = true; ;

            graphicsDevice.RasterizerState = WIREFRAME_RASTERIZER_STATE;    // draw in wireframe
            graphicsDevice.BlendState = BlendState.Opaque;                  // no alpha this time

            //   effect.DiffuseColor = Color.Red.ToVector3();
            effect.CurrentTechnique.Passes[0].Apply();

            effect.View = came.getview();
            effect.CurrentTechnique.Passes[0].Apply();
            graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexData, 0, 4, indexData, 0, 2);

            /*  // Draw wireframe box
              graphicsDevice.RasterizerState = WIREFRAME_RASTERIZER_STATE;    // draw in wireframe
              graphicsDevice.BlendState = BlendState.Opaque;                  // no alpha this time

              effect.TextureEnabled = false;
             // effect.DiffuseColor = Color.Black.ToVector3();
              effect.CurrentTechnique.Passes[0].Apply();

              graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexData, 0, 4, indexData, 0, 2);
                 */
        }
开发者ID:Jupotter,项目名称:Nameless-Tales,代码行数:28,代码来源:DrawThings.cs


示例7: CreateShape

        public void CreateShape()
        {
            double angle = MathHelper.TwoPi / CIRCLE_NUM_POINTS;

            _vertices = new VertexPositionNormalTexture[CIRCLE_NUM_POINTS + 1];

            _vertices[0] = new VertexPositionNormalTexture(
                Vector3.Zero, Vector3.Forward, Vector2.One);

            for (int i = 1; i <= CIRCLE_NUM_POINTS; i++)
            {
                float x = (float)Math.Round(Math.Sin(angle * i), 4);
                float y = (float)Math.Round(Math.Cos(angle * i), 4);
                Vector3 point = new Vector3(
                                 x,
                                 y,
                                  0.0f);

                _vertices[i] = new VertexPositionNormalTexture(
                    point,
                    Vector3.Forward,
                    new Vector2());
            }

            buffer = new VertexBuffer(graphicsDevice, typeof(VertexPositionNormalTexture), _vertices.Length,
                BufferUsage.None);

            // Set the vertex buffer data to the array of vertices
            buffer.SetData<VertexPositionNormalTexture>(_vertices);

            InitializeLineStrip();
        }
开发者ID:ravduke,项目名称:Tank-Wars,代码行数:32,代码来源:BoundingSphere3D.cs


示例8: Bullet

        public Bullet(Game game)
            : base(game)
        {
            vertex = new VertexPositionNormalTexture[12];

            // Base
            vertex[0] = new VertexPositionNormalTexture(new Vector3(-2.0f, 0.0f, -2.0f), BottomNormal, new Vector2(0.0f, 1.0f));
            vertex[1] = new VertexPositionNormalTexture(new Vector3(2.0f, 0.0f, -2.0f), BottomNormal, new Vector2(1.0f, 1.0f));
            vertex[2] = new VertexPositionNormalTexture(new Vector3(2.0f, 0.0f, 2.0f), BottomNormal, new Vector2(1.0f, 0.0f));
            vertex[3] = new VertexPositionNormalTexture(new Vector3(-2.0f, 0.0f, 2.0f), BottomNormal, new Vector2(0.0f, 0.0f));

            // Face 1 and 2
            vertex[4] = new VertexPositionNormalTexture(new Vector3(0.0f, 3.0f, 0.0f), TopNormal, new Vector2(0.0f, 0.0f));
            vertex[5] = new VertexPositionNormalTexture(new Vector3(2.0f, 0.0f, -2.0f), new Vector3(1, 0, -1), new Vector2(1.0f, 1.0f));
            vertex[6] = new VertexPositionNormalTexture(new Vector3(2.0f, 0.0f, 2.0f), new Vector3(1, 0, 1), new Vector2(0.5f, 1.0f));
            vertex[7] = new VertexPositionNormalTexture(new Vector3(-2.0f, 0.0f, 2.0f), new Vector3(-1, 0, 1), new Vector2(0.0f, 1.0f));

            // Face 3 and 4
            vertex[8] = new VertexPositionNormalTexture(new Vector3(0.0f, 3.0f, 0.0f), TopNormal, new Vector2(0.0f, 0.0f));
            vertex[9] = new VertexPositionNormalTexture(new Vector3(-2.0f, 0.0f, 2.0f), new Vector3(-1, 0, 1), new Vector2(1.0f, 1.0f));
            vertex[10] = new VertexPositionNormalTexture(new Vector3(-2.0f, 0.0f, -2.0f), new Vector3(-1, 0, -1), new Vector2(0.5f, 1.0f));
            vertex[11] = new VertexPositionNormalTexture(new Vector3(2.0f, 0.0f, -2.0f), new Vector3(1, 0, -1), new Vector2(0.0f, 1.0f));

            triangleListIndices = new short[18] {   0, 2, 1,
                                                  0, 3, 2,
                                                  4, 5, 6,
                                                  4, 6, 7,
                                                  8, 9, 10,
                                                  8, 10, 11
            };

            texture_metal = game.Content.Load<Texture2D>("metal3");
        }
开发者ID:silenthunter,项目名称:MPG4803,代码行数:33,代码来源:Bullet.cs


示例9: CreateVertexBuffer

        void CreateVertexBuffer()
        {
            VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[number_of_vertices];

            float halfWidth = (number_of_cols - 1) * 0.5f;
            float halfDepth = (number_of_rows - 1) * 0.5f;

            float du = 1.0f / (number_of_cols - 1);
            float dv = 1.0f / (number_of_rows - 1);
            for (int i = 0; i < number_of_rows; ++i)
            {
                float z = halfDepth - i;
                for (int j = 0; j < number_of_cols;++j)
                {
                    float x = -halfWidth + j;

                    float y = getHeight(x, z);

                    vertices[i * number_of_cols + j].Position = new Vector3(x, y, z);

                    vertices[i * number_of_cols + j].TextureCoordinate = new Vector2(j * du, i * dv);

                    Vector3 normal = new Vector3();
                    normal.X = -0.03f * z * (float)Math.Cos(0.1f * x) - 0.3f * (float)Math.Cos(0.1f * z);
                    normal.Y = 1;
                    normal.Z = -0.3f * (float)Math.Sin(0.1f * x) + 0.03f * x *(float)Math.Sin(0.1f * z);
                    normal.Normalize();
                    vertices[i * number_of_cols + j].Normal = normal;
                }
            }

            vertexBuffer = new VertexBuffer(GraphicsDevice, VertexPositionNormalTexture.VertexDeclaration, number_of_vertices, BufferUsage.WriteOnly);
            vertexBuffer.SetData<VertexPositionNormalTexture>(vertices);
        }
开发者ID:east1011,项目名称:PhysicallyBasedRendering,代码行数:34,代码来源:Game1Backreference.cs


示例10: StartDrawing

 private unsafe void StartDrawing(VertexFragment vertexFragment, out VertexPositionColor* vertices, out VertexPositionNormalTexture* textures, out short* indices, out short baseIndex)
 {
     textures = null;
     if (vertexFragment.PrimitiveType == PrimitiveType.LineList)
     {
         if ((this.SortMode == DrawingSortMode.Order) && (this._triangleVertexCount > 0))
         {
             Flush();
             StartLineDrawing(vertexFragment, out vertices, out indices, out baseIndex);
         }
         else
         {
             StartLineDrawing(vertexFragment, out vertices, out indices, out baseIndex);
         }
     }
     else if (vertexFragment.PrimitiveType == PrimitiveType.TriangleList)
     {
         if ((this.SortMode == DrawingSortMode.Order) && (this._lineVertexCount > 0))
         {
             Flush();
             StartTriangleDrawing(vertexFragment, out vertices, out textures, out indices, out baseIndex);
         }
         else
         {
             StartTriangleDrawing(vertexFragment, out vertices, out textures, out indices, out baseIndex);
         }
     }
     else
     {
         throw new NotSupportedException(string.Format("PrimitiveType: {0} is not supported.", vertexFragment.PrimitiveType));
     }
 }
开发者ID:mind0n,项目名称:hive,代码行数:32,代码来源:DrawingBatch.cs


示例11: Create3DPlane

        public Create3DPlane(Vector3 position, float size, Vector3 normal)
        {
            vertexes = new VertexPositionNormalTexture[6];

            //Vértices
            //1º triângulo
            Vector3 topLeft = new Vector3(position.X - size / 2, position.Y, -position.Z - size / 2);
            Vector3 bottomLeft = new Vector3(position.X - size / 2, position.Y, position.Z + size / 2);
            Vector3 topRight = new Vector3(position.X + size / 2, position.Y, position.Z - size / 2);

            //2º triângulo
            //bottomLeft já está definido
            Vector3 bottomRight = new Vector3(position.X + size / 2, position.Y, position.Z + size / 2);
            //topRight já está definido

            // Coordenadas da textura
            Vector2 textureTopLeft = new Vector2(0.0f, 0.0f);
            Vector2 textureTopRight = new Vector2(1.0f, 0.0f);
            Vector2 textureBottomLeft = new Vector2(0.0f, 1.0f);
            Vector2 textureBottomRight = new Vector2(1.0f, 1.0f);

            vertexes[0] = new VertexPositionNormalTexture(topLeft, normal, textureTopLeft);
            vertexes[1] = new VertexPositionNormalTexture(bottomLeft, normal, textureBottomLeft);
            vertexes[2] = new VertexPositionNormalTexture(topRight, normal, textureTopRight);

            vertexes[3] = new VertexPositionNormalTexture(bottomLeft, normal, textureBottomLeft);
            vertexes[4] = new VertexPositionNormalTexture(bottomRight, normal, textureBottomRight);
            vertexes[5] = new VertexPositionNormalTexture(topRight, normal, textureTopRight);
        }
开发者ID:pedroabgmarques,项目名称:IP3D,代码行数:29,代码来源:Create3DPlane.cs


示例12: GenerateNormalsForTriangleStrip

        public static void GenerateNormalsForTriangleStrip( VertexPositionNormalTexture[] verts, int[] indices )
        {
            // first reset all normals
            VertexUtils.ResetAllNormals( verts );

            // iterate through and add normals to all vertices for each indexed primitive
            //  because indexed as triange strip, need to keep track of swap vert winding to get normals pointing in correct direction
            bool swapWinding = false;
            for ( int i = 2; i < indices.Length; i++ ) {
                Vector3 firstVec = verts[indices[i - 1]].Position - verts[indices[i]].Position;
                Vector3 secondVec = verts[indices[i - 2]].Position - verts[indices[i]].Position;
                Vector3 normal = Vector3.Cross( firstVec, secondVec );
                normal.Normalize();

                if ( swapWinding ) {
                    normal *= -1;
                }

                verts[indices[i]].Normal += normal;
                verts[indices[i - 1]].Normal += normal;
                verts[indices[i - 2]].Normal += normal;

                swapWinding = !swapWinding;
            }

            VertexUtils.NormalizeAllNormals( verts );
        }
开发者ID:tgorkin,项目名称:XEngine,代码行数:27,代码来源:VertexUtils.cs


示例13: Dot

        public Dot(Vector3 position, int scale)
        {
            if (scale <= 0) throw new ArgumentOutOfRangeException("scale", "Parameter must be grater than zero");

            Center = startCenter = position;

            startVertices = new VertexPositionNormalTexture[3];
            currentVertices = new VertexPositionNormalTexture[3];
            lineIndices = new short[6];
            triangleIndices = new short[6];

            currentVertices[0] = new VertexPositionNormalTexture
                                    (position - 0.01f * scale * Vector3.UnitX + 0.01f * scale * Vector3.UnitZ,
                                    Vector3.Up, Vector2.Zero);
            currentVertices[1] = new VertexPositionNormalTexture
                                    (position + 0.01f * scale * Vector3.UnitX + 0.01f * scale * Vector3.UnitZ,
                                    Vector3.Up, Vector2.UnitX);
            currentVertices[2] = new VertexPositionNormalTexture
                                    (position - 0.01f * scale * Vector3.UnitZ,
                                    Vector3.Up, Vector2.UnitY);

            lineIndices[0] = 0; lineIndices[1] = 1; lineIndices[2] = 1; lineIndices[3] = 2; lineIndices[4] = 2; lineIndices[5] = 0;
            triangleIndices[0] = 0; triangleIndices[1] = 1; triangleIndices[2] = 2; triangleIndices[3] = 2; triangleIndices[4] = 1; triangleIndices[5] = 0;

            Array.Copy(currentVertices, startVertices, startVertices.Length);
        }
开发者ID:mikhaildubov,项目名称:Planets,代码行数:26,代码来源:Dot.cs


示例14: BuildPrimitive

        protected override void BuildPrimitive()
        {
            const float MAGIC_NUMBER = 666f;

              vertices = new VertexPositionNormalTexture[6];
              int n = 0;

              vertices[n++] = new VertexPositionNormalTexture(Vector3.Zero, Vector3.Zero, new Vector2(1, 1));
              vertices[n++] = new VertexPositionNormalTexture(Vector3.Zero, Vector3.Zero, new Vector2(1, 0));
              vertices[n++] = new VertexPositionNormalTexture(Vector3.Zero, Vector3.Zero, new Vector2(0, 1));
              vertices[n++] = new VertexPositionNormalTexture(Vector3.Zero, Vector3.Zero, new Vector2(0, 0));
              vertices[n++] = new VertexPositionNormalTexture(Vector3.Zero, Vector3.Zero, new Vector2(0, 1));
              vertices[n++] = new VertexPositionNormalTexture(Vector3.Zero, Vector3.Zero, new Vector2(1, 0));

              for (int i = 0; i < vertices.Length; ++i)
              {
            float u = (float)core.art.GetTileSize() / (float)core.art.GetTiles().Width;
            float v = (float)core.art.GetTileSize() / (float)core.art.GetTiles().Height;

            float integral = (float)Math.Truncate(u * (int)tileType);
            float x = u * (int)tileType - integral;
            float y = v * integral;

            vertices[i].TextureCoordinate = vertices[i].TextureCoordinate * new Vector2(u, v) + new Vector2(x, y) + vertices[i].TextureCoordinate * MAGIC_NUMBER;
              }
        }
开发者ID:iodiot,项目名称:Maze,代码行数:26,代码来源:BillboardPrimitive.cs


示例15: Bilboard

    public Bilboard(Texture2D tex, Matrix scale)
    {
        vertices = new VertexPositionNormalTexture[4];

        vertices[0] = new VertexPositionNormalTexture (new Vector3(-0.5f, -0.5f, 0.0f), new Vector3(0.0f,0.0f,1.0f), new Vector2(0.0f,0.0f));
        vertices[1] = new VertexPositionNormalTexture (new Vector3(0.5f, -0.5f, 0.0f), new Vector3(0.0f,0.0f,1.0f), new Vector2(1.0f,0.0f));
        vertices[2] = new VertexPositionNormalTexture (new Vector3(-0.5f, 0.5f, 0.0f), new Vector3(0.0f,0.0f,1.0f), new Vector2(0.0f,1.0f));
        vertices[3] = new VertexPositionNormalTexture (new Vector3(0.5f, 0.5f, 0.0f), new Vector3(0.0f,0.0f,1.0f), new Vector2(1.0f,1.0f));

        offsets = new Vector3[4];

        offsets [0] = new Vector3 (-0.5f, -0.5f, 0.0f);
        offsets [1] = new Vector3 (0.5f, -0.5f, 0.0f);
        offsets [2] = new Vector3 (-0.5f, 0.5f, 0.0f);
        offsets [3] = new Vector3 (0.5f, 0.5f, 0.0f);

        indices = new short[6];

        indices [0] = 0;
        indices [1] = 1;
        indices [2] = 2;

        indices [3] = 1;
        indices [4] = 3;
        indices [5] = 2;

        this.texture = tex;
        this.scale = scale;
        inUse = false;
    }
开发者ID:BackgroundNose,项目名称:KSP_External_Navball_MK2,代码行数:30,代码来源:Bilboard.cs


示例16: Entity

        public Entity(Island i, Vector2 size, Vector3 pos)
        {
            this.island = i;
            billboardVertices = new VertexPositionNormalTexture[6];
            reverseBillboardVertices = new VertexPositionNormalTexture[6];
            Vector3 e = new Vector3(-size.X / 2, size.Y, 0);
            Vector3 f = new Vector3(size.X / 2, size.Y, 0);
            Vector3 g = new Vector3(size.X / 2, 0, 0);
            Vector3 h = new Vector3(-size.X / 2, 0, 0);

            this.size = new Vector3(size.X, size.Y, size.X);

            Vector3 frontNormal = new Vector3(0.0f, 0.0f, 1.0f);
            billboardVertices[0] = new VertexPositionNormalTexture(h, frontNormal, new Vector2(0, 1));
            billboardVertices[1] = new VertexPositionNormalTexture(e, frontNormal, new Vector2(0, 0));
            billboardVertices[2] = new VertexPositionNormalTexture(f, frontNormal, new Vector2(1, 0));
            billboardVertices[3] = new VertexPositionNormalTexture(h, frontNormal, new Vector2(0, 1));
            billboardVertices[4] = new VertexPositionNormalTexture(f, frontNormal, new Vector2(1, 0));
            billboardVertices[5] = new VertexPositionNormalTexture(g, frontNormal, new Vector2(1, 1));
            this.Position = pos;

            Vector3 backNormal = new Vector3(0.0f, 0.0f, -1.0f);
            reverseBillboardVertices[0] = new VertexPositionNormalTexture(h, backNormal, new Vector2(0, 1));
            reverseBillboardVertices[1] = new VertexPositionNormalTexture(e, backNormal, new Vector2(0, 0));
            reverseBillboardVertices[2] = new VertexPositionNormalTexture(f, backNormal, new Vector2(1, 0));
            reverseBillboardVertices[3] = new VertexPositionNormalTexture(h, backNormal, new Vector2(0, 1));
            reverseBillboardVertices[4] = new VertexPositionNormalTexture(f, backNormal, new Vector2(1, 0));
            reverseBillboardVertices[5] = new VertexPositionNormalTexture(g, backNormal, new Vector2(1, 1));
        }
开发者ID:Frib,项目名称:LD24,代码行数:29,代码来源:Entity.cs


示例17: LoadContent

        protected override void LoadContent()
        {
            base.LoadContent();

            _basicEffect = new BasicEffect(GraphicsDevice);
            _basicEffect.EnableDefaultLighting();

            _numVertices = SIZE * SIZE;

            int numInternalRows = SIZE - 2;
            _numIndices = (2 * SIZE * (1 + numInternalRows)) + (2 * numInternalRows);

            VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[_numVertices];
            for (int z = 0; z < SIZE; z++)
            {
                for (int x = 0; x < SIZE; x++)
                {
                    vertices[GetIndex(x, z)] = new VertexPositionNormalTexture(
                        new Vector3(x, 0, -z), new Vector3(0, 1, 0),
                        new Vector2(x / (float)(SIZE - 1) * 8, z / (float)(SIZE - 1) * 8));
                }
            }

            _vertexBuffer = new VertexBuffer(
                this.GraphicsDevice,
                VertexPositionNormalTexture.VertexDeclaration,
                vertices.Length,
                BufferUsage.WriteOnly);
            _vertexBuffer.SetData<VertexPositionNormalTexture>(vertices);

            short[] indices = new short[_numIndices]; int indexCounter = 0;
            for (int z = 0; z < SIZE - 1; z++)
            {
                // insert index for degenerate triangle
                if (z > 0)
                    indices[indexCounter++] = GetIndex(0, z);

                for (int x = 0; x < SIZE; x++)
                {
                    indices[indexCounter++] = GetIndex(x, z);
                    indices[indexCounter++] = GetIndex(x, z + 1);
                }

                // insert index for degenerate triangle
                if (z < SIZE - 2)
                    indices[indexCounter++] = GetIndex(SIZE - 1, z);
            }

            _indexBuffer = new IndexBuffer(
                this.GraphicsDevice,
                typeof(short),
                indices.Length,
                BufferUsage.WriteOnly);
            _indexBuffer.SetData<short>(indices);

            Texture2D texture = Game.Content.Load<Texture2D>(@"Textures\dirt");

            _basicEffect.Texture = texture;
            _basicEffect.TextureEnabled = true;
        }
开发者ID:tgjones,项目名称:particlephysics,代码行数:60,代码来源:Ground.cs


示例18: IndexedVertexModel

 public IndexedVertexModel(Vector3[] positions, Vector3[] normals, short[] indices)
 {
     Indices = indices;
     var texdata = new[] { new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1) };
     Vertices = new VertexPositionNormalTexture[positions.Length];
     for (int i = 0; i < positions.Length; i++)
         Vertices[i] = new VertexPositionNormalTexture(positions[i], normals[i], texdata[i % 3]);
 }
开发者ID:TioTioSan,项目名称:diplom,代码行数:8,代码来源:IndexedVertexModel.cs


示例19: MeshPart

        public MeshPart(VertexPositionNormalTexture[] vertices, ushort[] indices)
        {
            if (vertices == null) throw new ArgumentNullException("vertices");
            if (indices == null) throw new ArgumentNullException("indices");

            Vertices = vertices;
            Indices = indices;
        }
开发者ID:willcraftia,项目名称:TestBlocks,代码行数:8,代码来源:MeshPart.cs


示例20: LoadContent

        // Creates the graphics resources (e.g. the vertex buffer).
        public void LoadContent(GraphicsDevice graphicsDevice, IGeometricObject geometricObject)
        {
            // Create a mesh for the given shape. (The arguments define the desired resolution if the
              // mesh is only approximated - for example for a sphere.)
              TriangleMesh mesh = geometricObject.Shape.GetMesh(0.01f, 3);

              // Abort if we have nothing to draw. (This happens for "EmptyShapes".)
              if (mesh.Vertices.Count == 0)
            return;

              // Apply the scaling that is defined in the geometric object.
              if (geometricObject.Scale != Vector3F.One)
            mesh.Transform(Matrix44F.CreateScale(geometricObject.Scale));

              _numberOfTriangles = mesh.NumberOfTriangles;

              // Create vertex data for a triangle list.
              VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[mesh.NumberOfTriangles * 3];

              // Create vertex normals. Do not merge normals if the angle between the triangle normals
              // is > 70°.
              Vector3F[] normals = mesh.ComputeNormals(false, MathHelper.ToRadians(70));

              // Loop over all triangles and copy vertices to the vertices array.
              for (int i = 0; i < _numberOfTriangles; i++)
              {
            // Get next triangle of the mesh.
            Triangle triangle = mesh.GetTriangle(i);

            // Add new vertex data.
            // DigitalRune.Geometry uses counter-clockwise front faces. XNA uses
            // clockwise front faces (CullMode.CullCounterClockwiseFace) per default.
            // Therefore we change the vertex orientation of the triangles.
            // We could also keep the vertex order and change the CullMode to CullClockwiseFace.
            vertices[i * 3 + 0] = new VertexPositionNormalTexture(
              (Vector3)triangle.Vertex0,
              (Vector3)normals[i * 3 + 0],
              Vector2.Zero);
            vertices[i * 3 + 1] = new VertexPositionNormalTexture(
              (Vector3)triangle.Vertex2,  // triangle.Vertex2 instead of triangle.Vertex1 to change vertex order!
              (Vector3)normals[i * 3 + 2],
              Vector2.Zero);
            vertices[i * 3 + 2] = new VertexPositionNormalTexture(
              (Vector3)triangle.Vertex1,  // triangle.Vertex1 instead of triangle.Vertex2 to change vertex order!
              (Vector3)normals[i * 3 + 1],
              Vector2.Zero);
              }

              // Create a vertex buffer.
              _vertexBuffer = new VertexBuffer(
            graphicsDevice,
            vertices[0].GetType(),
            vertices.Length,
            BufferUsage.WriteOnly);

              // Fill the vertex buffer.
              _vertexBuffer.SetData(vertices);
        }
开发者ID:HATtrick-games,项目名称:ICT309,代码行数:59,代码来源:DrawableShape.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Graphics.VertexPositionTexture类代码示例发布时间:2022-05-26
下一篇:
C# Graphics.VertexPositionColorTexture类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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