CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D...
Transcript of CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D...
![Page 1: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/1.jpg)
CS324e - Elements of Graphics
and Visualization
Fractals and 3D Landscapes
![Page 2: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/2.jpg)
Fractals
• A geometric figure in which smaller parts
share characteristics of the entire figure
– a detailed pattern that repeats itself
– contain self similar patterns
– appearance of details matches the overall
figure
– often described mathematically
2
![Page 3: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/3.jpg)
Fractals
• Mandelbrot Set
• Burning Ship
Fractal
3
![Page 4: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/4.jpg)
Sierpinski Triangle Fractal
• Described by Polish mathematician
Wacław Sierpiński in 1915
• Algorithm
– Pick a side length and the lower left vertex
for an equilateral triangle
– If the side length is less than some
minimum draw the triangle
– else draw three smaller Sierpinski Triangles
4
![Page 5: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/5.jpg)
Sierpinski Triangle
5
x, y
side length
x + .5*side length, y
x + .25 * side length,
y + sqrt(3) / 4 *
side length
![Page 6: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/6.jpg)
Sierpinski Triangle
• min length
= start length
6
![Page 7: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/7.jpg)
Sierpinski Triangle
• min length
= start length / 2
7
![Page 8: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/8.jpg)
Sierpinski Triangle
• min length
= start length / 4
8
![Page 9: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/9.jpg)
Sierpinski Triangle
• min length
= start length / 8
9
![Page 10: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/10.jpg)
Sierpinski Triangle
• min length
= start length / 16
10
![Page 11: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/11.jpg)
Sierpinski Triangle
• min length
= start length / 32
11
![Page 12: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/12.jpg)
Sierpinski Triangle
• min length
= start length / 64
12
![Page 13: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/13.jpg)
Sierpinski Triangle
• min length
= start length / 128
13
![Page 14: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/14.jpg)
Close up - Self Similar
• Close up of bottom, right triangle from
minLength = startLength / 128
14
![Page 15: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/15.jpg)
Implementation of Sierpinski
15
![Page 16: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/16.jpg)
Implementation of Sierpinski
16
Base Case
Recursive
Case
![Page 17: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/17.jpg)
Implementation of Sierpinski
17
Base Case - Draw One Triangle
![Page 18: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/18.jpg)
Fractal Land
• Example from KGPJ chapter 26
• Create a mesh of quads
– example 256 x 256 tiles
• allow the height of points in the quad to
vary from one to the next
• split quads into one of 5 categories based
on height
– water, sand, grass, dry earth, stone
– appearance based on texture (image file)18
![Page 19: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/19.jpg)
Fractal Mesh
• Generate varied height of quads using a
"Diamond - Square" algorithm
• looking
down on
mesh
• heights of
points
A, B, C, D
A B
C D
![Page 20: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/20.jpg)
Generate Fractal Mesh - Diamond Step
20
A B
C D
E
dHeight = max height
- min height
Height of Point E =
(Ah + Bh + Ch + Dh) / 4
+ random(-dHeight/2,
+dHeight/2)
average of 4 corner points
plus some random value
in range of max and min
allowed height
![Page 21: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/21.jpg)
Square Step
• With heightof E set generate height of 4 points around E
• Gh = (Ah + Eh + Eh + Ch) / 4 + random(-dHeight/2,+dHeight/2 )
21
A B
C D
E
F
G H
I
![Page 22: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/22.jpg)
Repeat Diamond Step
22
A B
C D
E
F
G H
I
J K
L M
![Page 23: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/23.jpg)
Completing Mesh
• Continuing alternating diamond and
square step until the size of the quad is 1.
• Each point of quad at a fixed x and z
coordinate, but the y has been generated
randomly
• Problem: if the height is allowed to vary
between the min and max height for
every point how different can points on a
quad be?23
![Page 24: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/24.jpg)
A Spear Trap
24
![Page 25: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/25.jpg)
What is the Problem?
• By allowing the points that form a single quad to vary anywhere in the range from min to max height we get vast differences
• Solution: after a pair of diamond - square steps reduce the range of the random value
• referred to as the flatness factor
• range = range / flatness
25
![Page 26: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/26.jpg)
Flatness of 1.5
26
![Page 27: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/27.jpg)
Flatness of 2.5
27
![Page 28: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/28.jpg)
Flatness of 2.0
28
![Page 29: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/29.jpg)
Textures
• Shapes in Java3D may be wrapped in a
texture
• In FractalLand the mesh is simply a
QuadArray
• Each texture is an image file
• Quad Array created and texture
coordinates generated for each quad
– how does image map to quad
29
![Page 30: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/30.jpg)
Simple Textures
• Texture can also be applied to the
primitive shapes: box, cone, sphere,
cylinder
• From the interpolator example
• When creating box must add primFlag to
generate texture coordinates
30
![Page 31: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/31.jpg)
Creating Appearance
• Appearance for shape based on texture
not material
31
![Page 32: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/32.jpg)
Result
• texture
wrapped and
repeated as
necessary
• can lead to odd
seams, creases,
and stretching
32
![Page 33: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/33.jpg)
Combining Texture and Material• can combine material and texture to create
modulated material
33
![Page 34: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/34.jpg)
Result
34
![Page 35: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/35.jpg)
Controls
• Version of FractalLand shown had orbit
controls to allow movement of camera
anywhere in scene
• program includes method to add key
controls and keeps camera close to the
ground
– as if moving across the landscape
35
![Page 36: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/36.jpg)
Result
36
![Page 37: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/37.jpg)
Adding Fog
• Java3D includes ability to add fog
• LinearFog
• ExponentialFog
• density of fog as function of distance
from the camera
• fog has color and parameters to
determine density of fog
37
![Page 38: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/38.jpg)
LinearFog
38
![Page 39: CS324e -Elements of Graphics and Visualization · 2012-08-22 · and Visualization Fractals and 3D Landscapes. Fractals • A geometric figure in which smaller parts share characteristics](https://reader034.fdocuments.in/reader034/viewer/2022043008/5f976e4de56aef591d6f9d96/html5/thumbnails/39.jpg)
Result
39