In-Layer Y-Axis Render Sort
by Paolo · in Torque Game Builder · 03/16/2006 (7:12 am) · 37 replies
I was wondering if you guys could add a in-layer y-axis sort.
Basically, you can set Layer 0 to a default sort (where you can manipulate the in-layer order by moving things FORWARD and BACKWARD), but on Layer 1 you can set all sceneobjects within Layer 1 to sort on the y-axis for rendering.
Something like:
mySceneGraph.IsoMetricSort(Layer0, false);
mySceneGraph.IsoMetricSort(Layer1, false);
Some of the compiled code changes script suggestions on the forum don't really work out too well. The code changes to make everything sort on the y-axis affects EVERYTHING, not just within a layer. While other algorithms using TorqueScript involve double-linked list and other complex logic to create a sort order.
Since there are many games that use y-axis sorting such as RPGS, 2.5D top-down view, and Isometric games, I thought it would be good to have this functionality available for the full release of TGB.
Thanks guys for a wonderful product! I've loved T2D since it's Alpha release and can't wait for the full release of TGB!
Basically, you can set Layer 0 to a default sort (where you can manipulate the in-layer order by moving things FORWARD and BACKWARD), but on Layer 1 you can set all sceneobjects within Layer 1 to sort on the y-axis for rendering.
Something like:
mySceneGraph.IsoMetricSort(Layer0, false);
mySceneGraph.IsoMetricSort(Layer1, false);
Some of the compiled code changes script suggestions on the forum don't really work out too well. The code changes to make everything sort on the y-axis affects EVERYTHING, not just within a layer. While other algorithms using TorqueScript involve double-linked list and other complex logic to create a sort order.
Since there are many games that use y-axis sorting such as RPGS, 2.5D top-down view, and Isometric games, I thought it would be good to have this functionality available for the full release of TGB.
Thanks guys for a wonderful product! I've loved T2D since it's Alpha release and can't wait for the full release of TGB!
About the author
#22
05/13/2006 (7:55 pm)
Hey this is awesome, I got it working in beta 3... BUT, it will crash sometimes when creating/positioning? objects in the scene. I'm not really sure why.
#23
Maybe I can take a look at it in the next couple of days. This should be posted as a resource anyway.
05/14/2006 (3:38 am)
Well, it shouldn't crash ;)Maybe I can take a look at it in the next couple of days. This should be posted as a resource anyway.
#24
As soon as my mouse cursor enters the frames available (the cells in the imagemap) on the left of the window, it will crash.
Might just be that I added the feature in wrong, so I'm going to retry it with a clean version of beta 3.
05/14/2006 (10:04 pm)
I've been trying to figure out what is going on when it decides to crash, one way that it happens is when I click the create new animation button, and then I select my imagemap, and it changes the window to allow me to add frames to the animation.As soon as my mouse cursor enters the frames available (the cells in the imagemap) on the left of the window, it will crash.
Might just be that I added the feature in wrong, so I'm going to retry it with a clean version of beta 3.
#25
05/26/2006 (11:24 am)
So is this built into Beta 4 now or is this still a custom fix?
#26
05/26/2006 (4:20 pm)
Still custom. I don't know if it will ever be part of the stock engine.
#27
The C++ function is called "t2dSceneGraph::setRenderSortFunction()".
The default for the t2dSceneGraph render function is a function defined as...
- Melv.
05/29/2006 (2:09 am)
I added the ability to choose a render sort function from C++ (as a great suggestion by Michael) quite a while ago but without a stock list of ones to choose from, there didn't seem any point in adding an associated script function.The C++ function is called "t2dSceneGraph::setRenderSortFunction()".
The default for the t2dSceneGraph render function is a function defined as...
S32 QSORT_CALLBACK t2dSceneGraph::layeredRenderSort(const void* a, const void* b)
{
// Layer-Order Sort.
return ((*((t2dSceneObject**)a))->mLayerOrder) - ((*((t2dSceneObject**)b))->mLayerOrder);
}... which just does the standard ascending intra-layer sort.- Melv.
#28
and as for:
" You can also delete every occurance of the mRenderSortFn member-variable (its declaration in t2dSceneGraph.h and its initialization in the constructor). It is not needed anymore. "
is that just these 2 lines ?
mRenderSortFn(layeredRenderSort),
S32 (QSORT_CALLBACK *mRenderSortFn)(const void *, const void *);
or is there more to it than that? :D
05/29/2006 (7:27 pm)
Has anyone gotten this working with beta 3 or 4 ? it just crashes at certain times for me (for example, try creating a new animation in the level builder). Seems to be something related to the mouse cursor going over an area of the GUI? also happens with the imagemap builder..and as for:
" You can also delete every occurance of the mRenderSortFn member-variable (its declaration in t2dSceneGraph.h and its initialization in the constructor). It is not needed anymore. "
is that just these 2 lines ?
mRenderSortFn(layeredRenderSort),
S32 (QSORT_CALLBACK *mRenderSortFn)(const void *, const void *);
or is there more to it than that? :D
#29
I hope I can get time to have a look at this. I don't see a reason why it should crash but maybe I have overlooked something.
As for your second question: If you delete the declaration in t2dSceneObject.h then compiler will automatically complain about every other occurance.
05/30/2006 (1:16 am)
Ezra,I hope I can get time to have a look at this. I don't see a reason why it should crash but maybe I have overlooked something.
As for your second question: If you delete the declaration in t2dSceneObject.h then compiler will automatically complain about every other occurance.
#30
06/07/2006 (5:40 am)
I'll give this an update if needed when the final release is out.
#31
07/15/2006 (11:20 am)
Is there a resource for this?
#32
07/15/2006 (12:10 pm)
In the next version we have Y axis sorting in, though it is uses some great code from Tom Spilman, it uses a sort point on the object and by default that point is in the center of the object.
#33
will we be able to define different sorting methods on different layers?
07/15/2006 (5:07 pm)
Hey Matt,will we be able to define different sorting methods on different layers?
#34
07/15/2006 (5:56 pm)
Yes :) Presently in the internal version you can see a list which has a dropdown for each layer to define the different sorting methods.
#36
07/16/2006 (2:11 am)
Oh cool.. i just implemented that by myself for my game :)
#37
07/17/2006 (11:10 am)
Yup, thinking along the same lines Oliver :) In fact your plan reminded me that we had implemented it shortly after the release.
Torque Owner Michael Woerister