Game Development Reference
In-Depth Information
p A
p p' B
B
Figure5.7. Insteadofthepenetration-depthvector,weusetheinterpolatedsurfacenormal
at p A fortrianglemeshes.Thecontactpoint p B ismappedto p B inordertoalignitwith
thesurfacenormal.
coordinatesforthepointonatriangleisnotdifficult.Wesimplyneedtoaddthe
barycentriccoordinatesoftheduplicateverticestofindthecoordinatesforthat
vertex.Ithelpstostoreavertexindex0,1,or2witheachofthesupportpointsto
quicklyfindduplicatesandstorethebarycentriccoordinatesinthecorrectorder.
Afterchangingtheorientationofthecontactplanetotheinterpolatedsurface
normalofthemesh,theclosestpointonthequeryobjectisnolongeralignedwith
theclosestpointonthemeshandshouldberemapped.Otherwise,theobjectsmay
receiveanunwantedtorquefromthecontactsolver.Apropercontactpointonthe
boundaryofthequeryobjectcanbefoundbymultiplyingtheinterpolatedsurface
normalbythepenetrationdepthandsubtractingitfromthecontactpointonthe
mesh.Let p A and p B betheclosestpointson,respectively,themeshandthe
queryobject,andlet n betheinterpolatedsurfacenormal.Then,thecorrected
contactpoint p B onthequeryobjectiscomputedas
p B = p A
n
p A
p B
.
Figure5.7illustratestheremappingofthecontactpoint.Notethatthecorrected
contactpointmaynotlieperfectlyontheboundaryofthequeryobject,butfor
ourpurposesitisgoodenough.
Vertexnormalsareusuallycreatedbyacontent-creationtoolandarestored
withvertexpositionsinthemesh.Theyarenothardtocompute,incasetheyare
missinginthecollisionmesh.Avertexnormalistheweightedsumoftheface
normalsoftheadjacenttriangles.Asaweighttheangleofthetriangle'sedgesat
thevertexshouldbeused.Withouttheanglesasweights,thenormalswouldbe
pulledtoomuchtowheretherearemanyadjacenttriangles.Theangledefinesthe
amountof“pull”thatatrianglecanhaveonavertexnormal.
Asingraphics,moredetailcanbeaddedbyusinganormalmapratherthan
aninterpolatednormal.Anormalmapisatwo-dimensionaltextureimagethat
containsnormal x;y;z -coordinatesratherthanRGBcolors.Insteadofthevertex
 
Search Nedrilad ::




Custom Search