Box2D Render.bmx Question

BlitzMax Forums/Brucey's Modules/Box2D Render.bmx Question

Rico(Posted 2008) [#1]
I am just writing my own version of the Render.bmx program that is used in all the Test modules. Mine is not done using DebugDraw though - it is in the main body of the program after the DoStep part. I use Body.GetWorldPoint(ObjectVertex) for everypoint on a body - I store the Vertices for each shape in Userdata. The main reason I am doing this is because I want my objects to be different colours that I choose. e.g. my bullets as yellow and my spaceships as blue and red respectively.

Its working ok but I am confused in DrawSolidPolygon it does
SetAlpha 0.5
SetColor (color.red/2,color.green/2,color.blue/2)
.....
DrawPoly(poly)

If I do this exact same code in my drawing-routine nothing is drawn. I have to set the alpha to 1.0 (or higher than 0.5) for it to draw anything.

Its a minor point really, but I am not sure why the debugdraw routine can draw objects using this code when my routine can't. I think I must be missing something obvious, but i am not sure what.

Can someone enlighten me? - Thank you (I don't really understand a lot about alpha anyway - except it is like transparency)


Brucey(Posted 2008) [#2]
do you have a code-snippet for the bit that doesn't work?

Alpha is transparency. A value of 1 means it is opaque (not see through). A value of 0 means it is completely transparent. In between, is a percentage of transparency, becoming less so the closer to 1.


Rico(Posted 2008) [#3]
haha - This doesn't work below (doesn't draw anything) - but I suddenly realised I am not setting it to Alphablend. I guess if you don't do this then a value of 0.5 or below will mean invisible. Schoolboy error :)

' drawpoly.bmx

' draws a simple triangle using the
' DrawPoly command and an array of
' floats listed as 3 pairs of x,y
' coordinates

Local tri#[]=[0.0,0.0,100.0,100.0,0.0,100.0]

Graphics 640,480

While Not KeyHit(KEY_ESCAPE)
	Cls
	SetAlpha 0.5
	SetColor(255,255,255)
	DrawPoly tri
	Flip
Wend