
por
Cibertronic
Exelente,, Render to texture.... ahora mismo lo estoy revisando y parece justo lo que necesitabamos, asi ya dejamos tranquilo al giles

Buenas, no había posteado por aqui antes (creo, hace mucho tiempo que me registré xD), pero he visto el hilo y como veo que estais al filo con el tema del Blitz 3D, vengo a compartir un poco mi experiencia con el.
Yo utilizo el Render to Texture del MAX para generar los Lightmaps, y ya que muchas veces es un coñazo tener que poner la textura resultante en cada material de cada objeto (y si tienes muchos objetos que tengan el mismo material, ya ni te digo), hice un pequeño metodo de ayuda para cargar los lightmaps resultantes:
Código:
Function LoadAnimMeshLightmapped(file$, lightmapfolder$="(same)", parent=0, slot=7)
; Load animated mesh
Mesh = LoadAnimMesh(file$)
If (Mesh=0) Then Return Mesh
; If needed, strip the lightmap folder path
If (lightmapfolder$="(same)") Then lightmapfolder$=LoadAnimmeshLightmapped_ExtractPath$(file$)
; Iterate through each child object
LoadAnimMeshLightmapped_Child(Mesh, lightmapfolder$, slot)
; Done
Return Mesh
End Function
Function LoadAnimMeshLightmapped_Child(node, lightmapfolder$, slot)
; Check out node's class
If (EntityClass$(node)<>"Mesh") Then Goto IterateChilds
DebugLog("Load mesh "+EntityName$(node))
DebugLog("-> Trying to load lightmap at "+lightmapfolder$+"/"+EntityName$(node)+"LightingMap.tga")
; Load texture and if it exists, apply to all surfaces at the selected slot
LightmapTexture = LoadTexture(lightmapfolder$+"/"+EntityName$(node)+"LightingMap.tga", 1)
If (LightmapTexture=0) Then Goto IterateChilds
DebugLog("-> Success")
; Setup lightmap texture
TextureBlend(LightmapTexture, 2)
TextureCoords(LightmapTexture, 1)
; Find out if the entity has only one brush or multiple.
Brush = GetEntityBrush(node)
If (Brush = 0) Then
; Iterate through all surfaces
For i=1 To CountSurfaces(node)
; Acquire brush
Surface = GetSurface(node, i)
Brush = GetSurfaceBrush(Surface)
; Set lightmap to slot
BrushTexture(Brush, LightmapTexture, 0, slot)
; Apply brush to surface
PaintSurface(Surface, Brush)
; Free brush
FreeBrush(Brush)
Next
Else
; Set lightmap to slot
BrushTexture(Brush, LightmapTexture, 0, slot)
; Apply brush to surface
PaintEntity(node, Brush)
; Free brush
FreeBrush(Brush)
End If
FreeTexture(LightmapTexture)
EntityFX(node, 1)
.IterateChilds
For i=1 To CountChildren(node)
LoadAnimMeshLightmapped_Child(GetChild(node, i), lightmapfolder$, slot)
Next
End Function
Function LoadAnimmeshLightmapped_ExtractPath$(File$)
Path$ = "."
Found = False
Offset = 1
Check = 1
While(True)
Check = Instr(File$, "/", Offset+1)
If (Check = 0) Then Check = Instr(File$, "\", Offset+1)
If (Check > Offset) Then
Found = True
Offset = Check
Else
Exit
End If
Wend
If (Found = True) Then Path$ = Left$(File$, Offset)
Return Path$
End Function
Principalmente se utiliza como el LoadAnimMesh, pero automaticamente busca en el directorio de la malla si encuentra una textura lightmap correspondiente al nombre del objeto de la malla y la carga automaticamente en el slot.
Ejemplo:
Código:
Nivel = LoadAnimMeshLightmapped("Nivel.b3d", ".\Lightmaps\")
Marcadores