Skip navigation
Greek Fellows
Currently Being Moderated

Reordering display by Z -- not sprites

Jun 26, 2012 7:18 AM

Tags: #3d #as3.0 #actionscript3

Hello.

I'm making a 3D rendering engine that doesn't use sprites, only draws on graphics.

Three points of each triangle is represented by three Vector3D objects.

To reorder drawing order of every triangle, I get the Z position of the Vector3D with the furthest Z value (biggest Z value), and the one with the closest Z value (smallest) then add them up, divide them into two (to get the average Z) then sort the array containing the triangles by the average Z values. Like:

 

1, 2, 3 -> 1 + 3 -> 4 -> 4 / 2 -> 2.

 

This way, I can start drawing from the furthest triangle and end up with the closest one. But sometimes there are bugs, where some triangles that should be behind others show up in front of them. How shall I fix this? Is there any other efficient and easy-to-understand way to reorder the drawing order?

Thanks!

 
Replies
  • kglad
    61,985 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 26, 2012 10:12 AM   in reply to Greek Fellows

    if triangles intersect that method won't work.

     
    |
    Mark as:
  • kglad
    61,985 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 27, 2012 6:49 AM   in reply to Greek Fellows

    fi two triangles intersect only part of one may be in front of part of the other.  neither may be entirely in front.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points