//----------------------------------------------------------------// void ZLPrism::GetAABB ( ZLBox& box ) const { ZLVec3D walker = mLoc; box.Init ( walker ); walker.Add ( mYAxis ); box.Grow ( walker ); walker.Add ( mZAxis ); box.Grow ( walker ); walker.Sub ( mYAxis ); box.Grow ( walker ); walker.Add ( mXAxis ); box.Grow ( walker ); walker.Sub ( mZAxis ); box.Grow ( walker ); walker.Add ( mYAxis ); box.Grow ( walker ); walker.Add ( mZAxis ); box.Grow ( walker ); }
//----------------------------------------------------------------// 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 ); }
//----------------------------------------------------------------// 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; } }