GLBasic forum

Main forum => FAQ => Topic started by: equinox on 2010-Feb-27

Title: There will be opportunities can have depth-order ?
Post by: equinox on 2010-Feb-27
There will be opportunities can have X, Y, Z, for a just ordering of depth of objects (depth-order) in GLBasic-2D function ?

Tags: zorder, z-order, z order
Title: Re: There will be opportunities can have depth-order ?
Post by: Ian Price on 2010-Feb-27
Here is one simple method of z-ordering sprites - basically it relies on you drawing the sprites in order based on their Y position and their height.

The graphics come from Jack The Nipper

Attachment contains .EX and source.

[attachment deleted by admin]
Title: Re: There will be opportunities can have depth-order ?
Post by: equinox on 2010-Feb-27
Tnk1000.

This code was what I was looking.
Title: Re: There will be opportunities can have depth-order ?
Post by: Hemlos on 2010-Feb-28
My message here is not directly related to the Q&A, however it is similiar.

Ian, i have a 3d particle engine which is in dire need of z ordering.

MY question is, do you have any simple solution for handling the Z depth using 3d decimal coordinate system which might have thousands of sprite objects?
Title: Re: There will be opportunities can have depth-order ?
Post by: Ian Price on 2010-Feb-28
Hemlos: Short and simple answer - no. I'm strictly 2D only. The code above will happily deal with hundreds of sprites, but probably not thousands - but I've not tried TBH.

I don't know if it could be incorporated into 3D (I see no reason why not), but isn't the point of 3D that you don't need to depth sort? Doesn't the graphics card do this for you?
Title: Re: There will be opportunities can have depth-order ?
Post by: Moru on 2010-Feb-28
Billboards don't sort sadly, you need to place them in z-order yourself. (From the camera viewpoint no less...)
Title: Re: There will be opportunities can have depth-order ?
Post by: Kitty Hello on 2010-Mar-01
I used the SORTARRAY function, which makes the drawing a lot faster and also would work for floating point z values. See attached file.

[attachment deleted by admin]
Title: Re: There will be opportunities can have depth-order ?
Post by: Hemlos on 2010-Mar-01
Quote from: Kitty Hello on 2010-Mar-01
I used the SORTARRAY function, which makes the drawing a lot faster and also would work for floating point z values. See attached file.

Its not the speed which is an issue, its the ordering itself making ugly graphics overlapping.
Ive tried adding a sortarray to reorder all the particles each frame.....this drops this speed(FPS) by roughly 25-50% because of an additional sorting loop.
The result is roughly 500 stablized particles.
This is not good because the main stream c++ particle libs i was testing, run 5k-15k # of particles, at the same FPS speeds without any asthetic z ordering issues.


Title: Re: There will be opportunities can have depth-order ?
Post by: Kitty Hello on 2010-Mar-01
try using sortarray on the existing array. If it was sorted once, the SORTARRAY function returns very fast.