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


C# VertexBuffer.SetData方法代码示例

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


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

示例1: LoadContent

        public void LoadContent(ContentManager content, GraphicsDeviceManager graphicsDeviceManager)
        {
            texture = content.Load<Texture2D>("brick_texture_map");

            wall = new VertexPositionTexture[22];
            wall[0] = new VertexPositionTexture(new Vector3(200, 0, 200), new Vector2(0, 0));
            wall[1] = new VertexPositionTexture(new Vector3(200, 200, 200), new Vector2(2, 0));
            wall[2] = new VertexPositionTexture(new Vector3(0, 0, 200), new Vector2(0, 2));
            wall[3] = new VertexPositionTexture(new Vector3(0, 200, 200), new Vector2(2, 2));
            wall[4] = new VertexPositionTexture(new Vector3(0, 0, 220), new Vector2(0, 0));
            wall[5] = new VertexPositionTexture(new Vector3(0, 200, 220), new Vector2(2, 0));
            wall[6] = new VertexPositionTexture(new Vector3(200, 0, 220), new Vector2(0, 2));
            wall[7] = new VertexPositionTexture(new Vector3(200, 200, 220), new Vector2(2, 2));
            wall[8] = new VertexPositionTexture(new Vector3(200, 0, 200), new Vector2(0, 0));
            wall[9] = new VertexPositionTexture(new Vector3(200, 200, 220), new Vector2(2, 0));
            wall[10] = new VertexPositionTexture(new Vector3(200, 200, 200), new Vector2(2, 2));
            wall[11] = new VertexPositionTexture(new Vector3(0, 200, 220), new Vector2(0, 2));
            wall[12] = new VertexPositionTexture(new Vector3(0, 200, 200), new Vector2(0, 0));

            // Set vertex data in VertexBuffer
            vertexBuffer = new VertexBuffer(graphicsDeviceManager.GraphicsDevice, typeof(VertexPositionTexture), wall.Length, BufferUsage.None);
            vertexBuffer.SetData(wall);

            // Initialize the BasicEffect
            effect = new BasicEffect(graphicsDeviceManager.GraphicsDevice);
        }
开发者ID:Woodje,项目名称:3DGame,代码行数:26,代码来源:Wall.cs

示例2: BuildBuffers

        private void BuildBuffers(IGenerator generator)
        {
            List<MyOwnVertexFormat> vertices = new List<MyOwnVertexFormat>();

            for (int x = 0; x < sideSize; x++)
            {
                for (int z = 0; z < sideSize; z++)
                {

                    for (int y = 0; y < sideSize; y++)
                    {
                        double sample = generator.Sample(new Vector3(x, y, z) + location);
                        if ( sample > 0.6f)
                        {
                            CreateVertices(vertices, x, y, z, new Color((float)sample, (float)sample, (float)sample));
                        }

                    }
                }
            }

            if(vertices.Count > 0)
            {
                vertexBuffer = new VertexBuffer(device, MyOwnVertexFormat.VertexDeclaration, vertices.Count, BufferUsage.WriteOnly);
                vertexBuffer.SetData(vertices.ToArray());
            }

            numVertices = vertices.Count;
        }
开发者ID:nordsoyv,项目名称:GraphicsFun,代码行数:29,代码来源:GeneratingLeafNode.cs

示例3: InitializeGraphics

        public static void InitializeGraphics(GraphicsDevice graphicsDevice,
                                              Triangle[] triangles,
                                              Guid id)
        {
            var basicEffect = new BasicEffect(graphicsDevice)
                                  {
                                      LightingEnabled = false,
                                      VertexColorEnabled = false
                                  };

            var index = 0;
            var vertices = new VertexPositionColor[triangles.SelectMany(i => i.Points).Count()];

            foreach (var point in triangles.SelectMany(triangle => triangle.Points))
                vertices[index++] = new VertexPositionColor(new Vector3(point.X,
                                                                        point.Y,
                                                                        point.Z),
                                                            Color.White);

            var vertexBuffer = new VertexBuffer(graphicsDevice,
                                                typeof (VertexPositionColor),
                                                vertices.Length,
                                                BufferUsage.None);
            vertexBuffer.SetData(vertices);

            Subscriptions.Add(id, new RendererHelperData
                                       {
                                           BasicEffect = basicEffect,
                                           VertexBuffer = vertexBuffer
                                       });
        }
开发者ID:naighes,项目名称:AsteroidChallenge,代码行数:31,代码来源:TrianglesRenderer.cs

示例4: Tile

        public Tile(Texture2D texture2D, GraphicsDeviceManager graphicsDeviceManager, Vector3 position, Vector3 dimension)
        {
            texture = texture2D;

            tile = new VertexPositionTexture[14];
            tile[0] = new VertexPositionTexture(new Vector3(position.X, position.Y, position.Z), new Vector2(0, 0));
            tile[1] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y, position.Z), new Vector2(1, 0));
            tile[2] = new VertexPositionTexture(new Vector3(position.X, position.Y + dimension.Y, position.Z), new Vector2(0, 1));
            tile[3] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y + dimension.Y, position.Z), new Vector2(1, 1));
            tile[4] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y + dimension.Y, position.Z + dimension.Z), new Vector2(1, 0));
            tile[5] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y, position.Z), new Vector2(0, 1));
            tile[6] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y, position.Z + dimension.Z), new Vector2(0, 0));
            tile[7] = new VertexPositionTexture(new Vector3(position.X, position.Y, position.Z), new Vector2(1, 1));
            tile[8] = new VertexPositionTexture(new Vector3(position.X, position.Y, position.Z + dimension.Z), new Vector2(1, 0));
            tile[9] = new VertexPositionTexture(new Vector3(position.X, position.Y + dimension.Y, position.Z), new Vector2(0, 1));
            tile[10] = new VertexPositionTexture(new Vector3(position.X, position.Y + dimension.Y, position.Z + dimension.Z), new Vector2(0, 0));
            tile[11] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y + dimension.Y, position.Z + dimension.Z), new Vector2(1, 0));
            tile[12] = new VertexPositionTexture(new Vector3(position.X, position.Y, position.Z + dimension.Z), new Vector2(0, 1));
            tile[13] = new VertexPositionTexture(new Vector3(position.X + dimension.X, position.Y, position.Z + dimension.Z), new Vector2(1, 1));

            // Set vertex data in VertexBuffer
            vertexBuffer = new VertexBuffer(graphicsDeviceManager.GraphicsDevice, typeof(VertexPositionTexture), tile.Length, BufferUsage.None);
            vertexBuffer.SetData(tile);

            // Initialize the BasicEffect
            effect = new BasicEffect(graphicsDeviceManager.GraphicsDevice);
        }
开发者ID:Woodje,项目名称:3DGame,代码行数:27,代码来源:Tile.cs

示例5: Resolve

        public void Resolve(bool injectHardEdges)
        {
            _vertices = new List<VertexPositionNormalTexture>();
            //ushort indIdx = 0;

            List<UInt16> indices = new List<UInt16>(_vertexPositions.Count);

            foreach (CModel model in _models)
            {
                model.HardEdgesInserted = injectHardEdges;
                model.IndexBufferStart = indices.Count;
                model.Polygons.Sort(delegate(Polygon p1, Polygon p2) { return p1.MaterialIndex.CompareTo(p2.MaterialIndex); });

                model.Resolve(indices, _vertices, _vertexTextureMap, _vertexPositions);
            }

            if (_vertices.Count > 0)
            {
                _vertexBuffer = new VertexBuffer(Engine.Device, VertexPositionNormalTexture.SizeInBytes * _vertices.Count, BufferUsage.WriteOnly);
                _vertexBuffer.SetData<VertexPositionNormalTexture>(_vertices.ToArray());

                if (!injectHardEdges)
                {
                    _indexBuffer = new IndexBuffer(Engine.Device, typeof(UInt16), indices.Count, BufferUsage.WriteOnly);
                    _indexBuffer.SetData<UInt16>(indices.ToArray());
                    _indices = indices;
                }
            }

            _vertexDeclaration = new VertexDeclaration(Engine.Device, VertexPositionNormalTexture.VertexElements);
            _vertexTextureMap = null; //dont need this data anymore
        }
开发者ID:sikora507,项目名称:OpenC1,代码行数:32,代码来源:CModelGroup.cs

示例6: RenderToDevice

        public override void RenderToDevice(GraphicsDevice device, BasicEffect basicEffet)
        {
            if (Visible)
            {
                if (!basicEffet.LightingEnabled)
                {
                    if (isConstructed == false)
                        Construct();

                    using
                        (
                        VertexBuffer buffer = new VertexBuffer(
                        device,
                        VertexPositionColor.VertexDeclaration,
                        points,
                        BufferUsage.WriteOnly)
                      )
                    {
                        // Load the buffer
                        buffer.SetData(pointList);

                        // Send the vertex buffer to the device
                        device.SetVertexBuffer(buffer);
                        device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, pointList, 0, 6, lineListIndices, 0, 3);
                    }
                }
            }
        }
开发者ID:codec-abc,项目名称:3DIsoTetrisXNA,代码行数:28,代码来源:DummyObject.cs

示例7: Sphere

    public Sphere(float Radius, GraphicsDevice graphics, Texture2D tex, Texture2D prograde, Texture2D retrograde,
        Texture2D maneuverPrograde, Texture2D targetPrograde, Texture2D targetRetrograde)
    {
        this.prograde = new Bilboard (prograde, Matrix.CreateScale (1.0f));
        this.retrograde = new Bilboard (retrograde, Matrix.CreateScale (1.0f));
        this.maneuverPrograde = new Bilboard (maneuverPrograde, Matrix.CreateScale (1.0f));
        this.targetPrograde = new Bilboard (targetPrograde, Matrix.CreateScale (1.0f));
        this.targetRetrograde = new Bilboard (targetRetrograde, Matrix.CreateScale (1.0f));

        texture = tex;
        radius = Radius;
        graphicd = graphics;
        effect = new BasicEffect(graphicd);

        nvertices = res * res; // 90 vertices in a circle, 90 circles in a sphere
        nindices = res * res * 6;
        vbuffer = new VertexBuffer(graphics, typeof(VertexPositionNormalTexture), nvertices, BufferUsage.WriteOnly);
        ibuffer = new IndexBuffer(graphics, IndexElementSize.SixteenBits, nindices, BufferUsage.WriteOnly);
        createspherevertices();
        createindices();
        vbuffer.SetData<VertexPositionNormalTexture>(vertices);
        ibuffer.SetData<short>(indices);
        effect.TextureEnabled = true;
        effect.LightingEnabled = true;

        rotQuat = Quaternion.Identity;
    }
开发者ID:BackgroundNose,项目名称:KSP_External_Navball_MK2,代码行数:27,代码来源:Sphere.cs

示例8: TextureStrip

        public TextureStrip(GraphicsDevice device,Texture2D tex)
        {
            worldMatrix = Matrix.Identity;
            Indices = new int[4];
            effect = new BasicEffect(device);
            float aspectRatio = (float)device.Viewport.Width /
            device.Viewport.Height;
            CamX = 0.0f;
            CamY = 2.0f;
            CamZ = 2.0f;
            effect.View = Matrix.CreateLookAt(new Vector3(CamX, CamY, CamZ),Vector3.Zero, Vector3.Up);
            effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10.0f);
            effect.VertexColorEnabled = false;
            textura = tex;
            effect.Texture = this.textura;
            effect.TextureEnabled = true;

            CreateVertices();

            Indices[0]=0;
            Indices[1]=1;
            Indices[2]=2;
            Indices[3]=3;

            effect.LightingEnabled = true;
            effect.DirectionalLight0.DiffuseColor = new Vector3(1, 1, 1);
            effect.DirectionalLight0.Direction = new Vector3(0, -1, 0);
            effect.DirectionalLight0.SpecularColor = new Vector3(0, 0, 0);

            vertexBuffer1 = new VertexBuffer(device, typeof(VertexPositionNormalTexture), vertices.Length, BufferUsage.None);
            vertexBuffer1.SetData<VertexPositionNormalTexture>(vertices);

            indexBuffer1 = new IndexBuffer(device, typeof(int), Indices.Length, BufferUsage.None);
            indexBuffer1.SetData<int>(Indices);
        }
开发者ID:joaomlo2,项目名称:TPC4,代码行数:35,代码来源:TextureStrip.cs

示例9: SetVertexNormalBuffer

 public void SetVertexNormalBuffer(GraphicsDevice device, Vector3[] vectors)
 {
     VertexCount = vectors.Length / 2;
     VertexBuffer = new VertexBuffer(device, vertexDecl, VertexCount, BufferUsage.None);
     VertexBuffer.SetData(vectors);
     //BufferBindings[0] = new VertexBufferBinding(VertexBuffer, 0, 0);
 }
开发者ID:rhynodegreat,项目名称:BulletSharp,代码行数:7,代码来源:MeshFactory.cs

示例10: DrawColoredRectangle

 public static void DrawColoredRectangle(Device dev,RectangleF rect,Color color)
 {
     VertexBuffer vb=null;
     IndexBuffer ib=null;
     try{
         int colorArgb=color.ToArgb();
         CustomVertex.PositionColored[] quadVerts=new CustomVertex.PositionColored[] {
                 new CustomVertex.PositionColored(rect.Left,rect.Bottom,0,colorArgb),
                 new CustomVertex.PositionColored(rect.Left,rect.Top,0,colorArgb),
                 new CustomVertex.PositionColored(rect.Right,rect.Top,0,colorArgb),
                 new CustomVertex.PositionColored(rect.Right,rect.Bottom,0,colorArgb),
             };
         vb=new VertexBuffer(typeof(CustomVertex.PositionColored),
             CustomVertex.PositionColored.StrideSize*quadVerts.Length,
             dev,Usage.WriteOnly,CustomVertex.PositionColored.Format,Pool.Managed);
         vb.SetData(quadVerts,0,LockFlags.None);
         int[] indicies=new int[] { 0,1,2,0,2,3 };
         ib=new IndexBuffer(typeof(int),indicies.Length,dev,Usage.None,Pool.Managed);
         ib.SetData(indicies,0,LockFlags.None);
         dev.VertexFormat=CustomVertex.PositionColored.Format;
         dev.SetStreamSource(0,vb,0);
         dev.Indices=ib;
         dev.DrawIndexedPrimitives(PrimitiveType.TriangleList,0,0,quadVerts.Length,0,indicies.Length/3);
     }finally{
         if(vb!=null){
             vb.Dispose();
             vb=null;
         }
         if(ib!=null){
             ib.Dispose();
             ib=null;
         }
     }
 }
开发者ID:nampn,项目名称:ODental,代码行数:34,代码来源:ToothChartDirectX.cs

示例11: Load

 public void Load(GraphicsDevice device)
 {
     VertexBuf = new VertexBuffer(device,
                                  VertexPositionNormalTexture.SizeInBytes*Vertices.Length,
                                  BufferUsage.WriteOnly);
     VertexBuf.SetData(Vertices);
 }
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:7,代码来源:Quad.cs

示例12: ParticleEngine

		/// <summary>
		/// 
		/// </summary>
		/// <param name="drawer">パーティクルを描画するためのシェーダー</param>
		/// <param name="device"></param>
		/// <param name="tex">パーティクルのテクスチャ</param>
		/// <param name="number">パーティクル最大数</param>
		public ParticleEngine(Effect drawer, GraphicsDevice device, Texture2D tex, ushort number,
			ParticleMode mode, Matrix projection, Vector2 fieldSize)
			:base(tex, number)
		{
			Device = device;
			
			//int[] x = { -1, -1, 1, 1 };
			//int[] y = { 1, -1, -1, 1 };
			
			VertexDataBuffer = new DynamicVertexBuffer(device, typeof(ParticleVertex), ParticleNum * 1, BufferUsage.WriteOnly);

		
			IndexVertexBuffer = new VertexBuffer(device, typeof(ParticleIndexVertex), indexVertex.Length, BufferUsage.WriteOnly);
			IndexVertexBuffer.SetData(indexVertex);

			short[] index = new short[] { 0, 1, 2, 0, 2, 3 };
			Index = new IndexBuffer(device, IndexElementSize.SixteenBits, index.Length, BufferUsage.WriteOnly);
			Index.SetData(index);
			
			Drawer = drawer;
			InitEffectParam();
			Mode = mode;
			Projection = projection;
			FieldSize = fieldSize;
			BlendColor = Vector4.One;
			Enable = true;

			SetVertex();//初期化
			bind = new VertexBufferBinding(VertexDataBuffer, 0, 1);
		}
开发者ID:MasakiMuto,项目名称:MasaLibs,代码行数:37,代码来源:ParticleEngine.cs

示例13: Load

 public void Load(GraphicsDevice device)
 {
     VertexBuf = new VertexBuffer(device, VertexPositionNormalTexture.VertexDeclaration,
              Vertices.Length,
             BufferUsage.WriteOnly);
         VertexBuf.SetData<VertexPositionNormalTexture>(Vertices);
 }
开发者ID:jacs700,项目名称:Ganimedes,代码行数:7,代码来源:Primitives.cs

示例14: InitBuffers

 protected virtual void InitBuffers(GraphicsDevice graphics)
 {
     _vertexBuffer = new VertexBuffer(graphics, VertexPositionColorNormal.VertexDeclaration, _vertices.Length, BufferUsage.None);
     _vertexBuffer.SetData<VertexPositionColorNormal>(_vertices);
     _indexBuffer = new IndexBuffer(graphics, IndexElementSize.ThirtyTwoBits, _indices.Length, BufferUsage.None);
     _indexBuffer.SetData<int>(_indices);
 }
开发者ID:hkeeble,项目名称:Octane,代码行数:7,代码来源:VertexEntity.cs

示例15: Poke

        public void Poke( DateTime timestamp, Device world )
        {
            var vb = new VertexBuffer( typeof( CustomVertex.PositionColored ), 6, world, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default );

            var vertices = new CustomVertex.PositionColored[6];

            int i = 0;
            vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
            vertices[i++].Position = new Vector3( 100, 200, 1 );

            vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
            vertices[i++].Position = new Vector3( 0, 100, 1 );

            vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
            vertices[i++].Position = new Vector3( 200, 100, 1 );

            vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
            vertices[i++].Position = new Vector3( 200, 300, 1 );

            vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
            vertices[i++].Position = new Vector3( 0, 300, 1 );

            vertices[i].Color = System.Drawing.Color.Gray.ToArgb();
            vertices[i++].Position = new Vector3( 0, 100, 1 );

            vb.SetData( vertices, 0, LockFlags.None );
            world.SetStreamSource( 1, vb, 0 );
            world.DrawPrimitives( PrimitiveType.TriangleFan, 0, 6 );
        }
开发者ID:Zazcallabah,项目名称:jsdemos,代码行数:29,代码来源:PortedActor.cs


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