You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i make some adjust to overcome the missing function face() in lesson 1.
here is my code,I encapsulated x and y using the Point structure in the simplest way,so it may looks a lttle different from lesson 1.
struct Point
{
int x = 0;
int y = 0;
};
Model mFace("../_Input/african_head/african_head.obj");
int width = 800;
int height = 800;
TGAImage imageobj(width, height, TGAImage::RGB);
for (int i = 0; i < mFace.nfaces(); i++)
{
for (int j = 0; j < 3; j++)
{
vec3 v1 = mFace.vert(i, j);
vec3 v2 = mFace.vert(i, (j + 1) % 3);;
Point pt1{ (v1.x + 1.0f) * width / 2.0f,(v1.y + 1.0f) * height / 2.0f };
Point pt2{ (v2.x + 1.0f) * width / 2.0f,(v2.y + 1.0f) * height / 2.0f };// view transport
line(pt1, pt2, imageobj, white);
}
}
imageobj.write_tga_file("../_Output/lesson1_obj.tga");
according to the class Model,the Model class has an overloaded function 'vert' that allows you to access a specified vertex or visit a specified node in a specified face.
vec3 Model::vert(const int i) const {
return verts[i];
}
vec3 Model::vert(const int iface, const int nthvert) const {
return verts[facet_vrt[iface*3+nthvert]];
}
The text was updated successfully, but these errors were encountered:
i make some adjust to overcome the missing function face() in lesson 1.
here is my code,I encapsulated x and y using the Point structure in the simplest way,so it may looks a lttle different from lesson 1.
according to the class Model,the Model class has an overloaded function 'vert' that allows you to access a specified vertex or visit a specified node in a specified face.
The text was updated successfully, but these errors were encountered: