Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. void ZBuffer::Init()
  2. {
  3. for(int h = 0 ; h < depths.size ; h++) {
  4. for(int w = 0 ; w < depths.data[h].size ; w++) {
  5. depths.data[h].data[w] = std::numeric_limits<double>::infinity();
  6. }
  7. }
  8. }
  9.  
  10. bool ZBuffer::ReplaceCurrent(const Coord2D p)
  11. {
  12. if(!enabled) return true;
  13.  
  14. if(p.depth > depths.data[p.y].data[p.x]) return false;
  15.  
  16. depths.data[p.y].data[p.x] = p.depth;
  17.  
  18. return true;
  19. }
  20.  
  21. // Example Interpolation des points Scanline+Phong
  22. int interpolatedDepth1 = (p1.depth*wa + p2.depth*wb + p3.depth*wc);
  23. int interpolatedDepth2 = (p1.depth*wa + p2.depth*wb + p3.depth*wc);
  24.  
  25. int interpolatedDepth = (interpolatedDepth1*wa + interpolatedDepth2*wb);
  26. SetPoint(Coord2D(x,y,interpolatedDepth), interpolatedColor);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement