Creating multiple textures for an object


#1

I have a character that has several body, hat, shoes, body and top textures,
in which each body part takes 4 textures as normal example, diffusse, spec and gloss.

how can I import these textures for each body part.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////


#2
	const Path reginaTextureDiffBody = "../Data/regina/regina/Regina_Body_Diffuse.png";
	const Path reginaTextureMetalBody = "../Data/regina/regina/Regina_Body_Specular.png";
	const Path reginaTextureNormalBody = "../Data/regina/regina/Regina_Body_Normal.png";
	const Path reginaTextureRoughBody = "../Data/regina/regina/Regina_Body_Opacity.png";


	const Path reginaTextureBottomDiff = "../Data/regina/regina/Regina_Bottom_Diffuse.png";
	const Path reginaTextureBottomMetal = "../Data/regina/regina/Regina_Bottom_Specular.png";
	const Path reginaTextureBottomNormal = "../Data/regina/regina/Regina_Bottom_Normal.png";
	const Path reginaTextureBottomRough = "../Data/regina/regina/Regina_Bottom_Opacity.png";



	const Path reginaTextureHatDiff = "../Data/regina/regina.fbm/Regina_Hat_Diffuse.png";
	const Path reginaTextureHatMetal = "../Data/regina/regina.fbm/Regina_Hat_Specular.png";
	const Path reginaTextureHatNormal = "../Data/regina/regina.fbm/Regina_Hat_Normal.png";
	const Path reginaTextureHatRough = "../Data/regina/regina.fbm/Regina_Hat_Gloss.png";

	const Path Regina_Shoes_Diffuse = "../Data/regina/regina.fbm/Regina_Shoes_Diffuse.png";
	const Path Regina_Shoes_Specular = "../Data/regina/regina.fbm/Regina_Shoes_Specular.png";
	const Path Regina_Shoes_Normal = "../Data/regina/regina.fbm/Regina_Shoes_Normal.png";
	const Path Regina_Shoes_Gloss = "../Data/regina/regina.fbm/Regina_Shoes_Gloss.png";


	const Path Regina_Top_Diffuse = "../Data/regina/regina.fbm/Regina_Top_Diffuse.png";
	const Path Regina_Top_Specular = "../Data/regina/regina.fbm/Regina_Top_Specular.png";
	const Path Regina_Top_Normal = "../Data/regina/regina.fbm/Regina_Top_Normal.png";
	const Path Regina_Top_Gloss = "../Data/regina/regina.fbm/Regina_Top_Gloss.png";

	auto importTextures = TextureImportOptions::create();

	// body
	const HTexture reginaDiffBody = gImporter().import<Texture>(reginaTextureDiffBody);
	const HTexture reginaMetalBody = gImporter().import<Texture>(reginaTextureMetalBody);
	const HTexture reginaNormalBody = gImporter().import<Texture>(reginaTextureNormalBody);
	const HTexture reginaRoughBody = gImporter().import<Texture>(  reginaTextureRoughBody);

	// Bottom
	const HTexture reginaDiffBottom = gImporter().import<Texture>(reginaTextureBottomDiff);
	const HTexture reginaMetalBottom = gImporter().import<Texture>(reginaTextureBottomMetal);
	const HTexture reginaNormalBottom = gImporter().import<Texture>(reginaTextureBottomNormal);
	const HTexture reginaRoughBottom = gImporter().import<Texture>(reginaTextureBottomRough);

	// Hat
	const HTexture reginaDiffHat = gImporter().import<Texture>(reginaTextureHatDiff);
	const HTexture reginaMetalfHat = gImporter().import<Texture>(reginaTextureHatMetal);
	const HTexture reginaNormalfHat = gImporter().import<Texture>(reginaTextureHatNormal);
	const HTexture reginaRoughfHat = gImporter().import<Texture>(reginaTextureHatRough);


	// Hat
	const HTexture reginaSHoesDiff = gImporter().import<Texture>(reginaTextureHatDiff);
	const HTexture reginaSHoesSpec = gImporter().import<Texture>(reginaTextureHatMetal);
	const HTexture reginaSHoesNormal = gImporter().import<Texture>(reginaTextureHatNormal);
	const HTexture reginaSHoesRough = gImporter().import<Texture>(reginaTextureHatRough);

	// Hat
	const HTexture reginaTopDiff = gImporter().import<Texture>(reginaTextureHatDiff);
	const HTexture reginaTopSpec = gImporter().import<Texture>(reginaTextureHatMetal);
	const HTexture reginaTopNormal = gImporter().import<Texture>(reginaTextureHatNormal);
	const HTexture reginaTopRough = gImporter().import<Texture>(reginaTextureHatRough);


	const HShader shader = gBuiltinResources().getBuiltinShader(BuiltinShader::Standard);
	HMaterial riginaMaterialBody = Material::create(shader);
	riginaMaterialBody->setTexture("gAlbedoTex",    reginaDiffBody);
	riginaMaterialBody->setTexture("gMetalnessTex", reginaMetalBody);
	riginaMaterialBody->setTexture("gNormalTex",    reginaNormalBody);
	riginaMaterialBody->setTexture("gRoughnessTex", reginaRoughBody);

	const HShader shaderRigina = gBuiltinResources().getBuiltinShader(BuiltinShader::Standard);
	HMaterial riginaMaterialBottom = Material::create(shaderRigina);
	riginaMaterialBottom->setTexture("gAlbedoTex", reginaDiffBottom);
	riginaMaterialBottom->setTexture("gMetalnessTex", reginaMetalBottom);
	riginaMaterialBottom->setTexture("gNormalTex", reginaNormalBottom);
	riginaMaterialBottom->setTexture("gRoughnessTex", reginaRoughBottom);

	const HShader shaderRiginaHat = gBuiltinResources().getBuiltinShader(BuiltinShader::Standard);
	HMaterial riginaMaterialHat = Material::create(shaderRiginaHat);
	riginaMaterialHat->setTexture("gAlbedoTex", reginaDiffHat);
	riginaMaterialHat->setTexture("gMetalnessTex", reginaMetalfHat);
	riginaMaterialHat->setTexture("gNormalTex", reginaNormalfHat);
	riginaMaterialHat->setTexture("gRoughnessTex", reginaRoughfHat);

	const HShader shaderRiginaShoes = gBuiltinResources().getBuiltinShader(BuiltinShader::Standard);
	HMaterial riginaMaterialShoes = Material::create(shaderRiginaShoes);
	riginaMaterialShoes->setTexture("gAlbedoTex", reginaSHoesDiff);
	riginaMaterialShoes->setTexture("gMetalnessTex", reginaSHoesSpec);
	riginaMaterialShoes->setTexture("gNormalTex", reginaSHoesNormal);
	riginaMaterialShoes->setTexture("gRoughnessTex", reginaSHoesRough);

	const HShader shaderRiginaTop = gBuiltinResources().getBuiltinShader(BuiltinShader::Standard);
	HMaterial riginaMaterialTop = Material::create(shaderRiginaTop);
	riginaMaterialTop->setTexture("gAlbedoTex", reginaTopDiff);
	riginaMaterialTop->setTexture("gMetalnessTex", reginaTopSpec);
	riginaMaterialTop->setTexture("gNormalTex", reginaTopNormal);
	riginaMaterialTop->setTexture("gRoughnessTex", reginaTopRough);






	// Create new scene object at (0, 0, 0)
	 droneSO = SceneObject::create("Drone");

	 //Attach the Renderable component and hook up the mesh we loaded, and the material we created.
	HRenderable renderable = droneSO->addComponent<CRenderable>();
	renderable->setMesh(myModel);
	renderable->setMaterial(riginaMaterialBody);
	renderable->setMaterial(riginaMaterialBottom);
	renderable->setMaterial(riginaMaterialHat);
	renderable->setMaterial(riginaMaterialShoes);

image:


#3

Use Renderable::setMaterial overload which accepts an index of the sub-mesh. Then specify a different material for each sub-mesh. You need to match the exact index with the exact material so there might be some trial and error involved.