Have you found any code or used one to reorder entities based on distance?
You would need to edit the mojo3d source for this.
The file you need to look at is:
and the function RenderRenderOps
My advice would be to leave well alone, as Mark will certainly change things here at some stage. But if you are happy with a preserved version then tinker away 🙂
Thanks, I will have a peek. By the moment I use only mojo for drawing rects and stuff, up until I have a solid foundation for a codebase which later I can adapt faster to an engine.
OK. Think I got my wires crossed. I thought you were talking about 3d stuff.
In Mojo, everything is generally optimised on a first come first draw basis. so the only thing you need to do is run some form of depth system.
let’s assume you have a series of entities (of your creation, boxes, circles, sprites, etc). And each entity has an x,y location
You (the viewer) also need to have an x,y location – so you can depth sort
First you need a list or array of the wanted entities to be drawn
for each entity find the length from the viewer:
xx = vx-ex
yy = vy-ey
length =Sqrt(xx*xx + yy*yy)
then you just do a quick sort of the lengths – the bigger the length the further away from the viewer and the lower in the sortlist
Lastly you draw the entities in the sortlist starting with the item furthest away
Although I was thinking about crazy algorithms for a moment, up until I looked that it’s a matter only of sorting based on a specific criteria, which is cool, it makes things very simple.
You must be logged in to reply to this topic.
Monkey2 is an easy to use, cross platform, games oriented programming language from Blitz Research.