Exemplo n.º 1
0
void Geometry::setMatrix( const std::string& name, const Mat4& pMatrix )
{
	if (NULL == mMesh)
	{
		return;
	}
	if (NULL == mMaterial)
	{
		return;
	}
	Euclid::Effect* fx = mMaterial->getEffect();
	if (NULL == fx)
	{
		return;
	}
	fx->setMatrix(name, pMatrix);
	//
	{
		if (NULL == mSkeletonMaterial)
		{
			return;
		}
		Euclid::Effect* fx = mSkeletonMaterial->getEffect();
		if (NULL == fx)
		{
			return;
		}
		fx->setMatrix(name, pMatrix);
	}
}
Exemplo n.º 2
0
void Geometry::_renderMesh()
{
	if (NULL == mMesh)
	{
		return;
	}
	if (NULL == mMaterial)
	{
		return;
	}
	
	Euclid::Effect* fx = mMaterial->getEffect();
	if (NULL == fx)
	{
		return;
	}
	//
	mMaterial->apply();
	
	//
	if (NULL != mSkeleton)
	{
		//
		std::vector<Mat4> matrices;
		for(Euclid::BoneIDReferenceMap::iterator it = mMesh->_bones.begin(); it != mMesh->_bones.end(); ++it)
		{
			if (it->first < 255)
			{
				matrices.push_back(mSkeleton->_matrices[it->first]);
			}
		}
		if (matrices.size() >= 60 || matrices.empty())
		{
			mHardwareSkin = false;
		}
		else
		{
			fx->setMatrixArray("gMatrixPalette", &matrices[0], matrices.size()); 
			mHardwareSkin = true;
		}
		fx->setBool("gSkinned", mHardwareSkin);
	}
	
	fx->setMatrix("gUVMatrix", &mUVMatrix);
	float alpha = mMaterial->mAlphaKFs.getFrame(&mMaterial->mAlphaAnimationTime);
	mMaterial->mDiffuse.a *= alpha;
	Euclid::AnimationTime at;
	Euclid::Color3 c = mMaterial->mColorKFs.getFrame(&at);
	mMaterial->mDiffuse.r *= c.r;
	mMaterial->mDiffuse.g *= c.g;
	mMaterial->mDiffuse.b *= c.b;
	fx->setFloatArray("gDiffuse", &mMaterial->mDiffuse.r, 4);
	fx->setBool("gUseVertexColor", mMaterial->mUseVertexColor);
	u32 passes = 0;
	fx->begin(&passes);
	for (u32 i = 0; i != passes; ++i)
	{
		fx->beginPass(i);
		mMesh->render();
		fx->endPass();
	}
	fx->end();
}