Graphics Reference
In-Depth Information
class CArm : public UWB _ SceneNode {
Source file. Arm.h/cpp files
in the Model folder of the
D3D _ SceneNodeArm project.
A:
CArm( vec3 at, const char * name = "Arm");
.
}
CArm::CArm( vec3 at, const char * name) : UWB _ SceneNode(name)
B:
m _ xform.SetPivot(at); // Pivot of M a is the Arm location
UWB _ PrimitiveRectangle * pRectangle = new UWB _ PrimitiveRectangle(); // memory for R a 0
// sets R a 0 geometry based on at position
.
C:
UWB _ PrimitiveList * pArmPrim = new UWB _ PrimitiveList(); // Memory for a PrimitiveList
pArmPrim->Append(pRectangle); // insert R a 0 into list
D:
SetPrimitive(pArmPrim); // m _ pPrimitive is a PrimitiveList
.
E:
UWB _ SceneNode * pPalm= new CPalm( vec3 (at.x+4,at.y,at.z); // Palm is at 4 unit in X from Arm
InsertChildNode(pPalm); // insert the allocated CPalm as a child
F:
Listing 11.7. The CArm class of Tutorial 11.4.
class CModel {
Source file. Model.h/cpp
files in the Model folder of the
D3D _ SceneNodeArm project.
// ... similar to Tutorial 11.3 ...
CArm m _ OneArm;
A:
// This is the arm
void DrawModel();
// Draw everything in the CModel
};
CModel::CModel() : ...
// Constructor:
m _ OneArm( vec3 (0,0,0) )
B:
// initialize the arm to locate at (0,0,0)
{ ... }
void CModel::DrawModel()
C:
m _ OneArm.Draw(lod, m _ DrawHelper);
// Draws the SceneNode hierarchy
.
Listing 11.8. The CModel class of Tutorial 11.4.
is created and inserted as a child of the CArm object. Listing 11.8 shows that with
the CArm class, the CModel class only needs to define (label A) and instantiate
the CArm object at a proper location (label B). As in the case of Tutorial 11.3, the
drawing of the arm is accomplished by calling the Draw() function (label C).
Search WWH ::




Custom Search