Jump to content
  • Advertisement
Sign in to follow this  
PhonicUK

MD3D - Setting an alpha value on a material

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, im trying to set an alpha value on a material to make a mesh transparent. Problem is im using .NET CF and Color.FromARGB doesn't have an A param. Also Color.A is a ReadOnly property :S Any other methods I can use to create a Color with an alpha value? Thx!

Share this post


Link to post
Share on other sites
Advertisement
FromArgb doesn't have a param for A?

O rly? [wink]

All the best,
ViLiO

Edit: Oh is that what CF stands for ..my bad [lol]

[Edited by - ViLiO on July 3, 2006 10:59:46 AM]

Share this post


Link to post
Share on other sites
There are 2 overloads of Color.FromArgb, one of which takes an int. Construct the value like so: 0xaarrggbb, using bitwise operators.

EDIT: He's using the Compact Framework, guys, on which the overloads you linked to aren't supported. Check "Version Information" at the bottom of the documentation page, or check the Compact Framework documentation [smile]

Share this post


Link to post
Share on other sites
Oh, didn't notice that CF there :). Whoops.

At any rate, the int version seemed to give me problems with the 0xFFFFFFFF style since that's an unsigned int. I've had trouble with just casting it, so you might want to use caution. Might have been something else though :).

Share this post


Link to post
Share on other sites
I'm not entirely sure what you meant Sirob, but you can disable int range checking by using int i = unchecked((int)0xffffffff); - so you don't have to bother with uints. Hope this helps, makes sense or is somewhat applicable to the question at hand :)

Share this post


Link to post
Share on other sites

Public Function ARGBtoInt(ByVal A As Integer, ByVal R As Integer, ByVal G As Integer, ByVal B As Integer)
Dim RV As Integer
RV = B
RV += (G * 256)
RV += (R * 65536)
RV += (A * 4294967296)
Return RV
End Function





Tada? I think lol

Edit: Nope, integer overflow! Any ideas?

Share this post


Link to post
Share on other sites
I don't know the VB.NET syntax, but this generally works for me:

int argb = (a << 24) | (r << 16) | (g << 8) | b;

Share this post


Link to post
Share on other sites
Dim ARGB as Integer = (A << 24) Or (R << 16) Or (G << 8) Or B

Cheers dude :D

Edit: Woo it all works! I have alpha blending on my Pocket PC! :D

[Edited by - PhonicUK on July 3, 2006 4:40:26 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!