We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › 3D Sprite Particle System.. Z-order
Page Index Toggle Pages: 1
3D Sprite Particle System.. Z-order? (Read 1984 times)
3D Sprite Particle System.. Z-order?
Oct 6th, 2005, 4:16pm
 
http://wliia.org/projects/particle3D/

Having a little trouble with the particles rendering infront of eachother when they're behind..
How would i go about rendering the particles in the correct z-order?

Comments are also appreciated Smiley

-seltar
Re: 3D Sprite Particle System.. Z-order?
Reply #1 - Oct 6th, 2005, 4:52pm
 
hehe.. I dig this. Fantastic.

I love the WASD controls too. Everyone should use this.

I don't personally know how to do z sorting but I can imagine some schemes in which you can do this.

You can build a list of distances to the camera, then sort these with some sorting algorithm, then draw them in order. That's how I would approach it, at least.
Re: 3D Sprite Particle System.. Z-order?
Reply #2 - Oct 7th, 2005, 12:02am
 
Google throws this url when you type 'sorting' :
http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html
It shows a great variety of sorting algorythms illustrated with java applets. Nice!
Re: 3D Sprite Particle System.. Z-order?
Reply #3 - Oct 7th, 2005, 12:34am
 

One kind I used to employ for multiplexing sprites on the C64 was to take the z-pos and divide by 2 (as an int), this becomes an index value, whose position you occupy with a variable whose value goes from 0 - num of sprites.

All you do for a display is run through the array looking for anything other than 0xff say (null) and when you find a number, that's the sprite to display.

Push 0xff (null) back in its place and you don't need to flush the table.

Don't know if it's any use. Perhaps I'm just being nostalgic Smiley
Re: 3D Sprite Particle System.. Z-order?
Reply #4 - Oct 7th, 2005, 1:15am
 
Nostalgy rules though, and thanks for the comments Smiley
Made some updates: http://wliia.org/projects/particle3D/v2/
(more control as well)
Used the sorting mechanism that mflux suggested, or at least.. my own version of that basic idea that works somewhat like I want it.. havn't found alot of bugs in it... yet Tongue

-seltar
Re: 3D Sprite Particle System.. Z-order?
Reply #5 - Oct 7th, 2005, 2:13pm
 
v3ga wrote on Oct 7th, 2005, 12:02am:
Google throws this url when you type 'sorting' :
http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html
It shows a great variety of sorting algorythms illustrated with java applets. Nice!

yes that s a good site. although you really need to choose the sorting algorithm very carefully for your matter. we used the qsort algorithm in the begin, which is know to perform very well. it wasn t very reliable on sorted lists, so we switched to shellsort which is slower but handles sorted lists better.

for a much deeper insight i recommend wikipedia. http://en.wikipedia.org/wiki/Sorting_algorithm
Page Index Toggle Pages: 1