コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the TerrainData class.
 /// </summary>
 /// <param name="material">The terrain material.</param>
 /// <param name="createTime">The creation time of the terrain.</param>
 public TerrainData(TerrainMaterial material, TimeSpan createTime)
 {
     this.Material = material;
     this.State = material == TerrainMaterial.None ? TerrainState.Empty : TerrainState.Terrain;
     this.CreateTime = createTime;
     this.LightFronts = new Edge[0];
 }
コード例 #2
0
ファイル: TerrainModel.cs プロジェクト: iaco79/HiOctaneTools
        public TerrainModel(string name, HeightmapResource heightmap) : base()
        {
            Name           = name;
            this.heightmap = heightmap;

            color = new Vector4(0.4f, 0.4f, 0.4f, 1.0f);

            if (setupGeometry())
            {
                Log.WriteLine("Terrain '" + name + "' loaded " +
                              positionVboData.Length + " vertices, " +
                              normalVboData.Length + " normals, " +
                              indicesVboData.Length + " indices");

                material = new TerrainMaterial();
                if (!material.Ready)
                {
                    return;
                }

                createVBOs();
                createVAOs();

                ready = true;
            }
            else
            {
                Log.WriteLine(Log.LOG_ERROR, "failed setting up environment model '" + Name + "'");
            }
        }
コード例 #3
0
        public override void ComposeSensorTargetSet(GameActor gameActor, Reflex reflex)
        {
            List <Filter> filters = reflex.Filters;

            _typeList.Clear();

            /// We never fire until we have valid data to base a trigger on.

            if (TerrainMaterial.IsValid(OverrideSenseMaterial, false, false))
            {
                _typeList.AddType(OverrideSenseMaterial);

                reflex.targetSet.Param = _typeList;

                reflex.targetSet.Action = TestObjectSet(reflex);
            }
            else if (gameActor.Chassis.TerrainDataValid)
            {
                gameActor.Chassis.GetTerrainMaterials(_typeList);

                reflex.targetSet.Param = _typeList;

                reflex.targetSet.Action = TestObjectSet(reflex);
            }
            else
            {
                reflex.targetSet.Action = false;
            }
        }   // end of ComposeSensorTargetSet()
コード例 #4
0
            public void Load(BinaryReader br, bool use16BitMatIdx)
            {
                for (int i = 0; i < PixPerMap; ++i)
                {
                    for (int j = 0; j < PixPerMap; ++j)
                    {
                        ushort val;

                        if (use16BitMatIdx)
                        {
                            val = br.ReadUInt16();
                        }
                        else
                        {
                            val = br.ReadByte();
                        }

                        // If user was editing terrain with a huge brush and saved before
                        // all tiles were updated, some of them may be saved with the
                        // selection flag in place.  Obviously this doesn't make sense to
                        // have on loading, so clear it out just to be sure.
                        val &= (ushort)~TerrainMaterial.Flags.Selection;

                        // Is the material we read valid? If not, replace it with empty.
                        if (!TerrainMaterial.IsValid(val, true, false))
                        {
                            Debug.Assert(false, "Why are we reading invalid values from this map?");
                            val = TerrainMaterial.EmptyMatIdx;
                        }

                        map[i, j] = val;
                    }
                }
            }
コード例 #5
0
ファイル: MapLoader.cs プロジェクト: vtsingaras/OpenSAGE
        private TerrainPatch CreatePatch(
            TerrainMaterial terrainMaterial,
            HeightMap heightMap,
            BlendTileData blendTileData,
            Rectangle patchBounds,
            GraphicsDevice graphicsDevice,
            TerrainPatchIndexBufferCache indexBufferCache)
        {
            var indexBuffer = indexBufferCache.GetIndexBuffer(
                patchBounds.Width,
                patchBounds.Height,
                out var indices);

            var vertexBuffer = AddDisposable(CreateVertexBuffer(
                                                 graphicsDevice,
                                                 heightMap,
                                                 patchBounds,
                                                 indices,
                                                 out var boundingBox,
                                                 out var triangles));

            return(new TerrainPatch(
                       terrainMaterial,
                       patchBounds,
                       vertexBuffer,
                       indexBuffer,
                       (uint)indices.Length,
                       triangles,
                       boundingBox));
        }
コード例 #6
0
        /// <summary>
        /// Initializes the terrain materials and settings.
        /// </summary>
        public override bool init()
        {
            World world = World;
            TerrainEngine terr = world.Terrain;

            // Aor now, register a single ground material.
            MatGround = terr.RegisterMaterial("Ground");

            // Add the geometry for the terrain LoDs >= 9.
            int pipeline = MatGround.AddDefaultPipeline(9);
            MatGround.AddDefaultShadowAndZPre(pipeline);
            MatGround.AddMeshMaterial(pipeline, "Output", Resources.UseMaterial("::Terrain/GrassyMountains", HostScript.ModDomain), Renderer.Opaque.Mesh);

            // Add the geometry for the terrain LoDs 5-8. Add some tree impostors to make the ground look nicer.
            pipeline = MatGround.AddPipeline(Resources.UseGeometryPipeline("PineImpostorField", HostScript.ModDomain), "Input", 5, 8);
            MatGround.AddDefaultShadowAndZPre(pipeline, "Input");
            MatGround.AddMeshMaterial(pipeline, "Input", Resources.UseMaterial("::Terrain/GrassyMountains", HostScript.ModDomain), Renderer.Opaque.Mesh);
            MatGround.AddMeshMaterial(pipeline, "PineSpawns", Resources.UseMaterial("PineImpostor", HostScript.ModDomain), Renderer.Opaque.Mesh);

            // For terrain LoDs 0-4, spawn "real" tree models instead of the impostors.
            pipeline = MatGround.AddPipeline(Resources.UseGeometryPipeline("PineField", HostScript.ModDomain), "Input", 0, 4);
            MatGround.AddDefaultShadowAndZPre(pipeline, "Decimate");
            MatGround.AddMeshMaterial(pipeline, "Decimate", Resources.UseMaterial("::Terrain/GrassyMountains", HostScript.ModDomain), Renderer.Opaque.Mesh);
            MatGround.AddMeshMaterial(pipeline, "PineSpawns", Resources.UseMaterial("PineLeaves", HostScript.ModDomain), Renderer.Opaque.Mesh);
            MatGround.AddMeshMaterial(pipeline, "PineSpawns", Resources.UseMaterial("::Shadow", HostScript.ModDomain), Renderer.Shadow.Mesh);

            return base.init();
        }
    private Rect LegacyGetRandomBodyRect(Vector2 aInitialPos, Ferr2DT_SegmentDescription aDesc)
    {
#if UNITY_5_4_OR_NEWER
        UnityEngine.Random.State tSeed = default(UnityEngine.Random.State);
#else
        int tSeed = 0;
#endif
        if (randomByWorldCoordinates)
        {
#if UNITY_5_4_OR_NEWER
            tSeed = UnityEngine.Random.state;
            UnityEngine.Random.InitState((int)(aInitialPos.x + aInitialPos.y));
#else
            tSeed = UnityEngine.Random.seed;
            UnityEngine.Random.seed = (int)(aInitialPos.x + aInitialPos.y);
#endif
        }

        Rect body = TerrainMaterial.ToUV(aDesc.body[UnityEngine.Random.Range(0, aDesc.body.Length)]);
        if (randomByWorldCoordinates)
        {
#if UNITY_5_4_OR_NEWER
            UnityEngine.Random.state = tSeed;
#else
            UnityEngine.Random.seed = tSeed;
#endif
        }
        return(body);
    }
コード例 #8
0
ファイル: Voxel.cs プロジェクト: andynygard/game-dwarves
 /// <summary>
 /// Initialises a new instance of the Voxel struct.
 /// </summary>
 /// <param name="material">The material.</param>
 /// <param name="density">The density.</param>
 /// <param name="color">The colour.</param>
 public Voxel(TerrainMaterial material, byte density, short color)
     : this()
 {
     this.Material = material;
     this.Density = density;
     this.Color = color;
 }
コード例 #9
0
 /// <summary>
 /// Initialises a new instance of the TerrainPoint class.
 /// </summary>
 /// <param name="foreground">The density of the foreground.</param>
 /// <param name="background">The density of the background.</param>
 /// <param name="material">The material.</param>
 /// <param name="light">The light value.</param>
 public TerrainPoint(byte foreground, byte background, TerrainMaterial material, Colour light)
 {
     this.Foreground = foreground;
     this.Background = background;
     this.Material = material;
     this.Light = light;
 }
コード例 #10
0
        public void newMat()
        {
            // Create a unique material name.
            string matName = Util.getUniqueInternalName("newMaterial", "TerrainMaterialSet", true);
            // Create the new material.
            ObjectCreator oc = new ObjectCreator("TerrainMaterial");

            oc["internalName"] = matName;
            oc["parentGroup"]  = "TerrainMaterialDlgNewGroup";

            TerrainMaterial newMat = oc.Create();

            newMat.setFilename("art/terrains/materials.cs");
            // Mark it as dirty and to be saved in the default location.
            PersistenceManager ETerrainMaterialPersistMan = "ETerrainMaterialPersistMan";

            ETerrainMaterialPersistMan.setDirty(newMat, "art/terrains/materials.cs");
            GuiTreeViewCtrl matLibTree = this.findObjectByInternalName("matLibTree", true);

            //TerrainPainterAddition
            int root = matLibTree.findItemByName("RootMaterial");

            int folder = matLibTree.findItemByName("Unused");

            if (folder == 0)
            {
                folder = matLibTree.insertItem(root, "Unused", "Unused", "");
            }
            matLibTree.insertObject(folder, newMat, true);

            matLibTree.buildVisibleTree(true);
            SimObject item = matLibTree.findItemByObjectId(newMat);

            matLibTree.selectItem(item);
        }
コード例 #11
0
        public void restoreMaterials()
        {
            if (!"TerrainMaterialDlgSnapshot".isObject())
            {
                Util._error("TerrainMaterial::restoreMaterials - no snapshot present");
                return;
            }

            SimGroup TerrainMaterialDlgSnapshot = "TerrainMaterialDlgSnapshot";

            int count = TerrainMaterialDlgSnapshot.getCount();

            for (uint i = 0; i < count; i++)
            {
                ScriptObject obj = TerrainMaterialDlgSnapshot.getObject(i);

                TerrainMaterial mat = obj["material"];
                mat.setInternalName(obj.internalName);
                mat.diffuseMap           = obj["diffuseMap"];
                mat.normalMap            = obj["normalMap"];
                mat.detailMap            = obj["detailMap"];
                mat.macroMap             = obj["macroMap"];
                mat["detailSize"]        = obj["detailSize"];
                mat["diffuseSize"]       = obj["diffuseSize"];
                mat["detailStrength"]    = obj["detailStrength"];
                mat["detailDistance"]    = obj["detailDistance"];
                mat["macroSize"]         = obj["macroSize"];
                mat["macroStrength"]     = obj["macroStrength"];
                mat["macroDistance"]     = obj["macroDistance"];
                mat["useSideProjection"] = obj["useSideProjection"];
                mat["parallaxScale"]     = obj["parallaxScale"];
            }
        }
コード例 #12
0
        public override void Initialize()
        {
            base.Initialize();

            // Skybox
            RenderSettings.Skybox.Generate(Application.GraphicsDevice, Application.Content, DemoGame.BlueSkybox);

            // Camera
            var camera = new CameraPrefab("camera");

            camera.AddComponent <ControllerSwitcher>();
            camera.AddComponent <DemoBehaviour>();
            Add(camera);

            // Light
            var lightPrefab = new LightPrefab("light", LightType.Directional);

            lightPrefab.Transform.Translate(0, 10, 0);
            lightPrefab.Light.Range        = 25;
            lightPrefab.Light.Intensity    = 1.0f;
            lightPrefab.Light.FallOf       = 5f;
            lightPrefab.Transform.Rotation = new Vector3(-1, 1, 0);
            lightPrefab.Light.Angle        = MathHelper.PiOver4;
            lightPrefab.Light.ShadowGenerator.ShadowStrength = 0.6f;
            lightPrefab.Light.ShadowGenerator.SetShadowMapSize(Application.GraphicsDevice, 1024);
            lightPrefab.EnableShadows = true;
            Add(lightPrefab);

            // Finally a terrain
            var terrainMat = new TerrainMaterial(scene);

            var terrain = new TerrainPrefab("terrain");

            terrain.Randomize(4, 12);
            terrain.Renderer.Material = terrainMat;
            terrain.Transform.Translate(-terrain.Width >> 1, 0, -terrain.Depth / 2);
            Add(terrain);

            terrain.SetWeightData(0.5f, 4, 15, 30);

            terrainMat.Texture       = Application.Content.Load <Texture2D>("Textures/Terrain/Grass");
            terrainMat.SandTexture   = Application.Content.Load <Texture2D>("Textures/Terrain/Sand");
            terrainMat.SnowTexture   = Application.Content.Load <Texture2D>("Textures/Terrain/Snow");
            terrainMat.RockTexture   = Application.Content.Load <Texture2D>("Textures/Terrain/Rock");
            terrainMat.WeightTexture = terrain.GenerateWeightMap();
            terrainMat.Tiling        = new Vector2(4);

            // Water !
            var water = new WaterPrefab("water");

            Add(water);
            water.Generate("Textures/water", "Textures/wavesbump", new Vector3(terrain.Width * 0.5f));

            var waterMat = water.Renderer.Material as WaterMaterial;

            waterMat.ReflectiveMap     = scene.RenderSettings.Skybox.Texture;
            waterMat.WaterTransparency = 0.6f;
        }
コード例 #13
0
        }   // end of PlayCollision()

        /// <summary>
        /// Play audio for actor/terrrain collision
        /// </summary>
        /// <param name="actor"></param>
        /// <param name="material">Material index.</param>
        public static void PlayCollision(GameThing actor, ushort material)
        {
            // Get the proper collision sound from the material index.
            if (!TerrainMaterial.IsValid(material, false, false))
            {
                //Debug.Assert(false, "Why do we have an invalid material here?");
                // Why?  Well because we sometimes clear the material in the feeler
                // collision testing.  So it's no longer a valid way to tell what
                // terrain we're over.  In general, it works when we're on the ground
                // but not when jumping.  Argh.

                collisionMetalSoft.Play(actor);
                return;
            }

            PlayActorCollision(actor);

            CollisionSound cs = TerrainMaterial.Get(material).CollisionSound;

            switch (cs)
            {
            case CollisionSound.plasticHard:
                collisionPlasticHard.Play(actor);
                break;

            case CollisionSound.plasticSoft:
                collisionPlasticSoft.Play(actor);
                break;

            case CollisionSound.metalHard:
                collisionMetalHard.Play(actor);
                break;

            case CollisionSound.metalSoft:
                collisionMetalSoft.Play(actor);
                break;

            case CollisionSound.rover:
                collisionRover.Play(actor);
                break;

            case CollisionSound.dirt:
                collisionDirt.Play(actor);
                break;

            case CollisionSound.grass:
                collisionGrass.Play(actor);
                break;

            case CollisionSound.rock:
                collisionRock.Play(actor);
                break;

            default:
                break;
            }
        }   // end of PlayCollision()
コード例 #14
0
        public static void EPainter_TerrainMaterialAddCallback(TerrainMaterial mat, int matIndex)
        {
            if (!mat.isObject())
            {
                return;
            }

            ((TerrainEditor)"ETerrainEditor").addMaterial(mat.getInternalName());
            ((TerrainPainter)"TerrainPainter").setup(matIndex);
        }
コード例 #15
0
        public static Color GetColor(this TerrainMaterial material)
        {
            if (!_color.TryGetValue(material, out var color))
            {
                // unknown material
                color = unchecked (Color.Color8((byte)material, (byte)((int)material >> 8), (byte)((int)material >> 16), 254));
            }

            return(color);
        }
コード例 #16
0
        public override void Initialize()
        {
            base.Initialize();

            // Add a camera with a FPS controller
            var camera = new CameraPrefab("camera");

            camera.Setup(new Vector3(0, 2, -10), new Vector3(0, 0, 0), Vector3.Up);
            camera.AddComponent <ControllerSwitcher>();
            Add(camera);

            // And a light
            var lightPrefab = new LightPrefab("light", LightType.Directional);

            Add(lightPrefab);
            lightPrefab.Transform.Rotation = new Vector3(-1, 1, 0);
            lightPrefab.Light.Color        = Color.LightSkyBlue;
            lightPrefab.Light.Intensity    = 1.0f;
            lightPrefab.AddComponent <DemoBehaviour>();
            lightPrefab.EnableShadows = true;

            // Finally a terrain
            var terrainMat = new TerrainMaterial(scene);

            var terrain = new TerrainPrefab("terrain");

            scene.Add(terrain);
            terrain.LoadHeightmap("Textures/heightmap");
            terrain.Renderer.Material = terrainMat;
            terrain.Transform.Translate(-terrain.Width >> 1, -10, -terrain.Depth >> 1);
            terrain.AddComponent <WeightMapViewer>();
            var map = terrain.GenerateWeightMap();

            terrainMat.Texture       = Application.Content.Load <Texture2D>("Textures/Terrain/Grass");
            terrainMat.SandTexture   = Application.Content.Load <Texture2D>("Textures/Terrain/Sand");
            terrainMat.SnowTexture   = Application.Content.Load <Texture2D>("Textures/Terrain/Snow");
            terrainMat.RockTexture   = Application.Content.Load <Texture2D>("Textures/Terrain/Rock");
            terrainMat.WeightTexture = map;
            terrainMat.Tiling        = new Vector2(4);

            // With water !
            var water = new WaterPrefab("water");

            scene.Add(water);
            water.Generate("Textures/water", "Textures/wavesbump", new Vector3(terrain.Width * 0.5f));

            Screen.ShowCursor = true;

            // Don't miss the Skybox ;)
            RenderSettings.Skybox.Generate(Application.GraphicsDevice, Application.Content, DemoGame.BlueSkybox);

            // And fog
            RenderSettings.FogDensity = 0.0085f;
            RenderSettings.FogMode    = FogMode.Exp2;
        }
コード例 #17
0
        public static TerrainVoxel New(TerrainMaterial material, double noise)
        {
            if (noise <= 0)
            {
                material = TerrainMaterial.Air;
            }

            byte density = (byte)((int)(Math.Abs(noise) * byte.MaxValue)).Clamp(1, byte.MaxValue);

            return(new TerrainVoxel(material, density));
        }
コード例 #18
0
ファイル: Floor.cs プロジェクト: Seryusjj/FarmerLife
 private void CheckSelected()
 {
     if (Selected)
     {
         TerrainMaterial.SetShaderParam("borderwidth0_1", .56f);
     }
     else
     {
         TerrainMaterial.SetShaderParam("borderwidth0_1", 0);
     }
 }
コード例 #19
0
ファイル: Tile.cs プロジェクト: Yash-Codemaster/KoduGameLab
        /// <summary>
        /// An assured renderable for each possible material.
        /// Will create if it doesn't exist.
        /// </summary>
        /// <param name="matIdx"></param>
        /// <returns></returns>
        private Renderable GetOrMakeRenderable(ushort matIdx)
        {
            Debug.Assert(TerrainMaterial.IsValid(matIdx, false, true)); // There is no reason to fetch a renderable
                                                                        // for an empty or invalid material.

            if (!renderableDict.ContainsKey(matIdx))
            {
                renderableDict[matIdx] = new Renderable(matIdx);
            }
            return(renderableDict[matIdx]);
        }
コード例 #20
0
        public void setTerrainFolder(string terrainFolder)
        {
            TerrainMaterial mat        = this["activeMat"];
            GuiTreeViewCtrl matLibTree = FOT("matLibTree");

            if (mat.isObject())
            {
                mat["terrainFolder"] = terrainFolder;
                matLibTree.buildVisibleTree(false);
            }
        }
コード例 #21
0
ファイル: Tile.cs プロジェクト: Yash-Codemaster/KoduGameLab
        /// <summary>
        /// Build up renderable geometry for each possible material. Discard empties.
        /// </summary>
        /// <param name="neighbors"></param>
        /// <param name="colorMap"></param>
        /// <returns></returns>
        private bool MakeRenderables(
            VirtualMap.HeightMapNeighbors heightNeighbors,
            VirtualMap.ColorMapNeighbors colorNeighbors)
        {
            var heightMap = heightNeighbors[VirtualMap.HeightMapNeighbors.Dir.Center];

            VirtualMap.ColorMap colorMap = colorNeighbors[VirtualMap.ColorMapNeighbors.Dir.Center];

            Renderable.PrepareToBuild(heightMap.Size, Min, minLut);

            //Dispose();
            //renderableDict.Clear();

            // Reset number of local vertices in each Renderable
            // since we're about to remake the list.
            ResetAllVertexCounts();


            Vector2 cubeSize = new Vector2(
                heightMap.Scale.X / (float)heightMap.Size.X,
                heightMap.Scale.Y / (float)heightMap.Size.Y);
            Vector2 halfSize = cubeSize * 0.5f;

            Point vert = new Point(0, 0);

            for (vert.X = 0; vert.X < heightMap.Size.X; vert.X += 1)
            {
                for (vert.Y = 0; vert.Y < heightMap.Size.Y; vert.Y += 1)
                {
                    float h = heightMap.GetHeightUnsafe(vert.X, vert.Y);
                    if (h != 0)
                    {
                        ushort color = colorMap[vert.X, vert.Y];

                        //Debug.Assert(TerrainMaterial.IsValid(color, false, true));

                        if (TerrainMaterial.IsValid(color, false, true))
                        {
                            Vector3 pos = new Vector3(
                                (float)vert.X * cubeSize.X + halfSize.X,
                                (float)vert.Y * cubeSize.Y + halfSize.Y,
                                h);

                            Renderable r = GetOrMakeRenderable(colorMap[vert.X, vert.Y]);

                            r.AddVertices(pos, halfSize, vert, heightNeighbors, colorNeighbors);
                        }
                    }
                }
            }

            return(FinishGeometry(cubeSize, halfSize));
        }
コード例 #22
0
        public NoiseWorldVoxelGridChunkPopulator(
            INoise3D noise, double noiseScaling, int numberOfOctaves, TerrainMaterial material)
        {
            Contracts.Requires.That(noise != null);
            Contracts.Requires.That(noiseScaling > 0);
            Contracts.Requires.That(numberOfOctaves >= 1);

            this.noise     = noise;
            this.distorter = NoiseDistorter.New()
                             .Frequency(noiseScaling, noiseScaling, noiseScaling).Octaves(numberOfOctaves);
            this.material = material;
        }
コード例 #23
0
        public static void EPainter_TerrainMaterialUpdateCallback(TerrainMaterial mat, int matIndex)
        {
            if (matIndex == -1 || !mat.isObject())
            {
                return;
            }

            // Update the material and the UI.

            ((TerrainEditor)"ETerrainEditor").updateMaterial((uint)matIndex, mat.getInternalName());
            ((TerrainPainter)"TerrainPainter").setup(matIndex);
        }
コード例 #24
0
        public void setActiveMaterial(TerrainMaterial mat)
        {
            if (mat.isObject())
            {
                GuiTextEditCtrl matNameCtrl        = this.findObjectByInternalName("matNameCtrl", true);
                GuiBitmapCtrl   baseTexCtrl        = this.findObjectByInternalName("baseTexCtrl", true);
                GuiBitmapCtrl   detailTexCtrl      = this.findObjectByInternalName("detailTexCtrl", true);
                GuiBitmapCtrl   macroTexCtrl       = this.findObjectByInternalName("macroTexCtrl", true);
                GuiBitmapCtrl   normTexCtrl        = this.findObjectByInternalName("normTexCtrl", true);
                GuiTextEditCtrl detSizeCtrl        = this.findObjectByInternalName("detSizeCtrl", true);
                GuiTextEditCtrl baseSizeCtrl       = this.findObjectByInternalName("baseSizeCtrl", true);
                GuiTextEditCtrl detStrengthCtrl    = this.findObjectByInternalName("detStrengthCtrl", true);
                GuiTextEditCtrl detDistanceCtrl    = this.findObjectByInternalName("detDistanceCtrl", true);
                GuiCheckBoxCtrl sideProjectionCtrl = this.findObjectByInternalName("sideProjectionCtrl", true);
                GuiTextEditCtrl parallaxScaleCtrl  = this.findObjectByInternalName("parallaxScaleCtrl", true);

                GuiTextEditCtrl macroSizeCtrl     = this.findObjectByInternalName("macroSizeCtrl", true);
                GuiTextEditCtrl macroStrengthCtrl = this.findObjectByInternalName("macroStrengthCtrl", true);
                GuiTextEditCtrl macroDistanceCtrl = this.findObjectByInternalName("macroDistanceCtrl", true);

                //TerrainPainterAddition
                GuiTextEditCtrl terrainFolderCtrl = FOT("terrainFolderCtrl");

                this["activeMat"] = mat;

                matNameCtrl.setText(mat.internalName);

                baseTexCtrl.setBitmapX(mat.diffuseMap == "" ? "tools/materialeditor/gui/unknownImage" : mat.diffuseMap);
                detailTexCtrl.setBitmapX(mat.detailMap == "" ? "tools/materialeditor/gui/unknownImage" : mat.detailMap);
                macroTexCtrl.setBitmapX(mat.macroMap == "" ? "tools/materialeditor/gui/unknownImage" : mat.macroMap);
                normTexCtrl.setBitmapX(mat.normalMap == "" ? "tools/materialeditor/gui/unknownImage" : mat.normalMap);

                detSizeCtrl.setText(mat.detailSize.AsString());
                baseSizeCtrl.setText(mat.diffuseSize.AsString());
                detStrengthCtrl.setText(mat.detailStrength.AsString());
                detDistanceCtrl.setText(mat.detailDistance.AsString());
                sideProjectionCtrl.setValue(mat.useSideProjection.AsString());
                parallaxScaleCtrl.setText(mat.parallaxScale.AsString());

                macroSizeCtrl.setText(mat.macroSize.AsString());
                macroStrengthCtrl.setText(mat.macroStrength.AsString());
                macroDistanceCtrl.setText(mat.macroDistance.AsString());

                //TerrainPainterAddition
                terrainFolderCtrl.setText(mat["terrainFolder"]);
                activateMaterialCtrls(true);
            }
            else
            {
                this["activeMat"] = "0";
                activateMaterialCtrls(false);
            }
        }
    private void LegacyAddEdge()
    {
        // split the path into segments based on the split angle
        List <List <int>               > segments = new List <List <int>               >();
        List <Ferr2DT_TerrainDirection>  dirs     = new List <Ferr2DT_TerrainDirection>();
        List <int> order = new List <int>();

        segments = GetSegments(Path.GetVertsRaw(), out dirs);
        if (dirs.Count < segments.Count)
        {
            dirs.Add(directionOverrides[directionOverrides.Count - 1]);
        }
        for (int i = 0; i < segments.Count; i++)
        {
            order.Add(i);
        }

        order.Sort(
            new Ferr.LambdaComparer <int>(
                (x, y) => {
            Ferr2DT_TerrainDirection dirx = dirs[x] == Ferr2DT_TerrainDirection.None ? Ferr2D_Path.GetDirection(Path.pathVerts, segments[x], 0, fill == Ferr2DT_FillMode.InvertedClosed) : dirs[x];
            Ferr2DT_TerrainDirection diry = dirs[y] == Ferr2DT_TerrainDirection.None ? Ferr2D_Path.GetDirection(Path.pathVerts, segments[y], 0, fill == Ferr2DT_FillMode.InvertedClosed) : dirs[y];
            return(TerrainMaterial.GetDescriptor(diry).zOffset.CompareTo(TerrainMaterial.GetDescriptor(dirx).zOffset));
        }
                ));

        // process the segments into meshes
        for (int i = 0; i < order.Count; i++)
        {
            List <int> currSeg = segments[order[i]];
            List <int> prevSeg = order[i] - 1 < 0 ?  segments[segments.Count - 1] : segments[order[i] - 1];
            List <int> nextSeg = segments[(order[i] + 1) % segments.Count];

            int curr = currSeg[0];
            int prev = prevSeg[prevSeg.Count - 2];
            int next = currSeg[1];

            Vector2 p1        = Path.pathVerts[prev] - Path.pathVerts[curr];
            Vector2 p2        = Path.pathVerts[next] - Path.pathVerts[curr];
            bool    leftInner = Mathf.Atan2(p1.x * p2.y - p1.y * p2.x, Vector2.Dot(p1, p2)) < 0;

            curr = currSeg[currSeg.Count - 1];
            prev = currSeg[currSeg.Count - 2];
            next = nextSeg[1];

            p1 = Path.pathVerts[prev] - Path.pathVerts[curr];
            p2 = Path.pathVerts[next] - Path.pathVerts[curr];
            bool rightInner = Mathf.Atan2(p1.x * p2.y - p1.y * p2.x, Vector2.Dot(p1, p2)) < 0;

            LegacyAddSegment(Ferr2D_Path.IndicesToList <Vector2>(Path.pathVerts, segments[order[i]]), leftInner, rightInner, Ferr2D_Path.IndicesToList <float>(vertScales, segments[order[i]]), Ferr2D_Path.IndicesToList <CutOverrides>(cutOverrides, segments[order[i]]), order.Count <= 1 && Path.closed, smoothPath, dirs[order[i]]);
        }
    }
コード例 #26
0
ファイル: MapLoader.cs プロジェクト: vtsingaras/OpenSAGE
        private List <TerrainPatch> CreatePatches(
            GraphicsDevice graphicsDevice,
            HeightMap heightMap,
            BlendTileData blendTileData,
            TerrainMaterial terrainMaterial,
            TerrainPatchIndexBufferCache indexBufferCache)
        {
            const int numTilesPerPatch = Terrain.Terrain.PatchSize - 1;

            var heightMapWidthMinusOne = heightMap.Width - 1;
            var numPatchesX            = heightMapWidthMinusOne / numTilesPerPatch;

            if (heightMapWidthMinusOne % numTilesPerPatch != 0)
            {
                numPatchesX += 1;
            }

            var heightMapHeightMinusOne = heightMap.Height - 1;
            var numPatchesY             = heightMapHeightMinusOne / numTilesPerPatch;

            if (heightMapHeightMinusOne % numTilesPerPatch != 0)
            {
                numPatchesY += 1;
            }

            var patches = new List <TerrainPatch>();

            for (var y = 0; y < numPatchesY; y++)
            {
                for (var x = 0; x < numPatchesX; x++)
                {
                    var patchX = x * numTilesPerPatch;
                    var patchY = y * numTilesPerPatch;

                    var patchBounds = new Rectangle(
                        patchX,
                        patchY,
                        Math.Min(Terrain.Terrain.PatchSize, heightMap.Width - patchX),
                        Math.Min(Terrain.Terrain.PatchSize, heightMap.Height - patchY));

                    patches.Add(CreatePatch(
                                    terrainMaterial,
                                    heightMap,
                                    blendTileData,
                                    patchBounds,
                                    graphicsDevice,
                                    indexBufferCache));
                }
            }

            return(patches);
        }
コード例 #27
0
 public ushort this[int i, int j]
 {
     get
     {
         ushort val = map[i, j];
         return(val);
     }
     set
     {
         Debug.Assert(TerrainMaterial.IsValid(value, allowEmpty: true, allowSelectionFlag: true));
         map[i, j] = value;
     }
 }
コード例 #28
0
 public TerrainResource(string name, bool translucent = false)
 {
     if (Scripting.IsHost)
     {
         Material = terrain.RegisterMaterial(name, translucent);
     }
     else
     {
         Material = terrain.QueryMaterialFromName(name);
     }
     Index = Material.MaterialIndex;
     Name  = name;
 }
コード例 #29
0
        /// <summary>
        /// Load content for the screen.
        /// </summary>
        /// <param name="GraphicInfo"></param>
        /// <param name="factory"></param>
        /// <param name="contentManager"></param>
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            RasterizerState          = new RasterizerState();
            RasterizerState.FillMode = FillMode.WireFrame;

            ///Forward Shader (look at this shader construction for more info)
            TerrainMaterial material = new TerrainMaterial(factory, "Terrain//HeightMap");
            ///The object itself
            TerrainObject to  = new TerrainObject(factory, Vector3.Zero, Matrix.Identity, material.Model.GetHeights(), MaterialDescription.DefaultBepuMaterial());
            IObject       obj = new IObject(material, null, to);

            ///Add to the world
            this.World.AddObject(obj);

            ///add a camera
            RotatingCamera cam = new RotatingCamera(this, new Vector3(-200, -100, -300));

            this.World.CameraManager.AddCamera(cam);

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubeMap");

            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);


            {
                Texture2D   t           = factory.CreateTexture2DColor(1, 1, Color.Red);
                SimpleModel simpleModel = new SimpleModel(factory, "Model/block");
                simpleModel.SetTexture(t);
                ///Forward Shader (look at this shader construction for more info)
                ForwardXNABasicShader shader = new ForwardXNABasicShader();
                ///Forward material
                ForwardMaterial fmaterial = new ForwardMaterial(shader);
                for (int i = 0; i < 10; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        ///Physic info (position, rotation and scale are set here)
                        BoxObject tmesh = new BoxObject(new Vector3(j * 10 + 200, 100, i * 10 + 200), 1, 1, 1, 10, Vector3.One * 2, Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
                        ///The object itself
                        obj = new IObject(fmaterial, simpleModel, tmesh);
                        ///Add to the world
                        this.World.AddObject(obj);
                        objs.Add(obj);
                        tmesh.isMotionLess = true;
                    }
                }
                shader.BasicEffect.EnableDefaultLighting();
            }
        }
コード例 #30
0
        }   // end of MaterialPicker c'tor

        /// <summary>
        /// Sample the type under the cursor and translate to a UISlot.
        /// Return -1 on no terrain.
        /// </summary>
        /// <returns></returns>
        public int SampleType()
        {
            Vector2 pos = InGame.inGame.Cursor3D.Position2d;

            if (MouseEdit.TriggerSample())
            {
                Vector3 p = MouseEdit.HitInfo.TerrainPosition;
                pos = new Vector2(p.X, p.Y);
            }

            ushort t = Terrain.GetMaterialType(pos);

            return(TerrainMaterial.IsValid(t, false, false) ? Terrain.MaterialIndexToUISlot(t) : -1);
        }
    private void LegacyAddSegment(List <Vector2> aSegment, bool aLeftInner, bool aRightInner, List <float> aScale, List <CutOverrides> aCutOverrides, bool aClosed, bool aSmooth, Ferr2DT_TerrainDirection aDir = Ferr2DT_TerrainDirection.None)
    {
        Ferr2DT_SegmentDescription desc;

        if (aDir != Ferr2DT_TerrainDirection.None)
        {
            desc = TerrainMaterial.GetDescriptor(aDir);
        }
        else
        {
            desc = GetDescription(aSegment);
        }

        #if UNITY_5_4_OR_NEWER
        UnityEngine.Random.State tSeed = UnityEngine.Random.state;
        #else
        int tSeed = UnityEngine.Random.seed;
        #endif
        Rect  body      = TerrainMaterial.ToUV(desc.body[0]);
        float bodyWidth = body.width * unitsPerUV.x;

                #if UNITY_5_4_OR_NEWER
        UnityEngine.Random.InitState((int)(aSegment[0].x * 100000 + aSegment[0].y * 10000));
                #else
        UnityEngine.Random.seed = (int)(aSegment[0].x * 100000 + aSegment[0].y * 10000);
                #endif

        Vector2 capLeftSlideDir  = (aSegment[1] - aSegment[0]);
        Vector2 capRightSlideDir = (aSegment[aSegment.Count - 2] - aSegment[aSegment.Count - 1]);
        capLeftSlideDir.Normalize();
        capRightSlideDir.Normalize();
        aSegment[0] -= capLeftSlideDir * desc.capOffset;
        aSegment[aSegment.Count - 1] -= capRightSlideDir * desc.capOffset;

        LegacyCreateBody(desc, aSegment, aScale, aCutOverrides, bodyWidth, Mathf.Max(2, splitCount + 2), aClosed);

        if (!aClosed)
        {
            LegacyAddCap(aSegment, desc, aLeftInner, -1, aScale[0], aSmooth);
            LegacyAddCap(aSegment, desc, aRightInner, 1, aScale[aScale.Count - 1], aSmooth);
        }
                #if UNITY_5_4_OR_NEWER
        UnityEngine.Random.state = tSeed;
                #else
        UnityEngine.Random.seed = tSeed;
                #endif
    }
コード例 #32
0
        public TerrainCell(TerrainMaterial material, byte originalCoordX, byte originalCoordY, byte extra) : this()
        {
            Assert((int)material == ((int)material & 0b00001111_11111111), $"Invalid {nameof(TerrainCell)}.{nameof(Material)}: out of range");
            Assert(originalCoordX == (originalCoordX & 0b00111111), $"Invalid {nameof(TerrainCell)}.{nameof(OriginalCoordX)}: out of range");
            Assert(originalCoordY == (originalCoordY & 0b00111111), $"Invalid {nameof(TerrainCell)}.{nameof(OriginalCoordY)}: out of range");

            _material = (ushort)material;

            if (!BitConverter.IsLittleEndian)
            {
                var buff = _g;
                _g = _r;
                _r = buff;
            }

            _g |= (byte)(extra & 0b11110000);
            _b  = (byte)(originalCoordX | ((extra & 0b00001100) << 4));
            _a  = (byte)(originalCoordY | (extra << 6));
        }
コード例 #33
0
ファイル: WeightMapViewer.cs プロジェクト: tchekjunior/C3DE
        public override void Start()
        {
            var renderer = GetComponent <MeshRenderer>();

            if (renderer == null)
            {
                throw new Exception("You need to attach a mesh renderer first.");
            }

            var mat = renderer.Material as TerrainMaterial;

            if (mat == null)
            {
                throw new Exception("You need to use a TerrainMaterial with a non null weightMap.");
            }

            _material = mat;
            _rect     = new Rectangle(0, 0, 150, 150);
        }
コード例 #34
0
        public void snapshotMaterials()
        {
            if (!"TerrainMaterialDlgSnapshot".isObject())
            {
                new ObjectCreator("SimGroup", "TerrainMaterialDlgSnapshot").Create();
            }

            SimGroup group = "TerrainMaterialDlgSnapshot";
            SimSet   TerrainMaterialSet = "TerrainMaterialSet";

            group.clear();

            int matCount = TerrainMaterialSet.getCount();

            for (uint i = 0; i < matCount; i++)
            {
                TerrainMaterial mat = TerrainMaterialSet.getObject(i);
                if (!mat.isMemberOfClass("TerrainMaterial"))
                {
                    continue;
                }

                ObjectCreator oc = new ObjectCreator("ScriptObject");
                oc["parentGroup"]       = group.ID;
                oc["material"]          = mat;
                oc["internalName"]      = mat["internalName"];
                oc["diffuseMap"]        = mat["diffuseMap"];
                oc["normalMap"]         = mat["normalMap"];
                oc["detailMap"]         = mat["detailMap"];
                oc["macroMap"]          = mat["macroMap"];
                oc["detailSize"]        = mat["detailSize"];
                oc["diffuseSize"]       = mat["diffuseSize"];
                oc["detailStrength"]    = mat["detailStrength"];
                oc["detailDistance"]    = mat["detailDistance"];
                oc["macroSize"]         = mat["macroSize"];
                oc["macroStrength"]     = mat["macroStrength"];
                oc["macroDistance"]     = mat["macroDistance"];
                oc["useSideProjection"] = mat["useSideProjection"];
                oc["parallaxScale"]     = mat["parallaxScale"];
                oc.Create();
            }
        }
コード例 #35
0
        /// <summary>
        /// Draw a tiled terrain within the given bounds.
        /// </summary>
        /// <param name="spriteBatch">The sprite batch that is being drawn.</param>
        /// <param name="material">The terrain material.</param>
        /// <param name="scaledBounds">The bounds of the terrain block scaled by the terrain scale factor.</param>
        private void DrawTiledTerrain(SpriteBatch spriteBatch, TerrainMaterial material, Rectangle scaledBounds)
        {
            // Get the variations of this terrain material
            // TODO: Use the TerrainMaterial value, rather than just using mud here
            var spriteRects = new Dictionary<int, Rectangle>();
            foreach (int variation in this.resources.GetSpriteVariations("terrain", "earth", "mud"))
            {
                spriteRects.Add(variation, this.resources.GetSpriteRectangle("terrain", "earth", "mud", variation));
            }

            // Calculate the scaled tile size and determine the offset of the top-left corner of the tile
            int offsetX = scaledBounds.X % Const.TileSize;
            int offsetY = scaledBounds.Y % Const.TileSize;
            for (int x = scaledBounds.Left; x < scaledBounds.Right; x += Const.TileSize)
            {
                for (int y = scaledBounds.Top; y < scaledBounds.Bottom; y += Const.TileSize)
                {
                    // Calculate the top-left position of the tile
                    int tileX = x - offsetX;
                    int tileY = y - offsetY;

                    // Get a random sprite seeded by the x/y tile coordinate
                    int rectIndex = new Random(tileX ^ tileY).Next(0, spriteRects.Count);
                    Rectangle srcRect = spriteRects.ElementAt(rectIndex).Value;

                    // Clip the left bounds
                    if (tileX < scaledBounds.Left)
                    {
                        int diff = scaledBounds.Left - tileX;
                        tileX += diff;
                        srcRect.X += diff;
                        srcRect.Width -= diff;
                    }

                    // Clip the top bounds
                    if (tileY < scaledBounds.Top)
                    {
                        int diff = scaledBounds.Top - tileY;
                        tileY += diff;
                        srcRect.Y += diff;
                        srcRect.Height -= diff;
                    }

                    // Clip the right bounds
                    if (x + srcRect.Width > scaledBounds.Right)
                    {
                        srcRect.Width = scaledBounds.Right - x;
                    }

                    // Clip the bottom bounds
                    if (y + srcRect.Height > scaledBounds.Bottom)
                    {
                        srcRect.Height = scaledBounds.Bottom - y;
                    }

                    // Create the dest rectangle
                    var destRect = new Rectangle(tileX, tileY, srcRect.Width, srcRect.Height);

                    // Draw the sprite
                    spriteBatch.Draw(this.resources.SpriteSheet, destRect, srcRect, Color.White);
                }
            }
        }
コード例 #36
0
        /// <summary>
        /// Draw the fringe tiles such as grass and rocks.
        /// </summary>
        /// <param name="spriteBatch">The sprite batch that is being drawn.</param>
        /// <param name="material">The terrain material.</param>
        /// <param name="terrainBounds">The bounds of the terrain block in terrain units.</param>
        /// <param name="groundNodes">The ground nodes which represents the walkable ground in the terrain on which the
        /// fringe sprites will be rendered.</param>
        private void DrawTerrainFringe(
            SpriteBatch spriteBatch,
            TerrainMaterial material,
            Square terrainBounds,
            Dictionary<Point, LinkedPathNode> groundNodes)
        {
            // Determine which segments (if any) of this terrain block are ground nodes
            var groundPoints = new List<Tuple<int, int>>();
            int groundY = terrainBounds.Y - 1;
            int currentStart = -1;
            int currentLength = 0;
            for (int x = terrainBounds.X; x < terrainBounds.Right; x++)
            {
                // Check if this point is a ground node
                if (groundNodes.ContainsKey(new Point(x, groundY)))
                {
                    // This is a ground node, so add it to the current point set
                    if (currentStart != -1)
                    {
                        currentLength++;
                    }
                    else
                    {
                        currentStart = x;
                        currentLength = 1;
                    }
                }
                else
                {
                    // This is not a ground node. If a range was being build, add it to the collection
                    if (currentStart != -1)
                    {
                        groundPoints.Add(Tuple.Create(currentStart, currentLength));
                        currentStart = -1;
                    }
                }
            }

            // Add the last x range
            if (currentStart != -1)
            {
                groundPoints.Add(Tuple.Create(currentStart, currentLength));
                currentStart = -1;
            }

            // If there are no ground points for this terrain block, there is nothing to render
            if (groundPoints.Count == 0)
            {
                return;
            }

            // Get the variations of the lower fringe sprites
            // TODO: Use the TerrainMaterial value, rather than just using mud here
            var lowerFringeRects = new Dictionary<int, Rectangle>();
            foreach (int variation in this.resources.GetSpriteVariations("terrain", "lowerfringe", "mud"))
            {
                lowerFringeRects.Add(variation, this.resources.GetSpriteRectangle("terrain", "lowerfringe", "mud", variation));
            }

            // Get the variations of the upper fringe sprites
            // TODO: Use the TerrainMaterial value, rather than just using mud here
            var upperFringeRects = new Dictionary<int, Rectangle>();
            foreach (int variation in this.resources.GetSpriteVariations("terrain", "upperfringe", "mud"))
            {
                upperFringeRects.Add(variation, this.resources.GetSpriteRectangle("terrain", "upperfringe", "mud", variation));
            }

            // Do nothing if no sprites exist for this terrain material
            if (lowerFringeRects.Count == 0 && upperFringeRects.Count == 0)
            {
                return;
            }

            // Determine the offset of the left side of the tile
            int offsetX = terrainBounds.X % Const.TileSize;

            // Draw the sprites
            foreach (Tuple<int, int> range in groundPoints)
            {
                int startX = range.Item1;
                int width = range.Item2;

                for (int x = startX; x < startX + width; x += Const.TileSize)
                {
                    // Calculate the x position of the tile
                    int tileX = x - offsetX;

                    // Get a random sprite seeded by the x/y tile coordinate
                    int lowerFringeIndex = new Random(tileX ^ terrainBounds.Y).Next(0, lowerFringeRects.Count);
                    Rectangle lowerFringeRect = lowerFringeRects.ElementAt(lowerFringeIndex).Value;
                    int upperFringeIndex = new Random(tileX ^ terrainBounds.Y).Next(0, upperFringeRects.Count);
                    Rectangle upperFringeRect = upperFringeRects.ElementAt(upperFringeIndex).Value;

                    // Clip the left bounds
                    if (tileX < startX)
                    {
                        int diff = startX - tileX;
                        tileX += diff;
                        lowerFringeRect.X += diff;
                        lowerFringeRect.Width -= diff;
                        upperFringeRect.X += diff;
                        upperFringeRect.Width -= diff;
                    }

                    // Clip the right bounds
                    if (x + lowerFringeRect.Width > startX + width)
                    {
                        int newWidth = startX + width - x;
                        lowerFringeRect.Width = newWidth;
                        upperFringeRect.Width = newWidth;
                    }

                    // Create the dest rectangles
                    var lowerFringeDestRect =
                        new Rectangle(tileX, terrainBounds.Y, lowerFringeRect.Width, lowerFringeRect.Height);
                    var upperFringeDestRect = new Rectangle(
                        tileX,
                        terrainBounds.Y - upperFringeRect.Height, // Upper fringe is above ground, so offset by its height
                        upperFringeRect.Width,
                        upperFringeRect.Height);

                    // Draw the sprites
                    spriteBatch.Draw(this.resources.SpriteSheet, lowerFringeDestRect, lowerFringeRect, Color.White);
                    spriteBatch.Draw(this.resources.SpriteSheet, upperFringeDestRect, upperFringeRect, Color.White);
                }
            }
        }
コード例 #37
0
 public Gradient getColoringForMaterial(TerrainMaterial material)
 {
     return materialEditor.colorings[material];
 }
コード例 #38
0
ファイル: MaterialEditor.cs プロジェクト: parmandorc/PCG
    // -----------------------
    // Sets the corresponding toggle to On
    // Note: The currently active one will switch to Off as all toggles are in the same toggle group.
    public void setToggleOn(TerrainMaterial material)
    {
        switch (material) {

        case TerrainMaterial.GREEN_HILLS:
            greenHillsToggle.isOn = true;
            break;

        case TerrainMaterial.MOUNTAINS:
            mountainsToggle.isOn = true;
            break;

        case TerrainMaterial.DESERT:
            desertToggle.isOn = true;
            break;

        case TerrainMaterial.MESA:
            mesaToggle.isOn = true;
            break;

        case TerrainMaterial.SNOW_LANDS:
            snowLandsToggle.isOn = true;
            break;

        case TerrainMaterial.OCEAN:
            oceanToggle.isOn = true;
            break;
        }
    }
コード例 #39
0
ファイル: Voxel.cs プロジェクト: andynygard/game-dwarves
 /// <summary>
 /// Initialises a new instance of the Voxel struct.
 /// </summary>
 /// <param name="material">The material.</param>
 /// <param name="density">The density.</param>
 public Voxel(TerrainMaterial material, byte density)
     : this(material, density, short.MaxValue)
 {
 }
コード例 #40
0
        /// <summary>
        /// Fill the terrain with the given material below the surface and air above.
        /// </summary>
        /// <param name="chunk">The chunk</param>
        /// <param name="chunkIndex">The chunk index.</param>
        /// <param name="surfaceHeights">The y value of each surface point.</param>
        /// <param name="material">The material to fill below surface.</param>
        private void FillAroundSurface(
            ChunkVoxels chunk,
            Position chunkIndex,
            int[] surfaceHeights,
            TerrainMaterial material)
        {
            for (int chunkX = 0; chunkX < Chunk.Width; chunkX++)
            {
                int surfaceHeight = surfaceHeights[chunkX];

                for (int chunkY = 0; chunkY < Chunk.Height; chunkY++)
                {
                    if (chunkY < surfaceHeight)
                    {
                        chunk[chunkX, chunkY] = new Voxel(material, Voxel.DensityMin);
                    }
                    else if (chunkY > surfaceHeight)
                    {
                        chunk[chunkX, chunkY] = new Voxel(TerrainMaterial.Air, Voxel.DensityMax);
                    }
                }
            }
        }
コード例 #41
0
ファイル: MaterialEditor.cs プロジェクト: parmandorc/PCG
 // Sends to the TCE the gradient of the material that was set
 public void setMaterial(TerrainMaterial material)
 {
     TCE.ChangeMaterial(new Eppy.Tuple<TerrainMaterial, Gradient>(material, colorings[material]));
 }