Click here to download an obj file of Stanford bunny model.
You should also type-define Point struct as Vertex and Vector type.
to Canvas class. Now you have to image the Canvas in a 3D space setting. The canvas is center at z = 0, coincident with xy plane, and with size along x direction of hReso, and that of y direction vReso. The eye is at position (0, 0, eye_at), where eye_at is a positive value, and looking along negative z direction. The eye and the (rectangle) canvas forms a (infinite) pyramid, which is called viewing volume.double eye_at;
Add this line to the init() member function,
so the the eye has a default angle span(called field of view, fov) of 90 degreen along x direction.eye_at = Reso / 2;
If you want user control on eye position and therefore fov, you can write the appropriate access member function(s).
Point perspectiveProjection(Point const&);
This private member function computes the projected x and y values which, together with the unchanged z component, is returned as a Point object. The unchanged z value is used for z-buffer algorithm later.
intovoid WireTriangle(int x1, int y1, RGB const& col1, int x2, int y2, RGB const& col2, int x3, int y3, RGB const& col3);
You have to do the projections of all three points, and then proceed as usual (simply ignore the z-component for now).void WireTriangle(Point const& P1, RGB const& col1, Point const& P2, RGB const& col2, Point const& P3, RGB const& col3);
We should make loca copiesswap ( (RGB&)col1, (RGB&)col2 );
and then do the swap,RGB c1(col1), c2(col2);
and thereafter, every reference to col1(col2) should be replaced by c1(c2)swap (c1, c2);
namespace columbia { struct BBox { Point min, max; // A Constructor: create a bounding box from two points of the box, one is lowerleft corner, the other upperright corner.. // A Constructor: create a bounding box from a TriangleMesh object. This bascially creates a bbox for the model. }; }
1.3.6