本文整理汇总了C++中Matrix4::GetTranslationVector方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4::GetTranslationVector方法的具体用法?C++ Matrix4::GetTranslationVector怎么用?C++ Matrix4::GetTranslationVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4
的用法示例。
在下文中一共展示了Matrix4::GetTranslationVector方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void ParticleEmitter3D::PrepareEmitterParameters(Particle * particle, float32 velocity, int32 emitIndex)
{
Vector3 tempPosition = Vector3();
Matrix4 * worldTransformPtr = GetWorldTransformPtr();
Matrix3 rotationMatrix;
rotationMatrix.Identity();
if(worldTransformPtr)
{
tempPosition = worldTransformPtr->GetTranslationVector();
rotationMatrix = Matrix3(*worldTransformPtr);;
}
//Vector3 tempPosition = particlesFollow ? Vector3() : position;
if (emitterType == EMITTER_POINT)
{
particle->position = tempPosition;
}
else if (emitterType == EMITTER_RECT)
{
float32 rand05_x = (float32)Random::Instance()->RandFloat() - 0.5f; // [-0.5f, 0.5f]
float32 rand05_y = (float32)Random::Instance()->RandFloat() - 0.5f; // [-0.5f, 0.5f]
float32 rand05_z = (float32)Random::Instance()->RandFloat() - 0.5f; // [-0.5f, 0.5f]
Vector3 lineDirection(0, 0, 0);
if(size)
lineDirection = Vector3(size->GetValue(time).x * rand05_x, size->GetValue(time).y * rand05_y, size->GetValue(time).z * rand05_z);
//particle->position = tempPosition + lineDirection;
particle->position = tempPosition + TransformPerserveLength(lineDirection, rotationMatrix);
}
else if ((emitterType == EMITTER_ONCIRCLE_VOLUME) ||
(emitterType == EMITTER_ONCIRCLE_EDGES))
{
CalculateParticlePositionForCircle(particle, tempPosition, rotationMatrix);
}
if (emitterType == EMITTER_SHOCKWAVE)
{
// For "Shockwave" emitters the calculation is different.
PrepareEmitterParametersShockwave(particle, velocity, emitIndex, tempPosition, rotationMatrix);
}
else
{
PrepareEmitterParametersGeneric(particle, velocity, emitIndex, tempPosition, rotationMatrix);
}
if(worldTransformPtr)
{
Matrix4 newTransform = *worldTransformPtr;
newTransform._30 = newTransform._31 = newTransform._32 = 0;
float32 speedLength = particle->speed.Length();
particle->speed = particle->speed*newTransform;
float32 speedLengthAfter = particle->speed.Length();
if (speedLengthAfter)
particle->speed*=speedLength/speedLengthAfter;
}
}
示例2: UpdateArrowsNode
void EditorBodyControl::UpdateArrowsNode(Entity* node)
{
ArrowsNode* arrowsNode = GetArrowsNode(false);
if (node && arrowsNode)
{
if (node == arrowsNode)
{
arrowsNode->SetVisible(false);
return;
}
Matrix4 nodeWT = node->GetWorldTransform();
Matrix4 arrowsNodeTransform;
arrowsNodeTransform.CreateTranslation(nodeWT.GetTranslationVector());
arrowsNode->SetLocalTransform(arrowsNodeTransform);
arrowsNode->SetVisible(true);
arrowsNode->SetActive(InModificationMode());
}
}
示例3: if
void ParticleEmitter3D::PrepareEmitterParameters(Particle * particle, float32 velocity, int32 emitIndex)
{
Vector3 tempPosition = Vector3();
Matrix4 * worldTransformPtr = GetWorldTransformPtr();
if(worldTransformPtr)
{
tempPosition = worldTransformPtr->GetTranslationVector();
}
//Vector3 tempPosition = particlesFollow ? Vector3() : position;
if (emitterType == EMITTER_POINT)
{
particle->position = tempPosition;
}
else if (emitterType == EMITTER_LINE)
{
// TODO: add emitter angle support
float32 rand05 = (float32)Random::Instance()->RandFloat() - 0.5f; // [-0.5f, 0.5f]
Vector3 lineDirection(0, 0, 0);
if(size)
lineDirection = size->GetValue(time)*rand05;
particle->position = tempPosition + lineDirection;
}
else if (emitterType == EMITTER_RECT)
{
// TODO: add emitter angle support
float32 rand05_x = (float32)Random::Instance()->RandFloat() - 0.5f; // [-0.5f, 0.5f]
float32 rand05_y = (float32)Random::Instance()->RandFloat() - 0.5f; // [-0.5f, 0.5f]
float32 rand05_z = (float32)Random::Instance()->RandFloat() - 0.5f; // [-0.5f, 0.5f]
Vector3 lineDirection(0, 0, 0);
if(size)
lineDirection = Vector3(size->GetValue(time).x * rand05_x, size->GetValue(time).y * rand05_y, size->GetValue(time).z * rand05_z);
particle->position = tempPosition + lineDirection;
}
else if (emitterType == EMITTER_ONCIRCLE)
{
// here just set particle position
particle->position = tempPosition;
}
Vector3 vel = Vector3(1.0f, 0.0f, 0.0f);
if(emissionVector)
{
vel = emissionVector->GetValue(0);
vel = vel*rotationMatrix;
}
Vector3 rotVect(0, 0, 1);
float32 phi = PI*2*(float32)Random::Instance()->RandFloat();
if(vel.x != 0)
{
rotVect.y = sinf(phi);
rotVect.z = cosf(phi);
rotVect.x = - rotVect.y*vel.y/vel.x - rotVect.z*vel.z/vel.x;
}
else if(vel.y != 0)
{
rotVect.x = cosf(phi);
rotVect.z = sinf(phi);
rotVect.y = - rotVect.z*vel.z/vel.y;
}
else if(vel.z != 0)
{
rotVect.x = cosf(phi);
rotVect.y = sinf(phi);
rotVect.z = 0;
}
rotVect.Normalize();
float32 range = 0;
if(emissionRange)
range = DegToRad(emissionRange->GetValue(time) + angle);
float32 rand05 = (float32)Random::Instance()->RandFloat() - 0.5f;
Vector3 q_v(rotVect*sinf(range*rand05/2));
float32 q_w = cosf(range*rand05/2);
Vector3 q1_v(q_v);
float32 q1_w = -q_w;
q1_v /= (q_v.SquareLength() + q_w*q_w);
q1_w /= (q_v.SquareLength() + q_w*q_w);
Vector3 v_v(vel);
Vector3 qv_v = q_v.CrossProduct(v_v) + q_w*v_v;
float32 qv_w = - q_v.DotProduct(v_v);
Vector3 qvq1_v = qv_v.CrossProduct(q1_v) + qv_w*q1_v + q1_w*qv_v;
Vector3 speed = qvq1_v * velocity;
particle->speed = speed.Length();
particle->direction = speed/particle->speed;
if (particle->direction.x <= EPSILON && particle->direction.x >= -EPSILON)
particle->direction.x = 0.f;
if (particle->direction.y <= EPSILON && particle->direction.y >= -EPSILON)
particle->direction.y = 0.f;
if (particle->direction.z <= EPSILON && particle->direction.z >= -EPSILON)
particle->direction.z = 0.f;
if (emitterType == EMITTER_ONCIRCLE)
//.........这里部分代码省略.........