Using Multiple Textures

Blitz3D Forums/Blitz3D Programming/Using Multiple Textures

nivek(Posted 2004) [#1]
How do I apply different textures to the same object? I have a human model and I have a body texture and a head texture. I want to apply the body texture to the body only (below the neck) and I want to apply the head texture to the head only (above the neck).

Thanks


jfk EO-11110(Posted 2004) [#2]
the model requires multiple surfaces.

Print countsurfaces(mesh)
will tell you if there are 2 surfaces at all. If so, you can do this:

brush1=loadbrush("head.bmp")
brush2=loadbrush("body.bmp")

paintsurface getsurface(mesh,1),brush1
paintsurface getsurface(mesh,2),brush2

Well, basicly it's a bit more complicated since the order of the surfaces may differ each time you load it.
So maybe you better use the LoadAnimMesh command to load the Character.

If you did create the Character yourself, you'd know the Entitynames of the children, eg. "head" or "body". If you don't know the names, try this: http://www.blitzbasic.com/codearcs/codearcs.php?code=615

After knowing the names of the children, you can do this:

head=findchild("head")
body=findchild("bodyorwhatever")

entitytexture head, headtex
entitytexture body, bodytex

(assuming you used to load those textures)

After all I suggest to save the Models in a way that they automaticly load with textures in Blitz.

(There is also an other method that will allow to use LoadMesh, find out what texture each Surface uses and then identify the surfaces this way. Have a look at the SaveB3D Example in the 3D>Mesh Code Archives, it shows how to identify surfaces by texture usage)