diff options
Diffstat (limited to 'libraries/libTerrain/libTerrainTests')
4 files changed, 463 insertions, 0 deletions
diff --git a/libraries/libTerrain/libTerrainTests/Program.cs b/libraries/libTerrain/libTerrainTests/Program.cs new file mode 100644 index 0000000..cf3da3d --- /dev/null +++ b/libraries/libTerrain/libTerrainTests/Program.cs | |||
@@ -0,0 +1,299 @@ | |||
1 | /* | ||
2 | Redistribution and use in source and binary forms, with or without | ||
3 | modification, are permitted provided that the following conditions are | ||
4 | met: | ||
5 | |||
6 | * Redistributions of source code must retain the above copyright | ||
7 | notice, this list of conditions and the following disclaimer. | ||
8 | |||
9 | * Redistributions in binary form must reproduce the above | ||
10 | copyright notice, this list of conditions and the following | ||
11 | disclaimer in the documentation and/or other materials provided | ||
12 | with the distribution. | ||
13 | |||
14 | * Neither the name of libTerrain nor the names of | ||
15 | its contributors may be used to endorse or promote products | ||
16 | derived from this software without specific prior written | ||
17 | permission. | ||
18 | |||
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
23 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | |||
33 | using System; | ||
34 | using System.Collections.Generic; | ||
35 | using System.Text; | ||
36 | using libTerrain; | ||
37 | |||
38 | namespace libTerrainTests | ||
39 | { | ||
40 | class Program | ||
41 | { | ||
42 | static void Main(string[] args) | ||
43 | { | ||
44 | System.Console.WriteLine("Starting tests..."); | ||
45 | |||
46 | Channel test; | ||
47 | |||
48 | try | ||
49 | { | ||
50 | System.Console.WriteLine("Blank Heightmap"); | ||
51 | test = new Channel(); | ||
52 | test.fill(0); | ||
53 | test.saveImage("test_blank.png"); | ||
54 | } | ||
55 | catch (Exception e) | ||
56 | { | ||
57 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
58 | } | ||
59 | |||
60 | |||
61 | try | ||
62 | { | ||
63 | System.Console.WriteLine("Grayscale Cube"); | ||
64 | test = new Channel(); | ||
65 | test.fill(0); | ||
66 | test.gradientCube(); | ||
67 | test.saveImage("test_cube.png"); | ||
68 | |||
69 | test.Polar(); | ||
70 | test.saveImage("test_polarcube.png"); | ||
71 | } | ||
72 | catch (Exception e) | ||
73 | { | ||
74 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
75 | } | ||
76 | |||
77 | try | ||
78 | { | ||
79 | System.Console.WriteLine("Spiral Planters"); | ||
80 | test = new Channel(); | ||
81 | test.fill(0); | ||
82 | |||
83 | test.SpiralPlanter(200, Math.PI / 15, 0.75, 0, 0); | ||
84 | test.normalise(); | ||
85 | //test.Spiral(192, 192, 50); | ||
86 | test.saveImage("test_spiral.png"); | ||
87 | } | ||
88 | catch (Exception e) | ||
89 | { | ||
90 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
91 | } | ||
92 | |||
93 | try | ||
94 | { | ||
95 | System.Console.WriteLine("Spiral Cells"); | ||
96 | test = new Channel(); | ||
97 | test.fill(0); | ||
98 | |||
99 | double[] c = new double[2]; | ||
100 | c[0] = -1; | ||
101 | c[1] = 1; | ||
102 | |||
103 | test.SpiralCells(200, Math.PI / 15, 0.75, 0, 0, c); | ||
104 | test.normalise(); | ||
105 | //test.Spiral(192, 192, 50); | ||
106 | test.saveImage("test_spiralcells.png"); | ||
107 | |||
108 | test.fill(0); | ||
109 | test.SpiralCells(30, Math.PI / 30, 0, 75, 0, c); | ||
110 | test.normalise(); | ||
111 | //test.Spiral(192, 192, 50); | ||
112 | test.saveImage("test_circlecells.png"); | ||
113 | |||
114 | } | ||
115 | catch (Exception e) | ||
116 | { | ||
117 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
118 | } | ||
119 | |||
120 | try | ||
121 | { | ||
122 | System.Console.WriteLine("Fracturing"); | ||
123 | test = new Channel(); | ||
124 | test.fill(0); | ||
125 | test.fracture(300, 0, 1); | ||
126 | test.saveImage("test_fracture.png"); | ||
127 | } | ||
128 | catch (Exception e) | ||
129 | { | ||
130 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
131 | } | ||
132 | |||
133 | try | ||
134 | { | ||
135 | System.Console.WriteLine("Voronoi (Flat)"); | ||
136 | test = new Channel(); | ||
137 | test.fill(0); | ||
138 | test.voroflatDiagram(64, 384); | ||
139 | test.saveImage("test_voroflat.png"); | ||
140 | } | ||
141 | catch (Exception e) | ||
142 | { | ||
143 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
144 | } | ||
145 | |||
146 | |||
147 | try | ||
148 | { | ||
149 | System.Console.WriteLine("Voronoi (Flat / Fixnormal)"); | ||
150 | test = new Channel(); | ||
151 | test.fill(0); | ||
152 | test.voroflatDiagram(64, 384); | ||
153 | test ^= 4; | ||
154 | test.normalise(); | ||
155 | test.saveImage("test_voroflatfixnormal.png"); | ||
156 | } | ||
157 | catch (Exception e) | ||
158 | { | ||
159 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
160 | } | ||
161 | |||
162 | try | ||
163 | { | ||
164 | System.Console.WriteLine("File Import (Mask Flatten)"); | ||
165 | test = new Channel(); | ||
166 | Channel test2; | ||
167 | test2 = test.loadImage("test_chained_aerobic.png"); | ||
168 | |||
169 | test.fill(0); | ||
170 | test.voroflatDiagram(64, 384); | ||
171 | test ^= 4; | ||
172 | test.normalise(); | ||
173 | |||
174 | test.smooth(4); | ||
175 | test.normalise(); | ||
176 | |||
177 | test.saveImage("test_flatmask.png"); | ||
178 | test2.flatten(test, 1.0); | ||
179 | |||
180 | test2.saveImage("test_fileflatmask.png"); | ||
181 | } | ||
182 | catch (Exception e) | ||
183 | { | ||
184 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
185 | } | ||
186 | |||
187 | try | ||
188 | { | ||
189 | System.Console.WriteLine("Worms"); | ||
190 | test = new Channel(); | ||
191 | test.worms(100, 10, 20.0, 16, false); | ||
192 | test.normalise(); | ||
193 | test.saveImage("test_worms.png"); | ||
194 | } | ||
195 | catch (Exception e) | ||
196 | { | ||
197 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
198 | } | ||
199 | |||
200 | try | ||
201 | { | ||
202 | System.Console.WriteLine("Noise"); | ||
203 | test = new Channel(); | ||
204 | test.noise(); | ||
205 | test.saveImage("test_noise.png"); | ||
206 | } | ||
207 | catch (Exception e) | ||
208 | { | ||
209 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
210 | } | ||
211 | |||
212 | try | ||
213 | { | ||
214 | System.Console.WriteLine("Hills (Spherical)"); | ||
215 | test = new Channel(); | ||
216 | test.hillsSpheres(200, 20, 30, true, true, false); | ||
217 | test.saveImage("test_hillspheres.png"); | ||
218 | } | ||
219 | catch (Exception e) | ||
220 | { | ||
221 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
222 | } | ||
223 | |||
224 | try | ||
225 | { | ||
226 | System.Console.WriteLine("Hills (Blocks)"); | ||
227 | test = new Channel(); | ||
228 | test.hillsBlocks(200, 20, 30, true, true, false); | ||
229 | // test.hillsSpheres(200, 20, 30, true, true, false); | ||
230 | test.saveImage("test_hillblocks.png"); | ||
231 | } | ||
232 | catch (Exception e) | ||
233 | { | ||
234 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
235 | } | ||
236 | |||
237 | try | ||
238 | { | ||
239 | System.Console.WriteLine("Hills (Cones)"); | ||
240 | test = new Channel(); | ||
241 | test.fill(0); | ||
242 | test.hillsCones(200, 20, 30, true, true, false); | ||
243 | test.normalise(); | ||
244 | test.saveImage("test_hillcones.png"); | ||
245 | } | ||
246 | catch (Exception e) | ||
247 | { | ||
248 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
249 | } | ||
250 | |||
251 | try | ||
252 | { | ||
253 | System.Console.WriteLine("Voronoi Diagram"); | ||
254 | test = new Channel(); | ||
255 | double[] c = new double[2]; | ||
256 | c[0] = -1; | ||
257 | c[1] = 1; | ||
258 | test.voronoiDiagram(4, 128, c); | ||
259 | test.saveImage("test_voronoi.png"); | ||
260 | } | ||
261 | catch (Exception e) | ||
262 | { | ||
263 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
264 | } | ||
265 | |||
266 | try | ||
267 | { | ||
268 | System.Console.WriteLine("Raising Terrain"); | ||
269 | test = new Channel(); | ||
270 | test.fill(0); | ||
271 | test.raise(128, 128, 64, 1.0); | ||
272 | test.normalise(); | ||
273 | test.saveImage("test_raise.png"); | ||
274 | } | ||
275 | catch (Exception e) | ||
276 | { | ||
277 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
278 | } | ||
279 | |||
280 | try | ||
281 | { | ||
282 | System.Console.WriteLine("Flattening Terrain (unmasked)"); | ||
283 | test = new Channel(); | ||
284 | test.noise(); | ||
285 | test.flatten(128, 128, 64, 1.0); | ||
286 | test.normalise(); | ||
287 | test.saveImage("test_flatten.png"); | ||
288 | } | ||
289 | catch (Exception e) | ||
290 | { | ||
291 | System.Console.WriteLine("Unhandled exception: " + e.ToString()); | ||
292 | } | ||
293 | |||
294 | |||
295 | |||
296 | System.Console.WriteLine("Done"); | ||
297 | } | ||
298 | } | ||
299 | } | ||
diff --git a/libraries/libTerrain/libTerrainTests/Properties/AssemblyInfo.cs b/libraries/libTerrain/libTerrainTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..09e0845 --- /dev/null +++ b/libraries/libTerrain/libTerrainTests/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("libTerrainTests")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("")] | ||
12 | [assembly: AssemblyProduct("libTerrainTests")] | ||
13 | [assembly: AssemblyCopyright("Copyright © 2007")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("528417c9-dd71-487e-8e0b-e8e42e52fa10")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("1.0.0.0")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/libraries/libTerrain/libTerrainTests/libTerrain.csproj b/libraries/libTerrain/libTerrainTests/libTerrain.csproj new file mode 100644 index 0000000..047ad02 --- /dev/null +++ b/libraries/libTerrain/libTerrainTests/libTerrain.csproj | |||
@@ -0,0 +1,75 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
4 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
5 | <ProductVersion>8.0.50727</ProductVersion> | ||
6 | <SchemaVersion>2.0</SchemaVersion> | ||
7 | <ProjectGuid>{EEC06368-30E8-42E8-A23C-2C9D139AD495}</ProjectGuid> | ||
8 | <OutputType>Library</OutputType> | ||
9 | <AppDesignerFolder>Properties</AppDesignerFolder> | ||
10 | <RootNamespace>libTerrain</RootNamespace> | ||
11 | <AssemblyName>libTerrain</AssemblyName> | ||
12 | </PropertyGroup> | ||
13 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
14 | <DebugSymbols>true</DebugSymbols> | ||
15 | <DebugType>full</DebugType> | ||
16 | <Optimize>false</Optimize> | ||
17 | <OutputPath>bin\Debug\</OutputPath> | ||
18 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
19 | <ErrorReport>prompt</ErrorReport> | ||
20 | <WarningLevel>4</WarningLevel> | ||
21 | </PropertyGroup> | ||
22 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
23 | <DebugType>pdbonly</DebugType> | ||
24 | <Optimize>true</Optimize> | ||
25 | <OutputPath>bin\Release\</OutputPath> | ||
26 | <DefineConstants>TRACE</DefineConstants> | ||
27 | <ErrorReport>prompt</ErrorReport> | ||
28 | <WarningLevel>4</WarningLevel> | ||
29 | </PropertyGroup> | ||
30 | <ItemGroup> | ||
31 | <Reference Include="System" /> | ||
32 | <Reference Include="System.Data" /> | ||
33 | <Reference Include="System.Drawing" /> | ||
34 | <Reference Include="System.Xml" /> | ||
35 | </ItemGroup> | ||
36 | <ItemGroup> | ||
37 | <Compile Include="Bitmap\Bitmap.cs" /> | ||
38 | <Compile Include="Channel\Channel.cs" /> | ||
39 | <Compile Include="Channel\Common.cs" /> | ||
40 | <Compile Include="Channel\Editing\Flatten.cs" /> | ||
41 | <Compile Include="Channel\Editing\Raise.cs" /> | ||
42 | <Compile Include="Channel\File.cs" /> | ||
43 | <Compile Include="Channel\Generators\Cellular.cs" /> | ||
44 | <Compile Include="Channel\Generators\Fracture.cs" /> | ||
45 | <Compile Include="Channel\Generators\Gradient.cs" /> | ||
46 | <Compile Include="Channel\Generators\HillPlanter.cs" /> | ||
47 | <Compile Include="Channel\Generators\Midpoint.cs" /> | ||
48 | <Compile Include="Channel\Generators\Mountain.cs" /> | ||
49 | <Compile Include="Channel\Generators\Noise.cs" /> | ||
50 | <Compile Include="Channel\Generators\Spiral.cs" /> | ||
51 | <Compile Include="Channel\Generators\Voronoi.cs" /> | ||
52 | <Compile Include="Channel\Generators\Worms.cs" /> | ||
53 | <Compile Include="Channel\Grid.cs" /> | ||
54 | <Compile Include="Channel\Manipulators\AerobicErosion.cs" /> | ||
55 | <Compile Include="Channel\Manipulators\HydraulicErosion.cs" /> | ||
56 | <Compile Include="Channel\Manipulators\ThermalWeathering.cs" /> | ||
57 | <Compile Include="Channel\Neighbours.cs" /> | ||
58 | <Compile Include="Channel\Operators.cs" /> | ||
59 | <Compile Include="Properties\AssemblyInfo.cs" /> | ||
60 | <Compile Include="Test\SimpleTerrain.cs" /> | ||
61 | <Compile Include="Tools\Point2D.cs" /> | ||
62 | <Compile Include="Tools\Tools.cs" /> | ||
63 | </ItemGroup> | ||
64 | <ItemGroup> | ||
65 | <Content Include="TODO.txt" /> | ||
66 | </ItemGroup> | ||
67 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
68 | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
69 | Other similar extension points exist, see Microsoft.Common.targets. | ||
70 | <Target Name="BeforeBuild"> | ||
71 | </Target> | ||
72 | <Target Name="AfterBuild"> | ||
73 | </Target> | ||
74 | --> | ||
75 | </Project> \ No newline at end of file | ||
diff --git a/libraries/libTerrain/libTerrainTests/libTerrainTests.csproj b/libraries/libTerrain/libTerrainTests/libTerrainTests.csproj new file mode 100644 index 0000000..4227155 --- /dev/null +++ b/libraries/libTerrain/libTerrainTests/libTerrainTests.csproj | |||
@@ -0,0 +1,56 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
4 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
5 | <ProductVersion>8.0.50727</ProductVersion> | ||
6 | <SchemaVersion>2.0</SchemaVersion> | ||
7 | <ProjectGuid>{7214C9E2-1390-41BD-BFFC-83FA5931C5CF}</ProjectGuid> | ||
8 | <OutputType>Exe</OutputType> | ||
9 | <AppDesignerFolder>Properties</AppDesignerFolder> | ||
10 | <RootNamespace>libTerrainTests</RootNamespace> | ||
11 | <AssemblyName>libTerrainTests</AssemblyName> | ||
12 | </PropertyGroup> | ||
13 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
14 | <DebugSymbols>true</DebugSymbols> | ||
15 | <DebugType>full</DebugType> | ||
16 | <Optimize>false</Optimize> | ||
17 | <OutputPath>bin\Debug\</OutputPath> | ||
18 | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
19 | <ErrorReport>prompt</ErrorReport> | ||
20 | <WarningLevel>4</WarningLevel> | ||
21 | </PropertyGroup> | ||
22 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
23 | <DebugType>pdbonly</DebugType> | ||
24 | <Optimize>true</Optimize> | ||
25 | <OutputPath>bin\Release\</OutputPath> | ||
26 | <DefineConstants>TRACE</DefineConstants> | ||
27 | <ErrorReport>prompt</ErrorReport> | ||
28 | <WarningLevel>4</WarningLevel> | ||
29 | </PropertyGroup> | ||
30 | <ItemGroup> | ||
31 | <Reference Include="System" /> | ||
32 | <Reference Include="System.Data" /> | ||
33 | <Reference Include="System.Xml" /> | ||
34 | </ItemGroup> | ||
35 | <ItemGroup> | ||
36 | <Compile Include="Program.cs" /> | ||
37 | <Compile Include="Properties\AssemblyInfo.cs" /> | ||
38 | </ItemGroup> | ||
39 | <ItemGroup> | ||
40 | <ProjectReference Include="..\libTerrain\libTerrain-BSD.csproj"> | ||
41 | <Project>{EEC06368-30E8-42E8-A23C-2C9D139AD495}</Project> | ||
42 | <Name>libTerrain-BSD</Name> | ||
43 | </ProjectReference> | ||
44 | </ItemGroup> | ||
45 | <ItemGroup> | ||
46 | <Content Include="libTerrain.csproj" /> | ||
47 | </ItemGroup> | ||
48 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
49 | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
50 | Other similar extension points exist, see Microsoft.Common.targets. | ||
51 | <Target Name="BeforeBuild"> | ||
52 | </Target> | ||
53 | <Target Name="AfterBuild"> | ||
54 | </Target> | ||
55 | --> | ||
56 | </Project> \ No newline at end of file | ||