Yingcai Xiao Surface and Volume Representation and Procedural Animation Yingcai Xiao
Outline Why? Surface Representation Volume Representation Procedural Animation Application in Unity3D
Yingcai Xiao Why? Waves of tsunami Splashes of diving Drilling into the ground Moving inside an object (fluids)
Yingcai Xiao Surface Representations
. Analytical Planes: ax + by + cz + d=0 e.g. y = 0;
. Analytical Curved Surfaces : ax 2 + by 2 + cz 2 + dxy + eyz + fzx + gx + hy + iz + j = 0 a-j are constants. x 2 + y 2 + z 2 = 64;
. Analytical Parametrical Surfaces : x = x (s,t); y = y (s,t); B-Splines
Parametric Form of a line: x(t) = x 0 + t * (x 1 – x 0 ) y(t) = y 0 + t * (y 1 – y 0 ) 0 <= t <= 1 x(t) = (1-t) * x 0 + t * x 1 y(t) = (1-t) * y 0 + t * y 1 0 <= t <= 1
. Analytical Parametrical Surfaces : x = x (s,t); y = y (s,t); B-Splines Use control points to design the surface 1.jpg
Yingcai Xiao Surface Representations Discrete Forms
Yingcai Xiao Elevation Grid origin: 0,0,0 spacing: 1,1,1 dimension: 5, 5 elevation: 1,2,3,4,5, 11, 12, 13, 14, 15, 21, 22, 23, 24, 25, 31, 32, 33, 34, 35, 41, 42, 43, 44, 45
Carpet Plots V(r) = e -r cos(10r); r = sqrt (x*x + z*z)
Triangular Integrated Networks (TIN)
Triangle Strip Generation Triangle strips are compact representations of triangle polygons. Greedy method: The longer the average strip length is the better.
Triangulation: Connect points to form a triangulated topological structure. (topology generation)
Triangulation Use Edge Swapping to make a Delaunay Triangulation. 1. Find the minimum bounding triangle. (may need to add a fake point) 2. Add one point at a time, do triangulation. 3. After each point is added, check if the joined triangles are optimal or not; if not swap the joining edge (edge swapping). Check all other triangles and make sure they are still optimal after adding the current point. 4. Repeat step 3 to add each point and we when all points are added and all triangles are optimal. 5. Clean up: remove all fake points and related triangles.
Yingcai Xiao Surface Display
Polygon Normal Generation Shading Reflection: I~f(N,C) i.e., C.N. I Normal may not be given by the programmer. Facet Normal: Compute normal of a polygon from its vertexes. Ex.
Polygon Normal Generation: facet / polygonal normals
Polygon Normal Generation Vertex Normals: Use the average of the facet normals in the use set.
Polygon Normal Generation Vertex Normals: Shaded using vertex normal (average of facet normals), too smooth.
Polygon Normal Generation Feature Angle ~80 0 <90 0 Take the facet out of the average computation if the connected facets have angle greater than the feature angle
Decimation Polygon Reduction (Vertex Reduction) Threshold Distance: For lines: is the distance to the line without the vertex.
Decimation For surface: is the distance to the surface without the vertex.
Mesh Smoothing No reduction, no topology change. But the geometry changes to make the mesh smooth.
Mesh Smoothing No reduction, no topology change. But the geometry changes to make the mesh smooth.
Yingcai Xiao Volume Representations Discrete Forms
Data Structure Data Structure Design Criterion Compact (save space) Efficient (fast retrieval) Map-able (easy to convert) Minimal Coverage (small foot prints) Simple (easy to use)
Volumetric Data Structure Structure: topology and geometry Topology: is the set of properties invariant under certain geometric transformations. Geometry: is the instantiation of the topology; the specification of positions in a 3D space. The structure consists of cells and points. The cells specify the topology; while the points specify the geometry. Dataset Attributes: Normals, texture coordinates, and user-defined data.
Cell Types A data set consists of one or more cells A cell is defined by a “type” and an ordered list of point Type: topology, cell type Ordered list: geometry, points Together: organizational structure Use Set: all the cells using a point: U(p i ) = {C i : p i C i } A data set consists of one or more cells A cell is defined by a “type” and an ordered list of point Type: topology, cell type Ordered list: geometry, points Together: organizational structure Use Set: all the cells using a point: U(p i ) = {C i : p i C i }
Cell Types Vertex: zero-dimensional cell, It is defined by a single point. Line: one dimensional cell. It is defined by two points. Polyline: is a composite one-dimensional cell consisting of n connected lines. It is defined by an ordered list of n+1 points. Triangle: is a primary two-dimensional cell. The triangle is defined by a counter- clockwise ordered list of three points. Polygon: is a primary two-dimensional cell. The polygon is defined by an ordered list of three or more points lying in a plane Tetrahedron: is a primary three-dimensional cell. It is defined by a list of four nonplanar point. Hexahedron: is a primary three-dimensional cell. It is defined by a list of eight nonplanar point. Voxel: volume element, the smallest unity of a 3D grid, usually, a hexahedron. Vertex: zero-dimensional cell, It is defined by a single point. Line: one dimensional cell. It is defined by two points. Polyline: is a composite one-dimensional cell consisting of n connected lines. It is defined by an ordered list of n+1 points. Triangle: is a primary two-dimensional cell. The triangle is defined by a counter- clockwise ordered list of three points. Polygon: is a primary two-dimensional cell. The polygon is defined by an ordered list of three or more points lying in a plane Tetrahedron: is a primary three-dimensional cell. It is defined by a list of four nonplanar point. Hexahedron: is a primary three-dimensional cell. It is defined by a list of eight nonplanar point. Voxel: volume element, the smallest unity of a 3D grid, usually, a hexahedron.
Types of Datasets Dependent on topology of the dataset. Uniform Grid (uniform in each direction) Parameters: Dimension: n x, n y, n z Origin: x 0, y 0, z 0 Spacing: d x, d y, d z
Uniform Grid IJK space x = i*d x + x 0 y = j*d y + y 0 z = k*d z + z 0 Data array (i, j, k), loop i first, then j, k last. Simple, compact and speedy retrieval. Not flexible
Yingcai Xiao Elevation Grid: a special case of uniform grids origin: 0,0 spacing: 1,1 dimension: 5, 5 elevation: 1,2,3,4,5, 11, 12, 13, 14, 15, 21, 22, 23, 24, 25, 31, 32, 33, 34, 35, 41, 42, 43, 44, 45
Rectlinear Grid Dimension: n x, n y, n z Nonuniform spacing, but straight grid lines. float x[44]={0.0,1.2,2.8,3.9…….} float y[33]={1.0,……………} float z[22]={0.8,……………}
Rectlinear Grid IJK space. x = x[I]; y = y[J]; z = z[K]; Data array (i, j, k), i changes first, then j, k last. Simple compact (takes O(n x + n y + n z ) more space) speedy retrieval Little more flexible
Structured Grid Dimension: n x, n y, n z Nonuniform spacing IJK space (no formula) Coordinates of each grid node need to be given. x(I,J,K), y(I,J,K), z(I,J,K)
Indexed Surface and Volume Data Structures
Structure Representation P1 of T1 and P2 of T2 are connected at P(1,0,0)
Structure Representation The Wrong Way: Making Copies class Tri{ public: point P 1, P 2, P 3 ; }; Tri T1, T2; T1.P 1.x=1.0; T1.P 1.y=0.0; T1.P 1.z=0.0; ……. T2.P 2.x=1.0; T2.P 2.y=0.0; T2.P 2.z=0.0; ………
Structure Representation: Wrong Way Each triangle keeps a copy of the vertex values. Drawback: if the coordinates of P are changed, all cells having a copy of its value need to be updated.
Structure Representation: Correct Way Save the vertex values in an array (Point List). Store the indexes of the vertexes for each triangle in the triangle definition
Structure Representation The Correct Way: Indexing Point List P 0.x=0.0; P 0.y=0.0; P 0.z=0.0; P 1.x=1.0; P 1.y=0.0; P 1.z=0.0; P 2.x=1.0; P 2.y=1.0; P 2.z=0.0; P 3.x=0.0; P 3.y=1.0; P 3.z=0.0;
Structure Representation The Correct Way: Indexing class Tri{ public: int ID 1, ID 2, ID 3 ; }; Tri T1, T2; T1.ID 1 =0; T1.ID 2 =1; T1.ID 3 =3; T2.ID 1 =1; T2.ID 2 =2; T2.ID 3 =3;
Structure Representation: The Correct Way: Indexing Each triangle keeps an index list (cell list) of its vertexes. If the coordinate of P is changed, none of the cells using it needs to be changed. Only the one copy of its value in the point list needs to be updated.
Indexed Volume / Surface No dimensions parameters: n x, n y, n z No IJK space Coordinates of each node need to be given Most flexible, can represent any structures Easy to modify geometry, only need to change the point list. Not compact (need space to save xyz values and cell information) Slow retrieval
Indexed Data Structure
Summary of Volumetric Data Structures
Converting non-indexed to an indexed structure. Elevation grid => Triangular strips Uniform grid => Hexahedral mesh Uniform grid => Tetrahedral mesh
Morphing and Procedural Animation
Morphing Special effect hat changes (morphs) one image or geometry into another.
Morphing Geometric morphing: modify the xyz values in the point list in a coordinated way. open source for creating animation characters. makehuman_morphing_process.html
Procedural Morphing Use scripts to change the geometry of game objects at run-time. A demo in Unity3D to change the geometry of a plane to a wave form.
Demo in Unity3D To change the geometry of a plane to a wave form. Create a new project with Character Controller package. Add a plane (GameObject->CreateOhters->Plane) Scale it in the Inspector to 10X10 (in x and z). Uncheck the Mesh Collider (in the Inspector) Add a light (GameObject->CreateOhters->DirectionalLight) Add a FPC (Project->Assets->StandardAssets- >CharacterControllers->FirstPersonController, drag-and- drop it to Hierarchy.) Move it up. (Change its y position in the Inspector to 11). Add script to morph the plane (Plane->Inspector- >AddComponent->NewScript->JavaScript) name it Wave. Add the code on the next page to the Wave.js in Mono. Build->Build All in Mono to make sure there is no compilation errors.
Demo in Unity3D (Wave) #pragma strict function Start () { var mesh: Mesh = this.GetComponent(MeshFilter).mesh; var verts: Vector3[] = mesh.vertices; for (var v = 0; v < verts.Length; v++) { verts[v].y = Random.Range(0,10); } mesh.vertices = verts; mesh.RecalculateBounds(); mesh.RecalculateNormals(); this.gameObject.AddComponent(MeshCollider); } function Update () { }
Time-dependent Carpet Plots y(r,t) = A e -r-at cos(2 π (r-Vt) / λ ); r = sqrt ((x-x 0 )*(x-x 0 )+ (z-z 0 )*(z-z 0 )) P 0 (x 0, y 0, z 0 ) : center of the wave A: amplitude of the wave V: velocity of the wave λ : wave length of the wave a: speed of decaying t = current time – time of impact (t 0 )
Advanced Morphing Tools
- Major Issues Mesh generation Mesh modification Mesh node identification Grid based: x(i), y(j), z(k) Indexed: node => x, y, x X, y, z => node (graphical)
- Free software for students from AutoDesk Popular 3ds Max: 3D modeling, animation, rendering, and compositing software for games, film, and video content. AutoCAD (Computer Aided Design) CAD design, drafting, modeling, drawing, and engineering software. Inventor Professional 3D CAD software 3D mechanical CAD, visualization, and documentation software. Revit Building Information Modeling (BIM) tools for architectural design, MEP, and structural engineering.
- Maya: free for students from AutoDesk 3D animation, modeling, simulation, rendering, and compositing software Can be used to generate morphing. -Use Maya to create a 3D object. -Duplicate it and modify the duplicate to the needed shape. -Use Blend Shape Deformer of Maya to recognize all of the shapes. -Import the shapes into Unity3D. -Write C# or JavaScript to control the morphing animation.
MegaFiersMegaFiers plugin for Unity3D -Mesh deformation, animation and Morphing system. -Over 50 modifiers such as Bend, Twist, FFD, Displace. -Wave in a pond at1:24 in the first video. MegaFlowMegaFlow plugin for Unity3D Fluid flow simulation. CFD: Computational Fluid Dynamics using PDEs (partial deferential equations.) Volumetric rendering is challenging.
MegaFiersMegaFiers / MegaFlow plugin for Unity3DMegaFlow Mesh deformation example: Bending. Morphing example: Lysosomes.
Surface Morphing: -Mesh deformation via changing vertex values (geometry and attributes) of the surface mesh. -The surface mesh could represent the enclosure of a solid object. Volumetric Morphing / Deformation: Deformation based on changing the representation of a volume. Voxel (Volume Element) based processing algorithms. Voxel What could be changed: geometry, attributes, and topology (e.g. iso-surface generation).