load and apply textures to surfaces

Blitz3D Forums/Blitz3D Programming/load and apply textures to surfaces

Zmatrix(Posted 2014) [#1]
Im trying to load textures with n_ appended and apply them to the surface of the texture they match. In this case normalmaps for EnBm, environment map on layer 3

Works on single surface.
Works if i just reapply all the same textures on another layer replacing tex with my_tex .


Am I forgetting or overlooking somthing?

Been away from blitz for a long while..lol

function apply_textures(mesh$)

For index = 1 To CountSurfaces(mesh$)

surfs=GetSurface(mesh$,index)

my_brush=GetSurfaceBrush(surfs)

my_tex=GetBrushTexture(my_brush,1)     ;texture layer 1 for .b3d from 3dworldstudio

tex=LoadTexture("c:\mygame\"+"n_"+StripPath$(TextureName$(my_tex)))
;look for "n_" on the front of the texture name 
if tex<>0
    textureblend tex,fe_bump
    
    BrushTexture my_brush,tex,0,2  
     
    PaintSurface surfs,my_brush
endif

freebrush(my_brush)
next

end function






Thanks in Advance

Sam


RemiD(Posted 2014) [#2]
about your code :
mesh$ should be mesh% (an integer because it is a pointer/reference)

about what you are trying to do :
try to load your mesh with fragmotion and check what is the fx and the blendmode of each surface.
if the mesh is exported with 3DWS, there may be some properties set which prevent you to apply another brush on a surface, try to set the fx to default and the blendmode to alpha, these are the default properties of a surface. (vertex lighted)


Zmatrix(Posted 2014) [#3]
Thanks RemiD ill give that a shot.

I do know that it exports, layer 0 lightmaps, layer 1 diffuse , and the all the brushes are full bright.
Im not loading as animmesh so shouldnt have to step through children i dont think.




Sam


Rick Nasher(Posted 2014) [#4]
Somewhat related:
Does anybody know if it is possible to change textures of a B3D model that already has textures "baked" onto it by a 3D-modeler program?

I've noticed that when I tried to apply new textures using "EntityTexture B3Dmodel,texture", it seemingly ignored the new textures and kept the originals..


RemiD(Posted 2014) [#5]
@Rick>>Do the tweak i mentioned with Fragmotion, then, in Blitz3d, retrieve the surface, then create a brush, then add a texture to the brush, then set the fx of the brush (if you want vertex lighting or fullbright for a lightmap), then apply the brush to the surface, then free the brush. This should work.

This allows to configure and paint each surface as you want.


Rick Nasher(Posted 2014) [#6]
Many thanks, I'll give it a try.