|
-
ism
yeah awesome fenstalker. cast shadows are fantastic.
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
 Originally Posted by fenstalker
I put it away in November of last year, until this January when a recent project made it relevant again. I've since come up with what I think is a reliable, fast, and foolproof way of sorting in an isometric map. The only caveat is the overlap paradox, which is avoided in the level design phase by carefully placing blocks so that the paradox is not visible. All other sorting issues have been resolved in the algorithm.
You can check out a sample here:
http://www.fenstalker.com/content/isoworld
Your thoughts?
fenstalker, your demo is impressive. I'm curious about the overlap paradox you mention... can you show an example?
Also, any chance that you can give some insight on the algorithm you use for sorting?
Thank you.
-
 Originally Posted by paolobax
fenstalker, your demo is impressive. I'm curious about the overlap paradox you mention... can you show an example?
Also, any chance that you can give some insight on the algorithm you use for sorting?
Thank you.
In isometric worlds, object ordering is relative rather than absolute. Because of this, it's possible to place 3 objects in such a way that A is behind B, B is behind C, and C is behind A.
Check out this image for a sample: http://code.google.com/p/as3isolib/w...b_tutorial_002
The sorting algorithm is just a 2d array of relational data, combined with a bubble sort based on that data to constantly output a master "order" of all visible objects. Unfortunately the code is being developed as proprietary software so I can't post it. 
Thanks for the feedback!
Last edited by fenstalker; 04-19-2009 at 09:41 PM.
Reason: link change
-
Map the positions to their relevant 3D co-ordinates i.e. an [ x, y, z ] now create a point infront of the iso grid at where the viewer would be looking at it from. Now make a vector from the view point to the x, y, z co-ordinate of each tile and get the vectors length, last but not least, sort so that the longest vectors are placed first 
RipX
P.S. for overlapping tiles, you'd have to mask them!
-
 Originally Posted by fenstalker
... Unfortunately the code is being developed as proprietary software so I can't post it.
Thanks for the feedback!
That is a big pity!
Is there anyone working on an open source iso engine that offers these capabilities?
-
Senior Member
I had another go with depth sorting of large multi-tile objects in isometric view:
http://www.tonypa.pri.ee/test/isotest.html
The yellow, green and red blocks are objects covering several tiles. Last part of the text in each tile is its depth (higher depth means closer to viewer or above another tile with lower depth). Objects of course need to be concave, you cant use something like T, L or U shapes but they can fill any number of tiles. Blue object is the "hero" moving around with mouse.
Example of moving blue "hero" smoothly around:
http://www.tonypa.pri.ee/test/isotest2.html
Click to get focus, arrow keys to move.
Example of 3 dimensions, blocks stacked on top of others. Hero can move higher when next block is higher by 1 step, it will also fall back down when no blocks are below it.
http://www.tonypa.pri.ee/test/isotest3.html
Click to get focus, arrow keys to move.
Last edited by tonypa; 03-20-2010 at 03:58 PM.
-
My Research
I read a book "ActionScript for Multiplayer Games and Virtual Worlds"
in that book (P214) provide a way to sort the iso ojbect
the code is like this way:
Code:
private function sortIsoObjects(_objs:Vector.<IIsoObject>) : void
{
var list:Vector.<IIsoObject> = _objs.slice(0);
_objs = new Vector.<IIsoObject>();
for (var i:int = 0 ; i < list.length ; i++)
{
var newSortObject:IIsoObject = list[i];
var added:Boolean = false;
for (var j:int = 0 ; j < _objs.length ; j++)
{
var sortedObject:IIsoObject = _objs[j];
if (newSortObject.col <= sortedObject.col+sortedObject.maxCols -1
&& newSortObject.row <= sortedObject.row + sortedObject.maxRows -1)
{
_objs.splice(j,0,newSortObject);
added = true;
break;
}
}
if (!added)
{
_objs.push(newSortObject);
}
}
for (var k:int = 0 ; k < _objs.length ; k++)
{
isoObjectMangerContainer.addChildAt(_objs[k].container,k);
}
}
the key code is :
if (newSortObject.col <= sortedObject.col+sortedObject.maxCols -1
&& newSortObject.row <= sortedObject.row + sortedObject.maxRows -1)
i also check the as3lib sort code.
the key code is like :
var rightA:Number = objA.x + objA.width;
var frontA:Number = objA.y + objA.length;
var topA:Number = objA.z + objA.height;
for (var j:uint = 0; j < max; ++j)
{
var objB:IsoDisplayObject = children[j];
if ((objB.x < rightA) &&
(objB.y < frontA) &&
(objB.z < topA) &&
(i !== j))
{
behind.push(objB);
}
...
i use first one in my code,
the spped test is
Child Number :100 Cost :7
Child Number :200 Cost :28
Child Number :300 Cost :60
Child Number :400 Cost :108
Child Number :500 Cost :167
as you can see , if the objs is under 100+ , the speed is acceptable.
is there have any fast way to do it.
and i also have a prb about
Is this have to render all objs if have one object moved?
or just find those objects beside , and only render those object inside?
-
here is new update:
for those day i try to use As3 own sort function. it's really really fast. but unfortunately, it's only work with single tile. means every object maxCol = maxRow = 1 otherwise it's not working.
so , i start to optimize current function.
1` not use get/set function just use public property
it really fast a little bit . you can try yourself.
2` not caulate the vetror.length evert time. just use one property to reocrd it.
here it's my optimize result
* Sort:
100 1
200 3~4
300 8~9
400 13~14
1600 180 ~ 188
the key code is :
Code:
private function sortAndDisplayIsoObject():void
{
var isAdd:Boolean = false;
var swapIsoObjectLength:int = swapIsoObjectList.length = 0;
var i:int;
var j:int;
var newSortObject:IsoBox;
var sortedObject:IsoBox;
for(i = 0 ; i < isoObjectListLength ; i++)
{
newSortObject = isoObjectList[i];
isAdd = false;
for(j = 0 ; j < swapIsoObjectLength ; j++)
{
sortedObject = swapIsoObjectList[j];
if (newSortObject.col <= sortedObject.col+sortedObject.maxCols -1
&& newSortObject.row <= sortedObject.row + sortedObject.maxRows -1)
{
swapIsoObjectList.splice(j,0,newSortObject);
isAdd = true;
break;
}
}
if (!isAdd)
{
swapIsoObjectList.push(newSortObject);
}
swapIsoObjectLength++;
}
for(i = 0 ; i < isoObjectListLength ; i++)
{
sortedObject = swapIsoObjectList[i];
j = isoObjectMangerContainer.getChildIndex(sortedObject.container);
if(i != j)
{
isoObjectMangerContainer.addChildAt(sortedObject.container,i);
}
}
}
if you want see the all demo you need to check out my opensource engine http://code.google.com/p/copyengine/
but currently it's under developing , so the code maybe have mess up
-
by the way . i think use Alchemy to override this function will get mush more optimize .
but i'm good at it. so if some guy want do it ,or have fast way to sort objects.
please let me know .
it will mush helpful for me. thanks a lot.
My email is iamzealotwang at 126.com
-
I know this thread is quite old, but it helped my a lot last week, when I was changing the rendering of my TD game from 2d to isometric. There is not much info about isometric sorting on the web, and if so it is mostly about the more trivial cases with no fluently moving units. I documented my final implementation as well as the used resources here. Maybe someone else doing research on this topic might find it useful!
Thanks for the in-depth info on this board!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|