Esempio n. 1
0
//----------------------------------------------------------------//
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 );
}
Esempio n. 2
0
//----------------------------------------------------------------//
bool _vecToXYPlane ( const ZLVec3D& v0, const ZLVec3D& v1, ZLVec2D& result ) {

	ZLVec3D vec;
	
	vec = v1;
	vec.Sub ( v0 );

	if ( vec.mZ != 0.0f ) {

		result.mX = vec.mX;
		result.mY = vec.mY;
		
		float t = v0.mZ / -vec.mZ;
		
		if (( t > 0.0f ) && ( t <= 1.0f )) {
		
			result.Scale ( t );
		
			result.mX += v0.mX;
			result.mY += v0.mY;
			
			return true;
		}
	}
	return false;
}
Esempio n. 3
0
//----------------------------------------------------------------//
float ZLBox::GetRadius () const {

	ZLVec3D spans = mMax;
	spans.Sub ( mMin );
	spans.Scale ( 0.5f );
	return spans.Length ();
}
//----------------------------------------------------------------//
ZLVec3D MOAIAnimCurveVec::GetCurveDelta () const {

	ZLVec3D delta;

	u32 size = this->mKeys.Size ();
	if ( size > 1 ) {
		delta = this->mSamples [ size - 1 ];
		delta.Sub ( this->mSamples [ 0 ]);
	}
	else {
		delta.Init ( 0.0f, 0.0f, 0.0f );
	}
	return delta;
}
Esempio n. 5
0
//----------------------------------------------------------------//
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 );
	
}
Esempio n. 6
0
//----------------------------------------------------------------//
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;
	}
}