Started to implement road generation.

This commit is contained in:
Tiberiu Chibici 2015-05-20 11:26:46 +03:00
parent 11ca59d8bb
commit 7bd2b7b255
24 changed files with 616 additions and 119 deletions

Binary file not shown.

View File

@ -53,6 +53,9 @@
<Compile Include="Assets\Scripts\Model\Biome.cs" />
<Compile Include="Assets\Scripts\Model\Config\TerrainGeneratorConfig.cs" />
<Compile Include="Assets\Scripts\Model\Map.cs" />
<Compile Include="Assets\Scripts\Model\Road\RoadNetwork.cs" />
<Compile Include="Assets\Scripts\Model\Road\RoadNode.cs" />
<Compile Include="Assets\Scripts\Model\Road\RoadSegment.cs" />
<Compile Include="Assets\Scripts\Model\Texture.cs" />
<Compile Include="Assets\Scripts\Noise\NoiseGenerator.cs" />
<Compile Include="Assets\Scripts\Noise\PerlinNoiseGenerator.cs" />
@ -65,6 +68,7 @@
<Compile Include="Assets\Scripts\Utils\Logger.cs" />
<Compile Include="Assets\Scripts\Utils\RandomExtensions.cs" />
<Compile Include="Assets\Scripts\Utils\Range.cs" />
<Compile Include="Assets\Scripts\Utils\SerializationHelper.cs" />
<Compile Include="Assets\Scripts\Utils\Task.cs" />
<Compile Include="Assets\Scripts\Utils\Texture2DExtensions.cs" />
<Compile Include="Assets\Scripts\Utils\XmlHelper.cs" />

View File

@ -53,6 +53,9 @@
<Compile Include="Assets\Scripts\Model\Biome.cs" />
<Compile Include="Assets\Scripts\Model\Config\TerrainGeneratorConfig.cs" />
<Compile Include="Assets\Scripts\Model\Map.cs" />
<Compile Include="Assets\Scripts\Model\Road\RoadNetwork.cs" />
<Compile Include="Assets\Scripts\Model\Road\RoadNode.cs" />
<Compile Include="Assets\Scripts\Model\Road\RoadSegment.cs" />
<Compile Include="Assets\Scripts\Model\Texture.cs" />
<Compile Include="Assets\Scripts\Noise\NoiseGenerator.cs" />
<Compile Include="Assets\Scripts\Noise\PerlinNoiseGenerator.cs" />
@ -65,6 +68,7 @@
<Compile Include="Assets\Scripts\Utils\Logger.cs" />
<Compile Include="Assets\Scripts\Utils\RandomExtensions.cs" />
<Compile Include="Assets\Scripts\Utils\Range.cs" />
<Compile Include="Assets\Scripts\Utils\SerializationHelper.cs" />
<Compile Include="Assets\Scripts\Utils\Task.cs" />
<Compile Include="Assets\Scripts\Utils\Texture2DExtensions.cs" />
<Compile Include="Assets\Scripts\Utils\XmlHelper.cs" />

Binary file not shown.

View File

@ -21,7 +21,7 @@ namespace TransportGame.Business
public static void LoadConfiguration()
{
// Load terrgen config
TerrGenConfig = XmlHelper.Deserialize<TerrainGeneratorConfig>(Path.Combine(ConfigurationDirectory, TerrGenConfigFile));
TerrGenConfig = SerializationHelper.Deserialize<TerrainGeneratorConfig>(Path.Combine(ConfigurationDirectory, TerrGenConfigFile));
}
}
}

View File

@ -50,6 +50,8 @@ namespace TransportGame.Generator
float waterAmount = random.NextSingle(map.Biome.Moisture.Minimum, map.Biome.Moisture.Maximum);
map.WaterLevel = Mathf.Pow(waterAmount, ConfigurationManager.TerrGenConfig.WaterNonLinearPower) * map.Biome.Height;
DumpData(map, "dump.map");
return map;
}
@ -65,7 +67,7 @@ namespace TransportGame.Generator
{
for (int x = 0; x < map.Width; ++x)
for (int y = 0; y < map.Height; ++y)
map.Heights[x, y] = Noise.Generate(x, y, 0, 1);
map.Heightmap[x, y] = Noise.Generate(x, y, 0, 1);
}
private void DumpData(Map map, string filename)

View File

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using TransportGame.Model.Road;
using TransportGame.Utils;
namespace TransportGame.Model
{
@ -10,12 +12,9 @@ namespace TransportGame.Model
public class Map
{
private float[,] grid;
private float[,] population;
/// <summary>
/// Gets or sets the water level
/// </summary>
[XmlElement("waterLevel")]
public float WaterLevel { get; set; }
#region Properties
/// <summary>
/// Gets or sets the biome
@ -23,11 +22,17 @@ namespace TransportGame.Model
[XmlElement("biome")]
public Biome Biome { get; set; }
/// <summary>
/// Gets or sets the water level
/// </summary>
[XmlElement("waterLevel")]
public float WaterLevel { get; set; }
/// <summary>
/// Gets the heights array in range [0,1]
/// </summary>
[XmlIgnore()]
public float[,] Heights
public float[,] Heightmap
{
get
{
@ -38,49 +43,85 @@ namespace TransportGame.Model
/// <summary>
/// Gets or sets the heights as raw bytes
/// </summary>
/// <remarks>
/// Bytes are stored as such:
///
/// Offset Size Content
/// ------------------------
/// 0 4 Width
/// 4 8 Height
/// 8 var 32bit floating point values
///
/// </remarks>
[XmlElement("heights")]
public byte[] HeightsRaw
[XmlElement("heightmap")]
public byte[] HeightmapRaw
{
get
{
List<byte> bytes = new List<byte>();
bytes.AddRange(BitConverter.GetBytes(Width));
bytes.AddRange(BitConverter.GetBytes(Height));
for (int x = 0; x < Width; x++)
for (int y = 0; y < Height; y++)
bytes.AddRange(BitConverter.GetBytes(grid[x, y]));
return bytes.ToArray();
return grid.ToByteArray();
}
set
{
int pos = 0;
int w = BitConverter.ToInt32(value, pos); pos += sizeof(int);
int h = BitConverter.ToInt32(value, pos); pos += sizeof(int);
grid = new float[w, h];
for (int x = 0; x < w; x++)
for (int y = 0; y < h; y++)
{
grid[x, y] = BitConverter.ToSingle(value, pos);
pos += sizeof(float);
}
grid = value.GetFloatMatrix();
}
}
/// <summary>
/// Gets width of heightmap
/// </summary>
[XmlIgnore]
public int Width { get { return (grid == null) ? 0 : grid.GetLength(0); } }
/// <summary>
/// Gets height of heightmap
/// </summary>
[XmlIgnore]
public int Height { get { return (grid == null) ? 0 : grid.GetLength(1); } }
/// <summary>
/// Gets the population map
/// </summary>
[XmlIgnore()]
public float[,] Population
{
get
{
return population;
}
set
{
population = value;
}
}
/// <summary>
/// Gets or sets the population as raw bytes
/// </summary>
[XmlElement("population")]
public byte[] PopulationRaw
{
get
{
return population.ToByteArray();
}
set
{
population = value.GetFloatMatrix();
}
}
/// <summary>
/// Gets width of population map
/// </summary>
[XmlIgnore]
public int PopulationWidth { get { return (population == null) ? 0 : population.GetLength(0); } }
/// <summary>
/// Gets height of population map
/// </summary>
[XmlIgnore]
public int PopulationHeight { get { return (population == null) ? 0 : population.GetLength(1); } }
/// <summary>
/// Gets or sets the articulation road network
/// </summary>
[XmlElement("roadNetwork")]
public RoadNetwork RoadNetwork { get; set; }
#endregion
#region Constructors
/// <summary>
/// Initializes the map
/// </summary>
@ -94,43 +135,36 @@ namespace TransportGame.Model
/// <summary>
/// Initializes the map
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="width">Width</param>
/// <param name="height">Height</param>
public Map(int width, int height)
{
grid = new float[width, height];
}
#endregion
/// <summary>
/// Gets or sets the cell at specified position in range [0, Biome.Height]
/// Gets the cell at specified position in range [0, Biome.Height]
/// </summary>
/// <param name="x">X</param>
/// <param name="y">Y</param>
/// <returns>Cell</returns>
[XmlIgnore]
public float this[int x, int y]
/// <returns>Value</returns>
public float GetHeight(int x, int y)
{
get
{
return grid[x, y] * Biome.Height;
}
set
{
grid[x, y] = value / Biome.Height;
}
return grid[x, y] * Biome.Height;
}
/// <summary>
/// Gets width of map
/// Sets the height at specified position in range [0, Biome.Height]
/// </summary>
[XmlIgnore]
public int Width { get { return grid.GetLength(0); } }
/// <summary>
/// Gets height of map
/// </summary>
[XmlIgnore]
public int Height { get { return grid.GetLength(1); } }
/// <param name="x">X</param>
/// <param name="y">Y</param>
/// <param name="value">Value</param>
public void SetHeight(int x, int y, float value)
{
grid[x, y] = value / Biome.Height;
}
/// <summary>
/// Returns true if specified cell is a water cell
@ -140,7 +174,7 @@ namespace TransportGame.Model
/// <returns></returns>
public bool IsWater(int x, int y)
{
return this[x, y] <= WaterLevel;
return GetHeight(x, y) <= WaterLevel;
}
/// <summary>

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: dc46a301e57a8af41872e48f0b2cbd61
folderAsset: yes
timeCreated: 1431600774
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,147 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace TransportGame.Model.Road
{
[XmlRoot("roadNetwork")]
public class RoadNetwork
{
private int lastNodeId = -1, lastSegmentId = -1;
/// <summary>
/// Gets or sets the road nodes
/// </summary>
[XmlIgnore]
public Dictionary<int, RoadNode> Nodes { get; private set; }
/// <summary>
/// Gets or sets the road segments for the articulation graph
/// </summary>
[XmlIgnore]
public Dictionary<int, RoadSegment> ArticulationSegments { get; private set; }
/// <summary>
/// Gets or sets the road segments for the intersection graph
/// </summary>
[XmlIgnore]
public Dictionary<int, RoadSegment> IntersectionSegments { get; private set; }
/// <summary>
/// Gets or sets the nodes
/// </summary>
[XmlArray("nodes")]
public RoadNode[] NodesArray
{
get
{
return Nodes.Values.ToArray();
}
set
{
Nodes.Clear();
foreach (var node in value)
Nodes.Add(node.Id, node);
}
}
/// <summary>
/// Gets or sets the segments
/// </summary>
[XmlArray("articulationGraph")]
public RoadSegment[] ArticulationSegmentsArray
{
get
{
return ArticulationSegments.Values.ToArray();
}
set
{
ArticulationSegments.Clear();
foreach (var segment in value)
ArticulationSegments.Add(segment.Id, segment);
}
}
/// <summary>
/// Gets or sets the segments
/// </summary>
[XmlArray("intersectionGraph")]
public RoadSegment[] IntersectionSegmentsArray
{
get
{
return ArticulationSegments.Values.ToArray();
}
set
{
ArticulationSegments.Clear();
foreach (var segment in value)
ArticulationSegments.Add(segment.Id, segment);
}
}
/// <summary>
/// Creates a node and returns it
/// </summary>
/// <returns>Created node</returns>
public RoadNode CreateNode()
{
// Skip IDs that already exist
while (Nodes.ContainsKey(++lastNodeId)) ;
// Create node
RoadNode node = new RoadNode()
{
Id = lastNodeId,
ParentNetwork = this
};
Nodes.Add(node.Id, node);
return node;
}
/// <summary>
/// Creates a segment and returns it
/// </summary>
/// <returns>Created segment</returns>
public RoadSegment CreateArticulationSegment()
{
// Skip IDs that already exist
while (ArticulationSegments.ContainsKey(++lastSegmentId)) ;
// Create segment
RoadSegment segment = new RoadSegment()
{
Id = lastSegmentId,
ParentNetwork = this
};
ArticulationSegments.Add(segment.Id, segment);
return segment;
}
/// <summary>
/// Creates a segment and returns it
/// </summary>
/// <returns>Created segment</returns>
public RoadSegment CreateIntersectionSegment()
{
// Skip IDs that already exist
while (IntersectionSegments.ContainsKey(++lastSegmentId)) ;
// Create segment
RoadSegment segment = new RoadSegment()
{
Id = lastSegmentId,
ParentNetwork = this
};
IntersectionSegments.Add(segment.Id, segment);
return segment;
}
}
}

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: a4d12846fa3e22f4fbd829e42582d6a9
timeCreated: 1425647029
guid: bc333e8a29fbb8242856e43239c57425
timeCreated: 1431612790
licenseType: Free
MonoImporter:
serializedVersion: 2

View File

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace TransportGame.Model.Road
{
/// <summary>
/// Road node
/// </summary>
[XmlRoot("node")]
public class RoadNode
{
/// <summary>
/// Gets or sets a unique identifier for this node
/// </summary>
[XmlAttribute("id")]
public int Id { get; set; }
/// <summary>
/// Gets or sets the X coordinate of the node
/// </summary>
[XmlAttribute("x")]
public float X { get; set; }
/// <summary>
/// Gets or sets the Y coordinate of the node
/// </summary>
[XmlAttribute("y")]
public float Y { get; set; }
/// <summary>
/// Gets or sets the adjacent articulation segment IDs
/// </summary>
[XmlArray("articulationSegments")]
[XmlArrayItem("id")]
public List<int> ArticulationSegmentIds { get; set; }
/// <summary>
/// Gets or sets the adjacent articulation segment IDs
/// </summary>
[XmlArray("intersectionSegments")]
[XmlArrayItem("id")]
public List<int> IntersectionSegmentIds { get; set; }
/// <summary>
/// Gets or sets the parent network
/// </summary>
[XmlIgnore]
public RoadNetwork ParentNetwork { get; set; }
/// <summary>
/// Gets the adjacent articulation segments
/// </summary>
[XmlIgnore]
public IEnumerable<RoadSegment> ArticulationSegments
{
get
{
return ArticulationSegmentIds.Select(id => ParentNetwork.ArticulationSegments[id]);
}
}
/// <summary>
/// Gets the adjacent setments
/// </summary>
[XmlIgnore]
public IEnumerable<RoadSegment> Segments
{
get
{
return IntersectionSegmentIds.Select(id => ParentNetwork.ArticulationSegments[id]);
}
}
/// <summary>
/// Initializes the node
/// </summary>
public RoadNode()
{
ArticulationSegmentIds = new List<int>();
IntersectionSegmentIds = new List<int>();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5be58fb83def956479e9e3af7e96a347
timeCreated: 1431600782
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace TransportGame.Model.Road
{
/// <summary>
/// Represents a road segment
/// </summary>
[XmlRoot("segment")]
public class RoadSegment
{
/// <summary>
/// Gets or sets the id
/// </summary>
[XmlAttribute("id")]
public int Id { get; set; }
/// <summary>
/// Gets or sets the parent network
/// </summary>
[XmlIgnore]
public RoadNetwork ParentNetwork { get; set; }
/// <summary>
/// Gets or sets the id of the first terminal
/// </summary>
[XmlAttribute("term1")]
public int Terminal1Id { get; set; }
/// <summary>
/// Gets or sets the id of the second terminal
/// </summary>
[XmlAttribute("term2")]
public int Terminal2Id { get; set; }
/// <summary>
/// Gets or sets the first terminal
/// </summary>
[XmlIgnore]
public RoadNode Terminal1
{
get
{
return ParentNetwork.Nodes[Terminal1Id];
}
set
{
Terminal1Id = value.Id;
}
}
/// <summary>
/// Gets or sets the second terminal
/// </summary>
[XmlIgnore]
public RoadNode Terminal2
{
get
{
return ParentNetwork.Nodes[Terminal2Id];
}
set
{
Terminal2Id = value.Id;
}
}
/// <summary>
/// Gets or sets the number of lanes going from terminal 1 to terminal 2
/// </summary>
[XmlAttribute("lanesTo2")]
public int LanesTo2 { get; set; }
/// <summary>
/// Gets or sets the number of lanes going form terminal 2 to terminal 1
/// </summary>
[XmlAttribute("lanesTo1")]
public int LanesTo1 { get; set; }
/// <summary>
/// Initializes road segment
/// </summary>
public RoadSegment()
{
LanesTo1 = 1;
LanesTo2 = 1;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 51c5431eea527e34a8de870e7648758c
timeCreated: 1431600775
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -51,7 +51,7 @@ public class TerrainGeneratorScript : MonoBehaviour
private IEnumerator GenerateMap()
{
// Wait for the map generation thread
// Generate terrain
foreach (var i in Task.RunAsync(GenerateTerrainThread))
yield return i;
@ -60,7 +60,7 @@ public class TerrainGeneratorScript : MonoBehaviour
terrainData.heightmapResolution = Mathf.Max(map.Height, map.Width) + 1;
terrainData.size = new Vector3(map.Width, map.Biome.Height, map.Height);
terrainData.SetDetailResolution(1024, 8);
terrainData.SetHeights(0, 0, map.Heights);
terrainData.SetHeights(0, 0, map.Heightmap);
terrainData.name = "Generated Terrain Data";
yield return null;
@ -120,21 +120,20 @@ public class TerrainGeneratorScript : MonoBehaviour
int iy = Mathf.RoundToInt(y_01 * TerrainHeight);
// Get height
float height = map.Heights[ix, iy] * terrainData.size.y;
float height = map.GetHeight(ix, iy);
// Get steepness
int safex = (ix == 0) ? 1 : ix;
int safey = (iy == 0) ? 1 : iy;
float dx = map.Heights[safex - 1, safey] * map.Biome.Height - height;
float dy = map.Heights[safex, safey - 1] * map.Biome.Height - height;
float dx = map.GetHeight(safex - 1, safey) - height;
float dy = map.GetHeight(safex, safey - 1) - height;
float steepness = dx * dx + dy * dy;
// Go through each texture layer
float[] weights = new float[terrainData.alphamapLayers];
float sum = 0;
// Go through each texture layer
for (int t = 0; t < terrainData.alphamapLayers; t++)
{
// Set up expression

View File

@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace TransportGame.Utils
{
public static class SerializationHelper
{
/// <summary>
/// Converts float matrix to byte array
/// </summary>
/// <param name="matrix">Matrix to convert</param>
/// <remarks>
/// Bytes are stored as such:
///
/// Offset Size Content
/// ------------------------
/// 0 4 Width
/// 4 8 Height
/// 8 var 32bit floating point values
///
/// </remarks>
/// <returns>Byte array</returns>
public static byte[] ToByteArray(this float[,] matrix)
{
if (matrix == null)
return null;
int w = matrix.GetLength(0);
int h = matrix.GetLength(1);
List<byte> bytes = new List<byte>();
bytes.AddRange(BitConverter.GetBytes(w));
bytes.AddRange(BitConverter.GetBytes(h));
for (int x = 0; x < w; x++)
for (int y = 0; y < h; y++)
bytes.AddRange(BitConverter.GetBytes(matrix[x, y]));
return bytes.ToArray();
}
/// <summary>
/// Converts byte array to float matrix
/// </summary>
/// <param name="array">Byte array</param>
/// /// <remarks>
/// Bytes are expected to be stored as such:
///
/// Offset Size Content
/// ------------------------
/// 0 4 Width
/// 4 8 Height
/// 8 var 32bit floating point values
///
/// </remarks>
/// <returns>Float matrix</returns>
public static float[,] GetFloatMatrix(this byte[] array)
{
if (array == null)
return null;
int pos = 0;
int w = BitConverter.ToInt32(array, pos); pos += sizeof(int);
int h = BitConverter.ToInt32(array, pos); pos += sizeof(int);
float[,] grid = new float[w, h];
for (int x = 0; x < w; x++)
for (int y = 0; y < h; y++)
{
grid[x, y] = BitConverter.ToSingle(array, pos);
pos += sizeof(float);
}
return grid;
}
/// <summary>
/// Deserializes a file
/// </summary>
/// <typeparam name="T">Type to deserialize</typeparam>
/// <param name="filename">File name</param>
/// <returns>Deserialized object</returns>
public static T Deserialize<T>(string filename)
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
var stream = new StreamReader(filename);
return (T)serializer.Deserialize(stream);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 56d534d0f2e8f454698a8650dab0afb4
timeCreated: 1431612790
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,25 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace TransportGame.Utils
{
public static class XmlHelper
{
/// <summary>
/// Deserializes a file
/// </summary>
/// <typeparam name="T">Type to deserialize</typeparam>
/// <param name="filename">File name</param>
/// <returns>Deserialized object</returns>
public static T Deserialize<T>(string filename)
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
var stream = new StreamReader(filename);
return (T)serializer.Deserialize(stream);
}
}
}

View File

@ -23,7 +23,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Assembly-CSharp.csproj
Policies = $0
$0.TextStylePolicy = $1

View File

@ -29,7 +29,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Assembly-CSharp.csproj
Policies = $0
$0.TextStylePolicy = $1

View File

@ -7,14 +7,16 @@
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{02576F1D-BE9C-CFA7-763D-1EBF63B36977}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace></RootNamespace>
<RootNamespace>
</RootNamespace>
<AssemblyName>Assembly-CSharp</AssemblyName>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Unity Subset v3.5</TargetFrameworkProfile>
<CompilerResponseFile></CompilerResponseFile>
<CompilerResponseFile>
</CompilerResponseFile>
<UnityProjectType>Game:1</UnityProjectType>
<UnityBuildTarget>StandaloneWindows64:19</UnityBuildTarget>
<UnityVersion>5.0.1f1</UnityVersion>
@ -75,6 +77,9 @@
<Compile Include="Assets\Scripts\Model\Biome.cs" />
<Compile Include="Assets\Scripts\Model\Config\TerrainGeneratorConfig.cs" />
<Compile Include="Assets\Scripts\Model\Map.cs" />
<Compile Include="Assets\Scripts\Model\Road\RoadNetwork.cs" />
<Compile Include="Assets\Scripts\Model\Road\RoadNode.cs" />
<Compile Include="Assets\Scripts\Model\Road\RoadSegment.cs" />
<Compile Include="Assets\Scripts\Model\Texture.cs" />
<Compile Include="Assets\Scripts\Noise\NoiseGenerator.cs" />
<Compile Include="Assets\Scripts\Noise\PerlinNoiseGenerator.cs" />
@ -87,9 +92,9 @@
<Compile Include="Assets\Scripts\Utils\Logger.cs" />
<Compile Include="Assets\Scripts\Utils\RandomExtensions.cs" />
<Compile Include="Assets\Scripts\Utils\Range.cs" />
<Compile Include="Assets\Scripts\Utils\SerializationHelper.cs" />
<Compile Include="Assets\Scripts\Utils\Task.cs" />
<Compile Include="Assets\Scripts\Utils\Texture2DExtensions.cs" />
<Compile Include="Assets\Scripts\Utils\XmlHelper.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Assets\Data\Biomes\Grassland.xml" />

View File

@ -1,8 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapViewer", "MapViewer\MapViewer.csproj", "{A6DA2104-18B4-4A9A-BAD7-5AC8C98A5086}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityVS.Game.CSharp", "..\..\Game\UnityVS.Game.CSharp.csproj", "{02576F1D-BE9C-CFA7-763D-1EBF63B36977}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -13,6 +17,10 @@ Global
{A6DA2104-18B4-4A9A-BAD7-5AC8C98A5086}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6DA2104-18B4-4A9A-BAD7-5AC8C98A5086}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6DA2104-18B4-4A9A-BAD7-5AC8C98A5086}.Release|Any CPU.Build.0 = Release|Any CPU
{02576F1D-BE9C-CFA7-763D-1EBF63B36977}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02576F1D-BE9C-CFA7-763D-1EBF63B36977}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02576F1D-BE9C-CFA7-763D-1EBF63B36977}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02576F1D-BE9C-CFA7-763D-1EBF63B36977}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -79,7 +79,7 @@ namespace TransportGame.MapViewer
// Draw elevation
else if (elevation)
{
float alpha = map.Heights[mapX, mapY]; // map.Heights range is [0,1]
float alpha = map.Heightmap[mapX, mapY]; // map.Heights range is [0,1]
bitmap[x, y] = Color.Multiply(ElevationTerrainColor, alpha);
}

View File

@ -53,12 +53,6 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="..\..\..\Game\Assets\Scripts\Model\Biome.cs">
<Link>Model\Biome.cs</Link>
</Compile>
<Compile Include="..\..\..\Game\Assets\Scripts\Model\Map.cs">
<Link>Model\Map.cs</Link>
</Compile>
<Compile Include="Business\BitmapExtensions.cs" />
<Compile Include="Model\Bitmap24.cs" />
<Compile Include="Storage\MapStorage.cs" />
@ -66,9 +60,6 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="..\..\..\Game\Assets\Scripts\Utils\Range.cs">
<Link>Utils\Range.cs</Link>
</Compile>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
@ -116,6 +107,15 @@
<Resource Include="Resources\zoom_in.png" />
<Resource Include="Resources\zoom_out.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Game\UnityVS.Game.CSharp.csproj">
<Project>{02576f1d-be9c-cfa7-763d-1ebf63b36977}</Project>
<Name>UnityVS.Game.CSharp</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Utils\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.