Reputation: 159
I am looking for a 3D implementation of triangle rasterization using Bresenham's line drawing algorithm. Namely, I have this source:
http://www.sunshine2k.de/coding/java/TriangleRasterization/TriangleRasterization.html,
however the algorithm is in 2D. Is there any way I can extend this to 3D?
Thank you
Upvotes: 2
Views: 4577
Reputation: 2395
There is a posted 3D Bresenham here. The code is in matlab script, but I believe it would be straightforward to convert it to C++.
Upvotes: 1
Reputation:
As a first attempt, you can try to modify one of the 2D standard or Bresenham triangle algorithms so as to compute (X, Z) coordinates instead of X alone (computing intersections in the XZ plane or drawing with the 3D Bresenham line algorithm) and join the points using the 2D Bresenham line algorithm between these, instead of a simple row of pixels.
Upvotes: 1