IAnimatedMeshSceneNode with tangents(animated parallax)

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
roci
Posts: 1
Joined: Thu Dec 24, 2009 4:32 pm

IAnimatedMeshSceneNode with tangents(animated parallax)

Post by roci »

Here is simple function to add tangents to animation...
that means animated parallax ,normal ...

Code: Select all

void ConvertToAnimatedWithTangents(scene::IAnimatedMeshSceneNode *node,scene::ISceneManager* smgr)
{
	
		
	scene::IAnimatedMesh* Mesh = node->getMesh();
	scene::SAnimatedMesh* am = new scene::SAnimatedMesh();

	for(int i=0;i<=Mesh->getFrameCount();i++)
	{
	scene::IMesh* tangentMesh =smgr->getMeshManipulator()->createMeshWithTangents(Mesh->getMesh(i));
	am->addMesh(tangentMesh);
	}
	//Mesh->drop();
	node->setMesh(am);
	am->drop();
	
}
how to use :

Code: Select all

scene::IAnimatedMesh* mesh =smgr->getMesh("dwarf.x");;
if (mesh)
{scene::IAnimatedMeshSceneNode *node = smgr->addAnimatedMeshSceneNode(mesh);
		
		ConvertToAnimatedWithTangents(node,smgr);
		// load heightmap, create normal map from it and set it
		video::ITexture* NormalMap = driver->getTexture("rockwall_height.bmp");
		if (NormalMap)
		{
			driver->makeNormalMapTexture(NormalMap, 9.0f);
			node->setMaterialTexture(0, driver->getTexture("rockwall.jpg"));
			node->setMaterialTexture(1, NormalMap);
			node->setMaterialType(video::EMT_PARALLAX_MAP_SOLID);
			node->getMaterial(0).MaterialTypeParam = 0.035f;
		}
}
Last edited by roci on Thu Dec 24, 2009 10:44 pm, edited 1 time in total.
I♥♀♀♀♀♀♀♀♀♀♀♀...
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

good job!!! :):)
now make a correction for skinned mesh where you have bones and they move vertices
gbox
Posts: 37
Joined: Mon May 01, 2006 3:41 am
Location: jeonju, korea
Contact:

coverMeshToTangents????

Post by gbox »

IAnimatedMeshSceneNode heroMesh = smgr->getMesh(meshPath);
((scene::ISkinnedMesh*)heroMesh)->convertMeshToTangents();

why do not use this?
http://cafe.naver.com/jcga

professor of Jelabukdo Game Engine Academy
almondega
Posts: 37
Joined: Sat Jun 21, 2008 2:14 am

Post by almondega »

gbox, your solution worked fine, very thanks!!
Post Reply