Pixel perfect question

Blitz3D Forums/Blitz3D Programming/Pixel perfect question

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Ross,

The majic pivot in skidracers code confused me a bit so, a simpler way to get a texel's width on screen is initialising GUIsx, GUIsy with ...

GUIplane = CreatePlane( 1, GUIcamera )
RotateEntity GUIplane, -90,0,0
PositionEntity GUIplane, 0,0,1
EntityPickMode GUIplane, 2
CameraPick ( GUIcamera, 0,0 )
sx# = PickedX()
sy# = PickedY()
CameraPick ( GUIcamera, 1,1 )
GUIsx# = PickedX() - sx 
GUIsy# = sy - PickedY() 
FreeEntity GUIplane


Create quads like so ...

Function GUI_Quad( sx#, sy#, Texture=0 , Free = False , ox#=0, oy#=0 , oz# = 0 , order=-998 )

	mesh = CreateMesh( GUIcamera )
	s = CreateSurface( mesh )
	For iy = 0 To 1
		For ix = 0 To 1
			px# = ( ix * sx - ox ) * GUIsx
			py# = ( -iy * sy + oy ) * GUIsy
			AddVertex s, px, py, oz, ix+.5*(1.0/sx), iy+.5*(1.0/sy )
		Next
	Next
	AddTriangle s, 0,1,3
	AddTriangle s, 3,2,0
	EntityFX mesh, 1
	
	If Texture > 0
		EntityTexture mesh , Texture
		If Free FreeTexture Texture
	EndIf
		
	EntityOrder mesh, order
		
	Return mesh

End Function


Then position with .....

Function GUI_Position( Entity , x#, y# )

	PositionEntity Entity, ( x - HGW ) * GUIsx , ( HGH - y ) * GUIsy, 0

End Function


Where HGW, HGH are half graphics width / height

Stevie