Пример #1
0
void MSA::SetClustalWWeights(const Tree &tree)
	{
	const unsigned uSeqCount = GetSeqCount();
	const unsigned uLeafCount = tree.GetLeafCount();

	WEIGHT *Weights = new WEIGHT[uSeqCount];

	CalcClustalWWeights(tree, Weights);

	for (unsigned n = 0; n < uLeafCount; ++n)
		{
		const WEIGHT w = Weights[n];
		const unsigned uLeafNodeIndex = tree.LeafIndexToNodeIndex(n);
		const unsigned uId = tree.GetLeafId(uLeafNodeIndex);
		const unsigned uSeqIndex = GetSeqIndex(uId);
#if	DEBUG
		if (GetSeqName(uSeqIndex) != tree.GetLeafName(uLeafNodeIndex))
			Quit("MSA::SetClustalWWeights: names don't match");
#endif
		SetSeqWeight(uSeqIndex, w);
		}
	NormalizeWeights((WEIGHT) 1.0);

	delete[] Weights;
	}
Пример #2
0
	void Initialize( const PEBC& eval_base, PC& initial_particle )
		{
			double weight_sum;
			Init init( *this, eval_base, initial_particle, weight_sum );
#ifdef USING_TBB
			tbb::blocked_range<int> range( 0, particle_num_, 100 );
			tbb::parallel_for( range, init );
#else /* USING_TBB */
			init();
#endif /* USING_TBB */
			NormalizeWeights( weight_sum );
		}
Пример #3
0
	void UpdateParticles( const PEBC& eval_base, PC& estimated_particle )
		{
			double weight_sum;
			Update update( *this, eval_base, weight_sum );
#ifdef USING_TBB
			tbb::blocked_range<int> range( 0, static_cast<int>( update.prev_particles_.size() ), 100 );
			tbb::parallel_for( range, update );
			//update();
#else /* USING_TBB */
			update();
#endif /* USING_TBB */
			if( weight_sum > 0.0 ) {
				NormalizeWeights( weight_sum );
				generator_.GetWeightedMean( particles_, weights_, estimated_particle );
			} else {
				Initialize( eval_base, estimated_particle );
			}
			assert( evaluator_.Validate( estimated_particle, eval_base ) );
		}
	void ObjectAnimationMixer::SetTrackWeight(const System::string name, float value)
	{
		m_factors[name] = value;
		NormalizeWeights();
	}
	void ObjectAnimationMixer::EnableTrack(const System::string name, bool flag)
	{
		m_active[name] = flag;
		NormalizeWeights();
	}
Пример #6
0
int MeshCompiler::Compile( const char* InFilename, const char* OutFilename, bool LongIndices )
{
	m_StrippedFilename = FileUtil::StripExtensions( FileUtil::StripLeadingFolders( InFilename ) );

	TiXmlDocument XMLDoc;
	XMLDoc.LoadFile( InFilename );
	TiXmlElement* RootElement = XMLDoc.FirstChildElement();	// "mesh"

	// Sanity check
	if( _stricmp( RootElement->Value(), "mesh" ) )
	{
		PRINTF( "Input file is not a valid XML mesh file.\n" );
		return -1;
	}

	STATICHASH( BakeAOForDynamicMeshes );
	STATICHASH( BakeAOForAnimatedMeshes );
	STATICHASH( TraceTriangleBacks );
	STATICHASH( DynamicAORadius );
	STATICHASH( DynamicAOPushOut );
	MAKEHASH( m_StrippedFilename );

	ConfigManager::Load( FileStream( "tools.cfg", FileStream::EFM_Read ) );
	m_BakeAOForDynamicMeshes = ConfigManager::GetArchetypeBool( sBakeAOForDynamicMeshes, ConfigManager::EmptyContext, false, sm_StrippedFilename );
	m_BakeAOForAnimatedMeshes = ConfigManager::GetArchetypeBool( sBakeAOForAnimatedMeshes, ConfigManager::EmptyContext, false, sm_StrippedFilename );
	m_TraceTriangleBacks = ConfigManager::GetArchetypeBool( sTraceTriangleBacks, ConfigManager::EmptyContext, false, sm_StrippedFilename );
	m_AORadius = ConfigManager::GetArchetypeFloat( sDynamicAORadius, ConfigManager::EmptyContext, 0.1f, sm_StrippedFilename );
	m_AOPushOut = ConfigManager::GetArchetypeFloat( sDynamicAOPushOut, ConfigManager::EmptyContext, 0.01f, sm_StrippedFilename );

	m_Header.m_LongIndices = LongIndices;

	// Get armature first, which will make it easier to handle bone references in verts
	TiXmlElement* Arm = RootElement->FirstChildElement( "armature" );
	CompileArmature( Arm );

	int NumFaces = 0;
	for( TiXmlElement* Face = RootElement->FirstChildElement( "face" ); Face; Face = Face->NextSiblingElement( "face" ) )
	{
		CompileFace( Face );
		NumFaces++;
	}

	for( TiXmlElement* Mat = RootElement->FirstChildElement( "material" ); Mat; Mat = Mat->NextSiblingElement( "material" ) )
	{
		CompileMaterial( Mat );
	}

	m_Header.m_NumVertices = m_Positions.Size();
	m_Header.m_NumIndices = m_Indices.Size();

	NormalizeWeights();

	CalculateAABB();

	if( m_Header.m_HasUVs && m_Header.m_HasNormals )
	{
		m_Header.m_HasTangents = true;
	}
	PRINTF( "Calculating tangents...\n" );
	CalculateTangents();

	CalculateAmbientOcclusion();

	PRINTF( "Compile successful!\n" );
	PRINTF( "Imported %d faces.\n", NumFaces );

	Write( FileStream( OutFilename, FileStream::EFM_Write ) );

	PRINTF( "Exported %d vertices.\n", m_Header.m_NumVertices );
	PRINTF( "Exported %d indices (%d triangles).\n", m_Header.m_NumIndices, m_Header.m_NumIndices / 3 );
	if( m_Header.m_HasSkeleton )
	{
		PRINTF( "Exported %d bones.\n", m_Header.m_NumBones );
		PRINTF( "Exported %d frames.\n", m_Header.m_NumFrames );
		PRINTF( "Exported %d animations.\n", m_Header.m_NumAnims );
	}

	return 0;
}