本文整理汇总了C++中Cone::SetValues方法的典型用法代码示例。如果您正苦于以下问题:C++ Cone::SetValues方法的具体用法?C++ Cone::SetValues怎么用?C++ Cone::SetValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cone
的用法示例。
在下文中一共展示了Cone::SetValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RotateGameObject
Float RotateGameObject(Script * script)
{
if (script->VerifyArguments(3) == true)
{
Word * rotatePosWord = script->GetNextWord();
Point2D rotatePosition(0, 0);
Point2D * rotatePos = (Point2D *)(uint32)rotatePosWord->value;
if (rotatePos != NULL)
{
rotatePosition.SetValues(rotatePos->GetX(), rotatePos->GetY());
}
Word * angleWord = script->GetNextWord();
Word * directionWord = script->GetNextWord();
Vector3D direction(0, 0, 0);
Point2D * dirVector = (Point2D *)(uint32)directionWord->value;
if (dirVector != NULL)
{
direction.SetValues(dirVector->GetX(), dirVector->GetY(), 0);
}
GameObject * source = (GameObject *)script->GetSource();
Shape * shape = source->GetShape();
if ((rotatePos != NULL) && (source != NULL) && (source->CheckType(OBJ_TYPE_GAME_OBJECT) == true) && (shape != NULL))
{
Float distance = CalculateDistance(rotatePosition, source->GetPosition());
if (angleWord->value != NULL)
{
Vector3D sourceDirection(rotatePosition, source->GetPosition());
Float angle = sourceDirection.GetZeroAngleD() + angleWord->value;
source->SetPosition(rotatePosition.GetX() + (distance * CosD(angle)),
rotatePosition.GetY() + (distance * SinD(angle)));
direction.SetValues(rotatePosition, source->GetPosition());
direction.SetUnitVector();
}
else if (dirVector != NULL)
{
direction -= rotatePosition;
direction.SetUnitVector();
source->SetPosition(rotatePosition.GetX() + (direction.GetX() * distance),
rotatePosition.GetY() + (direction.GetY() * distance));
}
else
{
return false;
}
if ((shape->GetType() == SHAPE_TYPE_LINE) || (shape->GetType() == SHAPE_TYPE_LINE_SEGMENT))
{
Line * line = (Line *)shape;
Line * newLine = (Line *)line->CreateInstance();
newLine->Translate(source->GetPosition());
Vector3D v1(rotatePosition, newLine->GetPoint1());
Vector3D v2(rotatePosition, newLine->GetPoint2());
Float baseAngle = direction.GetZeroAngleD();
Float v1Length = v1.GetLength();
Float v2Length = v2.GetLength();
Float angle1 = v1.GetZeroAngleD() - baseAngle;
Float angle2 = v2.GetZeroAngleD() - baseAngle;
Point2D p1((v1Length * CosD(angle1)),
(v1Length * SinD(angle1)));
Point2D p2((v2Length * CosD(angle2)),
(v2Length * SinD(angle2)));
line->SetValues(p1 + rotatePosition, p2 + rotatePosition);
line->Translate(!source->GetPosition());
delete newLine;
}
else if (shape->GetType() == SHAPE_TYPE_CONE)
{
Cone * cone = (Cone *)shape;
cone->SetValues(cone->GetVertex(), Vector3D(dirVector->GetX(), dirVector->GetY(), 0), cone->GetHeight(), cone->GetAngle());
}
return true;
}
}
return false;
}