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


C# Texture.GenerateMipSublevels方法代码示例

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


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

示例1: Init

        public override void Init()
        {
            Content.ContentPath = "";
            Content.ContentCachePath = "Cache/";
            Meshes.Load(Device);
            billboard = Meshes.PositionTexcoord(Device, Meshes.IndexedPlane(-8.1640625f, -62f / 20f, 38, 62 / 2f));
            plane = Meshes.PositionTexcoord(Device, Meshes.IndexedGrid(new Vector3(-0.5f, -0.5f, 0), new Vector2(1, 1), 128, 128, Vector2.Zero, new Vector2(1, 1)));
            tree = SlimDX.Direct3D9.Mesh.FromFile(Device, "spruce.x", MeshFlags.Managed);
            unit = SlimDX.Direct3D9.Mesh.FromFile(Device, "unitcylinder.x", MeshFlags.Managed);
            Reloadable.Load((efn) =>
            {
                Effect e = EffectUtil.LoadWithDebugger(Device, efn);
                if(e == null) return;
                if (ef != null) ef.Dispose();
                ef = e;
            }, "geomorph.fx");
            text = Texture.FromFile(Device, "ground.jpg", Usage.None, Pool.Managed);
            text.GenerateMipSublevels();
            treeMap = Texture.FromFile(Device, "spruce.tga", Usage.None, Pool.Managed);
            treeMap.GenerateMipSublevels();
            treeBillboard = Texture.FromFile(Device, "spruceBillboard.tga", Usage.None, Pool.Managed);
            treeBillboard.GenerateMipSublevels();
            String hm = "heightmap-landscape.tga";

            HeightmapProcessor heightmapProcessor = new HeightmapProcessor();
            Reloadable.Load((h) =>
            {
                if (heightMap != null) heightMap.Dispose();
                heightMap = heightmapProcessor.Load(Device, h);
            }, hm);
            textureSize = heightMap.GetLevelDescription(0).Width;

            terrain = new GeoclipmappedTerrain(Device, resolution);

            DataRectangle r = heightMap.LockRectangle(0, LockFlags.ReadOnly);
            data = TextureUtil.ReadTexture<ClientCommon.TextureColor.R32G32B32A32F>(r, textureSize);
            heightMap.UnlockRectangle(0);

            DataRectangle r2 = heightMap.LockRectangle(5, LockFlags.ReadOnly);
            dataLod2 = TextureUtil.ReadTexture<ClientCommon.TextureColor.R32G32B32A32F>(r2, textureSize/(int)Math.Pow(2, 5));
            heightMap.UnlockRectangle(5);

            float prev = 20;
            cam = new WalkaroundCamera(this, (float x, float y) =>
            {
                float z = HeightAt(data, x, y);
                float re = z * 0.05f + prev * 0.95f;
                prev = re;
                return re + 1.8f;
            });
            cam.ZFar *= 100;
            cam.Speed = 2;
            values = new Values();
            values.Show();

            instanceVD = new VertexDeclaration(Device, instanceVES);
            instancingVB = new VertexBuffer(Device, ntrees * Vector3.SizeInBytes, Usage.None, VertexFormat.None, Pool.Managed);

            Random ra = new Random(0);
            trees = new Vector3[ntrees];
            treeRidgeDiff = new float[ntrees];
            for (int i = 0; i < ntrees/40; i++)
            {
                float x = ((float)ra.NextDouble() - 0.5f) * heightmapScale;
                float y = ((float)ra.NextDouble() - 0.5f) * heightmapScale * 0.5f;
                for (int k = 0; k < 40; k++)
                {
                    float x1 = x + ((float)ra.NextDouble() - 0.5f) * 100;
                    float y1 = y + ((float)ra.NextDouble() - 0.5f) * 100;
                    float z = HeightAt(data, x1, y1);
                    trees[i*40 + k] = new Vector3(x1, y1, z);
                    treeRidgeDiff[i*40 + k] = HeightAt(dataLod2, x1, y1) - z;
                }
            }

            //Fullscreen = false;
        }
开发者ID:Keldyn,项目名称:BattleOfTheClans,代码行数:77,代码来源:Program.cs


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