本文整理汇总了C++中Mat4x4::BuildTranslation方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4x4::BuildTranslation方法的具体用法?C++ Mat4x4::BuildTranslation怎么用?C++ Mat4x4::BuildTranslation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4x4
的用法示例。
在下文中一共展示了Mat4x4::BuildTranslation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
bool TransformComponent::Init(TiXmlElement* pData)
{
CB_ASSERT(pData);
Vec3 yawPitchRoll = m_Transform.GetYawPitchRoll();
yawPitchRoll.x = RADIANS_TO_DEGREES(yawPitchRoll.x);
yawPitchRoll.y = RADIANS_TO_DEGREES(yawPitchRoll.y);
yawPitchRoll.z = RADIANS_TO_DEGREES(yawPitchRoll.z);
Vec3 position = m_Transform.GetPosition();
TiXmlElement* pPositionElement = pData->FirstChildElement("Position");
if (pPositionElement)
{
double x = 0;
double y = 0;
double z = 0;
pPositionElement->Attribute("x", &x);
pPositionElement->Attribute("y", &y);
pPositionElement->Attribute("z", &z);
position = Vec3(x, y, z);
}
TiXmlElement* pOrientationElement = pData->FirstChildElement("YawPitchRoll");
if (pOrientationElement)
{
double yaw = 0;
double pitch = 0;
double roll = 0;
pOrientationElement->Attribute("x", &yaw);
pOrientationElement->Attribute("y", &pitch);
pOrientationElement->Attribute("z", &roll);
yawPitchRoll = Vec3(yaw, pitch, roll);
}
Mat4x4 translation;
translation.BuildTranslation(position);
Mat4x4 rotation;
rotation.BuildYawPitchRoll((float)DEGREES_TO_RADIANS(yawPitchRoll.x), (float)DEGREES_TO_RADIANS(yawPitchRoll.y), (float)DEGREES_TO_RADIANS(yawPitchRoll.z));
m_Transform = rotation * translation;
return true;
}
示例2: VInit
bool TransformComponent::VInit(TiXmlElement* pData)
{
AC_ASSERT(pData);
// [mrmike] - this was changed post-press - because changes to the TransformComponents can come in partial definitions,
// such as from the editor, its better to grab the current values rather than clear them out.
Vec3 yawPitchRoll = m_transform.GetYawPitchRoll();
yawPitchRoll.x = RADIANS_TO_DEGREES(yawPitchRoll.x);
yawPitchRoll.y = RADIANS_TO_DEGREES(yawPitchRoll.y);
yawPitchRoll.z = RADIANS_TO_DEGREES(yawPitchRoll.z);
Vec3 position = m_transform.GetPosition();
TiXmlElement* pPositionElement = pData->FirstChildElement("Position");
if (pPositionElement)
{
double x = 0;
double y = 0;
double z = 0;
pPositionElement->Attribute("x", &x);
pPositionElement->Attribute("y", &y);
pPositionElement->Attribute("z", &z);
position = Vec3(x, y, z);
}
TiXmlElement* pOrientationElement = pData->FirstChildElement("YawPitchRoll");
if (pOrientationElement)
{
double yaw = 0;
double pitch = 0;
double roll = 0;
pOrientationElement->Attribute("x", &yaw);
pOrientationElement->Attribute("y", &pitch);
pOrientationElement->Attribute("z", &roll);
yawPitchRoll = Vec3(yaw, pitch, roll);
}
Mat4x4 translation;
translation.BuildTranslation(position);
Mat4x4 rotation;
rotation.BuildYawPitchRoll((float)DEGREES_TO_RADIANS(yawPitchRoll.x), (float)DEGREES_TO_RADIANS(yawPitchRoll.y), (float)DEGREES_TO_RADIANS(yawPitchRoll.z));
/**
// This is not supported yet.
TiXmlElement* pLookAtElement = pData->FirstChildElement("LookAt");
if (pLookAtElement)
{
double x = 0;
double y = 0;
double z = 0;
pLookAtElement->Attribute("x", &x);
pLookAtElement->Attribute("y", &y);
pLookAtElement->Attribute("z", &z);
Vec3 lookAt((float)x, (float)y, (float)z);
rotation.BuildRotationLookAt(translation.GetPosition(), lookAt, g_Up);
}
TiXmlElement* pScaleElement = pData->FirstChildElement("Scale");
if (pScaleElement)
{
double x = 0;
double y = 0;
double z = 0;
pScaleElement->Attribute("x", &x);
pScaleElement->Attribute("y", &y);
pScaleElement->Attribute("z", &z);
m_scale = Vec3((float)x, (float)y, (float)z);
}
**/
m_transform = rotation * translation;
return true;
}