3d game engine design 1 3d game engine design ch. 2.5. 3d map lab
TRANSCRIPT
3D Game Engine Design 1
3D Game Engine Design3D Game Engine DesignCh. 2.5.Ch. 2.5.
3D MAP LAB
3D Game Engine Design 2
2.5. Standard 3D Objects2.5. Standard 3D Objects Useful as bounding regions for
Rapid culling in the rendering process Rapid determining of the collision
detection of two objects
Primitives Spheres Oriented Boxes Capsules, Lozenges Ellipsoids and etc.
3D Game Engine Design 3
Center Point and Radius with points
Sphere Containing Axis-Aligned Box Compute the minimum-volume axis-
aligned bounding box Select the smallest enclosing sphere of
the box with centered at the box center Rapid, but not as good a fit.
SpheresSpheresn
iiV
0}{
22
rcx
3D Game Engine Design 4
Spheres Spheres (cont’d)
Sphere Centered at Average of Points Sphere Center : Average of Points Sphere Radius : Smallest value from cent
er to points enclosing all points 2x Iteration than Axis-Aligned box method
Minimum-Volume Sphere (Welzl 91) Uses a randomized linear algorithm Maintain a set of supporting points( lying
on the sphere) while processing the input point set at a time.
3D Game Engine Design 5
Oriented BoxesOriented Boxes
Oriented Box Provide a better fit than spheres Defined by
A center 3 Orthonormal Axes for 3 extents of Axes
, points inside or on the box Orthonormal matrix where
C
i U
0 i e2, 1, 0 i
YR C X
X
) , , (2 1 0y y y Y
] , , [2 1 0U U U R
3D Game Engine Design 6
Oriented Boxes Oriented Boxes (cont’d)
Axis-Aligned Box Find the extreme points and
Fitting with a Gaussian Distribution Gaussian Distribution
: mean of the distribution : the covariance matrix of the distributi
on Fitting points with anisotropic gaussian di
stribution
min P
max P
)) ( ) exp((1
C X M C X AT
C
M
3D Game Engine Design 7
Oriented Boxes Oriented Boxes (cont’d)
Fitting with a Gaussian Distribution
Axes of the box : unit-length eigenvectors of covariance matrix M
Extents :
n
jj V
nC
0
1 T
j
n
jjC V C V
nM) () (
10
) ( maxC V U ej i j i
3D Game Engine Design 8
Oriented Boxes Oriented Boxes (cont’d)
Minimum-Volume Box Best-fitting box : the minimum volume con
taining the points Iterative scheme for a minimization
For any coordinate axes , points are projected onto the axes
The values :
i Ai As V
0
) (0 V V Aj i ij
) ( minij j i ) ( maxij j i 2
) (i ii
3D Game Engine Design 9
Oriented Boxes Oriented Boxes (cont’d)
Iterative Minimization for M-V Box Center of the minimum-volume box
Extents of the minimum-volume box
Selection of coordinate axes : unit length vector and an
angle The volume of Box : Find that minimizes the volume
2
00
jj jA V C
2/ ) (i i i e
i U
) , ( ) , (0 0 U U
i A
) , ( U
i U
3D Game Engine Design 10
Oriented Boxes Oriented Boxes (cont’d)
Fitting Triangles with Gaussian Distribution Data points : vertices of a triangle mesh Fit of an oriented box to the convex hull of the v
ertices triangles , i-th triangle Triangle and its interior
Mean point of the convex hull
l i i i oV V V., 2 ., 1 .,, ,
1 0 , 1 0 for ), ( ) ( ) , (., ., 2 ., ., 1 ., t s V Vt V Vs V t s Xi o i i o i i o i
2
0,
1
0 3
1j
i j
l
ijV
lC
3D Game Engine Design 11
Oriented Boxes Oriented Boxes (cont’d)
Fitting Triangles with Gaussian Distribution Covariance matrix of the convex hull
Axes of Oriented Box :
unit length eigenvectors of M Extents of Oriented Box :
2
0
2
0, ,
1
0
) )( (12
1jk
T
i k i j
l
ijC V C V
lM
i A
) ( maxC X A ej i j i
3D Game Engine Design 12
CapsulesCapsules Capsule
The set of all points that are distant from a line segment with end point and direction
Shape : a cylinder that has 2 hemispherical caps at the end points
Least square fitting Line fitting : , where average of
the data points and unit-length direction vector
to be the maximum distance from the data points to Line
0 rPD
WtA
i AW
0 r
3D Game Engine Design 13
Capsules Capsules (cont’d)
Least Square Fitting Select unit axes vectors and set
Data points Find the domain of for the 2
hemisphere at end
Find the largest so that all points lie above the hemisphere
V &
UYR A X
] , [1 0 t
0 2 2
0
2 2) (r w v u
}) ( min{2 2 2
0i i iv u r w
0
3D Game Engine Design 14
Capsules Capsules (cont’d)
Least Square Fitting Find the smallest so that all points lie
below the hemisphere
End points :
Minimum of minimum-Area Projected Circles Projection of points onto the Plane Compute the minimum-area circle of
projected points and find and
1
}) ( max{2 2 2
1i i iv u r w
W A Pj j
0 X W
0 r ] , [1 0 t
3D Game Engine Design 15
LozengesLozenges
Lozenges Set of all points that are distant
from a rectangle with origin and edge directions
Shape : an oriented rectangle with Attached 4 half-cylinder sides 4 quarter-spherical corners
0 rP1 0 and E E
3D Game Engine Design 16
LozengesLozenges
Fitting with a Gaussian Distribution Compute the mean of the points and t
he covariance matrix M Unit-length eigenvectors of the M : Data points : Data points are bounded by 2 planes
Lozenge radius : A
W V, U
and ,
i i i i i i iWw Vv Uu A X
min ) (w A X W
max ) (w A X W
2/ ) (min maxw w r
3D Game Engine Design 17
Lozenges Lozenges (cont’d)
Fitting with a Gaussian Distribution Lozenge edge : end of the hem
icylinder Find the Lozenge edge
Analogous to the fitting by 3D capsule 2D capsule containing
The largest so that all points lie above the hemicircle
1 0 and E E
) , (i iw v
2 2
0
2 2) (r v w
0
} { min2 2
0i
i iw r v
3D Game Engine Design 18
Lozenges Lozenges (cont’d)
Fitting with a Gaussian Distribution Find the Lozenge edge
The smallest so that all points lie below the hemicircle
The Lozenge edge1
} { max2 2
1i
i iw r v
V E
) (0 1 1
U E
) (0 1 0
3D Game Engine Design 19
CylindersCylinders
Cylinder A distance from a line
Least Squares Line Contains Axis Fit the points by a line using the least-
square algorithm , where average of the data
points and unit-length direction vector Select unit axes vectors and set
Data points
0 r Dt P
R t
WtA
WtA
i A W
V, U YR A X
3D Game Engine Design 20
Cylinders Cylinders (cont’d)
Least Squares Line Contains Axis Cylinder radius : Cylinder height : Modified Axis
Least Squares Line Moved to a Minimum-Area Center Minimum-area circle containing is
computed and has center
} max{2 2
i iv u r min maxw w h
Www
AA
2maxmin
) , (i iv u) , (v u
3D Game Engine Design 21
EllipsoidsEllipsoids
Ellipsoid Center Orthonormal axis directions The ellipsoid with center and axes
C
2 0 for i Ui
1 ) ( ) ( C X DR R C XT T
} / 1, / 1, / 1{2
2
2
1
2
0d d d diag D
i UC
i U
3D Game Engine Design 22
Ellipsoids Ellipsoids (cont’d)
Axis-Aligned Ellipsoid Firstly generate the axis-aligned box cont
aining the points be the vectors of the min/m
ax box components Compute the ratios of semi-axis lengths
Semi-Axis Lengths
max min and P P
2/ ) (max minP P C
) , , ( 2/ ) (2 1 0 min max P P
} / 1, / 1, / 1{
)} ( ) {( max /
2 1 0 diag D
C V D C V D DR R Mi
T
i i
T
0
3D Game Engine Design 23
Ellipsoids Ellipsoids (cont’d)
Fitting Points with a Gaussian Distribution Similar to the case of an oriented box Center of the ellipsoid : the mean of points Axes : eigenvectors of the covariance matrix Semi-Axis Lengths : eignevalues
} / 1, / 1, / 1{
)} ( ) {( max /
2 1 0 diag D
C V DR R C V DR R Mi
T T
i i
T
3D Game Engine Design 24
Ellipsoids Ellipsoids (cont’d)
Minimum-Volume Ellipsoid Random Linear Techniques (Welzl 91) Constrained numerical minimization
Difficult to implement Not possible for real-time apps.