Depth buffering; getting the Z position of a point on a 3D triangle


greetings.

 

i'm creating 3d library (if that's call them) on own, , about:

  1. defining triangles 3 vector3d instances.
  2. transforming them transform.matrix3d property of sprite instance.
  3. calculating , assigning w property of each vector3d instance , project().
  4. draw triangles out graphics instance, according x, y properties of projected vector3d instances.

 

there go, , i'm trying use depth buffering (or z buffering) library. according information read , comprehend (including wikipedia, results google search), depth buffering can solve problems of intersecting polygons , triangles. , algorithm works this:

  1. for each polygon, calculate z position of each pixel occupies after being rendered.
  2. compare current z position of pixel existing 1 in depth buffer.
    • if 1 in buffer larger current 1 (that is, current 1 being nearer viewer) replace pixel (color) of in depth buffer current pixel.
  3. draw pixels out.

 

please point out mistake made in my-way-of understanding how depth buffering works, thank you.

 

i'm having problem "calculating z position" of each pixel.

 

as 3 points define plane, tried using this algorithm paul brouke , z position x , y positions, along a, b, c, , d parameters calculated 3 vector3d instances define triangle, simple calculation:

 

z = (-ax-by-d) / c

 

but did not work. instead, triangles distorted.

 

is there other rather simple way depth buffering working? if yes, appreciate usages of simple words explain simple codes. if not, then... hope can me in way.

 

thanks again.

greekfellows



More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support