CS378 - Mobile Computing
CS324e - Elements of Graphics and VisualizationFractals and 3D LandscapesFractalsA geometric figure in which smaller parts share characteristics of the entire figurea detailed pattern that repeats itselfcontain self similar patternsappearance of details matches the overall figureoften described mathematically
2FractalsMandelbrot Set
Burning ShipFractal3
Sierpinski Triangle FractalDescribed by Polish mathematician Wacaw Sierpiski in 1915AlgorithmPick a side length and the lower left vertex for an equilateral triangleIf the side length is less than some minimum draw the triangleelse draw three smaller Sierpinski Triangles4Sierpinski Triangle5x, yside lengthx + .5*side length, yx + .25 * side length,y + sqrt(3) / 4 * side lengthSierpinski Trianglemin length = start length6
Sierpinski Trianglemin length = start length / 27
Sierpinski Trianglemin length = start length / 48
Sierpinski Trianglemin length = start length / 89
Sierpinski Trianglemin length = start length / 1610
Sierpinski Trianglemin length = start length / 3211
Sierpinski Trianglemin length = start length / 6412
Sierpinski Trianglemin length = start length / 12813
Close up - Self SimilarClose up of bottom, right triangle from minLength = startLength / 12814
Implementation of Sierpinski15
Implementation of Sierpinski16
Base CaseRecursiveCaseImplementation of Sierpinski17Base Case - Draw One Triangle
Fractal LandExample from KGPJ chapter 26Create a mesh of quads example 256 x 256 tilesallow the height of points in the quad to vary from one to the nextsplit quads into one of 5 categories based on heightwater, sand, grass, dry earth, stoneappearance based on texture (image file)18Fractal MeshGenerate varied height of quads using a "Diamond - Square" algorithmlookingdown onmeshheights ofpointsA, B, C, DABCDGenerate Fractal Mesh - Diamond Step20ABCDEdHeight = max height - min height
Height of Point E =
(Ah + Bh + Ch + Dh) / 4+ random(-dHeight/2, +dHeight/2)
average of 4 corner pointsplus some random valuein range of max and minallowed heightSquare StepWith heightof E set generate height of 4 points around EGh = (Ah + Eh + Eh + Ch) / 4 + random(-dHeight/2,+dHeight/2 )21ABCDEFGHIRepeat Diamond Step22ABCDEFGHIJKLMCompleting MeshContinuing 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 randomlyProblem: if the height is allowed to vary between the min and max height for every point how different can points on a quad be?23A Spear Trap24
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 differencesSolution: after a pair of diamond - square steps reduce the range of the random valuereferred to as the flatness factorrange = range / flatness25Flatness of 1.526
Flatness of 2.527
Flatness of 2.028
TexturesShapes in Java3D may be wrapped in a textureIn FractalLand the mesh is simply a QuadArrayEach texture is an image fileQuad Array created and texture coordinates generated for each quadhow does image map to quad29Simple TexturesTexture can also be applied to the primitive shapes: box, cone, sphere, cylinderFrom the interpolator exampleWhen creating box must add primFlag to generate texture coordinates30
Creating Appearance Appearance for shape based on texture not material
31
Resulttexture wrapped and repeated as necessarycan lead to odd seams, creases, and stretching32
Combining Texture and Materialcan combine material and texture to create modulated material
33
Result34
ControlsVersion of FractalLand shown had orbit controls to allow movement of camera anywhere in sceneprogram includes method to add key controls and keeps camera close to the groundas if moving across the landscape35Result
36Adding FogJava3D includes ability to add fogLinearFogExponentialFogdensity of fog as function of distance from the camerafog has color and parameters to determine density of fog37LinearFog38
Result39