Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ZBuffer::Init()
- {
- for(int h = 0 ; h < depths.size ; h++) {
- for(int w = 0 ; w < depths.data[h].size ; w++) {
- depths.data[h].data[w] = std::numeric_limits<double>::infinity();
- }
- }
- }
- bool ZBuffer::ReplaceCurrent(const Coord2D p)
- {
- if(!enabled) return true;
- if(p.depth > depths.data[p.y].data[p.x]) return false;
- depths.data[p.y].data[p.x] = p.depth;
- return true;
- }
- // Example Interpolation des points Scanline+Phong
- int interpolatedDepth1 = (p1.depth*wa + p2.depth*wb + p3.depth*wc);
- int interpolatedDepth2 = (p1.depth*wa + p2.depth*wb + p3.depth*wc);
- int interpolatedDepth = (interpolatedDepth1*wa + interpolatedDepth2*wb);
- SetPoint(Coord2D(x,y,interpolatedDepth), interpolatedColor);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement