MathEngine Collision - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

MathEngine Collision

Description:

Collision = true/false is just not good enough. ... You could write the code inbetween the Collision Toolkit and Dynaimc Toolkit yourself ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 15
Provided by: bentdalga
Category:

less

Transcript and Presenter's Notes

Title: MathEngine Collision


1
MathEngine - Collision
  • Bent Dalgaard Larsen
  • _at_imm.dtu.dk

2
Overview
  • The design of the collision engine
  • What the collision engine can do for you
  • How to use the collision engine
  • Integrating physics with the collision engine

3
Design of the collision engine
  • Designed to give the information needed for a
    physics engine. Collision true/false is just
    not good enough.
  • Physics engine is not restricted to be MathEngine
  • Farfield and nearfield testing
  • Farfield testing is the so called n-body
    processing problem, i.e. Which collisions should
    be considered
  • Nearfield testing finds the excact collision
    point when a collision occurs.

4
Structure of an application
5
Supported collision types
  • Primitives
  • Sphere, Box, Plane, Cylinder, Cone
  • Non-primitives
  • Convex mesh, Hieght field, Particles
  • Ray hit
  • Response is given as
  • Location of contact
  • The normal (i.e. what direction to move in order
    to prevent intersection)
  • Penetration depth

6
Implemented collision types
7
Initializing collision types
  • All types of used collision objects must be
    registered
  • McdPrimitivesRegisterTypes()
  • McdPrimitivesRegisterInteractions()
  • McdRGHeightFieldRegisterType()
  • McdRGHeightFieldRegisterInteractions()
  • McdConvexMeshRegisterType()
  • McdConvexMeshRegisterInteractions()
  • McdInit(McdPrimitivesGetTypeCount()x)

8
Building the space
  • Creating the collision space
  • McdSpace space McdSpaceAxisSortCreate(McdAllAxe
    s,MAX_BODIES,AVE_NEARBY_COUNTMAX_BODIES)
  • McdPairHandlerRegisterSpace(space)
  • Before building the space insert all models
  • McdSpaceBuild(space)

9
Creating collision model
  • Creating geomtry
  • McdGeometry prim McdSphereCreate (radius)
  • McdGeometry prim McdBoxCreate (x,y,z)
  • McdGeometry prim McdPlaneCreate()
  • Creating collision model
  • McdModelID model McdModelCreate(prim)
  • Defining postion and orientation of primitive
  • MeMatrix4 mat (MeMatrix4)malloc(sizeof(MeMatri
    x4))
  • McdModelSetTransformPtr(model, mat)
  • Inserting the model into collision space
  • McdSpaceInsertModel(space,model)

10
Getting results
  • First update the collisions
  • McdPairHandlerUpdate()
  • McdSpacePair pairsMAX_NUM_PAIRS
  • int pairs McdSpaceGetNewPairs(space, pairs,
    MAX_NUM_PAIRS)
  • McdIntersectResult result
  • McdIntersect(pairs0, result)
  • The collision results can now be read from result

11
Dynamic Toolkit Bridge
  • You could write the code inbetween the Collision
    Toolkit and Dynaimc Toolkit yourself
  • Or you could just use the Dynamic Toolkit Bridge
  • The bridge is prefixed with McdDt
  • The problem
  • Creating a connection between MdtBody and
    McdModel

12
Programming the bridge
  • Initialize the bridge
  • McdDtBridgeInit()
  • McdDtBridgeID bridge McdDtBridgeCreate()
  • Connecting McdBodyID and
  • McdDtBridgeSetBody(bridge,model, body)
  • Now there is no need to handle collisions
    yourself anymore.

13
Defining collision parameters
  • Now that the bridge handles the contact. How to
    get properties such as bouncyness
  • params McdDtBridgeGetContactParams(0, 0)

14
Advanced feature - compositing
  • If you e.g. want to make a chair you need to put
    several objects together.
  • MeMatrix m2Rel, m2Compound
  • McdDtBridgeSetBody(bridge, model1, body)
  • McdDtBridgeSetBody(bridge, model2, body)
  • McdDtBridgeSetRelativeTransformPtr(bridge,
    model2, m2Rel, m2Compound)
  • If the two objects collide you need to disable
    the collision detection between these two objects
  • McdModelSetInteractionDisabled(model1, model2)
Write a Comment
User Comments (0)
About PowerShow.com