Manipulating Object's Draw Order
by Darius · in Torque Game Builder · 02/24/2009 (1:21 pm) · 5 replies
So I've got some objects, and I want to change the order that they are drawn. The methods setLayerDrawOrder() and setSceneDrawOrder() look like they should do the trick, but I don't know how to get the object's relative positions in the draw order. So if I want to move object A in front of object B, I can't do that without sending object A to the front or object B to the back. But I don't want to do that, because I also have objects C through Z, and I don't necessarily want object A in front of all of them, nor do I want object B behind them all.
So any ideas on how I might accomplish this? Or perhaps there's another way? I'm trying to fake an isometric engine, by moving things in front of and behind each other, so if someone has a clever way of doing that, I'd love to hear it.
Thanks.
So any ideas on how I might accomplish this? Or perhaps there's another way? I'm trying to fake an isometric engine, by moving things in front of and behind each other, so if someone has a clever way of doing that, I'd love to hear it.
Thanks.
#2
Let me see if I can clarify. I have a group of monsters moving down a street. I'm trying to do an isometric perspective, so they will be overlapping. I need the monsters at the back of the street to be drawn behind the monsters at the front of the street. Whe
The problem, is that as the monsters turn corners and move through a city, the ones at the back can end up at the front and the ones at the front can end up at the back.
But since the draw order hasn't changed, the monsters at the back will overlap the monsters at the front. So I need a way to swap the draw order of the monsters at the back and front.
I could use layers, but I'm limited to 32 layers, and I have far more than 32 monsters.
The only methods I could find to manipulate the draw order were setLayerDrawOrder() and setSceneDrawOrder(). But they only allow you to move an object either all the way to the back of the layer/scene, all the way to the front or the layer/scene, forward one position, or back one position. This would work, if I could find a way to tell which monsters were drawn in front of any given monster.
Is that more clear? Thanks.
02/24/2009 (4:26 pm)
I'm sorry the explanation was hard to follow.Let me see if I can clarify. I have a group of monsters moving down a street. I'm trying to do an isometric perspective, so they will be overlapping. I need the monsters at the back of the street to be drawn behind the monsters at the front of the street. Whe
The problem, is that as the monsters turn corners and move through a city, the ones at the back can end up at the front and the ones at the front can end up at the back.
But since the draw order hasn't changed, the monsters at the back will overlap the monsters at the front. So I need a way to swap the draw order of the monsters at the back and front.
I could use layers, but I'm limited to 32 layers, and I have far more than 32 monsters.
The only methods I could find to manipulate the draw order were setLayerDrawOrder() and setSceneDrawOrder(). But they only allow you to move an object either all the way to the back of the layer/scene, all the way to the front or the layer/scene, forward one position, or back one position. This would work, if I could find a way to tell which monsters were drawn in front of any given monster.
Is that more clear? Thanks.
#3
02/25/2009 (7:32 am)
you might wanna use sort points for that
#4
Then, you need to make sure you levels have the right sort order. I don't know how to do that in the editor, sorry. But in the level file, find your layer and change the layerSortmode.
It'll look something like this now for layer 20.
You probably want something like this.
I know you can do it in the editor, but if somebody else wants to explain that, then they can.
02/25/2009 (7:44 am)
Oh, right. Now i have it. You need to set a good sort point on your objects, which should just be in a parent datablock anyway, so not a problem!Then, you need to make sure you levels have the right sort order. I don't know how to do that in the editor, sorry. But in the level file, find your layer and change the layerSortmode.
It'll look something like this now for layer 20.
layerSortMode20 = "Normal";
You probably want something like this.
layerSortMode16 = "Y Axis";
I know you can do it in the editor, but if somebody else wants to explain that, then they can.
#5
02/25/2009 (8:00 am)
That looks exactly like what I need to do. Thanks so much.
Torque 3D Owner Jason Ravencroft
To start with, have you been using layers to get the major sorting done? While doing that, you have to do the layer draw order within the draw order.