Пример #1
0
//----------------------------------------------------------------//
void USPrism::GetAABB ( USBox& box ) const {

	USVec3D 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 );
}
Пример #2
0
//----------------------------------------------------------------//
float USBox::GetRadius () const {

	USVec3D spans = mMax;
	spans.Sub ( mMin );
	spans.Scale ( 0.5f );
	return spans.Length ();
}
Пример #3
0
//----------------------------------------------------------------//
bool _vecToXYPlane ( const USVec3D& v0, const USVec3D& v1, USVec2D& result ) {

	USVec3D 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;
}
Пример #4
0
//----------------------------------------------------------------//
void USPlane3D::Init ( USVec3D& p1, USVec3D& p2, USVec3D& p3 ) {

	USVec3D r;

	mNorm = p2;
	mNorm.Sub ( p1 );

	r = p3;
	r.Sub ( p1 );

	mNorm.Cross ( r );
	mNorm.Norm ();

	mDist = -mNorm.Dot ( p1 );
}