Download presentation
Presentation is loading. Please wait.
Published byEvan Dorsey Modified over 8 years ago
2
Coming up Introduction Technologies Used & SDLC Analysis & Design Algorithms & Operations Output Formats Terrainium, the application Terrainium, the outputs References
3
Introduction Presented by Vanessa Ferrao
4
Objective The project aims at developing a cross platform fractal based terrain generator that will enable 3d content creators to utilize the generated terrain in their creative process.
5
What is terrain ? Terrain refers to the surface features of an area of land.
6
Terrains on Computers? 3 ways of obtaining terrains on computers. 1.Acquire real world data. 2.Model a terrain using 3d modeling tools. 3.Use algorithms to generate random terrain.
7
Real Data “Real” data comes from photos taken by orbiting satellites or airplanes. Height information extracted and called DEM (Digital Elevation Model).
8
Modeling Terrain Use 3d modeling primitives to create terrains. Primitives like sphere and cylinder can be used. Time consuming and results are predictable.
9
Random data Use algorithms to generate height information. Using noise like functions regularity of previous method is avoided. Such terrains have fractal properties. Heightmap can be more natural due to the randomness.
10
What is a fractal ? Fractal: A geometric pattern that is repeated at ever smaller scales to produce irregular shapes and surfaces. The key concept behind any fractal is self-similarity. An object is said to be self-similar when magnified subsets of the object look like (or identical to) the whole and to each other.
11
Fractals The fractals' growth mechanism can be visualized very easily with a simple example. Start with a “+” sign and grow it by adding a half size “+” in each of the four line ends. Repeat the exact same process recursively as many times as desired.
12
Heightmaps Heightmap or Heightfield is a raster image used to store values, such as surface elevation data. This surface elevation data is converted into a 3d mesh to render the terrain.
13
Arrays & Heightmaps Arrays can be used to represent heightmaps by storing the height value in a 2d array.
14
Images & Heightmaps By assigning intensity values to height values an image can represent a Heightmap.
15
Heightmap rendered
16
Applications Games Simulators Research Digital Art/ Neography Movies Almost every movie now involves heavy use of special effects, and many a times, the scenes depicted in movies are not real – but generated using computers. Games have become more and more engaging and realism has become just another feature. Again believable environments with outlandish terrain add to the gamers' visual experience. Simulators used to train aircraft pilots or land vehicles like tanks usually require realistic conditions in which the pilot/driver can be put to the test. Terrain data collected of other planets such as Mars via satellites and other means can be visualized for more effective study. The use of computers to create images unattainable through conventional photographic tools.
17
Project Outline
18
Technologies Used & SDLC Presented by Vanessa Ferrao
19
Technologies Used SOFTWARE Windows XP / Windows Vista / Ubuntu 8.04+ (Primary development on Windows XP with testing on Windows Vista & Ubuntu 8.04) Java SE Development Kit (JDK) 1.6 NetBeans IDE 6.1/6.5 POV-Ray 3.6 Assembla (online project management) SVN (via Assembla and Netbeans)
20
Technologies Used Hardware Development carried out primarily on a Core 2 Duo E6600 2.0 GHz system with 1 GB DDR2 RAM and compatible motherboard, hard disk etc.
21
Team Work Used Assembla.com – an online project management application. Allows multiple users to work on a single project. Allows sharing of files, setting milestones, sending messages and integration with subversion & trac.
22
Team Work SHARING FILES WITH VERSIONING
23
Team Work SVN INTEGRATION
24
Team Work TRAC INTEGRATION
25
Team Work TRAC CODE BROWSER
26
Team Work FILE CHANGELOG
27
Team Work FILE CHANGES
28
Team Work TIMELINE
29
Analysis & Design Presented by Vanessa Ferrao
30
Class Design
31
Use Case
32
System Design UI TerrainParameters TerrainGenerator ValidateT() Generate() Plasma() Perlin() Heightmap TP : TerrainParameters doubleArray[] : double imageBuffer[] : BufferedImage SetXY(x :integer,y :integer, value :double) GetXY(x:integer,y:integer):double CreateImage() SelectImageSaveLocation():String SaveImage() DisplayHM() ClearHM() Normalize() Sculpt() PovParameters Camera_loc : location Camera_lookat : location Light_loc: location Light_color : color Maxalt :integer Minalt :integer PovScriptGenerator ValidateP() : integer SelectHM() : String SelectSaveLoc() : String CreateScript() SaveScriptFile() RunPovRay() maxHeight : integer minHeight : integer size : integer persistence : double octaves : integer lacunarity : double roughness : double Terrain Parameters TP FileWriter TP : TerrainParameters PP : PovParameters Save_ter(String) Save_world() PP : PovParameters TP : TerrainParameters TG : TerrainGenerator HM : Heightmap PP : PovParameters PSG : PovScriptGenerator FW : FileWriter
33
Algorithms & Operations Presented by Vanessa Ferrao
34
Diamond Square Algorithm Initially the algorithm starts with a 2x2 grid. The heights of the four corners can be set to zero, a random value, or just some preset value.
35
The first step is to find a height for the center of the terrain. This value is computed as the average height of the four corners plus a random displacement. This step is know as the diamond step (if you render the terrain now you'll see four diamond shapes). Diamond Square Algorithm
36
What follows is the square step. In here the midpoints between the four corners, the blue dots, are computed as the average of the connected points plus a random displacement. Diamond Square Algorithm
37
Now we have four squares. The process is repeated for each square: first for all squares apply the diamond step, i.e. compute a height for each center (red points). Diamond Square Algorithm
38
After applying the diamond step to all squares, it is time to apply the square step. In the figure on the left, the points for the first square are the blue points. Diamond Square Algorithm
39
What is Perlin Noise ? A procedural texturing primitive. A gradient noise function that has a pseudo-random appearance. Can be used to generate large variety of textures. For ex : Smoke, fire, clouds, landscapes and other textures. Creator, Ken Perlin won Academy award in 1997.
40
Perlin Noise A function that maps R n :-> R For convenience we will explain for R 2 That is 2d Perlin noise. Takes a 2d co-ordinate vector (x,y) and returns a real number.
41
2d Perlin Noise For a given real numbered co-ordinate (x,y) we compute a unit grid whose corners lie on whole numbered co- ordinates. (x0,y0) (x1,y0) (x1,y1)(x0,y1) (x,y)
42
2d Perlin Noise For grid points compute pseudo-random gradients. Gradient is a unit vector pointing in some direction. g(x0,y0) g(x1,y0) g(x1,y1) g(x0,y1) (x,y)
43
2d Perlin Noise For each grid point compute a vector going from the grid point to the input co-ordinate (x,y). Subtract grid point from (x,y). (x0,y0) (x1,y0) (x1,y1)(x0,y1).
44
2d Perlin Noise Compute dot product of the gradient with the associated vector. s = g(x0,y0). ((x,y) - (xo,yo)) t = g(x1,y0). ((x,y) – (x1,y0)) u = g(x0,y1). ((x,y) – (x0,y1)) v = g(x1,y1). ((x,y) – (x1,y1))
45
2d Perlin Noise Combine the influences of the gradients by averaging s,t,u,v Take a weighted average so that if (x,y) is closer to x0,y0 s influence is stronger and so on. Use function 3p 2 – 2p 3 a = avg of s & t b = avg of u & v z = avg of a & b z is the final noise value we want.
46
Use 2d Perlin Noise Use the noise(x,y) function in expressions to generate textures. Heightmaps can be generated by summing up noise of different frequencies and amplitudes.
47
Combiner The combiner combines two separate terrains into one. There are a variety of different methods which can be used to combine the terrains. Each gives a different effect.
48
Combiner Methods Add : Add the 2 nd terrain to the 1 st. (Percentage of base heightmap can be controlled) Subtract : Subtract the 2 nd terrain from the 1 st. (Percentage of base heightmap can be controlled)
49
Combiner Methods Max : Use the tallest height of either terrain at each point. Min : Use the lowest height of either terrain at each point. Multiply : Multiply the two terrains together pointwise.
50
Operations on Height Map Invert : This operation will invert the height map. i.e. all high altitude points will become low altitude points and vice versa. Smoothen : This operation will smoothen the heightmap; making rough features smoother.
51
Output Formats Presented by Vanessa Ferrao
52
Applications of Terranium The output of the software depends on the requirement of the end-user It could be A terragen file (.ter) A POVRay script file A heightmap image file (.png) A world file
53
Height Map Image File Height Map images are saved as Png files. Png is portable – i.e works on both Windows & Linux Image file can be imported in various software and used.
54
Ter Format Ter is the file format of Terragen. Terragen has been in the market for many years now. Terragen has already been used in movies, games, and even television. Implementing ter allows our output to be also used by Terragen (Rendering and further editing).
55
.Ter (Terragen Terrain ) File Structure TERRAGENTERRAINSIZEXPTSYPTSALTWEOF 8 BYTES SIZE --4-byte marker 2-byte integer value XPTS and YPTS –4-byte marker 2-byte integer ALTW --4-byte marker HeightScale --a 2-byte signed integer value. BaseHeight -- a 2-byte signed integer value. Elevations -- a sequence of 2-byte signed integers. 4-byte
56
File Structure A terrain file contains a 16-byte identifier followed by a number of chunks. Each chunk contains a 4-byte marker then some data. Terrain Format
57
1.An 8-byte "TERRAGEN" string at the beginning of the file. 2.An 8-byte "TERRAIN " string located 8 bytes from the beginning of the file. (Note the last space character.) 3.A "SIZE" chunk. 4.If the terrain is not square, "XPTS" and "YPTS" chunks are required. 5.A 4-byte "EOF " string at the end of the file Terrain file must contain
58
chunks YPTS 4-byte marker. followed by a 2-byte integer value ypts followed by 2 bytes of padding. ypts is equal to the number of data points in the y-direction in the elevation image. XPTS 4-byte marker. followed by a 2-byte integer value xpts followed by 2 bytes of padding xpts is equal to the numbe of data points in the x- direction in the elevation image. SIZE 4-byte marker Is followed by a 2-byte integer value equal to n - 1, followed by 2 bytes of padding
59
SCAL 4-byte marker, optional. followed by three intel-ordered 4-byte floating point values (x,y,z). It represents the scale of the terrain in metres per terrain units. CRVM 4-byte marker, optional. followed by one unsigned integer. ALTW 4-byte marker stands for 'Altitude in 16-bit Words'. followed by HeightScale, a 2-byte signed integer value. BaseHeight, a 2-byte signed integer value. Elevations, a sequence of 2-byte signed integers. chunks
60
File Storage World Format Presented by Vanessa Ferrao
61
Purpose Save current terrain (heightmap) and the camera and light settings. User can resume working on already created world to make changes. Distribute created world to other Terrainium users.
62
Options for Format Create our own file format –Save each object by manually iterating through variables and saving the data in the file. –Opening world will require to manually scan file and reload the values. Use Serialization –Let Java save the objects and heightmap into a file. –Open the file and deserialize it to restore the objects
63
Why Serialization? Can save and load entire objects. Useful since our world format will be used by our software only. Easy to implement versus manually saving all parameters.
64
How to Serialize? The class whose object will be serialized must be marked for serialization by implementing the Serializable interface. class HeightMap implements Serializable {. }
65
How to Serialize? Make a FileOutputStream Make an ObjectOutputStream Write the object Close the ObjectOutputStream FileOutputStream file = new FileOutputStream(“World.twd”); ObjectOutputStream os = new ObjectOutputStream(file); os.writeObject(heightmap); os.writeObject(parameters); os.close();
66
How to Deserialize? Make a FileInputStream Make an ObjectInputStream Read the objects Cast the objects Close the ObjectInputStream FileInputStream file = new FileInputStream(“World.twd”); ObjectInputStream os = new ObjectInputStream(file); Object one = os.readObject(); Object two = os.readObject(); os.close(); terrain = (HeightMap) one; parameters = (Parameters) two;
67
Terrainium, the application Presented by Vanessa Ferrao
68
Terrainium, the outputs Presented by Vanessa Ferrao
69
Some terrains
76
Work Division
77
Karl FernandesProject report (entire compilation), Validation of all UI’s. Manoo GharseImplementation of importing and exporting of.ter files. Vanessa FerraoImplementation of the Terrainium world file (.twd), Project report. Rohit ArondekarImplementation of Terrain Generating algorithms and Applying filters on them. Amruta KunkolienkarImplementation of all the UI’s, the sculpt tool, Creation of Script file (.pov).
78
References Head First Java by Kathy Sierra & Bert Bates Texturing & Modeling - A Procedural Approach 3e by Ken Perlin et all Making Noise – A presentation by Ken Perlin www.noisemachine.com/talk1 Terrain Modeling by Matthias Grumet [PAPER]
79
Acknowledgements Dr. Louis Mesquita PROJECT GUIDE Mr. Tarence Johnson PROJECT GUIDE
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.