#### Archived

This topic is now archived and is closed to further replies.

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

This topic is 5345 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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!

##### Share on other sites
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.

##### Share on other sites
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.

##### Share on other sites
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

##### Share on other sites
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).

##### Share on other sites

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.

##### Share on other sites
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.

##### Share on other sites
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!

##### Share on other sites
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]

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633313
• Total Posts
3011316
• ### Who's Online (See full list)

There are no registered users currently online

×