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

C# Index3类代码示例

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

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



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

示例1: Draw

        public void Draw(Matrix view, Matrix projection, Index3 shift)
        {
            if (!loaded)
                return;

            Matrix worldViewProj = Matrix.CreateTranslation(
                shift.X * Chunk.CHUNKSIZE_X,
                shift.Y * Chunk.CHUNKSIZE_Y,
                shift.Z * Chunk.CHUNKSIZE_Z) * view * projection;

            simple.Parameters["WorldViewProj"].SetValue(worldViewProj);
            simple.Parameters["BlockTextures"].SetValue(textures);

            simple.Parameters["AmbientIntensity"].SetValue(0.4f);
            simple.Parameters["AmbientColor"].SetValue(Color.White.ToVector4());

            lock (this)
            {
                if (vb == null)
                    return;

                graphicsDevice.SetVertexBuffer(vb);
                graphicsDevice.Indices = ib;

                foreach (var pass in simple.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertexCount, 0, indexCount / 3);
                }
            }
        }
开发者ID:reicheltp,项目名称:octoawesome,代码行数:31,代码来源:ChunkRenderer.cs


示例2: GeneratePlanet

        public IPlanet GeneratePlanet(int universe, int seed)
        {
            Index3 size = new Index3(12, 12, 3);
            ComplexPlanet planet = new ComplexPlanet(0, universe, size, this, seed);

            return planet;
        }
开发者ID:RapidHelmus,项目名称:octoawesome,代码行数:7,代码来源:ComplexPlanetGenerator.cs


示例3: Populate

        public override void Populate(IDefinitionManager definitionManager, IPlanet planet, IChunkColumn column00, IChunkColumn column10, IChunkColumn column01, IChunkColumn column11)
        {
            // Tree Definitions initialisieren
            if (treeDefinitions == null)
            {
                treeDefinitions = definitionManager.GetDefinitions<ITreeDefinition>().OrderBy(d => d.Order).ToArray();
                foreach (var treeDefinition in treeDefinitions)
                    treeDefinition.Init(definitionManager);
            }

            int salt = (column00.Index.X & 0xffff) + ((column00.Index.Y & 0xffff) << 16);
            Random random = new Random(planet.Seed + salt);

            Index3 sample = new Index3(column00.Index.X * Chunk.CHUNKSIZE_X, column00.Index.Y * Chunk.CHUNKSIZE_Y, column00.Heights[0, 0]);
            foreach (var treeDefinition in treeDefinitions)
            {
                int density = treeDefinition.GetDensity(planet, sample);
                if (density <= 0) continue;

                for (int i = 0; i < density; i++)
                {
                    int x = random.Next(Chunk.CHUNKSIZE_X / 2, Chunk.CHUNKSIZE_X * 3 / 2);
                    int y = random.Next(Chunk.CHUNKSIZE_Y / 2, Chunk.CHUNKSIZE_Y * 3 / 2);
                    int z = LocalBuilder.GetSurfaceHeight(column00, column10, column01, column11, x, y);

                    LocalBuilder builder = new LocalBuilder(x, y, z + 1, column00, column10, column01, column11);
                    treeDefinition.PlantTree(definitionManager, planet, new Index3(x, y, z), builder, random.Next(int.MaxValue));
                }
            }
        }
开发者ID:reicheltp,项目名称:octoawesome,代码行数:30,代码来源:TreePopulator.cs


示例4: Index3ConstructorTest

        public void Index3ConstructorTest()
        {
            // Parameterlos
            Index3 i1 = new Index3();
            Assert.AreEqual(0, i1.X);
            Assert.AreEqual(0, i1.Y);
            Assert.AreEqual(0, i1.Z);

            // Simpler Parameter
            Index3 i2 = new Index3(21, 32, 99);
            Assert.AreEqual(21, i2.X);
            Assert.AreEqual(32, i2.Y);
            Assert.AreEqual(99, i2.Z);

            // Index2-Parameter
            Index3 i3 = new Index3(new Index2(-2, 80), 76);
            Assert.AreEqual(-2, i3.X);
            Assert.AreEqual(80, i3.Y);
            Assert.AreEqual(76, i3.Z);

            // Index3 Parameter
            Index3 i4 = new Index3(new Index3(int.MinValue, int.MaxValue, 3));
            Assert.AreEqual(int.MinValue, i4.X);
            Assert.AreEqual(int.MaxValue, i4.Y);
            Assert.AreEqual(3, i4.Z);
        }
开发者ID:Vengarioth,项目名称:octoawesome,代码行数:26,代码来源:Index3Tests.cs


示例5: ComplexPlanet

 public ComplexPlanet(int id, int universe, Index3 size, IMapGenerator generator, int seed)
     : base(id, universe, size, seed)
 {
     BiomeGenerator = new SurfaceBiomeGenerator(this, 40);
     this.Heightmap = null;
     ClimateMap = new Climate.ComplexClimateMap(this);
 }
开发者ID:Vengarioth,项目名称:octoawesome,代码行数:7,代码来源:ComplexPlanet.cs


示例6: Index3ComparerTest

        public void Index3ComparerTest()
        {
            Index3 i1 = new Index3(12, 13, 14);
            Index3 i2 = new Index3(12, 15, 33);
            Index3 i3 = new Index3(22, 13, 2);
            Index3 i4 = new Index3(22, 11, 14);
            Index3 i5 = new Index3(12, 13, 0);
            Index3 i6 = new Index3(0, 13, 14);
            Index3 i7 = new Index3(12, 0, 14);
            Index3 i8 = new Index3(12, 13, 14);

            Assert.AreEqual(i1, i1);
            Assert.AreEqual(i1, i8);
            Assert.AreNotEqual(i1, i2);
            Assert.AreNotEqual(i1, i3);
            Assert.AreNotEqual(i1, i4);
            Assert.AreNotEqual(i1, i5);
            Assert.AreNotEqual(i1, i6);
            Assert.AreNotEqual(i1, i7);

            Assert.IsTrue(i1 == i1);
            Assert.IsTrue(i1 == i8);
            Assert.IsTrue(i1 != i2);
            Assert.IsTrue(i1 != i3);
            Assert.IsTrue(i1 != i4);
            Assert.IsTrue(i1 != i5);
            Assert.IsTrue(i1 != i6);
            Assert.IsTrue(i1 != i7);
        }
开发者ID:Vengarioth,项目名称:octoawesome,代码行数:29,代码来源:Index3Tests.cs


示例7: GetCornerSet

        //public static Slb.Ocean.Petrel.DomainObject.PillarGrid.Zone GetZone(Index3 cellIndex, List<Slb.Ocean.Petrel.DomainObject.PillarGrid.Zone> Zones)//List<Slb.Ocean.Petrel.DomainObject.PillarGrid.Zone> TopZone)
        //{
        //    foreach (Slb.Ocean.Petrel.DomainObject.PillarGrid.Zone zone in Zones)
        //    {
        //        if (cellIndex.K > zone.BaseK && cellIndex.K)
        //       {
        //       }
        //    }
        //}
        public static Point3[] GetCornerSet(CellSide SideOfCell, Grid gridInContext, Index3 CellIndex)
        {
            CellCorner[] CellCorners = new CellCorner[4];
            Point3[] CellCornerPoints = new Point3[4];

            switch (SideOfCell)
            {
                case CellSide.Up:
                    CellCorners[0] = CellCorner.TopNorthWest; CellCorners[1] = CellCorner.TopNorthEast; CellCorners[2] = CellCorner.TopSouthWest;
                    CellCorners[3] = CellCorner.TopSouthEast;
                    CellCornerPoints = gridInContext.GetCellCorners(CellIndex, CellCorners);

                    break;

                case CellSide.East:
                    CellCorners[0] = CellCorner.TopSouthEast; CellCorners[1] = CellCorner.TopNorthEast; CellCorners[2] = CellCorner.BaseSouthEast;
                    CellCorners[3] = CellCorner.BaseNorthEast;
                    CellCornerPoints = gridInContext.GetCellCorners(CellIndex, CellCorners);

                    break;

                case CellSide.West:

                    CellCorners[0] = CellCorner.TopSouthWest; CellCorners[1] = CellCorner.TopNorthWest; CellCorners[2] = CellCorner.BaseSouthWest;
                    CellCorners[3] = CellCorner.BaseNorthWest;
                    CellCornerPoints = gridInContext.GetCellCorners(CellIndex, CellCorners);

                    break;

                case CellSide.South:
                    CellCorners[0] = CellCorner.TopSouthWest; CellCorners[1] = CellCorner.TopSouthEast; CellCorners[2] = CellCorner.BaseSouthWest;
                    CellCorners[3] = CellCorner.BaseSouthEast;
                    CellCornerPoints = gridInContext.GetCellCorners(CellIndex, CellCorners);

                    break;

                case CellSide.North:

                    CellCorners[0] = CellCorner.TopNorthWest; CellCorners[1] = CellCorner.TopNorthEast; CellCorners[2] = CellCorner.BaseNorthWest;
                    CellCorners[3] = CellCorner.BaseNorthEast;
                    CellCornerPoints = gridInContext.GetCellCorners(CellIndex, CellCorners);

                    break;

                case CellSide.Down:

                    CellCorners[0] = CellCorner.BaseNorthWest; CellCorners[1] = CellCorner.BaseNorthEast; CellCorners[2] = CellCorner.BaseSouthWest;
                    CellCorners[3] = CellCorner.BaseSouthEast;
                    CellCornerPoints = gridInContext.GetCellCorners(CellIndex, CellCorners);

                    break;
                default:

                    CellCornerPoints = null;
                    break;
            }

            return CellCornerPoints;
        }
开发者ID:walter-poquioma,项目名称:ModifiedKh,代码行数:68,代码来源:KandaIntersectionService.cs


示例8: Chunk

        /// <summary>
        /// Erzeugt eine neue Instanz der Klasse Chunk
        /// </summary>
        /// <param name="pos">Position des Chunks</param>
        /// <param name="planet">Index des Planeten</param>
        public Chunk(Index3 pos, int planet)
        {
            Blocks = new ushort[CHUNKSIZE_X * CHUNKSIZE_Y * CHUNKSIZE_Z];
            MetaData = new int[CHUNKSIZE_X * CHUNKSIZE_Y * CHUNKSIZE_Z];
            Resources = new ushort[CHUNKSIZE_X * CHUNKSIZE_Y * CHUNKSIZE_Z][];

            Index = pos;
            Planet = planet;
            ChangeCounter = 0;
        }
开发者ID:reicheltp,项目名称:octoawesome,代码行数:15,代码来源:Chunk.cs


示例9: PlantTree

        public override void PlantTree(IDefinitionManager definitionManager, IPlanet planet, Index3 index, LocalBuilder builder, int seed)
        {
            ushort ground = builder.GetBlock(0, 0, -1);
            if (ground == water) return;

            Random rand = new Random(seed);
            int height = rand.Next(2, 4);

            for (int i = 0; i < height; i++)
                builder.SetBlock(0, 0, i, cactus);
        }
开发者ID:ManuelHu,项目名称:octoawesome,代码行数:11,代码来源:CactusTreeDefinition.cs


示例10: GetPrecipitation

        public int GetPrecipitation(Index3 blockIndex)
        {
            int maxPrecipitation = 100;

            float rawValue = planet.BiomeGenerator.BiomeNoiseGenerator.GetTileableNoise2D(blockIndex.X, blockIndex.Y, Planet.Size.X * Chunk.CHUNKSIZE_X, Planet.Size.Y * Chunk.CHUNKSIZE_Y);

            int height = blockIndex.Z - planet.BiomeGenerator.SeaLevel;
            float precipitationDecreasePerBlock = 1;

            return (int)(((1 - rawValue) * maxPrecipitation) - (Math.Max(height, 0) * precipitationDecreasePerBlock));
        }
开发者ID:RapidHelmus,项目名称:octoawesome,代码行数:11,代码来源:ComplexClimateMap.cs


示例11: SetChunk

        public void SetChunk(ILocalChunkCache manager, int x, int y, int z)
        {
            var newPosition = new Index3(x, y, z);

            if (_manager == manager && newPosition == ChunkPosition)
                return;

            _manager = manager;
            ChunkPosition = newPosition;

            chunk = null;
            loaded = false;
        }
开发者ID:RapidHelmus,项目名称:octoawesome,代码行数:13,代码来源:ChunkRenderer.cs


示例12: Load

        public IChunk Load(int universe, int planet, Index3 index)
        {
            var root = GetRoot();
            string filename = planet.ToString() + "_" + index.X + "_" + index.Y + "_" + index.Z + ".chunk";

            if (!File.Exists(root.FullName + Path.DirectorySeparatorChar + filename))
                return null;

            using (Stream stream = File.Open(root.FullName + Path.DirectorySeparatorChar + filename, FileMode.Open, FileAccess.Read))
            {
                return serializer.Deserialize(stream, new PlanetIndex3(planet, index));
            }
        }
开发者ID:thedomingo,项目名称:octoawesome,代码行数:13,代码来源:ChunkDiskPersistence.cs


示例13: Load

        public IChunk Load(int universe, int planet, Index3 index)
        {
            var root = GetRoot();
            string filename = planet.ToString() + "_" + index.X + "_" + index.Y + "_" + index.Z + ".chunk";

            if (!File.Exists(root.FullName + Path.DirectorySeparatorChar + filename))
                return null;

            using (Stream stream = File.Open(root.FullName + Path.DirectorySeparatorChar + filename, FileMode.Open, FileAccess.Read))
            {
                IChunk chunk = new Chunk(index, planet);
                chunk.Deserialize(stream, BlockDefinitionManager.GetBlockDefinitions());
                return chunk;
            }
        }
开发者ID:Vengarioth,项目名称:octoawesome,代码行数:15,代码来源:ChunkDiskPersistence.cs


示例14: GetTemperature

 public float GetTemperature(Index3 blockIndex)
 {
     int equator = (Planet.Size.Y * Chunk.CHUNKSIZE_Y) / 2;
     float equatorTemperature = 40f;
     float poleTemperature = -10f;
     float tempFluctuation = tempFluctuationGenerator.GetTileableNoise2D(blockIndex.X, blockIndex.Y, Planet.Size.X * Chunk.CHUNKSIZE_X, Planet.Size.Y * Chunk.CHUNKSIZE_Y) * 5f;
     float temperatureDifference = poleTemperature - equatorTemperature;
     float temperatureDecreasePerBlock = 0.1f;
     float distance = Math.Abs(blockIndex.Y - equator);
     float temperature = tempFluctuation + equatorTemperature + temperatureDifference * (float)Math.Sin((Math.PI / 2) * distance / equator);  //equatorTemperature + distance * temperatureDifference / equator;
     float height = (blockIndex.Z - planet.BiomeGenerator.SeaLevel) / (Planet.Size.Z * Chunk.CHUNKSIZE_Z - planet.BiomeGenerator.SeaLevel);
     height = Math.Max(height, 0);
     height *= height;
     return temperature - height * temperatureDecreasePerBlock;
 }
开发者ID:RapidHelmus,项目名称:octoawesome,代码行数:15,代码来源:ComplexClimateMap.cs


示例15: PlantTree

        public override void PlantTree(IDefinitionManager definitionManager, IPlanet planet, Index3 index, LocalBuilder builder, int seed)
        {
            ushort ground = builder.GetBlock(0, 0, -1);
            if (ground == water) return;

            Random rand = new Random(seed);
            int height = rand.Next(3, 5);
            int radius = rand.Next(3, height);

            builder.FillSphere(0, 0, height, radius, leave);

            for (int i = 0; i < height + 2; i++)
            {
                builder.SetBlock(0, 0, 0 + i, wood);
            }
        }
开发者ID:ManuelHu,项目名称:octoawesome,代码行数:16,代码来源:SpruceTreeDefinition.cs


示例16: Index3AdditionTest

        public void Index3AdditionTest()
        {
            Index3 i1 = new Index3(20, 15, 17);     // Startwert
            Index2 in2 = new Index2(-100, -130); // Negativ Addition (2D)
            Index3 in3 = new Index3(-100, -130, -33); // Negativ Addition (3D)
            Index3 in2r = new Index3(-80, -115, 17);  // Ergebnis i1 + in2
            Index3 in3r = new Index3(-80, -115, -16);  // Ergebnis i1 + in3

            Index2 ip2 = new Index2(77, 44); // positive Addition (2D)
            Index3 ip3 = new Index3(77, 44, 54); // positive Addition (3D)
            Index3 ip2r = new Index3(97, 59, 17);  // Ergebnis i1 + ip2
            Index3 ip3r = new Index3(97, 59, 71);  // Ergebnis i1 + ip3

            // Addition
            Assert.AreEqual(in2r, i1 + in2);
            Assert.AreEqual(in3r, i1 + in3);
            Assert.AreEqual(ip2r, i1 + ip2);
            Assert.AreEqual(ip3r, i1 + ip3);
        }
开发者ID:Vengarioth,项目名称:octoawesome,代码行数:19,代码来源:Index3Tests.cs


示例17: GetBlock

        /// <summary>
        /// Liefert den Block an der angegebenen Block-Koodinate zurück.
        /// </summary>
        /// <param name="index">Block Index</param>
        /// <returns>Block oder null, falls dort kein Block existiert</returns>
        public IBlock GetBlock(int planetId, Index3 index)
        {
            IPlanet planet = GetPlanet(planetId);

            index.NormalizeXY(new Index2(
                planet.Size.X * Chunk.CHUNKSIZE_X,
                planet.Size.Y * Chunk.CHUNKSIZE_Y));
            Coordinate coordinate = new Coordinate(0, index, Vector3.Zero);

            // Betroffener Chunk ermitteln
            Index3 chunkIndex = coordinate.ChunkIndex;
            if (chunkIndex.X < 0 || chunkIndex.X >= planet.Size.X ||
                chunkIndex.Y < 0 || chunkIndex.Y >= planet.Size.Y ||
                chunkIndex.Z < 0 || chunkIndex.Z >= planet.Size.Z)
                return null;
            IChunk chunk = chunkCache.Get(new PlanetIndex3(planetId, chunkIndex));
            if (chunk == null)
                return null;

            return chunk.GetBlock(coordinate.LocalBlockIndex);
        }
开发者ID:Vengarioth,项目名称:octoawesome,代码行数:26,代码来源:ResourceManager.cs


示例18: Draw

        public override void Draw(GameTime gameTime)
        {
            Microsoft.Xna.Framework.Color background =
                new Microsoft.Xna.Framework.Color(181, 224, 255);
            GraphicsDevice.Clear(background);

            GraphicsDevice.BlendState = BlendState.AlphaBlend;
            GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            Index3 chunkOffset = player.Player.Position.ChunkIndex;

            foreach (var renderer in chunkRenderer)
            {
                if (!renderer.ChunkPosition.HasValue)
                    continue;

                Index3 shift = chunkOffset.ShortestDistanceXY(
                    renderer.ChunkPosition.Value.ChunkIndex, new Index2(
                        planet.Size.X,
                        planet.Size.Y));

                BoundingBox chunkBox = new BoundingBox(
                new Vector3(
                    shift.X * OctoAwesome.Chunk.CHUNKSIZE_X,
                    shift.Y * OctoAwesome.Chunk.CHUNKSIZE_Y,
                    shift.Z * OctoAwesome.Chunk.CHUNKSIZE_Z),
                new Vector3(
                    (shift.X + 1) * OctoAwesome.Chunk.CHUNKSIZE_X,
                    (shift.Y + 1) * OctoAwesome.Chunk.CHUNKSIZE_Y,
                    (shift.Z + 1) * OctoAwesome.Chunk.CHUNKSIZE_Z));

                if (camera.Frustum.Intersects(chunkBox))
                    renderer.Draw(camera, shift);
            }

            if (player.SelectedBox.HasValue)
            {
                Index3 offset = player.Player.Position.ChunkIndex * Chunk.CHUNKSIZE;
                Index3 planetSize = planet.Size * Chunk.CHUNKSIZE;
                Index3 relativePosition = new Index3(
                    Index2.ShortestDistanceOnAxis(offset.X, player.SelectedBox.Value.X, planetSize.X),
                    Index2.ShortestDistanceOnAxis(offset.Y, player.SelectedBox.Value.Y, planetSize.Y),
                    player.SelectedBox.Value.Z - offset.Z);

                Vector3 selectedBoxPosition = new Vector3(
                    player.SelectedBox.Value.X - (chunkOffset.X * Chunk.CHUNKSIZE_X),
                    player.SelectedBox.Value.Y - (chunkOffset.Y * Chunk.CHUNKSIZE_Y),
                    player.SelectedBox.Value.Z - (chunkOffset.Z * Chunk.CHUNKSIZE_Z));
                // selectionEffect.World = Matrix.CreateTranslation(selectedBoxPosition);
                selectionEffect.World = Matrix.CreateTranslation(relativePosition);
                selectionEffect.View = camera.View;
                selectionEffect.Projection = camera.Projection;
                foreach (var pass in selectionEffect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, selectionLines, 0, 8, selectionIndeces, 0, 12);
                }
            }

            GraphicsDevice.SetRenderTarget(MiniMapTexture);

            minimapEffect.View = camera.MinimapView;

            foreach (var renderer in chunkRenderer)
            {
                if (!renderer.ChunkPosition.HasValue)
                    continue;

                Index3 shift = chunkOffset.ShortestDistanceXY(
                    renderer.ChunkPosition.Value.ChunkIndex, new Index2(
                        planet.Size.X,
                        planet.Size.Y));

                BoundingBox chunkBox = new BoundingBox(
                new Vector3(
                    shift.X * OctoAwesome.Chunk.CHUNKSIZE_X,
                    shift.Y * OctoAwesome.Chunk.CHUNKSIZE_Y,
                    shift.Z * OctoAwesome.Chunk.CHUNKSIZE_Z),
                new Vector3(
                    (shift.X + 1) * OctoAwesome.Chunk.CHUNKSIZE_X,
                    (shift.Y + 1) * OctoAwesome.Chunk.CHUNKSIZE_Y,
                    (shift.Z + 1) * OctoAwesome.Chunk.CHUNKSIZE_Z));

                if (camera.Frustum.Intersects(chunkBox))
                    renderer.DrawMinimap(minimapEffect, shift);
            }

            GraphicsDevice.SetRenderTarget(null);
        }
开发者ID:felixrieseberg,项目名称:octoawesome,代码行数:89,代码来源:SceneComponent.cs


示例19: loadChunk

 private IChunk loadChunk(Index3 index)
 {
     return ResourceManager.Instance.GetChunk(player.Player.Position.Planet, index);
 }
开发者ID:felixrieseberg,项目名称:octoawesome,代码行数:4,代码来源:SceneComponent.cs


示例20: FillChunkRenderer

        private bool FillChunkRenderer()
        {
            Index3 destinationChunk = player.Player.Position.ChunkIndex;
            IPlanet planet = ResourceManager.Instance.GetPlanet(player.Player.Position.Planet);
            destinationChunk.Z = Math.Max(VIEWHEIGHT, Math.Min(planet.Size.Z - VIEWHEIGHT, destinationChunk.Z));

            // Nur ausführen wenn der Spieler den Chunk gewechselt hat
            if (destinationChunk != currentChunk)
            {
                #region Shift durchführen

                Index3 shift = currentChunk.ShortestDistanceXY(
                    destinationChunk, new Index2(planet.Size.X, planet.Size.Y));

                for (int i = activeChunkRenderer.Count - 1; i >= 0; i--)
                {
                    ChunkRenderer renderer = activeChunkRenderer[i];

                    Index3 absoluteIndex = renderer.ChunkPosition.Value.ChunkIndex;
                    Index3 relativeIndex = destinationChunk.ShortestDistanceXY(
                        absoluteIndex, new Index2(
                            planet.Size.X,
                            planet.Size.Y));

                    if (!renderer.ChunkPosition.HasValue ||
                        relativeIndex.X < -VIEWRANGE || relativeIndex.X > VIEWRANGE ||
                        relativeIndex.Y < -VIEWRANGE || relativeIndex.Y > VIEWRANGE ||
                        relativeIndex.Z < -VIEWHEIGHT || relativeIndex.Z > VIEWHEIGHT)
                    {
                        renderer.SetChunk(null);

                        freeChunkRenderer.Enqueue(renderer);
                        activeChunkRenderer.Remove(renderer);
                    }
                }

                #endregion

                #region Ungenutzte Chunks auffüllen

                foreach (var distance in distances)
                {
                    Index3 chunkIndex = destinationChunk + distance;
                    chunkIndex.NormalizeXY(planet.Size);

                    PlanetIndex3 chunkPosition = new PlanetIndex3(
                        player.Player.Position.Planet, chunkIndex);

                    if (!activeChunkRenderer.Any(c => c.ChunkPosition == chunkPosition))
                    {
                        ChunkRenderer renderer = freeChunkRenderer.Dequeue();
                        renderer.SetChunk(chunkPosition);
                        activeChunkRenderer.Add(renderer);
                    }
                }

                #endregion

                currentChunk = destinationChunk;
            }

            #region Chunkrenderer updaten

            int shortestDistance = int.MaxValue;
            ChunkRenderer updatableRenderer = null;
            foreach (var renderer in activeChunkRenderer)
            {
                if (!renderer.NeedUpdate())
                    continue;

                Index3 absoluteIndex = renderer.ChunkPosition.Value.ChunkIndex;
                Index3 relativeIndex = destinationChunk.ShortestDistanceXY(
                                   absoluteIndex, new Index2(
                                       planet.Size.X,
                                       planet.Size.Y));

                int distance = relativeIndex.LengthSquared();
                if (distance < shortestDistance)
                {
                    updatableRenderer = renderer;
                    shortestDistance = distance;
                }
            }

            if (updatableRenderer != null)
                updatableRenderer.RegenerateVertexBuffer();

            #endregion

            return updatableRenderer != null;
        }
开发者ID:felixrieseberg,项目名称:octoawesome,代码行数:91,代码来源:SceneComponent.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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