Page 1 of 1

IAnimatedMeshSceneNode with tangents(animated parallax)

Posted: Thu Dec 24, 2009 5:12 pm
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;
		}
}

Posted: Thu Dec 24, 2009 7:20 pm
by devsh
good job!!! :):)
now make a correction for skinned mesh where you have bones and they move vertices

coverMeshToTangents????

Posted: Tue Dec 29, 2009 4:55 pm
by gbox
IAnimatedMeshSceneNode heroMesh = smgr->getMesh(meshPath);
((scene::ISkinnedMesh*)heroMesh)->convertMeshToTangents();

why do not use this?

Posted: Wed Jan 06, 2010 9:30 pm
by almondega
gbox, your solution worked fine, very thanks!!