I've been getting confused with Alpha'd polys myself lately. I think playing around with the vertex alpha stuff didn't help me any. Anyways, I was thinking at one time I had problems with the EntityAlpha(mesh) command where my alpha polys where showing infront of all other solid polys in my level when they were not suppose to.
Anyways, I just tried doing an EntityAlpha test again and it seem to work good enough. It should do good for stuff like glass windows in indoor levels. Here is what I tested with:
; ###############
; Blitz var inits
; ###############
swidth=800
sheight=600
sdepth=32
;windowed=2
;fullscreen=1
; camera vars
cameraspeed#=.5
; ###########
; Blitz setup
; ###########
Graphics3D swidth,sheight,sdepth,1
Global camera=CreateCamera()
CameraRange camera,.1,10000
PositionEntity camera,0,0,-10
EntityType camera,1
light=CreateLight()
LightColor light,32,32,32
; Build scene to render
build_scene()
; center mouse
MoveMouse swidth/2,sheight/2
; #########
; Main Loop
; #########
While Not KeyHit(1)
; move camera
If KeyDown(31) Then MoveEntity camera,0,0,-cameraspeed#
If KeyDown(17) Then MoveEntity camera,0,0,cameraspeed#
If KeyDown(30) MoveEntity camera,-cameraspeed#,0,0
If KeyDown(32) MoveEntity camera,cameraspeed#,0,0
If MouseDown(1) MoveEntity camera,0,-cameraspeed#,0
If MouseDown(2) MoveEntity camera,0,cameraspeed#,0
; rotate camera
mx=MouseX()
my=MouseY()
mxs#=MouseXSpeed()
mys#=MouseYSpeed()
dest_cam_yaw#=dest_cam_yaw#-mxs#
dest_cam_pitch#=dest_cam_pitch#+mys#
RotateEntity camera,dest_cam_pitch#,dest_cam_yaw#,0
MoveMouse swidth/2,sheight/2
UpdateWorld
RenderWorld
Flip
Wend
End
Function build_scene()
brush=CreateBrush() ; create a brush
; the alpha surface
alphamesh=CreateMesh()
BrushColor brush,255,255,255
surf=CreateSurface(alphamesh,brush)
AddVertex surf,-1, 1,0;,0,0 ; 0 left top
AddVertex surf, 1, 1,0;,1,0 ; 1 right top
AddVertex surf,-1,-1,0;,0,1 ; 2 left bottom
AddVertex surf, 1,-1,0;,1,1 ; 3 right bottom
AddTriangle surf,2,0,1 ; and 2 triangles...
AddTriangle surf,2,1,3
EntityFX alphamesh,17
UpdateNormals alphamesh
EntityAlpha alphamesh,.5
; the solid back surface
solidmesh1=CreateMesh()
BrushColor brush,0,128,255
surf=CreateSurface(solidmesh1,brush)
AddVertex surf,-2, 1,0.125;,0,0 ; 0 left top
AddVertex surf, 0, 1,0.125;,1,0 ; 1 right top
AddVertex surf,-2,-1,0.125;,0,1 ; 2 left bottom
AddVertex surf, 0,-1,0.125;,1,1 ; 3 right bottom
AddTriangle surf,2,0,1 ; and 2 triangles...
AddTriangle surf,2,1,3
EntityFX solidmesh1,17
UpdateNormals solidmesh1
; the solid back surface
solidmesh2=CreateMesh()
BrushColor brush,255,128,0
surf=CreateSurface(solidmesh2,brush)
AddVertex surf, 0, 1,-0.125;,0,0 ; 0 left top
AddVertex surf, 2, 1,-0.125;,1,0 ; 1 right top
AddVertex surf, 0,-1,-0.125;,0,1 ; 2 left bottom
AddVertex surf, 2,-1,-0.125;,1,1 ; 3 right bottom
AddTriangle surf,2,0,1 ; and 2 triangles...
AddTriangle surf,2,1,3
EntityFX solidmesh2,17
UpdateNormals solidmesh2
; free brush from memory use
FreeBrush brush
End Function
|