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

C# DynamicVertexBuffer类代码示例

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

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



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

示例1: SpriteRenderer

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="maxSprites">The maximum number of sprites which can be batched.</param>
        public SpriteRenderer(GraphicsContext graphics, int maxSprites)
        {
            if (graphics == null)
                throw new ArgumentNullException("graphics");

            if (maxSprites <= 0)
                throw new ArgumentOutOfRangeException("maxSprites", "MaxSprites must be >= 1.");

            this.graphics = graphics;

            this.vertices = new Vertex[maxSprites * 4];

            this.vertexBuffer = new DynamicVertexBuffer<Vertex>(this.graphics);

            ushort[] indices = new ushort[1024 * 6];
            for (ushort i = 0, vertex = 0; i < indices.Length; i += 6, vertex += 4)
            {
                indices[i] = vertex;
                indices[i + 1] = (ushort)(vertex + 1);
                indices[i + 2] = (ushort)(vertex + 3);
                indices[i + 3] = (ushort)(vertex + 1);
                indices[i + 4] = (ushort)(vertex + 2);
                indices[i + 5] = (ushort)(vertex + 3);
            }

            this.indexBuffer = new StaticIndexBuffer<ushort>(this.graphics, indices);

            this.transform = new Matrix4()
            {
                M33 = 1f,
                M44 = 1f,
                M41 = -1f,
                M42 = 1f
            };
        }
开发者ID:smack0007,项目名称:Samurai,代码行数:40,代码来源:SpriteRenderer.cs


示例2: GenerateInstanceInfo

        public void GenerateInstanceInfo(GraphicsDevice device)
        {
            if (_subMeshes.Count == 0)
                return;
            if (_instanceTransforms.Length < _subMeshes.Count)
                _instanceTransforms = new Matrix[_subMeshes.Count * 2];
            for (int index = 0; index < _subMeshes.Count; index++)
            {
                Mesh.SubMesh subMesh = _subMeshes[index];
                _instanceTransforms[index] = subMesh.GlobalTransform;
            }

            // If we have more instances than room in our vertex buffer, grow it to the necessary size.
            if ((_instanceVertexBuffer == null) ||
                (_instanceTransforms.Length > _instanceVertexBuffer.VertexCount))
            {
                if (_instanceVertexBuffer != null)
                    _instanceVertexBuffer.Dispose();

                _instanceVertexBuffer = new DynamicVertexBuffer(device, _instanceVertexDeclaration,
                                                               _instanceTransforms.Length, BufferUsage.WriteOnly);
            }
            // Transfer the latest instance transform matrices into the instanceVertexBuffer.
            _instanceVertexBuffer.SetData(_instanceTransforms, 0, _subMeshes.Count, SetDataOptions.Discard);
        }
开发者ID:justshiv,项目名称:LightSavers,代码行数:25,代码来源:InstancingGroup.cs


示例3: Batcher

		public Batcher( GraphicsDevice graphicsDevice )
		{
			Assert.isTrue( graphicsDevice != null );

			this.graphicsDevice = graphicsDevice;

			_vertexInfo = new VertexPositionColorTexture4[MAX_SPRITES];
			_textureInfo = new Texture2D[MAX_SPRITES];
			_vertexBuffer = new DynamicVertexBuffer( graphicsDevice, typeof( VertexPositionColorTexture ), MAX_VERTICES, BufferUsage.WriteOnly );
			_indexBuffer = new IndexBuffer( graphicsDevice, IndexElementSize.SixteenBits, MAX_INDICES, BufferUsage.WriteOnly );
			_indexBuffer.SetData( _indexData );

			_spriteEffect = new SpriteEffect();
			_spriteEffectPass = _spriteEffect.CurrentTechnique.Passes[0];

			_projectionMatrix = new Matrix(
				0f, //(float)( 2.0 / (double)viewport.Width ) is the actual value we will use
				0.0f,
				0.0f,
				0.0f,
				0.0f,
				0f, //(float)( -2.0 / (double)viewport.Height ) is the actual value we will use
				0.0f,
				0.0f,
				0.0f,
				0.0f,
				1.0f,
				0.0f,
				-1.0f,
				1.0f,
				0.0f,
				1.0f
			);
		}
开发者ID:prime31,项目名称:Nez,代码行数:34,代码来源:Batcher.cs


示例4: Allocate

		private void Allocate()
		{
			if (this.vertexBuffer == null || this.vertexBuffer.IsDisposed)
			{
				this.vertexBuffer = new DynamicVertexBuffer(this.graphicsDevice, typeof(VertexPositionColorTexture), 8192, BufferUsage.WriteOnly);
				this.vertexBufferPosition = 0;
				this.vertexBuffer.ContentLost += delegate(object sender, EventArgs e)
				{
					this.vertexBufferPosition = 0;
				};
			}
			if (this.indexBuffer == null || this.indexBuffer.IsDisposed)
			{
				if (this.fallbackIndexData == null)
				{
					this.fallbackIndexData = new short[12288];
					for (int i = 0; i < 2048; i++)
					{
						this.fallbackIndexData[i * 6] = (short)(i * 4);
						this.fallbackIndexData[i * 6 + 1] = (short)(i * 4 + 1);
						this.fallbackIndexData[i * 6 + 2] = (short)(i * 4 + 2);
						this.fallbackIndexData[i * 6 + 3] = (short)(i * 4);
						this.fallbackIndexData[i * 6 + 4] = (short)(i * 4 + 2);
						this.fallbackIndexData[i * 6 + 5] = (short)(i * 4 + 3);
					}
				}
				this.indexBuffer = new DynamicIndexBuffer(this.graphicsDevice, typeof(short), 12288, BufferUsage.WriteOnly);
				this.indexBuffer.SetData<short>(this.fallbackIndexData);
				this.indexBuffer.ContentLost += delegate(object sender, EventArgs e)
				{
					this.indexBuffer.SetData<short>(this.fallbackIndexData);
				};
			}
		}
开发者ID:thegamingboffin,项目名称:Ulterraria_Reborn_GitHub,代码行数:34,代码来源:TileBatch.cs


示例5: Append

        public unsafe void Append(TextAnalyzer analyzer, FontFace font, string text)
        {
            var layout = new TextLayout();
            var format = new TextFormat {
                Font = font,
                Size = 32.0f
            };

            analyzer.AppendText(text, format);
            analyzer.PerformLayout(0, 32, 1000, 1000, layout);

            var memBlock = new MemoryBlock(text.Length * 6 * PosColorTexture.Layout.Stride);
            var mem = (PosColorTexture*)memBlock.Data;
            foreach (var thing in layout.Stuff) {
                var width = thing.Width;
                var height = thing.Height;
                var region = new Vector4(thing.SourceX, thing.SourceY, width, height) / 4096;
                var origin = new Vector2(thing.DestX, thing.DestY);
                *mem++ = new PosColorTexture(origin + new Vector2(0, height), new Vector2(region.X, region.Y + region.W), unchecked((int)0xff000000));
                *mem++ = new PosColorTexture(origin + new Vector2(width, height), new Vector2(region.X + region.Z, region.Y + region.W), unchecked((int)0xff000000));
                *mem++ = new PosColorTexture(origin + new Vector2(width, 0), new Vector2(region.X + region.Z, region.Y), unchecked((int)0xff000000));
                *mem++ = new PosColorTexture(origin, new Vector2(region.X, region.Y), unchecked((int)0xff000000));
                count++;
            }

            vertexBuffer = new DynamicVertexBuffer(memBlock, PosColorTexture.Layout);
        }
开发者ID:bitzhuwei,项目名称:SharpFont,代码行数:27,代码来源:TextBuffer.cs


示例6: Initialize

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            zNear = 0.001f;
            zFar = 1000.0f;
            fov = MathHelper.Pi * 70.0f / 180.0f;
            eye = new Vector3(0.0f, 0.7f, 1.5f);
            at = new Vector3(0.0f, 0.0f, 0.0f);
            up = new Vector3(0.0f, 1.0f, 0.0f);

            cube = new VertexPositionColor[8];
            cube[0] = new VertexPositionColor(new Vector3(-0.5f, -0.5f, -0.5f), new Color(0.0f, 0.0f, 0.0f));
            cube[1] = new VertexPositionColor(new Vector3(-0.5f, -0.5f,  0.5f), new Color(0.0f, 0.0f, 1.0f));
            cube[2] = new VertexPositionColor(new Vector3(-0.5f,  0.5f, -0.5f), new Color(0.0f, 1.0f, 0.0f));
            cube[3] = new VertexPositionColor(new Vector3(-0.5f,  0.5f,  0.5f), new Color(0.0f, 1.0f, 1.0f));
            cube[4] = new VertexPositionColor(new Vector3( 0.5f, -0.5f, -0.5f), new Color(1.0f, 0.0f, 0.0f));
            cube[5] = new VertexPositionColor(new Vector3( 0.5f, -0.5f,  0.5f), new Color(1.0f, 0.0f, 1.0f));
            cube[6] = new VertexPositionColor(new Vector3( 0.5f,  0.5f, -0.5f), new Color(1.0f, 1.0f, 0.0f));
            cube[7] = new VertexPositionColor(new Vector3( 0.5f,  0.5f,  0.5f), new Color(1.0f, 1.0f, 1.0f));

            vertexBuffer = new DynamicVertexBuffer(graphics.GraphicsDevice, typeof(VertexPositionColor), 8, BufferUsage.WriteOnly);
            indexBuffer = new DynamicIndexBuffer(graphics.GraphicsDevice, typeof(ushort), 36, BufferUsage.WriteOnly);

            basicEffect = new BasicEffect(graphics.GraphicsDevice); //(device, null);
            basicEffect.LightingEnabled = false;
            basicEffect.VertexColorEnabled = true;
            basicEffect.TextureEnabled = false;

            graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
            base.Initialize();
        }
开发者ID:BrainSlugs83,项目名称:MonoGame,代码行数:37,代码来源:Game1.cs


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


示例8: ParticleSystem

        public ParticleSystem(ParticleSettings settings, Effect effect)
        {
            if (settings == null) throw new ArgumentNullException("settings");
            if (effect == null) throw new ArgumentNullException("effect");
            if (settings.Texture == null) throw new ArgumentException("Texture is null.");

            Enabled = true;

            this.settings = settings;

            //----------------------------------------------------------------
            // システム名

            Name = settings.Name;

            //----------------------------------------------------------------
            // エフェクト

            particleEffect = new ParticleEffect(effect);
            particleEffect.Initialize(settings, settings.Texture);

            graphicsDevice = particleEffect.GraphicsDevice;

            //----------------------------------------------------------------
            // パーティクル

            particles = new ParticleVertex[settings.MaxParticles * 4];

            for (int i = 0; i < settings.MaxParticles; i++)
            {
                particles[i * 4 + 0].Corner = new Short2(-1, -1);
                particles[i * 4 + 1].Corner = new Short2(1, -1);
                particles[i * 4 + 2].Corner = new Short2(1, 1);
                particles[i * 4 + 3].Corner = new Short2(-1, 1);
            }

            //----------------------------------------------------------------
            // 頂点バッファ

            vertexBuffer = new DynamicVertexBuffer(
                graphicsDevice, ParticleVertex.VertexDeclaration, settings.MaxParticles * 4, BufferUsage.WriteOnly);

            //----------------------------------------------------------------
            // インデックス バッファ

            var indices = new ushort[settings.MaxParticles * 6];
            for (int i = 0; i < settings.MaxParticles; i++)
            {
                indices[i * 6 + 0] = (ushort) (i * 4 + 0);
                indices[i * 6 + 1] = (ushort) (i * 4 + 1);
                indices[i * 6 + 2] = (ushort) (i * 4 + 2);

                indices[i * 6 + 3] = (ushort) (i * 4 + 0);
                indices[i * 6 + 4] = (ushort) (i * 4 + 2);
                indices[i * 6 + 5] = (ushort) (i * 4 + 3);
            }

            indexBuffer = new IndexBuffer(graphicsDevice, typeof(ushort), indices.Length, BufferUsage.WriteOnly);
            indexBuffer.SetData(indices);
        }
开发者ID:willcraftia,项目名称:TestBlocks,代码行数:60,代码来源:ParticleSystem.cs


示例9: CalcVertexBuffer

        public void CalcVertexBuffer()
        {
            if (instanceVertexBuffer != null)
                instanceVertexBuffer.Dispose();

            instanceVertexBuffer = new DynamicVertexBuffer(BaseClass.Device, instanceVertexDeclaration, instanceTransformMatrices.Count, BufferUsage.WriteOnly);
            instanceVertexBuffer.SetData(instanceTransformMatrices.Values.ToArray(), 0, instanceTransformMatrices.Count, SetDataOptions.Discard);
        }
开发者ID:Andrusza,项目名称:PiratesArr,代码行数:8,代码来源:Instancer.cs


示例10: StoreOnGPU

        public void StoreOnGPU(GraphicsDevice device)
        {
            GPUMode = true;
            GPUBlendVertexBuffer = new DynamicVertexBuffer(device, MeshVertex.SizeInBytes * BlendVertexBuffer.Length, BufferUsage.None);
            GPUBlendVertexBuffer.SetData(BlendVertexBuffer);

            GPUIndexBuffer = new IndexBuffer(device, sizeof(short) * IndexBuffer.Length, BufferUsage.None, IndexElementSize.SixteenBits);
            GPUIndexBuffer.SetData(IndexBuffer);
        }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:9,代码来源:Mesh.cs


示例11: CreateBuffers

		private void CreateBuffers()
		{
			var vertexDeclaration = new VertexDeclaration(Format.Stride,
				nativeVertexFormat.ConvertFrom(Format));
			vertexBuffer = new DynamicVertexBuffer(nativeDevice, vertexDeclaration, NumberOfVertices,
				BufferUsage.WriteOnly);
			indexBuffer = new DynamicIndexBuffer(nativeDevice, IndexElementSize.SixteenBits,
				NumberOfIndices, BufferUsage.WriteOnly);
		}
开发者ID:caihuanqing0617,项目名称:DeltaEngine.Xna,代码行数:9,代码来源:XnaGeometry.cs


示例12: DebugDraw

        public DebugDraw(GraphicsDevice device)
        {
            vertexBuffer = new DynamicVertexBuffer(device, typeof(VertexPositionColor), MAX_VERTS, BufferUsage.WriteOnly);
            indexBuffer = new DynamicIndexBuffer(device, typeof(ushort), MAX_INDICES, BufferUsage.WriteOnly);

            basicEffect = new BasicEffect(device); //(device, null);
            basicEffect.LightingEnabled = false;
            basicEffect.VertexColorEnabled = true;
            basicEffect.TextureEnabled = false;
        }
开发者ID:mikkamikka,项目名称:AlfaTestInterface,代码行数:10,代码来源:DebugDraw.cs


示例13: EditingVoxture

        public EditingVoxture(string _name, OutpostColor baseColor, GraphicsDevice graphics)
        {
            name = new StringBuilder(_name);
            vox = new Voxture(baseColor);

            vBuff = new DynamicVertexBuffer(graphics, typeof(VertexPositionColorNormal), numVerts, BufferUsage.WriteOnly);
            iBuff = new IndexBuffer(graphics, IndexElementSize.SixteenBits, numInds, BufferUsage.WriteOnly);
            wfVBuff = new DynamicVertexBuffer(graphics, typeof(VertexPositionColor), numWfVerts, BufferUsage.WriteOnly);
            wfIBuff = new IndexBuffer(graphics, IndexElementSize.SixteenBits, numWfInds, BufferUsage.WriteOnly);

            makeIndices();

            _rotation = Matrix.Identity;
        }
开发者ID:littlebeast,项目名称:Outpost,代码行数:14,代码来源:EditingVoxture.cs


示例14: Initialize

 protected override void Initialize()
 {
     //Создаем буффер индексов и вершин
     graphics.GraphicsDevice.Flush();
     vertexBuffer = new DynamicVertexBuffer(graphics.GraphicsDevice, typeof(VertexPositionNormalTexture), vertex.Length, BufferUsage.WriteOnly);
     indexBuffer = new IndexBuffer(graphics.GraphicsDevice, typeof(int), indices.Length, BufferUsage.WriteOnly);
     //Создаем вершины для наших частиц.
     CreateVertex();
     //Переносим данные в буффер для видеокарты.
     indexBuffer.SetData(indices);
     vertexBuffer.SetData(vertex);
     //Вызываем иниталайз для базового класса и всех компоненетов, если они у нас есть.
     base.Initialize();
 }
开发者ID:Winbringer,项目名称:MonoGame3DKezumieParticles,代码行数:14,代码来源:Game1.cs


示例15: MMDCPUModelPartP

 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="triangleCount">三角形の個数</param>
 /// <param name="vertices">頂点配列</param>
 /// <param name="indexBuffer">インデックスバッファ</param>
 public MMDCPUModelPartP(int triangleCount, MMDVertex[] vertices,int[] vertMap, IndexBuffer indexBuffer)
     : base(triangleCount, vertices.Length, vertMap, indexBuffer)
 {
     this.vertices = vertices;
     //GPUリソース作成
     gpuVertices = new VertexPosition[vertices.Length];
     vertexBuffer = new DynamicVertexBuffer(indexBuffer.GraphicsDevice, typeof(VertexPosition), vertices.Length, BufferUsage.WriteOnly);
     //初期値代入
     for (int i = 0; i < vertices.Length; i++)
     {
         gpuVertices[i].Position = vertices[i].Position;
     }
     // put the vertices into our vertex buffer
     vertexBuffer.SetData(gpuVertices, 0, vertexCount, SetDataOptions.Discard);
 }
开发者ID:himapo,项目名称:ccm,代码行数:21,代码来源:MMDCPUModelPart.cs


示例16: Setup

        public void Setup(InstanceTransforms instanceTransforms)
        {
            // 頂点バッファーに必要なインスタンスを保持するための容量が足りない場合、バッファー サイズを増やす。
            if ((VertexBuffer == null) ||
                (instanceTransforms.Length > VertexBuffer.VertexCount))
            {
                if (VertexBuffer != null)
                    VertexBuffer.Dispose();

                VertexBuffer = new DynamicVertexBuffer(GraphicsDevice, instanceVertexDeclaration,
                                                               instanceTransforms.Length, BufferUsage.WriteOnly);
            }

            // 最新のトランスフォーム行列を InstanceVertexBuffer へコピーする。
            VertexBuffer.SetData(instanceTransforms.Matrices, 0, instanceTransforms.Length, SetDataOptions.Discard);
        }
开发者ID:himapo,项目名称:ccm,代码行数:16,代码来源:InstancedVertexBuffer.cs


示例17: CpuSkinnedModelPart

        internal CpuSkinnedModelPart(int triangleCount, CpuVertex[] vertices, IndexBuffer indexBuffer)
        {
            this.triangleCount = triangleCount;
            this.vertexCount = vertices.Length;
            this.cpuVertices = vertices;
            this.indexBuffer = indexBuffer;

            // create our GPU resources
            gpuVertices = new VertexPositionNormalTexture[cpuVertices.Length];
            vertexBuffer = new DynamicVertexBuffer(indexBuffer.GraphicsDevice, typeof(VertexPositionNormalTexture), cpuVertices.Length, BufferUsage.WriteOnly);

            // copy texture coordinates once since they don't change with skinnning
            for (int i = 0; i < cpuVertices.Length; i++)
            {
                gpuVertices[i].TextureCoordinate = cpuVertices[i].TextureCoordinate;
            }
        }
开发者ID:tykz,项目名称:xna-morijobi-win,代码行数:17,代码来源:CpuSkinnedModelPart.cs


示例18: draw

		protected override void draw(GameTime time, Matrix parent, Matrix transform)
		{
			if (this.Lines.Length == 0)
				return;

			if (this.vertexBuffer == null || this.vertexBuffer.IsContentLost || this.Lines.Length * 2 > this.vertexBuffer.VertexCount || this.changed)
			{
				this.changed = false;
				if (this.vertexBuffer != null)
					this.vertexBuffer.Dispose();

				this.vertexBuffer = new DynamicVertexBuffer(this.main.GraphicsDevice, VertexPositionColor.VertexDeclaration, (this.Lines.Length * 2) + 8, BufferUsage.WriteOnly);

				VertexPositionColor[] data = new VertexPositionColor[this.vertexBuffer.VertexCount];
				int i = 0;
				foreach (Line line in this.Lines)
				{
					data[i] = line.A;
					data[i + 1] = line.B;
					i += 2;
				}
				this.vertexBuffer.SetData<VertexPositionColor>(data, 0, this.Lines.Length * 2, SetDataOptions.Discard);
			}

			Viewport viewport = this.main.GraphicsDevice.Viewport;
			float inverseWidth = (viewport.Width > 0) ? (1f / (float)viewport.Width) : 0f;
			float inverseHeight = (viewport.Height > 0) ? (-1f / (float)viewport.Height) : 0f;
			Matrix projection = default(Matrix);
			projection.M11 = inverseWidth * 2f;
			projection.M22 = inverseHeight * 2f;
			projection.M33 = 1f;
			projection.M44 = 1f;
			projection.M41 = -1f;
			projection.M42 = 1f;
			projection.M41 -= inverseWidth;
			projection.M42 -= inverseHeight;

			this.effect.Parameters["Color"].SetValue(this.Color);
			this.effect.Parameters["Transform"].SetValue(transform * projection);

			this.effect.CurrentTechnique.Passes[0].Apply();
			this.main.GraphicsDevice.SetVertexBuffer(this.vertexBuffer);
			this.main.GraphicsDevice.DrawPrimitives(PrimitiveType.LineList, 0, this.Lines.Length);
			Model.DrawCallCounter++;
			Model.TriangleCounter += this.Lines.Length;
		}
开发者ID:dsmo7206,项目名称:Lemma,代码行数:46,代码来源:LineDrawer2D.cs


示例19: ISurfaceAlgorithm

        public ISurfaceAlgorithm(GraphicsDevice device, int resolution, int size, bool _3d, bool indexed = true, int vertex_size = 262144, int index_size = 4000000)
        {
            Device = device;
            Resolution = resolution;
            Size = size;

            Is3D = _3d;
            IsIndexed = indexed;

            VertexBuffer = new DynamicVertexBuffer(device, VertexPositionColorNormal.VertexDeclaration, vertex_size, BufferUsage.None);
            OutlineBuffer = new DynamicVertexBuffer(device, VertexPositionColor.VertexDeclaration, index_size, BufferUsage.None);
            if (indexed)
            {
                IndexBuffer = new DynamicIndexBuffer(device, IndexElementSize.ThirtyTwoBits, index_size, BufferUsage.None);
                Indices = new List<int>();
            }

            Vertices = new List<VertexPositionColorNormal>();
        }
开发者ID:chongbingbao,项目名称:isosurface,代码行数:19,代码来源:ISurfaceAlgorithm.cs


示例20: DynamicVertexBuffer

        void IDrawableAlphaComponent.DrawAlpha(Microsoft.Xna.Framework.GameTime time, RenderParameters p)
        {
            if (this.Lines.Count == 0 || LineDrawer.unsupportedTechniques.Contains(p.Technique))
                return;

            if (this.vertexBuffer == null || this.vertexBuffer.IsContentLost || this.Lines.Count * 2 > this.vertexBuffer.VertexCount || this.changed)
            {
                this.changed = false;
                if (this.vertexBuffer != null)
                    this.vertexBuffer.Dispose();

                this.vertexBuffer = new DynamicVertexBuffer(this.main.GraphicsDevice, VertexPositionColor.VertexDeclaration, (this.Lines.Count * 2) + 8, BufferUsage.WriteOnly);

                VertexPositionColor[] data = new VertexPositionColor[this.vertexBuffer.VertexCount];
                int i = 0;
                foreach (Line line in this.Lines)
                {
                    data[i] = line.A;
                    data[i + 1] = line.B;
                    i += 2;
                }
                this.vertexBuffer.SetData<VertexPositionColor>(data, 0, this.Lines.Count * 2, SetDataOptions.Discard);
            }

            p.Camera.SetParameters(this.effect);
            this.effect.Parameters["Depth" + Model.SamplerPostfix].SetValue(p.DepthBuffer);

            // Draw lines
            try
            {
                this.effect.CurrentTechnique = this.effect.Techniques[p.Technique.ToString()];
            }
            catch (Exception)
            {
                LineDrawer.unsupportedTechniques.Add(p.Technique);
                return;
            }

            this.effect.CurrentTechnique.Passes[0].Apply();
            this.main.GraphicsDevice.SetVertexBuffer(this.vertexBuffer);
            this.main.GraphicsDevice.DrawPrimitives(PrimitiveType.LineList, 0, this.Lines.Count);
        }
开发者ID:kernelbitch,项目名称:Lemma,代码行数:42,代码来源:LineDrawer.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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