本文整理汇总了C++中Matrix4::CreateScale方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4::CreateScale方法的具体用法?C++ Matrix4::CreateScale怎么用?C++ Matrix4::CreateScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4
的用法示例。
在下文中一共展示了Matrix4::CreateScale方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: v
TEST(Matrix, Scale)
{
Matrix4 scale;
scale.CreateScale(3.0f);
Vector3 v(1.0f, 1.0f, 1.0f);
v.Transform(scale);
EXPECT_NEAR(3.0f, v.GetX(), 0.01f);
EXPECT_NEAR(3.0f, v.GetY(), 0.01f);
EXPECT_NEAR(3.0f, v.GetZ(), 0.01f);
}
示例2: ApplyTransform
void EditorBodyControl::ApplyTransform(float32 x, float32 y, float32 z)
{
if (!InModificationMode())
return;
Entity *selectedNode = scene->GetProxy();
if(selectedNode)
{
Matrix4 modification;
modification.Identity();
Matrix4 t1, t2;
t1.CreateTranslation(-selectedNode->GetWorldTransform().GetTranslationVector());
t2.CreateTranslation(selectedNode->GetWorldTransform().GetTranslationVector());
switch (GetModificationMode())
{
case ResourceEditor::MODIFY_MOVE:
modification.CreateTranslation(Vector3(x, y, z));
break;
case ResourceEditor::MODIFY_ROTATE:
modification.CreateRotation(Vector3(1, 0, 0), DegToRad(x));
modification *= Matrix4::MakeRotation(Vector3(0, 1, 0), DegToRad(y));
modification *= Matrix4::MakeRotation(Vector3(0, 0, 1), DegToRad(z));
modification = (t1 * modification) * t2;
break;
case ResourceEditor::MODIFY_SCALE:
modification.CreateScale(Vector3(1, 1, 1) + Vector3(x + y + z, x + y + z, x + y + z) / 100.f);
modification = (t1 * modification) * t2;
break;
default:
break;
}
Matrix4 originalTransform = selectedNode->GetLocalTransform();
modification = originalTransform * modification;
if (IsLandscapeRelative())
{
modification = modification * GetLandscapeOffset(modification);
}
CommandsManager::Instance()->ExecuteAndRelease(new CommandTransformObject(selectedNode,
originalTransform,
modification),
scene);
}
}
示例3: PrepareModMatrix
void EditorBodyControl::PrepareModMatrix(const Vector2 & point)
{
float32 winx = point.x - touchStart.x;
float32 winy = point.y - touchStart.y;
Matrix4 modification;
modification.Identity();
ArrowsNode* arrowsNode = GetArrowsNode(false);
if (!arrowsNode)
return;
if (GetModificationMode() == ResourceEditor::MODIFY_MOVE)
{
Vector3 from, dir;
GetCursorVectors(&from, &dir, point);
Vector3 currPoint;
bool result = GetIntersectionVectorWithPlane(from, dir, planeNormal, rotationCenter, currPoint);
if (result)
{
if (arrowsNode)
{
switch (arrowsNode->GetModAxis())
{
case ArrowsNode::AXIS_X:
currPoint.y = startDragPoint.y;
currPoint.z = startDragPoint.z;
break;
case ArrowsNode::AXIS_Y:
currPoint.x = startDragPoint.x;
currPoint.z = startDragPoint.z;
break;
case ArrowsNode::AXIS_Z:
currPoint.x = startDragPoint.x;
currPoint.y = startDragPoint.y;
break;
default:
break;
}
modification.CreateTranslation(currPoint - startDragPoint);
}
}
}
else if (GetModificationMode() == ResourceEditor::MODIFY_ROTATE)
{
Matrix4 d;
switch (arrowsNode->GetModAxis())
{
case ArrowsNode::AXIS_X:
case ArrowsNode::AXIS_Y:
modification.CreateRotation(vect[arrowsNode->GetModAxis()], winy / 100.0f);
break;
case ArrowsNode::AXIS_Z:
modification.CreateRotation(vect[arrowsNode->GetModAxis()], winx / 100.0f);
break;
case ArrowsNode::AXIS_XY:
modification.CreateRotation(vect[ArrowsNode::AXIS_X], winx / 100.0f);
d.CreateRotation(vect[ArrowsNode::AXIS_Y], winy / 100.0f);
modification *= d;
break;
case ArrowsNode::AXIS_YZ:
modification.CreateRotation(vect[ArrowsNode::AXIS_Y], winx / 100.0f);
d.CreateRotation(vect[ArrowsNode::AXIS_Z], winy / 100.0f);
modification *= d;
break;
case ArrowsNode::AXIS_XZ:
modification.CreateRotation(vect[ArrowsNode::AXIS_X], winx / 100.0f);
d.CreateRotation(vect[ArrowsNode::AXIS_Z], winy / 100.0f);
modification *= d;
break;
default:
break;
}
modification = (translate1 * modification) * translate2;
}
else if (GetModificationMode() == ResourceEditor::MODIFY_SCALE)
{
float kf = winx / 100.0f;
if (kf < -1.0)
kf = - kf - 2.0;
modification.CreateScale(Vector3(1,1,1) + Vector3(1,1,1) * kf);
modification = (translate1 * modification) * translate2;
}
currTransform = startTransform * modification;
}