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


C# IBuffer.SetBufferDatas方法代码示例

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


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

示例1: Intro

        public override void Intro( params object [] args )
        {
            Core.GraphicsDevice.ImmediateContext.CullMode = CullMode.ClockWise;

            contentManager = new ResourceTable ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
            contentManager.AddDefaultContentLoader ();

            texture1 = contentManager.Load<ITexture2D> ( "Resources/Terrain/terrain_02.png" );
            texture2 = contentManager.Load<ITexture2D> ( "Resources/Terrain/terrain_01.png" );
            Color [] colours = texture2.Buffer;
            effect = contentManager.Load<IEffect> ( "Resources/Terrain/TerrainShader.xml" );

            textureArgs = new SamplerState ( texture1, TextureFilter.Anisotropic, TextureAddressing.Clamp,
                Core.GraphicsDevice.Information.MaximumAnisotropicLevel );

            vertexBuffer = Core.GraphicsDevice.CreateBuffer ( BufferType.VertexBuffer, typeof ( TerrainVertex ), texture2.Width * texture2.Height );
            vertexDeclaration = Core.GraphicsDevice.CreateVertexDeclaration ( Utilities.CreateVertexElementArray<TerrainVertex> () );
            numOfIndices = ( texture2.Width - 1 ) * ( texture2.Height - 1 ) * 2;
            indexBuffer = Core.GraphicsDevice.CreateBuffer ( BufferType.IndexBuffer, typeof ( TerrainIndex ), numOfIndices );

            TerrainVertex [] vertices = new TerrainVertex [ texture2.Width * texture2.Height ];
            int index = 0;
            for ( int x = 0; x < texture2.Height; x++ )
            {
                for ( int z = 0; z < texture2.Width; z++ )
                {
                    int location = x * texture2.Width + z;
                    vertices [ index ] = new TerrainVertex ()
                    {
                        Position = new Vector3 (
                            ( x - texture2.Height / 2 ) * 5.0f,
                            colours [ location ].RedValue * 5.0f / 3,
                            ( z - texture2.Width / 2 ) * 5.0f
                        ),
                        UV = new Vector2 (
                            z / ( float ) texture2.Width,
                            x / ( float ) texture2.Height
                        )
                    };
                    ++index;
                }
            }
            vertexBuffer.SetBufferDatas<TerrainVertex> ( vertices );

            TerrainIndex [] indices = new TerrainIndex [ numOfIndices ];
            index = 0;
            for ( int z = 0; z < texture2.Height - 1; z++ )
            {
                for ( int x = 0; x < texture2.Width - 1; x++ )
                {
                    indices [ index ]._0 = z * texture2.Width + x;
                    indices [ index ]._1 = z * texture2.Width + ( x + 1 );
                    indices [ index ]._2 = ( z + 1 ) * texture2.Width + x;
                    ++index;
                    indices [ index ]._0 = ( z + 1 ) * texture2.Width + x;
                    indices [ index ]._1 = z * texture2.Width + ( x + 1 );
                    indices [ index ]._2 = ( z + 1 ) * texture2.Width + ( x + 1 );
                    ++index;
                }
            }
            indexBuffer.SetBufferDatas<TerrainIndex> ( indices );

            proj = new PerspectiveFieldOfViewProjection ( 3.141592f / 4, 4 / 3f, 1, 10000 );
            look = new LookAt ( new Vector3 ( 1000, 2000, 1000 ), new Vector3 ( 0, 0, 0 ), new Vector3 ( 0, 1, 0 ) );
            world = new World3 ();

            sprite = new Sprite ( null );
            spriteWorld = new World2 ();

            Add ( new FpsCalculator () );

            base.Intro ( args );
        }
开发者ID:Daramkun,项目名称:Misty,代码行数:73,代码来源:Container.cs


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