Game Development Community

setSkinName

by Stephen Colbran · in Torque 3D Professional · 08/08/2009 (4:26 pm) · 5 replies

Just a question, does the setSkinName in T3D allow for multiple textures (eg, body, legs)

I have been trying to get a model to work, but if I add the legs texture first, I cannot add a body texture (vice-versa).
Is it possible for setSkinName to work with multiple textures.

If not, will this be implemented?

#2
08/09/2009 (1:27 pm)
Yep, vanilla Torque 3D has a ShapeBase console method setMeshHidden(meshname, hidden), where hidden is a boolean. Pass true to hide the mesh, false to show it. Also, there's setAllMeshesHidden(hidden) which does the same to all meshes of a ShapeBase object.
#3
08/09/2009 (3:59 pm)
Im going to try and implement the TGEA solution (I have no idea how meshes work :P)
As I am not a C++ programmer, I have very little knowledge, but am learning ;)

As far as implementing goes, I think that I have done it correctly, and i only have 1 error which makes no sense to me (invalid conversion from 'BaseMatInstance' to 'MatInstance').

Here is the piece of code that has the error (line 31):

void TSShapeInstance::reSkin( String newBaseName, String oldBaseName )
{  
	//BCS - Swaps skin on shapebase and static objects  
	const char* MatName = NULL;  
	const char* newMatName = NULL;  
	if (oldBaseName && newBaseName) {  
        MatName = oldBaseName;  
		newMatName = newBaseName;  
	}  
	if (MatName == NULL || newMatName == NULL){return;}  
	if (ownMaterialList() == false) {cloneMaterialList();}  
	// Cycle through the materials.  
	
	
	
	// Cycle through the materials.
	TSMaterialList* pMatList = getMaterialList();
	const Vector<String> &materialNames = pMatList->getMaterialNameList();
	
	for (S32 j = 0; j < materialNames.size(); j++) 
	{
		// Get the name of this material.
		const String &pName = materialNames[j];
		if( !pName.isEmpty() )
		{
			continue;
		}
		
		if(!dStricmp(pName,MatName))  
		{  
			MatInstance * matInst = pMatList->getMaterialInst(j);  // Error line
			if(!matInst->swapMaterial(newMatName)){  
				Con::errorf("reSkin failed. Material %s not found.",newMatName);  
			}  
		} 
	}
			
			
	
//	TSMaterialList* pMatList = getMaterialList();  
//	for (S32 j = 0; j < pMatList->mMaterialNames.size(); j++)  
	//{  
		//const char* pName = pMatList->mMaterialNames[j];  
		 
	//}  
}