Need to create a 50% opacity quad to display text on, in my 3d scene

Started by
7 comments, last by oxygen_728 20 years ago
I have a 3d scene with bouncing balls and all kinds of good stuff. However, I need to draw a rectangle which is 50% opaque... which I can then draw text on... such as: R: Toggle Rotation S: Increase Speed etc.. I know one way to do this is to use 2 triangles with black, 50% alpha vertices... but then It seems a pain to remember where to draw these triangles. Is there a simple way to draw a 2d triangle on my 3d scene? I thank you for your time.. and feel free to point me to a tutorial. Have a great day!
Advertisement
You answered your own question. Draw two triangles (or a quad if your environment allows it) at 50% alpha. That''s how I do it (and I assume most programmers).

You could wrap this in a function so that you can ignore the details.
when you define your vertex for 2d, include a homogenous coordinate component w ( float x,y,z,w ) and define your FVF as D3DFVF_XYZRHW rather than D3DFVF_XYZ.
quote:Original post by nhatkthanh
when you define your vertex for 2d, include a homogenous coordinate component w ( float x,y,z,w ) and define your FVF as D3DFVF_XYZRHW rather than D3DFVF_XYZ.


Just so that it makes sense for him, why?

MindEngine Development
http://medev.sourceforge.net
when you use the RHW flag it is transform vertex and that it will not get transform when it go through the vertex transformation pipeline. So when you create the vertex with this flag you will get it to where you want (you can specify its coordinate in screen position).

You can use WHITE, 50% alpha vertex colors, and then modulate (multiply) your vertex color with the texture color of your text texture. Then turn on alpha blending with srcalpha/one-minus-srcalpha.
enum Bool { True, False, FileNotFound };
To the anonymous poster... I did not answer my own question. I asked if there was a simpler way than going through all that trouble... but thanks for the suggestion.

Thank you for the help guys, it is much appreciated.

Hmm.. I thought I understood this earlier...

If I specify the coordinates in screen position, isn''t that 2-dimensional?

If I want a quad from 50,50 to 250,250 ... Am I going to have to mess with Z coordinates?

I''m trying to figure out exactly how this RHW business works.

Thanks!
AFAIK, with RHW, the Z coordinate only specifies the z-order.. eg. with two objects overlapping, the one with the lower z value will be on top. But you won't actually see any depth to objects, nor will they actually look as though they go back into the screen.

[Edit:] Scratch that, after some playing round, it seems as though Z coord. has no effect whatsoever... But the order in which the polys are drawn determines their z-order.

[edited by - henrym on March 28, 2004 6:29:07 PM]

This topic is closed to new replies.

Advertisement