Panda3D Manual: Tinting and Recoloring
Color and the Model LoaderWhen you create a 3D model in Max, Maya, or the like, you can color the model right in the modeling program. I'm not talking about using a texture. I'm talking about just setting a single color to the model as whole. This is called a "flat color." These art programs also allow you to "paint vertex colors": you can color each vertex of the model a different color. Of course, sometimes you do neither, in which case the model is just white. Every model you load already has a color attribute. Color Attributes are usually not created by the programmer explicitly, they're usually created by the model loader only. There are three possible color attributes created by the model loader:
Panda combines these color attributes with the textures. If you are accustomed to Photoshop, you should think of the model's color as the bottom (background) layer, and the textures go above that. By default, each texture is modulated (multiplied) with the previous layer, but as in Photoshop, that can be changed.
Recoloring the ModelIf you wish, you can manually override the color attribute which has been specified by the model loader. nodePath.setColor(r,g,b,a) Again, this is an override. If the model already had vertex colors, these will disappear: the It should be mentioned that the color attribute created by the model loader has low priority. That means that even a default-priority You can remove a previous Tinting the ModelSometimes, you don't want to replace the existing color, sometimes, you want to tint the existing colors. For this, you need setColorScale: nodePath.setColorScale(r,g,b,a) This color will be modulated (multiplied) with the existing color. You can remove a previous DemonstrationTo see the difference between import direct.directbase.DirectStart This produces the following output: The model on the left is the original, unaltered model. Nik has used vertex colors throughout. The yellow of the belly, the black eyes, the red mouth, these are all vertex colors. The one in the
middle has been Related Classes© Carnegie Mellon University 2010 |