Graphics Reference
In-Depth Information
void
CModel::UpdateSimulation() {
.
UWB
_
XformInfo pxf = m
_
Plane->GetXformInfo();
//
M
t
: parent (Trophy) transform
.
UWB
_
XformInfo cxf = child->GetXformInfo();
A:
//
M
s
:child (shusui) transform
.
B:
//
P
o
,
P
y
,
P
z
: initial positions of the ref frame
vec3
pos(0,0,0), yPos(0,1,0), zPos(0,0,1);
.
pxf.SetUpModelStack(drawHelper);
// Top of stack is now:
M
t
cxf.SetUpModelStack(drawHelper);
// Top of stack is now:
M
s
M
t
// Compute:
P
o
M
s
M
t
drawHelper.TransformPoint(pos);
// Compute:
P
y
M
s
M
t
drawHelper.TransformPoint(yPos);
.
// Compute:
V
y
=
P
y
−
P
o
C:
vec3
Vy = yPos - pos;
.
vec3
nVz = pos - zPos;
// Forward direction: this is negative
z
vec3
Vx = cross(Vy, -nVz);
// This is the side vector
Vy = cross(-nVz, Vx);
// Ensure all vectors are perpendicular
normalize(Vy); ...
// Ensure all vectors are noramlized
.
D:
R[0][0]=Vx.x;
R[0][1]=Vx.y;
R[0][2]=Vx.z;
// The computed orthonomal basis is
R[1][0]=Vy.x;
R[1][1]=Vy.y;
R[1][2]=Vy.z;
// is the rotation matrix
R[2][0]=-nVz.x;R[2][1]=-nVz.y;R[2][2]=-nVz.z;
.
UWB
_
XformInfo rxf=m
_
RefNode->GetXformInfo();
// Axis Frame objects XformInfo
.
rxf.SetTranslation(pos);
E:
// Set the position to draw the axis frame
rxf.SetRotation(R);
// Orthonormal basis is the rotation matrix
m
_
RefNode->SetXformInfo(rxf);
.
UWB
_
XformInfo bxf=m
_
BallNode.GetXformInfo();
// The traveling sphere's XformInfo
.
bxf.SetTranslation(pos);
F:
// Sphere starts at the axis frame position
.
m
_
BallNode.SetVelocity(nVz);
// Sphere velocity is negative-Z direction
Listing 16.22.
Computing the orthonormal basis of a scene node.
Search WWH ::
Custom Search