Graphics Reference
In-Depth Information
bool UWBD3D _ DrawHelper::AccumulateModelTransform( vec3 trans,
vec3 scale, vec3 rotation, vec3 pivot) {
.
Source file.
uwbgl _ D3DDrawHelper6.cpp
file in the D3D Files/
DrawHelper
// the three major axes variables
D3DXVECTOR3 xaxis(1,0,0), yaxis(0,1,0), zaxis(0,0,1);
.
// M t 1 T ( t x , t y , t z ) M t
m _ pMatrixStack->TranslateLocal(trans.x, trans.y, trans.z);
// M t 2 T ( p x , p y , p z ) M t 1
m _ pMatrixStack->TranslateLocal(pivot.x, pivot.y, pivot.z);
// M t 3 R x
folder
of
the
UWBGL _ D3D _ Lib14 project.
( θ x ) M t 2
m _ pMatrixStack->RotateAxisLocal(&xaxis, rotation.x);
// M t 4 R y
A:
( θ y ) M t 3
m _ pMatrixStack->RotateAxisLocal(&yaxis, rotation.y);
// M t 5 R z
( θ z ) M t 4
m _ pMatrixStack->RotateAxisLocal(&zaxis, rotation.z);
// M t 6 S ( s x , s y , s z ) M t 5
m _ pMatrixStack->ScaleLocal(scale.x, scale.y, scale.z);
// M t 7 T ( p x ,− p y ,− p z ) M t 6
m _ pMatrixStack->TranslateLocal(-pivot.x, -pivot.y, -pivot.z);
// M W M t 7
pDevice->SetTransform( D3DTS _ WORLD, m _ pMatrixStack->GetTop());
.
Listing 15.6. Lib14 implementation of 3D rotation.
For now, with the above implementation, we can only rotate with respect to one
of the axes. That is, we can accomplish intuitive rotation control as long as one
and only one of
θ x ,
θ y ,or
θ z has nonzero value. As we will see in the next tutorial,
as soon as more than one
θ
has nonzero value, the rotation results become almost
impossible to interpret.
Tutorial 15.1.
Project Name:
D3D _ CameraLib
Library Support:
UWB _ MFC _ Lib1
UWB _ D3D _ Lib14
Tutorial 15.1. Integration with UWBGL
Goal. Demonstrate working with the UWB _ Camera and UWB _ WindowHandler
classes and that our simple implementation of rotations in 3D does not sup-
port intuitive user interactions.
Approach. Implement the simple 3D scene of Figure 13.1 based on the
UWBGL library and support full GUI controls for model manipulations.
Search WWH ::




Custom Search