本文整理汇总了C++中Point3F::neg方法的典型用法代码示例。如果您正苦于以下问题:C++ Point3F::neg方法的具体用法?C++ Point3F::neg怎么用?C++ Point3F::neg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point3F
的用法示例。
在下文中一共展示了Point3F::neg方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateCameraPos
void Etherform::updateCameraPos(F32 delta)
{
//
// Update 3rd person camera position.
//
F32 min,max;
Point3F offset;
MatrixF rot;
this->getCameraParameters(&min,&max,&offset,&rot);
Point3F vec = mCameraTargetPos - mCameraPos;
F32 dist = vec.len();
if(dist == 0)
{
// Catch camera position up to its target position.
mCameraPos = mCameraTargetPos;
}
else if(dist > max)
{
// Catch camera up to max allowed dist from target position.
vec.normalize(); vec.neg();
mCameraPos = mCameraTargetPos + vec * max;
}
else
{
// Move camera pos towards its target pos.
#if 0
F32 speed = mDataBlock->accelerationForce;
speed *= 1 - (1/vec.lenSquared());
vec.normalize();
mCameraPos += vec * speed * delta;
#else
//F32 speedScale = this->getVelocity().len() / mDataBlock->accelerationForce;
F32 speedScale = 4; //mDataBlock->accelerationForce / 2;
F32 distScale = 1 - (1/vec.lenSquared());
vec *= speedScale * distScale * delta;
if(vec.len() > dist)
mCameraPos = mCameraTargetPos;
else
mCameraPos += vec;
#endif
}
}
示例2: resolveCollision
/** Resolve collision with another rigid body
Computes & applies the collision impulses needed to keep the bodies
from interpenetrating.
tg: This function was commented out... I uncommented it, but haven't
double checked the math.
*/
bool Rigid::resolveCollision(const Point3F& p, const Point3F &normal, Rigid* rigid)
{
atRest = false;
Point3F v1,v2,r1,r2;
getOriginVector(p,&r1);
getVelocity(r1,&v1);
rigid->getOriginVector(p,&r2);
rigid->getVelocity(r2,&v2);
// Make sure they are converging
F32 nv = mDot(v1,normal);
nv -= mDot(v2,normal);
if (nv > 0.0f)
return false;
// Compute impulse
F32 d, n = -nv * (1.0f + restitution * rigid->restitution);
Point3F a1,b1,c1;
mCross(r1,normal,&a1);
invWorldInertia.mulV(a1,&b1);
mCross(b1,r1,&c1);
Point3F a2,b2,c2;
mCross(r2,normal,&a2);
rigid->invWorldInertia.mulV(a2,&b2);
mCross(b2,r2,&c2);
Point3F c3 = c1 + c2;
d = oneOverMass + rigid->oneOverMass + mDot(c3,normal);
Point3F impulse = normal * (n / d);
applyImpulse(r1,impulse);
impulse.neg();
applyImpulse(r2,impulse);
return true;
}
示例3: updateForces
//.........这里部分代码省略.........
for (j = 0; j < 2; j++) {
if (compression[j] != 0.0) {
mFloating = false;
// Spring force and damping
Point3F springForce = -stabPoints[j].wsExtension;
springForce.normalize();
springForce *= compression[j] * mDataBlock->stabSpringConstant;
Point3F springDamping = -stabPoints[j].wsExtension;
springDamping.normalize();
springDamping *= -getMin(mDot(springDamping, stabPoints[j].wsVelocity), 0.7f) * mDataBlock->stabDampingConstant;
force += springForce + springDamping;
}
}
// Gravity
if (reallyFloating == false)
force += gravForce;
else
force += gravForce * mDataBlock->floatingGravMag;
// Braking
F32 vellen = mRigid.linVelocity.len();
if (mThrottle == 0.0f &&
mLeftThrust == 0.0f &&
mRightThrust == 0.0f &&
vellen != 0.0f &&
vellen < mDataBlock->brakingActivationSpeed)
{
Point3F dir = mRigid.linVelocity;
dir.normalize();
dir.neg();
force += dir * mDataBlock->brakingForce;
}
// Gyro Drag
torque = -mRigid.angMomentum * mDataBlock->gyroDrag;
// Move to proper normal
Point3F sn, r;
currTransform.getColumn(2, &sn);
if (normalSet[0] || normalSet[1]) {
if (normalSet[0] && normalSet[1]) {
F32 dot = mDot(normal[0], normal[1]);
if (dot > 0.999) {
// Just pick the first normal. They're too close to call
if ((sn - normal[0]).lenSquared() > 0.00001) {
mCross(sn, normal[0], &r);
torque += r * mDataBlock->normalForce * normalMod[0];
}
} else {
Point3F rotAxis;
mCross(normal[0], normal[1], &rotAxis);
rotAxis.normalize();
F32 angle = mAcos(dot) * (normalMod[0] / (normalMod[0] + normalMod[1]));
AngAxisF aa(rotAxis, angle);
QuatF q(aa);
MatrixF tempMat(true);
q.setMatrix(&tempMat);
Point3F newNormal;
tempMat.mulV(normal[1], &newNormal);
if ((sn - newNormal).lenSquared() > 0.00001) {