how to sort entities manually?

Blitz3D Forums/Blitz3D Programming/how to sort entities manually?

LAB[au](Posted 2003) [#1]
Since alphaed entities can't be sorted properly is there a way of ordering entities/faces in blitz3d? I would like to solve the flicker that happens sometimes when several alphaed entities overlap and that the one on the background will pop as it was in the foreground.

Thanks.


Litobyte(Posted 2003) [#2]
EntityOrder may help


Bot Builder(Posted 2003) [#3]
Entity Order could help, but problems arise when one part of an entity is in front AND in back of another entity. This is the principle of the zbuffer.


LAB[au](Posted 2003) [#4]
Somebody mentionned that it would be possible here http://www.blitzbasic.com/bbs/posts.php?topic=25701

I assumed it is with keeping Z buffer ordering or to do it manually.


jfk EO-11110(Posted 2003) [#5]
I think Anthony said he is reassembling all alpha Meshes each Frame based on Surfaces, in the order he wants them to be displayed.

Personally I had the Impression that this didn't happen, when I used .TGAs with Alphamaps included. At least it didn't happen with non-overlapping meshes.(the windows in my latest FPS Demo)


Pepsi(Posted 2003) [#6]
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