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.

DarkBASIC Professional Discussion / 3D->2D sprite on other 2D images with transparency?

Author
Message
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 28th Sep 2011 08:45 Edited at: 28th Sep 2011 08:47
I was coding something that mostly works, where I have a 3D object that I apply to a sprite. I tried setting the backdrop to RGB(255, 0, 255) then set the image colorkey to RGB(255, 0, 255) yet it still shows pink.

I was wondering what am I doing wrong?

Here's the code:

Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 28th Sep 2011 13:39 Edited at: 28th Sep 2011 13:40
For the SET IMAGE COLORKEY to have any effect it has to be called before any images are loaded. BTW I can't see any pink in your screenie

Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 28th Sep 2011 17:43
Lol... Well, it's not the screenie1.png that is showing pink. It's the image created from the camera with the pink backdrop. Attached is an image of what I see.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 28th Sep 2011 21:05
Does anyone have any ideas as to how I could fix this?

Any help would be greatly appreciated.
Webber
15
Years of Service
User Offline
Joined: 27th May 2011
Location:
Posted: 28th Sep 2011 21:39
You can change the backdrop color if you don't like the color. But are you trying to make a sprite using a 3D object? You can just use the get image command, and save image command to create your own custom image, and you can make the background of that image transparent. I suggest saving the images as a bmp or png. I would only use the camera as a tool for creating your images. If your planing on making multiple cameras for multiple images, don't do it. Your program will run extremely slow.

If you want the image to animate then just make multiple images, and create an animated sprite with them.

I like games, and stuff.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 29th Sep 2011 03:18
What I don't understand though is it's already been made into an image using "SET CAMERA TO IMAGE", so it should automatically accept the color key though, shouldn't it?
Webber
15
Years of Service
User Offline
Joined: 27th May 2011
Location:
Posted: 29th Sep 2011 03:29
You would think so, but I think making an image with the camera is different. Because the image is always changing, I don't think that it treats it like a normal image. You might be able to get it to work that way, but I have never seen anything like that before. Because the image is constantly changing, there might be a way if you can update the transparency. But if your making a 2D game I would try to avoid using cameras or anything 3D, other then tools for creating 2D images. Multiple cameras can slow down a program a lot.

I like games, and stuff.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 29th Sep 2011 03:48
True... I probably won't use multiple cameras. It would be nice if there was a way to load the 3D in the 2D playing field directly, then be able to get the screen coordinates to make a bounding square around it for 2D usability.
Webber
15
Years of Service
User Offline
Joined: 27th May 2011
Location:
Posted: 29th Sep 2011 04:06
Animated sprites would look just as good, and you will be able to paste large amounts of them without slowing the program down much.

I like games, and stuff.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 29th Sep 2011 04:34
Yeah... the only problem with animated sprites is that they are limited by what you record with them. With 3D models you can load them up real time and change verts as needed.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 29th Sep 2011 04:47
BTW, I tried making a bmp of the image, then reloading it. It didn't show the image at all when I reloaded it from the newly created file.

Webber
15
Years of Service
User Offline
Joined: 27th May 2011
Location:
Posted: 29th Sep 2011 04:49
Well if you want 2D make it 2D, and if you want 3D make it 3D.

If you want to load 3D objects into your program, but still want a down view 2D effect, then just use plains, boxes, etc, instead of sprites, and place the camera with a down view over the 3D environment.

I like games, and stuff.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 29th Sep 2011 04:59
I take it what you're after is what "Sprite Me" does? http://forum.thegamecreators.com/?m=forum_view&t=189201&b=5

I've not looked deeply into it but it shouldn't really be that hard to grab an image from a 3d render. One thing to note, depending on the background colour and anti aliasing your sprite may have odd blurs around the edges. ie grabbed an image with background 255,0,255, then pasted image onto a background 0,0,0 may have a purple edge due to the aliasing.

Warning! May contain Nuts!
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 29th Sep 2011 05:06
WLGfx - I can grab images from cameras just fine... But the issue lies with the transparency. I'm trying to use the SET COLOR KEY command with the image I got from the camera, and for some reason it's not drawing transparent. It should though, judging that the backdrop is the COLOR KEY, which is RGB (255, 0, 255). It didn't even draw it transparently when I utilized the PASTE IMAGE function with the image I got from the camera...

What I'm trying to do is have real time 3D on a 2D background.

Webber - I wouldn't mind doing that, though if I were to do that I might as well remodel everything I've done as far as the editor and all is concerned. Right now I'm just trying to stick to a single plan.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 29th Sep 2011 05:29
I kind of understand what you mean. If you can do all your 2D stuff before any 3D gets rendered would be ideal?

I've just had a look through the help files but not found yet what I'm looking for. Maybe it's cos I'm getting tired now...

Warning! May contain Nuts!
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 29th Sep 2011 06:21
Well 3d before 2d because I want to load 3d objects to use in real time, then copy them in real timeto images and then use those images as sprites for my 2d game. The original code snippet there should show what I'm trying to accomplish.
Rais
23
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 29th Sep 2011 09:43
Someone called Mage posted something a while back that would copy a 3d object to an image with transparency. Have a look here it may help.
[href]null[/href]http://forum.thegamecreators.com/?m=forum_view&t=184514&b=1
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 29th Sep 2011 13:21
That was the other one I was looking for. Cheers Rais

Warning! May contain Nuts!
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 29th Sep 2011 19:25
Thanks Rais! And thanks WLGfx.

I was looking at that code, and I saw how slow it actually did run, so Webber had a good point... (I'm trying to make my code run at 60fps ideally, at least 30fps, and the rate at which images could be loaded up with that was 11fps average for me).

I have another idea though, I'm not sure how well it will work... rather than having one camera per object, have the same kind of isometric view for the camera and for each frame where there would be 3D object shown, it's all shown on that camera. Then get the current bitmap of that camera, get the images of the models from that current bitmap, and then reset the current bitmap to the screen, draw to the screen, and paste the images accordingly with the other sprites.

Or, if there was a way I could get the screen coordinates of the projection of the camera, I could set up bounding squares for each object on the projection, and then draw the sprites around them according to their bottom y value.
Rais
23
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 29th Sep 2011 19:38
I did play around with Mage's example a bit... The codes a bit messy now but I think this still works, its a lot quicker. Have a look.

Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 29th Sep 2011 20:07
Cool! What all did you change? Also is the Image Kit necessary for this?
Rais
23
Years of Service
User Offline
Joined: 7th Jul 2003
Location:
Posted: 29th Sep 2011 21:44
Mage originally had the camera's and image kit being setup & destroyed every time you called the SnapShot function. I just moved all that out to the top of the program.

As for image kit, yes its necessary for the version I played around with - but I dont fully understand everything it does! AS i use image kit i never looked at removing it.

There is a version in mages post that doesnt use it. not sure how quick it is...
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 29th Sep 2011 21:52
I tried the version without it, and that was the one that only got like 11 frames per second with just a cube. So now I'm deciding to go all-out 3D (which might save me trouble in the long run).
Webber
15
Years of Service
User Offline
Joined: 27th May 2011
Location:
Posted: 30th Sep 2011 05:35
Making your editor in 3D will give you a lot more options for graphics, game play, and you can still draw sprites over the 3D world.

I like games, and stuff.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 30th Sep 2011 08:24
Well, I'm making my game in 3D.

My only concern now is I make my 3D models in blender, and export them as my own file format. My layout is similar to a wavefront OBJ file. Only difference is that it has multiple frames with the objects in each frame for animation.

I've made an OBJ loader using memblocks, but I'm trying to figure how to load animation data. Is the internal DBP object format similar to the .DBO format?

Login to post a reply

Server time is: 2026-07-11 02:55:36
Your offset time is: 2026-07-11 02:55:36