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 / Displaying multiple layers of terrain

Author
Message
Alaror
15
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 27th Dec 2011 21:53
Right now I'm using the default matrix commands to display the terrain in my 2d platformer. I like the flexibility that they provide, especially the ability to edit the data in real time. Up until now I've only needed to display a single "layer" of terrain, but I'd like to start adding a wider range of terrain types (such as fluids and foreground objects). While all the terrain up until now needed to be displayed behind the player, the new terrain layers would need to be displayed in front of the player. Here's a rough breakdown of the various layers:

-Ground tiles (dirt, stone, etc)
-Objects (player, traps, etc)
-Fluids (water, lava, gas, etc)
-Foreground objects (vines, small stones, etc).

I've done some tests using two different matrices layered on top of each other with the player sandwiched in between, but they don't display correctly. The player appears in front of all the layers despite the position being set behind the "fluids" layer. I believe this is happening because the position values I'm using are different only by .0001, so the ground tiles are set to 1.0004, intractable objects are set to 1.0005, the player is set to 1.0006, and the fluids matrix is set at 1.0007. I have to do it this way or they'll appear to move at different speeds from the camera.

Is there any way to fix what appears first, second, third etc while appearing to be the same distance from the camera?
Alaror
15
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 28th Dec 2011 05:58
After some more digging it seems that what I'm really doing is trying to find a way to set the object drawing priority. There seems to be a command to set the priority for Sprites, but there's no equivalent for objects. I'd really like all the objects to be the same distance from the camera and give each one a priority instead of using their distance from the camera.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th Dec 2011 10:51
the command 'Disable Object ZDepth' will stop objects being drawn according to their distance from the camera. After this, the lowest (?) object number gets drawn first.

My signature is NOT a moderator plaything! Stop changing it!
Alaror
15
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 28th Dec 2011 20:29
Alright, I disabled ZDEPTH for all the objects and changed how the object numbers are allocated so that those which are supposed to appear above the others have a higher object number. It doesn't seem to be working. It's most apparent in the screenshot below which was taken during a "transition" phase where the screen fades to white and then back to the game. The player object and GUI are supposed to fade behind the white, semitransparent object but they appear above it.

There are a few things I can think of that might be causing it, but I don't have any experience using these commands so I don't really know.

1. Because there are no rotate options for MATRIX commands and the game is a platformer, I'm forced to use the Y position value as the Z value. Every object is rotated the same amount to ensure they're facing the camera.

2. The player object is made up of limbs which have had their Z position changed to ensure that the limbs overlap correctly (the back leg should not appear above the front leg, etc). Does ZDEPTH have to be disabled for each limb separately, or is there some other way to establish what limb appears above the rest?

3. I use the LOCK OBJECT ON command for the menu objects since they need to stay in the same location relative to the camera.
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 28th Dec 2011 23:17
try using SET OBJECT ZBIAS command

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 29th Dec 2011 02:55
was going to say try the 2D plugin but I recall issues for win7... can someone confirm this? I would like to confirm this..

Alaror
15
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 29th Dec 2011 04:32
Quote: "try using SET OBJECT ZBIAS command"


This would be perfect, but there's absolutely no information about how it works. It seems like no one knows what "Slope Scale" and "Depth" mean


Quote: "was going to say try the 2D plugin"


I'd really rather not purchase a plugin to do this. A large amount of code would have to be changed to get it working.
david w
20
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 29th Dec 2011 18:02
I would not recommend ZBIAS simply because its never had a standard implementation accross graphics cards. ATI,NVIDIA, INTEL, have all implemented it differently and on occassion they have even done it differently in thier own house. You simply can't count on platform compatability with this command.
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 29th Dec 2011 18:43 Edited at: 29th Dec 2011 18:44
Quote: ""Slope Scale""

set it to 1

Quote: ""Depth""

all the object that are overlapping should have different values.
The object that should be on top of all the other objects should have the smallest value, the one that should be the last in drawing order should have the biggest value, etc..
If you set the slope value to 1 that depth values should be between 0 and 1

Alaror
15
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 29th Dec 2011 21:25
@Brendy boy

I'll have to give that a try when I get a chance. Have you used it yourself successfully without any of the issues that david w mentioned?
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 29th Dec 2011 21:46
Quote: "Have you used it yourself successfully without any of the issues that david w mentioned? "

i allways had an ATI card and it worked correctly, i can't say for other cards

Alaror
15
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 30th Dec 2011 19:27
I think I found a solution that works for me.

I remember IanM mentioning a command that allowed you to manually set how objects are created in this previous topic of mine (http://forum.thegamecreators.com/?m=forum_view&t=190311&b=1). The command he mentioned is SET GLOBAL OBJECT CREATION, and by using the value 4 it seems to correctly display objects depending on their object number. All the objects are set to have the same height, and those with a higher object number appear above the others. Now I just have to hope that it doesn't cause other problems in the future

Login to post a reply

Server time is: 2026-07-10 10:21:16
Your offset time is: 2026-07-10 10:21:16