本文整理汇总了C++中GMatrix::Translation方法的典型用法代码示例。如果您正苦于以下问题:C++ GMatrix::Translation方法的具体用法?C++ GMatrix::Translation怎么用?C++ GMatrix::Translation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GMatrix
的用法示例。
在下文中一共展示了GMatrix::Translation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPosRotScale
/**
* @brief
* Returns position, rotation and scale from a matrix
*/
void PLTools::GetPosRotScale(const GMatrix &mTransform, Point3 &vPos, Quat &qRot, Point3 &vScale, bool bFlip)
{
// Get the position
vPos = mTransform.Translation();
// Get the rotation of the node as quaternion
qRot = mTransform.Rotation();
// Flip 180 degree around the y-axis? (true for camera and spot lights)
if (bFlip) {
Quat qRotationOffset;
// We have to add a rotation about the x-axis of -90 degree... is this a IGame transform bug or something other odd??
float fAngles[] = {static_cast<float>(HALFPI), 0.0f, 0.0f};
EulerToQuat(fAngles, qRotationOffset);
qRot = qRotationOffset*qRot;
// We have to 'invert the z-axis', this is no PixelLight bug or so, we decided to do so to make things more universal
fAngles[0] = 0.0f;
fAngles[2] = static_cast<float>(PI);
EulerToQuat(fAngles, qRotationOffset);
qRot = qRotationOffset*qRot;
}
// Look out! We REALLY need to take the parity of the transform matrix into account!
vScale = mTransform.Scaling()*static_cast<float>(mTransform.Parity());
}
示例2: _dumpJoint
void MeshExporter::_dumpJoint(IGameNode * node)
{
IGameObject * obj = node->GetIGameObject();
IGameObject::MaxType T = obj->GetMaxType();
IGameObject::ObjectTypes type = obj->GetIGameType();
const char * name = node->GetName();
switch(type)
{
case IGameObject::IGAME_BONE:
case IGameObject::IGAME_HELPER:
{
joint * bone = mMeshSource->NewJoint(node->GetName());
int parent = -1;
if (node->GetNodeParent())
{
parent = _getJointId(node->GetNodeParent()->GetName());
mMeshSource->SetJointLink(parent, mMeshSource->GetJointCount() - 1);
}
else
{
INode* pNode = node->GetMaxNode()->GetParentNode();
if (pNode)
parent = _getJointId(pNode->GetName());
}
IGameControl * pGameControl = node->GetIGameControl();
// base matrix
{
GMatrix matWorld = node->GetLocalTM();
bone->position = Utility::ToFloat3(matWorld.Translation());
bone->rotation = Utility::ToQuat(matWorld.Rotation());
bone->scale = Utility::ToFloat3(matWorld.Scaling());
/*
if (node->GetNodeParent())
{
int parentId = _getBoneId(node->GetNodeParent()->GetName());
if (parentId != -1)
{
xBone * parentBn = GetBone(parentId);
bone->position = bone->position - parentBn->position;
bone->orientation = parentBn->orientation.Inverse() * bone->orientation;
bone->scale = bone->scale / parentBn->scale;
}
}
*/
}
_dumpAnimation(pGameControl, mMeshSource->GetJointCount() - 1);
}
break;
}
}
示例3: CheckCancel
void Unreal3DExport::WriteTracking()
{
Tab<Point3> Loc;
Tab<Quat> Quat;
Tab<Point3> Euler;
Loc.SetCount(FrameCount);
Quat.SetCount(FrameCount);
Euler.SetCount(FrameCount);
for( int n=0; n<TrackedNodes.Count(); ++n )
{
IGameNode* node = TrackedNodes[n];
for( int t=0; t<FrameCount; ++t )
{
// Progress
CheckCancel();
// Set frame
int curframe = FrameStart + t;
pScene->SetStaticFrame(curframe);
// Write tracking
GMatrix objTM = node->GetWorldTM();
Loc[t] = objTM.Translation();
Quat[t] = objTM.Rotation();
float eu[3];
QuatToEuler(Quat[t],eu);
Euler[t]=Point3(eu[0],eu[1],eu[2]);
Euler[t] *= 180.0f/pi;
eu[1] *= -1;
EulerToQuat(eu,Quat[t],EULERTYPE_YXZ);
}
for( int t=0; t<FrameCount; ++t )
{
_ftprintf( fLog, _T("%sLoc[%d]=(X=%f,Y=%f,Z=%f)\n"), node->GetName(), t, Loc[t].x, Loc[t].y, Loc[t].z );
}
for( int t=0; t<FrameCount; ++t )
{
_ftprintf( fLog, _T("%sQuat[%d]=(W=%f,X=%f,Y=%f,Z=%f)\n"), node->GetName(), t, Quat[t].w, Quat[t].x, Quat[t].y, Quat[t].z );
}
for( int t=0; t<FrameCount; ++t )
{
_ftprintf( fLog, _T("%sEuler[%d]=(X=%f,Y=%f,Z=%f)\n"), node->GetName(), t, Euler[t].x, Euler[t].y, Euler[t].z );
}
}
}
示例4: ExportStaticPos
void SGMExporter::ExportStaticPos(IGameNode *gNode, BinaryWriter *bw)
{
/*INode *node = gNode ->GetMaxNode();
assert(node != NULL);
Control *tmCtrl = node ->GetTMController();
assert(tmCtrl != NULL);
Control *ctrl = tmCtrl ->GetPositionController();
assert(ctrl != NULL);
Interval i(0, 0);
Point3 pos;
ctrl ->GetValue(0, &pos, i, CTRL_ABSOLUTE);*/
Point3 pos;
GMatrix m = gNode ->GetLocalTM();
pos = m.Translation();
bw ->Write(pos.x);
bw ->Write(pos.y);
bw ->Write(pos.z);
}