Download Virtual Reality Applications
Transcript
}
/**
Adds the HHRotation2 geometry as last child to the specified griup-node parent.
The return value is the result of the operation (TRUE / FALSE).
*/
FLAG HHRotation2::addAsChild(WtGroup *parent)
{
return parent->AddChild(whole);
}
/**
Rotates the specified part of the geometry around the specified axis (X, Y, Z). The
angle radians should of course be given in radians!
*/
void HHRotation2::rotate(int axis, float radians)
{
}
/**
Rotates the specified part of the geometry according to the transformation values
read from the mouse.
*/
void HHRotation2::rotate(const float &transX, const float &transY, int part)
{
switch (part)
{
case 0:
((WtMovable*)whole)->MovAxisRotation(X, transX*PI/180);
((WtMovable*)whole)->MovAxisRotation(Y, transY*PI/180);
break;
case 1:
turretRotation(transY*PI/180);
break;
}
}
/**
Controls the specified node path if any of the movable parts of the geometry is
along it. If so, a task (HHRotationTask) is activated, which makes sure that this
sub-geometry is rotated in a specific pattern (different for different parts).
*/
void HHRotation2::chkNode(WtNodePath *nodePath)
{
int currentNodeNum;
WtNode *currentNode;
currentNodeNum = nodePath->NumNodes() - 1;
char *name;
while (0 <= currentNodeNum)
{
currentNode = nodePath->GetNode(currentNodeNum);
if (NULL != currentNode)
{
name = currentNode->GetName();
if ((turret == currentNode)||((NULL != name)&&(0 == strcmp(name, turret>GetName()))))
{
if (!taskRunning)
{
if (taskElevate) // Thus the turret is elevated; time to deelevate
{
currentAngle = 60;
taskElevate = FALSE;
}
else
// Time to elevate
{
currentAngle = 0;
taskElevate = TRUE;
}
taskRunning = TRUE;
rotationTask = new WtTask(this, HHRotation2::HHRotationTask, 1.f);
}
break;
}
}
currentNodeNum--;
}
}
71