Beispiel #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);
	}
}
Beispiel #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)
		{
			mHardwareSkin = false;
		}
		else
		{
			mHardwareSkin = true;
		}
		fx->setMatrixArray("gMatrixPalette", &matrices[0], matrices.size()); 
	}
	
	u32 passes = 0;
	fx->begin(&passes);
	for (u32 i = 0; i != passes; ++i)
	{
		fx->beginPass(i);
		mMesh->render();
		fx->endPass();
	}
	fx->end();
}
Beispiel #3
0
void Geometry::renderSkeleton()
{
	if (NULL == mSkeleton)
	{
		return;
	}
	if (NULL == mSkeletonMaterial)
	{
		return;
	}
	Euclid::Effect* fx = mSkeletonMaterial->getEffect();
	if (NULL == fx)
	{
		return;
	}
	//
	mSkeletonMaterial->apply();

	Euclid::BoneNodeMapIterator it = mSkeleton->getCommandMapIterator();
	while(!it.isAtEnd())
	{
		Euclid::BoneNode* n = it.getCurrentValue();
		Euclid::BoneNode* p = n->getParentNode();
		if (NULL != p)
		{
			Euclid::Bone* b = n->getBone();
			Euclid::Bone* f = p->getBone();
			//
			Euclid::sPosition p[2];
			p[0].position = mSkeleton->_matricesFull[b->id] * p[0].position;
			p[1].position = mSkeleton->_matricesFull[f->id] * p[1].position;

			//
			{
				u32 passes = 0;
				fx->begin(&passes);
				for (u32 i = 0; i != passes; ++i)
				{
					fx->beginPass(i);

					RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->drawPrimitiveUP(Euclid::ePrimitive_LineList, 1, p, sizeof(Euclid::sPosition));
					//
					RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->drawPrimitiveUP(Euclid::ePrimitive_PointList, 2, p, sizeof(Euclid::sPosition));

					fx->endPass();
				}
				fx->end();
			}
		}
		//
		++it;
	}
	//
	it.toStart();
	//
	Mat4 vm, pm;
	fx->getMatrix("gView", &vm);
	fx->getMatrix("gProjection", &pm);
	while(!it.isAtEnd())
	{
		Euclid::BoneNode* n = it.getCurrentValue();
		{
			Euclid::Bone* b = n->getBone();
			//
			Vec3 p;
			RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->objectSpace2ScreenSpace(&p, &p, NULL, &pm, &vm, &mSkeleton->_matricesFull[b->id]);
			//
			{
				RenderEngineImp::getInstancePtr()->getRenderEngine()->getFontManager()->getFont("freeNormal")->render(p, Vec3(1, 0, 0), Euclid::Color::Red, b->name);
			}
		}
		//
		++it;
	}
}
Beispiel #4
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();
}