//----------------------------------------------------------------// float ZLBox::GetRadius () const { ZLVec3D spans = mMax; spans.Sub ( mMin ); spans.Scale ( 0.5f ); return spans.Length (); }
//----------------------------------------------------------------// void ZLPrism::GetCenter ( ZLVec3D& center ) const { center = this->mXAxis; center.Add ( this->mYAxis ); center.Add ( this->mZAxis ); center.Scale ( 0.5f ); center.Add ( this->mLoc ); }
//----------------------------------------------------------------// void ZLQuaternion::Multiply ( const ZLQuaternion& rhs ) { ZLVec3D cross; cross.Cross ( mV, rhs.mV ); ZLVec3D resultVec; resultVec.Init ( rhs.mV ); resultVec.Scale ( mS ); ZLVec3D scaledVec; scaledVec.Init ( mV ); scaledVec.Scale ( rhs.mS ); resultVec.Add ( scaledVec ); resultVec.Sub ( cross ); mS = mS * rhs.mS - mV.Dot ( rhs.mV ); mV.Init ( resultVec ); }
//----------------------------------------------------------------// ZLVec3D MOAIAnimCurveVec::GetValue ( const MOAIAnimKeySpan& span ) const { MOAIAnimKey& key = this->mKeys [ span.mKeyID ]; ZLVec3D v0 = this->mSamples [ span.mKeyID ]; if ( span.mTime > 0.0f ) { ZLVec3D v1 = this->mSamples [ span.mKeyID + 1 ]; v0.mX = ZLInterpolate::Interpolate ( key.mMode, v0.mX, v1.mX, span.mTime, key.mWeight ); v0.mY = ZLInterpolate::Interpolate ( key.mMode, v0.mY, v1.mY, span.mTime, key.mWeight ); v0.mZ = ZLInterpolate::Interpolate ( key.mMode, v0.mZ, v1.mZ, span.mTime, key.mWeight ); } if ( span.mCycle != 0.0f ) { ZLVec3D curveDelta = this->GetCurveDelta (); curveDelta.Scale ( span.mCycle ); v0.Add ( curveDelta ); } return v0; }
//----------------------------------------------------------------// void MOAIParticleForce::Eval ( const ZLVec3D& loc, float mass, ZLVec3D& acceleration, ZLVec3D& offset ) { ZLVec3D force ( 0.0f, 0.0f, 0.0f ); ZLVec3D origin = this->mLocalToWorldMtx.GetTranslation (); switch ( this->mShape ) { case ATTRACTOR: { ZLVec3D vec = origin; vec.Sub ( loc ); float dist = vec.NormSafe () / this->mRadius; if ( dist <= 1.0f ) { dist = 1.0f - dist; dist = dist * dist * this->mPull; force.mX = vec.mX * dist; force.mY = vec.mY * dist; } break; } case BASIN: { ZLVec3D vec = origin; vec.Sub ( loc ); float dist = vec.NormSafe () / this->mRadius; dist = dist * dist * this->mPull; force.mX = vec.mX * dist; force.mY = vec.mY * dist; break; } case LINEAR: { force = this->mWorldVec; break; } case RADIAL: { force = origin; force.Sub ( loc ); force.NormSafe (); force.Scale ( this->mPull ); break; } } switch ( this->mType ) { case FORCE: force.Scale ( 1.0f / mass ); acceleration.Add ( force ); break; case GRAVITY: acceleration.Add ( force ); break; case OFFSET: offset.Add ( force ); break; } }