Ejemplo n.º 1
0
bool BSPBoxSplitSelector::getSplitPlane( const util::Vector<BSPPolygon*>& polys,
	ProgressIndicator* progress, Vector4* splitPlane ) const
{
	assert( polys.size() > 0 );

	double workUnit = polys.size();

	if ( progress )
		progress->addProgress( workUnit );

	OBBoxBuilder builder;
	while ( builder.nextPass() )
	{
		for ( int i = 0 ; i < polys.size() ; ++i )
		{
			const BSPPolygon& poly = *polys[i];
			for ( int k = 0 ; k < poly.vertices() ; ++k )
				builder.addPoints( &poly.getVertex(k), 1 );
		}
	}

	OBBox box = builder.box();
	Vector3 center = box.translation();
	Vector3 normal = box.rotation().getColumn(0);
	*splitPlane = Vector4( normal.x, normal.y, normal.z, -center.dot(normal) );
	return Math::abs(normal.length()-1.f) < 1e-3f && splitPlane->finite();
}
Ejemplo n.º 2
0
void AnimExportUtil::addFloatAnimation( const util::Vector<float>& frames, Interval animRange, KeyFrameContainer* anim, float maxErr )
{
	int firstFrame = animRange.Start() / SGEXPORT_TICKS_PER_SAMPLE;
	for ( TimeValue ticks = animRange.Start() ; ticks <= animRange.End() ; ticks += SGEXPORT_TICKS_PER_SAMPLE )
	{
		require( firstFrame >= 0 && firstFrame < frames.size() );
		anim->insertKey( KeyFrame(TicksToSec(ticks),INTERP_TYPE,&frames[firstFrame++],1) );
	}
}
Ejemplo n.º 3
0
void AnimExportUtil::resampleFloatAnimation( const util::Vector<float>& frames, Interval animRange, KeyFrameContainer* anim, float maxErr )
{
	int firstFrame = animRange.Start() / SGEXPORT_TICKS_PER_SAMPLE;
	require( firstFrame >= 0 && firstFrame < frames.size() );
	anim->insertKey( KeyFrame(TicksToSec(animRange.Start()),INTERP_TYPE,&frames[firstFrame],1) );
	anim->insertKey( KeyFrame(TicksToSec(animRange.End()),INTERP_TYPE,&frames.lastElement(),1) );
	resampleFloatKeys( *anim, animRange, maxErr, frames );
	if ( anim->keys() == 2 && isEqualValue(anim->getKey(0),anim->getKey(1),3) )
		anim->removeKey( 1 );
}