It appears to be related to the fact that I load the 2nd texture (the crack.jpg) with a flag of 4 - if I don't then all is ok. Why is this?
; CreateCamera Example
; --------------------
alpha# = 1
Graphics3D 640,480
SetBuffer BackBuffer()
; Create camera
camera=CreateCamera()
light=CreateLight()
cube=map_create_unstable_block()
PositionEntity cube,0,0,5
While Not KeyDown( 1 )
If KeyDown(200)
If alpha < 1
alpha = alpha + 0.005
EndIf
EntityAlpha cube, alpha
EndIf
If KeyDown(208)
If alpha > 0
alpha = alpha - 0.005
EndIf
EntityAlpha cube, alpha
EndIf
TurnEntity cube, 0.4, 0.6, 0.9
RenderWorld
Flip
Wend
End
Function map_create_unstable_block()
m = CreateMesh()
s = CreateSurface(m)
;bottom face
v0 = AddVertex(s,-1,+1,+1,0,1)
v1 = AddVertex(s,+1,+1,+1,0,0)
v2 = AddVertex(s,+1,+1,-1,1,0)
v3 = AddVertex(s,-1,+1,-1,1,1)
AddTriangle s,v0,v1,v2
AddTriangle s,v0,v2,v3
s1 = CreateSurface(m)
;top face
v0 = AddVertex(s1,-1,-1,-1,1,0)
v1 = AddVertex(s1,+1,-1,-1,1,1)
v2 = AddVertex(s1,+1,-1,+1,0,1)
v3 = AddVertex(s1,-1,-1,+1,0,0)
AddTriangle s1,v0,v1,v2
AddTriangle s1,v0,v2,v3
s2 = CreateSurface(m)
;left face
v0 = AddVertex(s2,-1,+1,+1,0,0)
v1 = AddVertex(s2,-1,+1,-1,1,0)
v2 = AddVertex(s2,-1,-1,-1,1,1)
v3 = AddVertex(s2,-1,-1,+1,0,1)
AddTriangle s2,v0,v1,v2
AddTriangle s2,v0,v2,v3
;right face
v0 = AddVertex(s2,+1,+1,-1,0,0)
v1 = AddVertex(s2,+1,+1,+1,1,0)
v2 = AddVertex(s2,+1,-1,+1,1,1)
v3 = AddVertex(s2,+1,-1,-1,0,1)
AddTriangle s2,v0,v1,v2
AddTriangle s2,v0,v2,v3
; front face
v0 = AddVertex(s2,-1,+1,-1,0,0)
v1 = AddVertex(s2,+1,+1,-1,1,0)
v2 = AddVertex(s2,+1,-1,-1,1,1)
v3 = AddVertex(s2,-1,-1,-1,0,1)
AddTriangle s2,v0,v1,v2
AddTriangle s2,v0,v2,v3
;back face
v0 = AddVertex(s2,+1,+1,+1,0,0)
v1 = AddVertex(s2,-1,+1,+1,1,0)
v2 = AddVertex(s2,-1,-1,+1,1,1)
v3 = AddVertex(s2,+1,-1,+1,0,1)
AddTriangle s2,v0,v1,v2
AddTriangle s2,v0,v2,v3
UpdateNormals m
crack = LoadTexture("crack.jpg", 4)
TextureBlend crack, 3
floor_brush = CreateBrush()
BrushTexture floor_brush, LoadTexture("wood2.jpg"), 0, 0
BrushTexture floor_brush, crack, 0, 1
PaintSurface s, floor_brush
ceiling_brush = CreateBrush()
BrushTexture ceiling_brush, LoadTexture("wood2.jpg"), 0, 0
BrushTexture ceiling_brush, crack, 0, 1
PaintSurface s1, ceiling_brush
wall_brush = CreateBrush()
BrushTexture wall_brush, LoadTexture("wood2.jpg"), 0, 0
BrushTexture wall_brush, crack, 0, 1
PaintSurface s2, wall_brush
Return m
End Function
You'll need 2 texture files...
|