Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / creating a simple cockpit. sprite cockpit overlay over 3d models

Author
Message
Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 17th Feb 2011 01:09
I'm trying to combine sprites to create a cockpit, using the 'draw to front' command to prioritise sprites so they are drawn before any 3d is rendered. heres my code:



Unfortunately, the cockpit image, despite me even checking in mspaint to ensure the areas that need to be transparent are in fact, the correct color as specified in set image colorkey, i.e.. rgb(0,0,0), seems not to be allowing the transparent areas to show through.

they appear black, and the 3D sphere test object is obscured.
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 17th Feb 2011 03:50 Edited at: 17th Feb 2011 03:56
Not sure if "DRAW TO FRONT" is what you want there, if you are going to use sprites. I don't see any sprites in your code, but if you did use some sprites, there are commands DRAW SPRITES FIRST and DRAW SPRITES LAST as well.

You would be much better off using a .png file that already has transparency, instead of a .jpg with black areas. JPEG compression can change the colors in your image, so it might be making the black something besides 0,0,0.

So, a very basic demo of a sprite overlaid on a 3D environment...



As you can see, you don't have to use "DRAW TO FRONT" for this at all.

A version that uses a pasted image works the same way, no "DRAW TO FRONT", just pasting the image inside the loop.



If you want to attach your image, I would be happy to turn it into a .png with alpha channel, assuming you don't have that capability.

EDIT: In the above two examples, you don't actually need the SET IMAGE COLORKY statement, since DBP defaults to 0,0,0 as transparent in sprites and images pasted with transparency. Which is one reason why the .png format is better - what if your HUD graphic has some black pixels that you want to display?

Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 17th Feb 2011 23:09
I'll try making a .png with the checkered transparency... it makes sense that the jpeg format is making the black a different hue, as the compression does stuff like that.
Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 17th Feb 2011 23:25
Thanks so much Rich. I had one of those funny moments, when i re-loaded my original program, it was actually working fine! that was when i tried jpegs, but if anyone else browsing this has a similiar problem, keep in mind, jpegs alter images under compression.

also, very kind of you to offer to do transperency on my image, thats what makes dark basic programming such a pleasure, is the community spirit. You guys make this the best hobby ive ever had.

Login to post a reply

Server time is: 2024-09-29 02:32:52
Your offset time is: 2024-09-29 02:32:52