Graphics Reference
In-Depth Information
Source file.
Pseudocode; no
corresponding source file.
bool CModel::ComputeFrontVelocity()
// Step 1. Compute the current V f -- Shown in Listing 12.2
// Step 2. Compute and decrease
θ -- Shown in Listing 12.3
// Step 3. Compute the velocity for moving the Arm -- Shown in Listing 12.4
Listing 12.1. The ComputeFrontVelocity() function.
bool CModel::ComputeFrontVelocity( float sec) {
.
Source file.
Model _ MoveToTarget.cpp
file in the Model folder of
the D3D _ OrientationIn2D
project.
// initPos= p w o ; front= p w f ; frontDir= V wc
f
A:
vec3 front(1,0,0), initPos(0,0,0), frontDir;
// Arm's OC to WC Xform ( M a from Figure 12.3 )
UWB _ XformInfo axf = m _ pArmDrive->GetXformInfo();
// Initiate scene graph traversal
dh.PushModelTransform();
// to compute OC->WC xform
B:
dh.InitializeModelTransform();
// TopofStack= M a (Arm's OC->WC xform matrix)
axf.SetUpModelStack(dh);
// Compute p wc
f
= p oc
f
M a
C:
dh.TransformPoint(front);
// Compute p w o = p o o M a
dh.TransformPoint(initPos);
dh.PopModelTransform();
// Compute V wc
f
= p w f p wc
o
D:
frontDir = front - initPos;
. //contiune with code from Listing 12.3 : compute and decrease
θ
Listing 12.2. Step 1: Compute the forward direction ( V wc
f
).
We can decrease
θ
by changing the rotation angle of M a accordingly. In our Tu-
Ta rg e t p o s i t i o n ( p t ). Notice
that the target position p t
is specified by the user's
left mouse button click
(in DC). As discussed in
Section 10.5 and demon-
strated in Tutorial 10.14, the
WindowHandler supports the
DC-to-WC transform. We
must transform mouse click
p t to the WC space.
torial 12.1 implementation, we call CModel::ComputeFrontVelocity() during
every timer event service to turn and move the arm object gradually toward the
target position. Listing 12.1 shows that our implementation can be described as
three main steps, to be detailed in the following listings. Listing 12.2 shows the
details of the first step. The OC positions are defined at label A. At label B, we
imitate the scene graph traversal procedure by setting up the matrix stack and
loading the M a matrix to the top of the matrix stack. At label C, the WC posi-
tions are computed. Finally, at label D, the front direction of the arm in WC is
Search WWH ::




Custom Search