本文整理汇总了C++中vec3::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ vec3::Length方法的具体用法?C++ vec3::Length怎么用?C++ vec3::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec3
的用法示例。
在下文中一共展示了vec3::Length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rotate
void Cube::rotate(vec3 velocity, float elapsedTime)
{
float angleInclinaisonPlan = 0.0f;
vec3 norm;
vec3 normal;
vec3 d;
float angle;
float speed;
speed = ((velocity.Length())/getSize()) * elapsedTime;// / (90);
//normal = this->getNormal();
normal = vec3(0,1,0);
if(normal != this->normal)
{
this->normal = normal;
norm = MF.normalizeVector(normal);
norm = vec3(norm.x * (float)sin((angleInclinaisonPlan/M_PI)*180), norm.y * (float)cos((angleInclinaisonPlan/M_PI)*180),0);
this->norm = norm;
}
d.x = velocity.z;
d.y = 0.0;//velocity.y;
d.z = velocity.x * -1;
d = MF.normalizeVector(d);
d *= -1;
angle = speed * 180.0f / M_PI;
if(angle >= this->rotationPrecision)
{
vec4 q;
vec4 qPrime;
vec4 result;
vec3 u;
u = d;
u = MF.normalizeVector(u);
q = this->components.getQuaternion()->getQuaternion4f(angle, u);
qPrime = this->components.getQuaternion()->getQuaternion4f(angle, u* (-1));
int i;
for(i = 0; i < 8; ++i)
{
this->quadPosition.at(i) -= this->centerOfObject;
result = this->components.getQuaternion()->multiplyQuaternion4f(q, vec4(0,this->quadPosition.at(i).x, this->quadPosition.at(i).y, this->quadPosition.at(i).z));
this->quadPosition.at(i) = this->components.getQuaternion()->multiplyQuaternion3f(result, qPrime);
this->quadPosition.at(i) += this->centerOfObject;
}
// AXES
for(i = 0; i < 2; ++i)
{
this->axeX.at(i) -= this->centerOfObject;
result = this->components.getQuaternion()->multiplyQuaternion4f(q, vec4(0,axeX.at(i).x, axeX.at(i).y, axeX.at(i).z));
this->axeX.at(i) = this->components.getQuaternion()->multiplyQuaternion3f(result, qPrime);
this->axeX.at(i) += this->centerOfObject;
this->axeY.at(i) -= this->centerOfObject;
result = this->components.getQuaternion()->multiplyQuaternion4f(q, vec4(0,axeY.at(i).x, axeY.at(i).y, axeY.at(i).z));
this->axeY.at(i) = this->components.getQuaternion()->multiplyQuaternion3f(result, qPrime);
this->axeY.at(i) += this->centerOfObject;;
this->axeZ.at(i) -= this->centerOfObject;
result = this->components.getQuaternion()->multiplyQuaternion4f(q, vec4(0,axeZ.at(i).x, axeZ.at(i).y, axeZ.at(i).z));
this->axeZ.at(i) = this->components.getQuaternion()->multiplyQuaternion3f(result, qPrime);
this->axeZ.at(i) += this->centerOfObject;
}
getComponents()->getRigidBody()->rotate(angle, d);
}
}
示例2: Length
float Length(vec3 v)
{
return v.Length();
}