2D Boundaries in 3D?
Blitz3D Forums/Blitz3D Programming/2D Boundaries in 3D?
| ||
Hello fellow programmers.. I am creating a 3rd person game in wich the 3d-player moves across a 2d-background (Grim Fandango, Monkey Island 4 etc.). I've created an editor that allows one to place lines where the character is suppose to stop from walking too far into the image. However, I can't seem to find a good way of setting up these boundaries in the game. Can anyone give me a hint? |
| ||
Maybe you could map your lines into a two-dimensional array (0=no line, 1=line). And because you know the x and z position of your 3d player, you can tell your 3D character to stop moving through all the 1s. |
| ||
Why not just fire your backdrop into a paint program, add another layer and paint a colour for where you can and can't go, maybe different colours for the the sound of the footsteps etc. Then save the layer as a separate image, maybe scale it down or something if you don't need pixel accuracy. The just read the colour from your new image based on where the feet are on the screen... Or load the image into an array... or whatever you feel most comfortable with. The bottom line is a paint package is probably the easiest and quickest editor you're going to have. |
| ||
Yeah Rob's method is probably the best. This is basically how Sierra's old AGI and SCI interpreters worked. A problem with this method is that it assumes all areas are flat. Stairs etc. where you would need the y-dimension would require a different approach. Well I guess you could script that.... What I first had in mind was to create a 3d-surface and just using blitz's collision-checking to check for boundaries, that would allow height-changes too... Well I think I try both and see which one works out best. |
| ||
Well, you could always try the resident evil approach. Basically, you have a 3d scene. But it's all colored the same color, full bright, no shininess, etc. Every frame, you grab the entire screen, put it in a normal 2d image. Have that image's transparency set to the same color as the scenery. Draw the 2d cartoon scene or whatever you're using for actual graphics. The paste the 3d stuff over the top. The great thing about this is that if the 3d scene lines up perfectly with the 2d scene, you can have objects which obscure the characters within the scene. That is, if a dog hides behind a rock, they will actually be hidden by the rock. Then they can jump out or what-have-you. \o/ Obviously, this has some pros and cons. But you can use simple 3d collisions stuff for stopping your player from walking where you don't want them to. :) |
| ||
When you render the 3d scene to a 2d image... make a VERY low res mesh of all of the bounding areas. Entityalpha the bounding mesh to 0.0(not hideentity so it handles collisions) and use blitz's collisions... for areas you can walk behind, you will have to make masks and separate layers. |
| ||
Yes, and you could also hide the mesh and use a second render pass. I don't know which is the fastest method. Guess I'll go find out. :) |
| ||
what vertigo said sounds the best way of doing it. Ie to make a lo res 3d version of the surrounding 2d and make it alpha 0 |
| ||
Then how do I draw the backdrop without the camera overwriting it? |
| ||
Use CameraClsMode to stop RenderWorld from clearing the screen each time, then you can draw you backdrop and have the 3D rendered on top of it. |