automatic generation of dynamics models

61
Automatic Automatic Generation of Generation of Dynamics Models Dynamics Models John W. Ratcliff John W. Ratcliff Most Worshipful Senior Most Worshipful Senior Programmer Simutronics Programmer Simutronics Corporation Corporation

Upload: hayes-levine

Post on 02-Jan-2016

56 views

Category:

Documents


5 download

DESCRIPTION

Automatic Generation of Dynamics Models. John W. Ratcliff Most Worshipful Senior Programmer Simutronics Corporation. Introduction. Work for this presentation was supported by Ageia Technologies. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Automatic Generation of Dynamics Models

Automatic Automatic Generation of Generation of

Dynamics ModelsDynamics ModelsJohn W. RatcliffJohn W. Ratcliff

Most Worshipful Senior Most Worshipful Senior Programmer Simutronics Programmer Simutronics

CorporationCorporation

Page 2: Automatic Generation of Dynamics Models

IntroductionIntroduction

Work for this presentation was Work for this presentation was supported by Ageia Technologies.supported by Ageia Technologies.

This is an open source project to This is an open source project to facilitate the rapid production of physics facilitate the rapid production of physics content from raw source graphics datacontent from raw source graphics data

Much assistance provided by Matthias Much assistance provided by Matthias Mueller, Pierre Terdiman, Adam Mueller, Pierre Terdiman, Adam Moravansky, Billy Zelsnack and Dilip Moravansky, Billy Zelsnack and Dilip SequeiraSequeira

Page 3: Automatic Generation of Dynamics Models

The Code SuppositoryThe Code Suppositorywww.codesuppository.blogswww.codesuppository.blogs

pot.compot.com

““A Place Where I Insert My Code into the A Place Where I Insert My Code into the Anus of the InternetAnus of the Internet” ” John W. Ratcliff, Flipcode, John W. Ratcliff, Flipcode, January 12, 2000January 12, 2000

““Yes, I know what that word meansYes, I know what that word means” John ” John W. Ratcliff in response to an email received W. Ratcliff in response to an email received on January 13, 2000.on January 13, 2000.

Page 4: Automatic Generation of Dynamics Models

The ProblemThe Problem

The rapid acceptance of pervasive The rapid acceptance of pervasive physics in games has created new physics in games has created new authoring and asset requirements.authoring and asset requirements.

There is a general lack of tools to There is a general lack of tools to facilitate the rapid creation of dynamics facilitate the rapid creation of dynamics assets.assets.

Many games send their raw graphics Many games send their raw graphics assets to the physics engine which is assets to the physics engine which is highly inefficient and often causes highly inefficient and often causes significant problems.significant problems.

Page 5: Automatic Generation of Dynamics Models

Where should Physics Where should Physics Content be Authored?Content be Authored?

Physics models are usually derived from Physics models are usually derived from a final production art asset.a final production art asset.

Iteration on physics assets is primarily a Iteration on physics assets is primarily a ‘design’ problem rather than an art ‘design’ problem rather than an art issue.issue.

Ideally editing of dynamics data assets Ideally editing of dynamics data assets should occur directly in the game should occur directly in the game engine/editor for rapid iteration cycles to engine/editor for rapid iteration cycles to test the behavior and interaction of the test the behavior and interaction of the models in real-time.models in real-time.

Page 6: Automatic Generation of Dynamics Models

Existing Tools to Author Existing Tools to Author Physics ContentPhysics Content

Feeling SoftwareFeeling Software : www.feelingsoftware.com : www.feelingsoftware.com PhysX Plugin for 3D Studio Max (free open source)PhysX Plugin for 3D Studio Max (free open source) Nima for Maya : (Unsupported version Free)Nima for Maya : (Unsupported version Free) Lead developer Christian LaforteLead developer Christian Laforte

Blender 3DBlender 3D : : www.blender.orgwww.blender.org (Free open source) (Free open source) Lead developer Ton RoosendaalLead developer Ton Roosendaal

Bullet Physics LibraryBullet Physics Library : : www.continuousphysics.comwww.continuousphysics.com (Free open source) (Free open source) Developed by Erwin CoumansDeveloped by Erwin Coumans

CreateDynamicsCreateDynamics : : www.codesuppository.blogspot.comwww.codesuppository.blogspot.com (Free open (Free open source)source)

Developed by John W. RatcliffDeveloped by John W. Ratcliff Unreal EditorUnreal Editor : : www.epicgames.comwww.epicgames.com

Proprietary tools.Proprietary tools. Physics authoring happens in the game editorPhysics authoring happens in the game editor Uses some of the CreateDynamics toolkit for generating compound objects.Uses some of the CreateDynamics toolkit for generating compound objects. Lead developer on the physics tools James GoldingLead developer on the physics tools James Golding

Scythe Physics EditorScythe Physics Editor : : www.physicseditor.comwww.physicseditor.com Supports ODE, Newton, PhysXSupports ODE, Newton, PhysX Free and Commercial vesions availableFree and Commercial vesions available Lead developer Chris HuntLead developer Chris Hunt

Page 7: Automatic Generation of Dynamics Models

Existing Standardized File Existing Standardized File Formats for Physics Formats for Physics

ContentContent COLLADA 1.4.1 : COLLADA 1.4.1 : www.collada.orgwww.collada.org

Supports basic rigid body physics markup in an Supports basic rigid body physics markup in an XML format.XML format.

NxuStream : NxuStream : www.ageia.comwww.ageia.com Provided as part of the free PhysX SDK. Provided as part of the free PhysX SDK. Source library.Source library. Exact reflective object model of every Exact reflective object model of every

component in the SDK, including rigid body, component in the SDK, including rigid body, constraints, all shapes, including heightfields, constraints, all shapes, including heightfields, cloth, softbodies, fluids, collision filters, energy cloth, softbodies, fluids, collision filters, energy fields, and much more.fields, and much more.

XML, Binary, and supports COLLADA 1.4.1 XML, Binary, and supports COLLADA 1.4.1 physics only specification.physics only specification.

Scythe : www.physicseditor.comScythe : www.physicseditor.com

Page 8: Automatic Generation of Dynamics Models

Multiple Collision Models Multiple Collision Models Per AssetPer Asset

For any given art asset there are usually at least For any given art asset there are usually at least three, if not more, physics representations.three, if not more, physics representations. Raycast modelRaycast model: A static triangle mesh that is identical : A static triangle mesh that is identical

to the original graphics model for precise line of sight to the original graphics model for precise line of sight evaluation as well as certain graphics support such as evaluation as well as certain graphics support such as decal generation.decal generation.

Static collision modelStatic collision model: An often dramatically : An often dramatically simplified version which corresponds to what the player simplified version which corresponds to what the player character would collide with (rarely should be the character would collide with (rarely should be the raycast version.) May be a simplified mesh, a convex raycast version.) May be a simplified mesh, a convex hull, or a compound shape.hull, or a compound shape.

Dynamic collision model(s):Dynamic collision model(s): One or more versions to One or more versions to be used when the object is dynamic. Should never be a be used when the object is dynamic. Should never be a triangle mesh. Typically a single convex hull or triangle mesh. Typically a single convex hull or compound object.compound object.

Page 9: Automatic Generation of Dynamics Models

Components of a Physics Components of a Physics AssetAsset

Rigid Body propertiesRigid Body properties Collision ShapesCollision Shapes

Triangle MeshTriangle Mesh BoxBox CapsuleCapsule Convex HullConvex Hull SphereSphere HeightFieldHeightField

ConstraintsConstraints Cloth properties and topologyCloth properties and topology Soft Body properties and topologySoft Body properties and topology Fluid and fluid emitter propertiesFluid and fluid emitter properties Energy FieldsEnergy Fields

Page 10: Automatic Generation of Dynamics Models

Typical Rigid Body Typical Rigid Body PropertiesProperties

World Transform (global pose)World Transform (global pose) List of collision shapesList of collision shapes Collision group and/or other flagsCollision group and/or other flags Dynamics PropertiesDynamics Properties

Linear Velocity and Angular VelocityLinear Velocity and Angular Velocity Mass or DensityMass or Density Mass Local Pose and Mass Space Inertia TensorMass Local Pose and Mass Space Inertia Tensor

Engine specific components Engine specific components Solver IterationsSolver Iterations Sleep ThresholdSleep Threshold Maximum Angular VelocityMaximum Angular Velocity Etc.Etc.

Page 11: Automatic Generation of Dynamics Models

Collision Shape Collision Shape PropertiesProperties

Local Transform (relative to parent rigid body)Local Transform (relative to parent rigid body) Material IndexMaterial Index Collision filtering informationCollision filtering information Contact report flagsContact report flags Shape data:Shape data:

Box dimensionsBox dimensions Sphere radiusSphere radius Capsule height and radiusCapsule height and radius Convex hull facesConvex hull faces Triangle mesh trianglesTriangle mesh triangles Heightfield sample dataHeightfield sample data Plane equationPlane equation

Page 12: Automatic Generation of Dynamics Models

Programmable ConstraintProgrammable ConstraintCustomizable on all 6 degrees of freedom angular and Customizable on all 6 degrees of freedom angular and

linearlinearPhysX SDK implementation by Matthias Mueller-PhysX SDK implementation by Matthias Mueller-

FischerFischer A constraint that can be configured on three angular and three linear A constraint that can be configured on three angular and three linear degrees of freedom. Each degree of freedom can be fixed, free, or degrees of freedom. Each degree of freedom can be fixed, free, or limited and can be configured to support drive, motors, and springs.limited and can be configured to support drive, motors, and springs.

AdvantagesAdvantages A single model can be configured to behave in any of the A single model can be configured to behave in any of the

most common custom joint configurations. most common custom joint configurations. Allows for a much simpler and easier to maintain code path.Allows for a much simpler and easier to maintain code path. Provides new types of constraints not typically available Provides new types of constraints not typically available

with most engines.with most engines. Predictable behavior in all configurations.Predictable behavior in all configurations. Orthogonal data definition.Orthogonal data definition.

DisadvantagesDisadvantages Initially can be more difficult to configure. This can be Initially can be more difficult to configure. This can be

improved by providing helper setup routines for common improved by providing helper setup routines for common constraint types.constraint types.

Page 13: Automatic Generation of Dynamics Models

Authoring Collision Authoring Collision ShapesShapes

For simple objects, when a single For simple objects, when a single shape is sufficient, collision fitting is shape is sufficient, collision fitting is not difficultnot difficult

Single Collision Shape with Oriented Bounding Box approximation

Single Collision Shape Convex Hull approximation

Page 14: Automatic Generation of Dynamics Models

Compound ShapesCompound ShapesApproximate Convex Approximate Convex

DecompositionDecomposition Published workPublished work

Approximate Convex DecompositionApproximate Convex DecompositionTexas A&M UniversityTexas A&M University

Algorithms & Applications GroupAlgorithms & Applications Group

Jyh-Ming Lien and Nancy M. AmatoJyh-Ming Lien and Nancy M. Amato(parasol.tamu.edu/groups/amatogroup/research/app-cd)(parasol.tamu.edu/groups/amatogroup/research/app-cd)

Variational, meaningful shape Variational, meaningful shape decompositiondecompositionUniversity of British ColumbiaUniversity of British Columbia

Vladislav Krayevoy and Alla SchefferVladislav Krayevoy and Alla Scheffer(www.cs.ubc.ca/~vlady/Papers/Segmentation.pdf)(www.cs.ubc.ca/~vlady/Papers/Segmentation.pdf)

Page 15: Automatic Generation of Dynamics Models

Convex DecompositionConvex DecompositionAlgorithm by John W. RatcliffAlgorithm by John W. Ratcliff

‘‘Inspired’ by the work of Jyh-Ming Lien Inspired’ by the work of Jyh-Ming Lien and Nancy M. Amato at Texas A&M. and Nancy M. Amato at Texas A&M. However, this brute force However, this brute force implementation has little in common implementation has little in common with their technique.with their technique. Accepts open meshesAccepts open meshes Not real timeNot real time Available as a plug-in or open source Available as a plug-in or open source

librarylibrary Simple interfaceSimple interface

Page 16: Automatic Generation of Dynamics Models

The AlgorithmThe Algorithm A recursive routine is passed, as input, the source A recursive routine is passed, as input, the source

triangle meshtriangle mesh The first step is to compute the ‘volume of concavity’The first step is to compute the ‘volume of concavity’

Build a convex hull around the mesh.Build a convex hull around the mesh. Project each triangle on the original mesh onto the hull.Project each triangle on the original mesh onto the hull. Compute the volume of the mesh that results from the Compute the volume of the mesh that results from the

projected triangle onto the convex hull skin.projected triangle onto the convex hull skin. The sum of the volume of all projected triangles to the convex The sum of the volume of all projected triangles to the convex

hull surrounding it becomes the ‘volume of concavity’hull surrounding it becomes the ‘volume of concavity’ Compute the percentage volume of concavity by Compute the percentage volume of concavity by

dividing it by the volume of the hull around the original dividing it by the volume of the hull around the original source mesh.source mesh. If the percentage volume of concavity is below a user supplied If the percentage volume of concavity is below a user supplied

threshold then accept this mesh as sufficiently convex. threshold then accept this mesh as sufficiently convex. By measuring against the total volume this allows highly By measuring against the total volume this allows highly

concave pieces to be ignored if they are quite small and concave pieces to be ignored if they are quite small and unimportant relative to the overall size of the object.unimportant relative to the overall size of the object.

Page 17: Automatic Generation of Dynamics Models

The Algorithm cont.The Algorithm cont. Compute the best fit oriented bounding boxCompute the best fit oriented bounding box

If the mesh is concave then compute the best fit If the mesh is concave then compute the best fit oriented bounding box around the mesh.oriented bounding box around the mesh.

Compute a split plane along the long axis of the OBBCompute a split plane along the long axis of the OBB Split all of the input triangles against the plane Split all of the input triangles against the plane

producing two output meshesproducing two output meshes Each triangle is tested to see which side of the plane Each triangle is tested to see which side of the plane

it lies on.it lies on. If the triangle straddles the plane it is split and one If the triangle straddles the plane it is split and one

triangle piece is sent to the ‘top’ mesh and the other triangle piece is sent to the ‘top’ mesh and the other sent to the ‘bottom’ mesh.sent to the ‘bottom’ mesh.

The ‘edge’ of each split triangle is added to an edge The ‘edge’ of each split triangle is added to an edge list.list.

Page 18: Automatic Generation of Dynamics Models

The Algorithm cont.The Algorithm cont. Using the edges that lie along the split plane Using the edges that lie along the split plane

compute a delaunay triangulation.compute a delaunay triangulation. Project the points onto the plane so the operation can be Project the points onto the plane so the operation can be

performed in 2dperformed in 2d Must support multiple polygonsMust support multiple polygons Must support ‘holes’ by testing polygons inside other Must support ‘holes’ by testing polygons inside other

polygons (example splitting a glass in half)polygons (example splitting a glass in half) See: “Triangle : A Two-Dimensional Quality Mesh See: “Triangle : A Two-Dimensional Quality Mesh

Generator and Delaunay Triangulator “ by Generator and Delaunay Triangulator “ by Jonathan Richard Jonathan Richard ShewchukShewchuk http://www.cs.cmu.edu/~quake/triangle.htmlhttp://www.cs.cmu.edu/~quake/triangle.html

Project the polygon points back into 3d and weld them Project the polygon points back into 3d and weld them into the mesh producing a whole piece.into the mesh producing a whole piece.

Without this operation deep recursion produces hollow Without this operation deep recursion produces hollow objects and does not converge to an optimal solution set.objects and does not converge to an optimal solution set.

Page 19: Automatic Generation of Dynamics Models

The Algorithm cont.The Algorithm cont. Pass the top and bottom split meshes back into the Pass the top and bottom split meshes back into the

recursive routine.recursive routine. Wash, rinse, and repeat until there are no concave pieces left Wash, rinse, and repeat until there are no concave pieces left

or at the maximum recursion depth provided by the user.or at the maximum recursion depth provided by the user. This results in an oriented bounding volume tree This results in an oriented bounding volume tree

based on the original source mesh.based on the original source mesh. The output hulls are over described since an optimal split was The output hulls are over described since an optimal split was

not performed.not performed. To correct for this a cleanup phase is run where hulls are To correct for this a cleanup phase is run where hulls are

merged back together again if they are largely convex merged back together again if they are largely convex afterwards.afterwards.

In short, what the process has done is created too many hulls In short, what the process has done is created too many hulls but a straightforward cleanup pass can easily stitch them back but a straightforward cleanup pass can easily stitch them back together again. Simply compute the volume of two hulls together again. Simply compute the volume of two hulls separate then compute the volume of the two hulls combined. separate then compute the volume of the two hulls combined. If the volume is within a percentage threshold provided by the If the volume is within a percentage threshold provided by the user (called the merge threshold) then these two hulls are user (called the merge threshold) then these two hulls are combined back into one.combined back into one.

Page 20: Automatic Generation of Dynamics Models

The Algorithm cont.The Algorithm cont.

Attempt to merge hulls by largest volume Attempt to merge hulls by largest volume first.first. At each phase of the merge process select the At each phase of the merge process select the

largest hull first and then attempt to merge it in largest hull first and then attempt to merge it in order of the largest volume to the smallest.order of the largest volume to the smallest.

The end result is that even though the mesh The end result is that even though the mesh was chopped up more than was necessary, the was chopped up more than was necessary, the post-process cleanup phase ends up producing post-process cleanup phase ends up producing results as if the most optimal split had been results as if the most optimal split had been performed in the first place. Behold the power performed in the first place. Behold the power of brute force, sometimes a blunt instrument of brute force, sometimes a blunt instrument beats out the most advanced mathematics.beats out the most advanced mathematics.

Page 21: Automatic Generation of Dynamics Models

Create DynamicsCreate DynamicsConvex Decomposition User InterfaceConvex Decomposition User Interface

Page 22: Automatic Generation of Dynamics Models

Approximate Convex Approximate Convex DecompositionDecomposition

Examples using various fitting rulesExamples using various fitting rules

Page 23: Automatic Generation of Dynamics Models

Approximate Convex Approximate Convex Decomposition ExamplesDecomposition Examples

Page 24: Automatic Generation of Dynamics Models

VideoVideoA high poly count helix mesh simulated A high poly count helix mesh simulated

as a rigid body composed of only 15 as a rigid body composed of only 15 convex hull shapesconvex hull shapes

Page 25: Automatic Generation of Dynamics Models

Automatic Rag Doll Automatic Rag Doll GenerationGeneration

Directly from Skeletal Deformed Directly from Skeletal Deformed MeshMesh Creating Ragdoll models can be very Creating Ragdoll models can be very

time consuming. Artists spend a great time consuming. Artists spend a great deal of time rigging up a skeletal system deal of time rigging up a skeletal system for an art asset to begin with. There for an art asset to begin with. There should not be a need to spend an equal should not be a need to spend an equal amount of time producing a physics amount of time producing a physics representation of the same.representation of the same.

Embedded within a standard skeletal Embedded within a standard skeletal deformed mesh is sufficient information deformed mesh is sufficient information to auto-generate a reasonable to auto-generate a reasonable approximate ragdoll model.approximate ragdoll model.

Page 26: Automatic Generation of Dynamics Models

Automatic Rag Doll Automatic Rag Doll GenerationGeneration

Step 1 : Skeleton Step 1 : Skeleton PruningPruning The skeleton used for a ragdoll physics The skeleton used for a ragdoll physics

simulation is typically far simpler than what is simulation is typically far simpler than what is used for graphics.used for graphics.

The graphics version may include many details The graphics version may include many details such as fingers, toes, facial bones and marker such as fingers, toes, facial bones and marker bones for game play elements. None of these bones for game play elements. None of these bones are desirable in the physics bones are desirable in the physics representationrepresentation

Before attempting to generate constraints for Before attempting to generate constraints for all of the bones in the skeleton the skeleton all of the bones in the skeleton the skeleton needs to be pruned and a new skeleton created needs to be pruned and a new skeleton created which is usable for a real-time physics which is usable for a real-time physics simulation.simulation.

Page 27: Automatic Generation of Dynamics Models

Automatic Rag Doll Automatic Rag Doll GenerationGeneration

Step 1 : Skeleton Step 1 : Skeleton PruningPruning Traverse the skeleton and examine the Traverse the skeleton and examine the

triangles which have significant weightings to triangles which have significant weightings to each bone.each bone. Bones which are not influenced by any geometry Bones which are not influenced by any geometry

are marked for deletion.are marked for deletion. For the rest of the bones compute the volume of For the rest of the bones compute the volume of

the convex hull around the triangles weighted to it.the convex hull around the triangles weighted to it. Compare the volume of the geometry associated Compare the volume of the geometry associated

with the volume of the whole. If the volume is with the volume of the whole. If the volume is below a user supplied percentage threshold this below a user supplied percentage threshold this bone should be marked for removal. This will bone should be marked for removal. This will leave only bones associated with larger leave only bones associated with larger components of the source mesh; in a humanoid components of the source mesh; in a humanoid character this would correspond to head, arms, character this would correspond to head, arms, legs, and torso, but not eyes, fingers, or toes.legs, and torso, but not eyes, fingers, or toes.

Page 28: Automatic Generation of Dynamics Models

Automatic Rag Doll Automatic Rag Doll GenerationGeneration

Step 1 : Skeleton Step 1 : Skeleton PruningPruning Now a new skeleton must be produced that leaves only Now a new skeleton must be produced that leaves only

the bones which were marked for removal.the bones which were marked for removal. Leaf node bones marked for deletion may simply be removed.Leaf node bones marked for deletion may simply be removed. Bones marked for removal that are not leaf nodes must have Bones marked for removal that are not leaf nodes must have

their child/parent relationship patched up so the skeleton will their child/parent relationship patched up so the skeleton will still be intact. The parent should keep track of the now dead still be intact. The parent should keep track of the now dead child bones it has inherited.child bones it has inherited.

Now that a reduced skeleton has been created the Now that a reduced skeleton has been created the deformed mesh geometry has to be revised so the bone deformed mesh geometry has to be revised so the bone indices point to the correct locations in the new indices point to the correct locations in the new skeleton.skeleton. For each bone referenced in the source mesh re-assign it to For each bone referenced in the source mesh re-assign it to

the corresponding bone in the new skeleton for the output the corresponding bone in the new skeleton for the output mesh.mesh.

If a vertex refers to a bone that has been deleted then attach it If a vertex refers to a bone that has been deleted then attach it to the parent bone that the original bone was collapsed into.to the parent bone that the original bone was collapsed into.

Page 29: Automatic Generation of Dynamics Models

Automatic Rag Doll Automatic Rag Doll GenerationGeneration

Step 2 : Generating Collision Step 2 : Generating Collision ShapesShapes Walk the reduced skeleton and collect Walk the reduced skeleton and collect

the triangles associated with each bone.the triangles associated with each bone. On a per-bone basis run the On a per-bone basis run the

CreateDynamics shape fitting tool and CreateDynamics shape fitting tool and approximate the shape as a box, sphere, approximate the shape as a box, sphere, capsule, or convex hull based on user capsule, or convex hull based on user input selection.input selection.

Using a rules based system, different Using a rules based system, different shape fitting techniques can be applied shape fitting techniques can be applied to the skeleton using wildcards and to the skeleton using wildcards and inheritance.inheritance.

Page 30: Automatic Generation of Dynamics Models

Automatic Rag Doll Automatic Rag Doll GenerationGeneration

Step 3 : Generating ConstraintsStep 3 : Generating Constraints Constraints are created based on the Constraints are created based on the

transforms of the reduced skeleton.transforms of the reduced skeleton. Joint types and limits are selected from Joint types and limits are selected from

user input using the same rules system for user input using the same rules system for deciding shape fitting.deciding shape fitting. Though not currently implemented it would be Though not currently implemented it would be

feasible to infer joint types and limits by feasible to infer joint types and limits by interpreting a reference animation.interpreting a reference animation.

Joint limits and types are supported by Maya Joint limits and types are supported by Maya and might be able to be passed as part of the and might be able to be passed as part of the export process.export process.

Page 31: Automatic Generation of Dynamics Models

Automatic Rag Doll Automatic Rag Doll GenerationGeneration

Step 4 : Generating Collision Step 4 : Generating Collision FiltersFilters To prevent the ragdoll model from constantly To prevent the ragdoll model from constantly

colliding with itself collision filters are needed colliding with itself collision filters are needed to prevent this artifact.to prevent this artifact. Walk the skeleton and compute the skeletal Walk the skeleton and compute the skeletal

distance between bones. Bones which are near distance between bones. Bones which are near each other along the skeleton should have collisions each other along the skeleton should have collisions disabled between their bodies.disabled between their bodies.

For more accurate collision modeling (such as For more accurate collision modeling (such as convex hulls) the filtering need not be too deep. convex hulls) the filtering need not be too deep. For cruder collision models such as capsules or For cruder collision models such as capsules or boxes, filtering to avoid the model colliding with boxes, filtering to avoid the model colliding with itself will need to be more aggressive.itself will need to be more aggressive.

Though not currently implemented, it might be best Though not currently implemented, it might be best to decide where collision filters are needed by to decide where collision filters are needed by detecting contacts while the skeletal model is in its detecting contacts while the skeletal model is in its rest pose.rest pose.

Page 32: Automatic Generation of Dynamics Models

Simplified Auto Generated Simplified Auto Generated RagDollRagDoll

Page 33: Automatic Generation of Dynamics Models

Detailed Auto Generated Detailed Auto Generated RagdollRagdoll

Page 34: Automatic Generation of Dynamics Models

Video : Auto Generated Video : Auto Generated RagDoll Models Simulated RagDoll Models Simulated

with the PhysX SDKwith the PhysX SDK

Page 35: Automatic Generation of Dynamics Models

Auto Generated Auto Generated ConstraintsConstraints

The previous example showed how to The previous example showed how to create a ragdoll from a skeletal create a ragdoll from a skeletal deformed mesh rigged up by an artist. deformed mesh rigged up by an artist.

If you don’t have an already rigged up If you don’t have an already rigged up skeletal deformed mesh but still want skeletal deformed mesh but still want to get a fast ragdoll or cheap illusion of to get a fast ragdoll or cheap illusion of soft body then a skeletal deformed soft body then a skeletal deformed mesh can be automatically generated.mesh can be automatically generated.

Page 36: Automatic Generation of Dynamics Models

Auto Generated Auto Generated ConstraintsConstraints

First generate an oriented bounding First generate an oriented bounding volume system for the raw source mesh.volume system for the raw source mesh.

This is easy to implement because all we This is easy to implement because all we have to do is disable the merge portion have to do is disable the merge portion of the convex decomposition algorithm.of the convex decomposition algorithm.

By removing the merge option the By removing the merge option the system is much more balanced and will system is much more balanced and will simulate more realistically.simulate more realistically.

Page 37: Automatic Generation of Dynamics Models

Auto Generated Auto Generated ConstraintsConstraints

Original Raw Source Mesh : No Skeleton No Bone

Weightings

Auto-Generated Oriented Bounding Volume System using

Approximate Convex Decomposition without Merge

Page 38: Automatic Generation of Dynamics Models

Auto Generated Auto Generated ConstraintsConstraints

Auto-generating the constraints uses a recursive Auto-generating the constraints uses a recursive algorithm that begins with finding the largest volume algorithm that begins with finding the largest volume hull in the decomposed object. The largest hull is hull in the decomposed object. The largest hull is used as the root node for the skeleton.used as the root node for the skeleton. From this hull locate all hulls which ‘touch it’.From this hull locate all hulls which ‘touch it’. Touching is determined by finding two triangles which have Touching is determined by finding two triangles which have

roughly the same vector normal pointing in opposite roughly the same vector normal pointing in opposite directions.directions.

If the two triangles lie along the same plane, then they are If the two triangles lie along the same plane, then they are projected into 2d along that plane and a 2d triangle-triangle projected into 2d along that plane and a 2d triangle-triangle intersection test is performed.intersection test is performed.

If these two triangles intersect then they are considered If these two triangles intersect then they are considered ‘touching’ and are added to an intersection bounding ‘touching’ and are added to an intersection bounding volume.volume.

If the two hulls were found to be touching then the median If the two hulls were found to be touching then the median intersection point of those touching surfaces becomes the intersection point of those touching surfaces becomes the anchor point for the constraint.anchor point for the constraint.

This same process is repeated for every hull in the object, This same process is repeated for every hull in the object, each time starting with the last hulls that were connected.each time starting with the last hulls that were connected.

In the end each hull will have a single constraint at the In the end each hull will have a single constraint at the location where it touches a neighbor hull.location where it touches a neighbor hull.

Page 39: Automatic Generation of Dynamics Models

Auto Generated Skinned Auto Generated Skinned MeshesMeshes

Once the auto-generated constrained rigid Once the auto-generated constrained rigid body system has been saved there are now body system has been saved there are now run-time considerations.run-time considerations. A skeletal deformed mesh has to be created from A skeletal deformed mesh has to be created from

the original raw source mesh. This could be done the original raw source mesh. This could be done as a pre-process step but is more powerful to do as a pre-process step but is more powerful to do on the fly at run time.on the fly at run time.

Converting the raw mesh to a skeletal deformed Converting the raw mesh to a skeletal deformed mesh requires that each vertex be assigned bone mesh requires that each vertex be assigned bone indices and bone weightings.indices and bone weightings.

For each vertex in the source mesh, compute the For each vertex in the source mesh, compute the four nearest bones (rigid bodies) and the distance four nearest bones (rigid bodies) and the distance of those bones from the vertex.of those bones from the vertex.

Compute the weighting of each bone based on the Compute the weighting of each bone based on the ratio of the distance of that bone relative to the ratio of the distance of that bone relative to the sum total of the distances of all four. An sum total of the distances of all four. An additional weighting bias can be applied if desired additional weighting bias can be applied if desired (Example: 4x bone1, 2x bone2, 1x, bone 3 and 4.)(Example: 4x bone1, 2x bone2, 1x, bone 3 and 4.)

Page 40: Automatic Generation of Dynamics Models

Video : Auto-Generated Video : Auto-Generated constrained system mapped to an constrained system mapped to an

auto-generated skinned meshauto-generated skinned mesh

Page 41: Automatic Generation of Dynamics Models

Auto-Generated Pre-Fractured Auto-Generated Pre-Fractured ObjectsObjects

The same technique used to produce skeletal The same technique used to produce skeletal meshes from raw mesh data can be applied meshes from raw mesh data can be applied for pre-fractured objectsfor pre-fractured objects Do not disable the merge in this case.Do not disable the merge in this case. Constraints are generated against fewer shapes at Constraints are generated against fewer shapes at

more natural break boundaries.more natural break boundaries. The constraints are rigged up to be fixed joints with The constraints are rigged up to be fixed joints with

a particular breaking force based on game design.a particular breaking force based on game design. The difficult part is producing fracture artwork. The difficult part is producing fracture artwork.

This is a ‘This is a ‘hardhard’ problem, but not unsolvable. ’ problem, but not unsolvable. Currently the CreateDynamics toolkit cannot Currently the CreateDynamics toolkit cannot produce pre-fracture graphics, only pre-fracture produce pre-fracture graphics, only pre-fracture physics.physics.

Page 42: Automatic Generation of Dynamics Models

VideoVideo

Page 43: Automatic Generation of Dynamics Models

Cloth AuthoringCloth Authoring

Cloth is simulated based on a source Cloth is simulated based on a source triangle mesh. triangle mesh. Authoring is straightforward as the physics Authoring is straightforward as the physics

representation is simply the source triangle representation is simply the source triangle mesh with duplicate vertex positions mesh with duplicate vertex positions removed.removed.

Additional data associated with cloth are Additional data associated with cloth are numerous physics properties describing how numerous physics properties describing how the simulation should behave.the simulation should behave.

Attachment points must be captured where Attachment points must be captured where needed.needed.

Page 44: Automatic Generation of Dynamics Models

Cloth at Run-TimeCloth at Run-Time The graphics representation of the cloth usually The graphics representation of the cloth usually

does not exactly match up to the physics does not exactly match up to the physics representation due to material assignments.representation due to material assignments. A mapping table must exist between the indices in the A mapping table must exist between the indices in the

physics mesh to the indices in the graphics mesh.physics mesh to the indices in the graphics mesh. Additional challenges arise from dealing with torn cloth Additional challenges arise from dealing with torn cloth

which creates new triangle indices, and those indices which creates new triangle indices, and those indices must be remapped to the graphics representation on the must be remapped to the graphics representation on the fly.fly.

Double sided cloth can be visualized using a Double sided cloth can be visualized using a shader that renders the cloth twice; flipping the shader that renders the cloth twice; flipping the normals and culling direction on the back side.normals and culling direction on the back side.

Cloth is typically authored in a ‘rest pose’ so a Cloth is typically authored in a ‘rest pose’ so a simulation may need to be run a number of frames simulation may need to be run a number of frames before rendering it initially to avoid watching the before rendering it initially to avoid watching the cloth ‘fall into place’.cloth ‘fall into place’.

Page 45: Automatic Generation of Dynamics Models

Cloth Simulation VideoCloth Simulation Video

Page 46: Automatic Generation of Dynamics Models

Authoring FluidsAuthoring Fluids Fluids are represented as a set of Fluids are represented as a set of

simulation properties and emitters. simulation properties and emitters. 3D fluids have numerous and often complex 3D fluids have numerous and often complex

physical properties that influence the physical properties that influence the behavior of the simulation.behavior of the simulation.

Emitters can be attached to rigid body Emitters can be attached to rigid body actors.actors.

Numerous emitter properties can be edited as Numerous emitter properties can be edited as well.well.

A real-time preview tool to rapidly iterate A real-time preview tool to rapidly iterate on fluid properties is essential to achieve on fluid properties is essential to achieve good results.good results.

Page 47: Automatic Generation of Dynamics Models

Rendering FluidsRendering Fluids The challenges in turning a set of 3d points The challenges in turning a set of 3d points

into a compelling visual illusion of fluid into a compelling visual illusion of fluid surfaces would take a whole talk by itself.surfaces would take a whole talk by itself.

Think outside the box. Just because you are Think outside the box. Just because you are using a physics simulation called ‘fluids’ using a physics simulation called ‘fluids’ doesn’t mean you have to visualize it as a fluid doesn’t mean you have to visualize it as a fluid surface.surface. SmokeSmoke SparksSparks Micro-DebrisMicro-Debris FogFog Energy fieldsEnergy fields And whatever your artists imagination can come up And whatever your artists imagination can come up

with.with.

Page 48: Automatic Generation of Dynamics Models

Common Fluid Common Fluid Visualization MethodsVisualization Methods

SpritesSprites Each fluid particle is rendered using a camera Each fluid particle is rendered using a camera

facing billboard sprite.facing billboard sprite. Excellent opportunity to use hardware point sprites.Excellent opportunity to use hardware point sprites. Multi-Pass techniques on each sprite can produce Multi-Pass techniques on each sprite can produce

interesting layered effects.interesting layered effects. Full Screen multipass effects can produce the illusion Full Screen multipass effects can produce the illusion

of refraction and reflection by rendering sprites as of refraction and reflection by rendering sprites as normals which are then Gaussian blurred in an off-normals which are then Gaussian blurred in an off-screen buffer.screen buffer.

Surface MeshSurface Mesh Algorithm by Matthias MuellerAlgorithm by Matthias Mueller Performs mesh operations in 2d and then back-Performs mesh operations in 2d and then back-

projects the results producing a highly efficient projects the results producing a highly efficient 3d mesh.3d mesh.

Page 49: Automatic Generation of Dynamics Models

Video : Screen Space Video : Screen Space SurfacesSurfaces

Page 50: Automatic Generation of Dynamics Models

Video : Comparison Fluid Video : Comparison Fluid Visualization TechniquesVisualization Techniques

Page 51: Automatic Generation of Dynamics Models

Video Video

Page 52: Automatic Generation of Dynamics Models

Soft Body AuthoringSoft Body Authoring Soft Bodies are simulated as a tetrahedral Soft Bodies are simulated as a tetrahedral

volumetric mesh.volumetric mesh. Similar to the cloth simulation presented in the Similar to the cloth simulation presented in the

paper ‘Position Based Dynamics’ authors paper ‘Position Based Dynamics’ authors Matthias Müller, Bruno Heidelberger, Marcus Hennix, and John Ratcliff. (http://graphics.ethz.ch/~mattmuel/publications/posBasedDyn.pdf)

Rather than solving for stretching along vertex edges instead solve for conservation of volume.

Highly dependent upon the quality of the input tetrahedral mesh.

Page 53: Automatic Generation of Dynamics Models

Soft Body AuthoringSoft Body AuthoringMathias Mueller-Fischer, PhDMathias Mueller-Fischer, PhD

http://graphics.ethz.ch/~mattmuel/http://graphics.ethz.ch/~mattmuel/Ageia TechnologiesAgeia Technologies

Begin with arbitrary 3d meshBegin with arbitrary 3d mesh Does not need to be a closed mesh.Does not need to be a closed mesh.

Generate an isosurface for the input mesh.Generate an isosurface for the input mesh. Generate an iso-surface of the distance field to the triangle Generate an iso-surface of the distance field to the triangle

mesh and triangulate it via marching cubes.mesh and triangulate it via marching cubes. Perform a quadric mesh optimization on the isosurfacePerform a quadric mesh optimization on the isosurface

This is a mesh simplification technique which does not affect This is a mesh simplification technique which does not affect the morphology of large scale features. This will produce the morphology of large scale features. This will produce fewer tetrahdrons without affecting the visual quality of the fewer tetrahdrons without affecting the visual quality of the simulation and, therefore, simulate faster.simulation and, therefore, simulate faster.

Using the optimized isosurface mesh perform the delaunay Using the optimized isosurface mesh perform the delaunay tetrahedralization to produce the set of tetrahedrons for tetrahedralization to produce the set of tetrahedrons for simulation. Adding randomly distributed vertices inside simulation. Adding randomly distributed vertices inside the isosurface will reduce the tetrahedral size.the isosurface will reduce the tetrahedral size.

Finally allow the user the option of editing individual Finally allow the user the option of editing individual tetrahedron based on game design needs.tetrahedron based on game design needs.

Page 54: Automatic Generation of Dynamics Models

Soft Body VisualizationSoft Body Visualization Use free form deformation to produce the real-time Use free form deformation to produce the real-time

graphics mesh synchronized to the tetrahedral physics graphics mesh synchronized to the tetrahedral physics simulation.simulation. For each vertex in the graphics mesh compute the nearest For each vertex in the graphics mesh compute the nearest

tetrahedron to it.tetrahedron to it. Compute the set of barycentric coordinates that map the four Compute the set of barycentric coordinates that map the four

vertices of the tetrahedron to the single vertex on the graphics vertices of the tetrahedron to the single vertex on the graphics mesh.mesh.

These barycentric coordinates can be pre-computed and stored These barycentric coordinates can be pre-computed and stored as part of the graphics mesh data, or can be built on the fly as part of the graphics mesh data, or can be built on the fly when the mesh is initially loaded.when the mesh is initially loaded.

During rendering, for each vertex in the graphics mesh deform During rendering, for each vertex in the graphics mesh deform it by the projection of the tetrahedron that maps to that vertex it by the projection of the tetrahedron that maps to that vertex using the current positions and the previously computed using the current positions and the previously computed barycentric values.barycentric values.

This deformation is difficult to perfom in a vertex shader This deformation is difficult to perfom in a vertex shader unless, perhaps under DirectX 10. Even then, the operation is unless, perhaps under DirectX 10. Even then, the operation is so fast in software that it difficult to imagine significant so fast in software that it difficult to imagine significant performance gains.performance gains.

Page 55: Automatic Generation of Dynamics Models

VideoVideo

Page 56: Automatic Generation of Dynamics Models

VideoVideo

Page 57: Automatic Generation of Dynamics Models

The Production PipelineThe Production Pipeline For each source asset in the product generate For each source asset in the product generate

a default INI file.a default INI file. The default file should correspond to the minimum The default file should correspond to the minimum

expected set of physics models required for any expected set of physics models required for any asset. Typically this would include a raycast asset. Typically this would include a raycast version, a static collision version, and a dynamic version, a static collision version, and a dynamic collision version.collision version.

Provide a user interface within the game editor Provide a user interface within the game editor that allows designers to modify all of the default that allows designers to modify all of the default settings and add additional physical settings and add additional physical representations.representations.

Save the INI file as a permanent asset that Save the INI file as a permanent asset that corresponds to the source graphics model. The corresponds to the source graphics model. The physics assets only need to be regenerated if the physics assets only need to be regenerated if the morphology of the graphics asset changes or the morphology of the graphics asset changes or the user makes explicit editing changes.user makes explicit editing changes.

Page 58: Automatic Generation of Dynamics Models

The Production PipelineThe Production Pipeline During game editing or prior to producing final During game editing or prior to producing final

production assets.production assets. Auto-generate the various physics versions for each asset Auto-generate the various physics versions for each asset

by using the CreateDynamics library. This will produce by using the CreateDynamics library. This will produce an ASCII version of the physics representation as either an ASCII version of the physics representation as either COLLADA or NxuStream. COLLADA or NxuStream.

Since the COLLADA specification cannot represent many Since the COLLADA specification cannot represent many of the types of physics presented here; cloth, soft body, of the types of physics presented here; cloth, soft body, fluids, heightfields, it is recommended to use NxuStream.fluids, heightfields, it is recommended to use NxuStream.

If you do not use the PhysX SDK or COLLADA it is easy If you do not use the PhysX SDK or COLLADA it is easy to modify the source code in CreateDynamics to output to modify the source code in CreateDynamics to output the physics data in a format that is of your choosing. the physics data in a format that is of your choosing. (Accumulate.cpp)(Accumulate.cpp)

Store the various ASCII versions of the physics asset in Store the various ASCII versions of the physics asset in your repository for day to day use.your repository for day to day use.

Page 59: Automatic Generation of Dynamics Models

The Production PipelineThe Production Pipeline At run-time, and for final production content, convert the At run-time, and for final production content, convert the

XML version of the art assets into a binary cooked form.XML version of the art assets into a binary cooked form. The XML version can be converted into a binary representation The XML version can be converted into a binary representation

very easily and quickly.very easily and quickly. The binary versions are not backwards compatible and should The binary versions are not backwards compatible and should

never be used as a persistent storage format for the physics data.never be used as a persistent storage format for the physics data. It is best to create the binary versions on the fly on the users It is best to create the binary versions on the fly on the users

machine and store it in a local repository.machine and store it in a local repository. During level load time, the pre-cooked binary assets are During level load time, the pre-cooked binary assets are

in a format that can be rapidly submitted to the physics in a format that can be rapidly submitted to the physics engine. Not only is parsing of XML and other ASCII data engine. Not only is parsing of XML and other ASCII data avoided, but all mesh preprocessing is bypassed as well.avoided, but all mesh preprocessing is bypassed as well.

Extremely fast level load times can be achieved using Extremely fast level load times can be achieved using this technique. Massive game levels can be loaded and this technique. Massive game levels can be loaded and submitted to a physics engine in under a second.submitted to a physics engine in under a second.

Page 60: Automatic Generation of Dynamics Models

The Future of The Future of CreateDynamicsCreateDynamics

This is a ‘hobby’ project and while it is being used This is a ‘hobby’ project and while it is being used in a production environment no guarantees can in a production environment no guarantees can be made as to a schedule of features, bug fixes, or be made as to a schedule of features, bug fixes, or support.support.

Open to discussion for collaboration or Open to discussion for collaboration or sponsorship of the future development of these sponsorship of the future development of these tools.tools.

Special thanks to: Special thanks to: Matthias Muller, Pierre Matthias Muller, Pierre Terdiman, Adam Moravansky, Billy Zelsnack, Terdiman, Adam Moravansky, Billy Zelsnack, Dilip Sequeira, James Dolan, James Golding, Dilip Sequeira, James Dolan, James Golding, David Whatley, Simon Schirm, Erwin Coumans, David Whatley, Simon Schirm, Erwin Coumans, Christian Laforte, Stan Melax, Worshipful Brother Christian Laforte, Stan Melax, Worshipful Brother Lou Castle, Jesus Christ, Mahatma Ghandi, etc.Lou Castle, Jesus Christ, Mahatma Ghandi, etc.

Page 61: Automatic Generation of Dynamics Models

Questions???Questions???

Contact:Contact: John W. RatcliffJohn W. Ratcliff Email: Email: [email protected]@infiniplex.net Coding website: Coding website:

www.codesuppository.comwww.codesuppository.com Skype: jratcliff63367Skype: jratcliff63367 Skype Phone: US (636)-486-4040Skype Phone: US (636)-486-4040 Karma Contribution Site: Karma Contribution Site:

www.amillionpixels.uswww.amillionpixels.us