本文整理汇总了C++中Quat::FromAxis方法的典型用法代码示例。如果您正苦于以下问题:C++ Quat::FromAxis方法的具体用法?C++ Quat::FromAxis怎么用?C++ Quat::FromAxis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quat
的用法示例。
在下文中一共展示了Quat::FromAxis方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnUpdate
virtual void OnUpdate()
{
Quat q;
q.FromAxis(Float3(0, 1, 0), 0.5f * Root::Instance()->GetFrameTime());
gMesh->Rotate(q);
}
示例2: _updateBuffer
void PS_Billboard::_updateBuffer()
{
mRenderOp.primCount = mParent->GetParticleCount() * 2;
if (mRenderOp.primCount == 0)
return ;
Camera * pCamera = World::Instance()->GetCurrentRenderContext()->GetCamera();
const Quat & worldQ = mParent->GetParent()->GetWorldRotation();
Mat4 worldTM;
if (mParent->IsScaleAble())
worldTM = mParent->GetParent()->GetWorldTM();
else
worldTM.MakeTransform(mParent->GetParent()->GetWorldPosition(), worldQ, Float3(1, 1, 1));
pCamera->GetWorldRotation().ToAxis(mCamXAxis, mCamYAxis, mCamZAxis);
mCamPos = pCamera->GetWorldPosition();
mCommonDir = mParent->GetCommonDirection();
mCommonUp = mParent->GetCommonUpVector();
if (mParent->GetBillboardType() == PS_BillboardType::PERPENDICULAR ||
mParent->GetBillboardType() == PS_BillboardType::PERPENDICULAR_COMMON)
{
mCommonDir.TransformQ(worldQ);
mCommonUp.TransformQ(worldQ);
}
float width, height, asecpt = 1;
Float3 xAxis, yAxis;
Float3 pos, dir;
const Float2 & center = mParent->GetBillboardCenter();
if (mParent->IsKeepAspect())
asecpt = mParent->_getTexture()->_getAscept();
PS_Vertex * v = (PS_Vertex *)mRenderOp.vertexBuffers[0]->Lock(eLockFlag::WRITE);
for (int i = 0; i < mParent->GetParticleCount(); ++i)
{
const Particle * p = mParent->GetParticle(i);
height = Max(0.0f, p->Size.y);
if (!mParent->IsKeepAspect())
width = Max(0.0f, p->Size.x);
else
width = height * asecpt;
pos = p->Position;
dir = p->Direction;
if (mParent->IsLocalSpace())
{
pos.TransformA(worldTM);
dir.TransformQ(mParent->GetParent()->GetWorldRotation());
}
_getBillboardXYAxis(xAxis, yAxis, pos, dir);
if (p->Rotation.x != 0)
{
Quat q;
q.FromAxis(Float3::Cross(xAxis, yAxis), Math::DegreeToRadian(p->Rotation.x));
xAxis.TransformQ(q);
yAxis.TransformQ(q);
}
xAxis *= width, yAxis *= height;
v->position = pos - xAxis * center.x + yAxis * center.y;
v->color = p->Color;
v->uv.x = p->UVRect.x1, v->uv.y = p->UVRect.y1;
++v;
v->position = pos + xAxis * (1 - center.x) + yAxis * center.y;
v->color = p->Color;
v->uv.x = p->UVRect.x2, v->uv.y = p->UVRect.y1;
++v;
v->position = pos - xAxis * center.x - yAxis * (1 - center.y);
v->color = p->Color;
v->uv.x = p->UVRect.x1, v->uv.y = p->UVRect.y2;
++v;
v->position = pos + xAxis * (1 - center.x) - yAxis * (1 - center.y);
v->color = p->Color;
v->uv.x = p->UVRect.x2, v->uv.y = p->UVRect.y2;
++v;
}
mRenderOp.vertexBuffers[0]->Unlock();
}