Game Development Community

the object-material connection

by Thomas Bang · in Torque 3D Professional · 05/14/2011 (8:15 am) · 6 replies

Hi

Rendered shapes (TSStatic, Item, Player, StaticShape, ...) have a method called changeMaterial(...).
When i use this method, where is the name of the newly assigned material stored? Directly in the DTS?

Greetings
Thomas

#1
05/14/2011 (8:04 pm)
Yes, the materials will be defined in the dts, and script will use a singleton datablock to define the location of the texture files. One way to get the names of the textures used in the dts (aside from looking at them in Milkshape or similar program) is to use %player.getMeshVisibility();
#2
05/16/2011 (2:54 am)
Thanks. But i did not found getMeshVisibility() ...
#3
05/16/2011 (5:28 am)
Oops, sorry. GetMeshVisibility() isn't a stock T3D function. Use dumpMeshVisibility();
#4
05/16/2011 (10:36 am)
It works, thanks. The other way to get the assigned materials and textures can be:

function getMatInfo(%objID)
{
   %numSurfaces = %objID.getTargetCount();
   for (%i=0; %i<%numSurfaces; %i++)
   {
      %surface = %objID.getTargetName(%i);
      %material = getMaterialMapping(%surface);
      
      %diffuseMap = %material.diffuseMap[0];
      %normalMap = %material.normalMap[0];
      %specularMap = %material.specularMap[0];
   }
}

I think, the problem is the line "%material = getMaterialMapping(%surface);" because it sounds to me, that the used names of the surfaces have to be unique in the game and not only in the mesh itself.
#5
05/19/2011 (10:17 am)
Can anyone confirm that?
#6
05/20/2011 (7:12 pm)
Yes, material mapping is global. This is a somewhat borked aspect of the system. mapTo really isn't the best of ideas.