|
@@ -42,8 +42,74 @@ IGL_INLINE void igl::draw_mesh(
|
|
|
// loop over corners of triangle
|
|
|
for(int j = 0;j<3;j++)
|
|
|
{
|
|
|
- glColor3d(C(F(i,j),0),C(F(i,j),1),C(F(i,j),2));
|
|
|
- if(C.rows() == V.rows())
|
|
|
+ if(C.rows() == 1)
|
|
|
+ {
|
|
|
+ glColor3d(C(0,0),C(0,1),C(0,2));
|
|
|
+ }else if(C.rows() == V.rows())
|
|
|
+ {
|
|
|
+ glColor3d(C(F(i,j),0),C(F(i,j),1),C(F(i,j),2));
|
|
|
+ }else if(C.rows() == F.rows()*3)
|
|
|
+ {
|
|
|
+ glColor3d(C(i*3+j,0),C(i*3+j,1),C(i*3+j,2));
|
|
|
+ }else if(C.rows() == F.rows())
|
|
|
+ {
|
|
|
+ glColor3d(C(i,0),C(i,1),C(i,2));
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ assert(C.size() == 0);
|
|
|
+ }
|
|
|
+ if(N.rows() == V.rows())
|
|
|
+ {
|
|
|
+ glNormal3d(N(F(i,j),0),N(F(i,j),1),N(F(i,j),2));
|
|
|
+ }else if(N.rows() == F.rows()*3)
|
|
|
+ {
|
|
|
+ glNormal3d(N(i*3+j,0),N(i*3+j,1),N(i*3+j,2));
|
|
|
+ }else if(N.rows() == F.rows())
|
|
|
+ {
|
|
|
+ glNormal3d(N(i,0),N(i,1),N(i,2));
|
|
|
+ }
|
|
|
+ glVertex3d(V(F(i,j),0),V(F(i,j),1),V(F(i,j),2));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ glEnd();
|
|
|
+}
|
|
|
+
|
|
|
+IGL_INLINE void igl::draw_mesh(
|
|
|
+ const Eigen::MatrixXd & V,
|
|
|
+ const Eigen::MatrixXi & F,
|
|
|
+ const Eigen::MatrixXd & N,
|
|
|
+ const Eigen::MatrixXd & C,
|
|
|
+ const Eigen::MatrixXd & TC)
|
|
|
+{
|
|
|
+ glBegin(GL_TRIANGLES);
|
|
|
+ // loop over faces
|
|
|
+ for(int i = 0; i<F.rows();i++)
|
|
|
+ {
|
|
|
+ // loop over corners of triangle
|
|
|
+ for(int j = 0;j<3;j++)
|
|
|
+ {
|
|
|
+
|
|
|
+ if(TC.rows() == 1)
|
|
|
+ {
|
|
|
+ glTexCoord2d(TC(F(i,j),0),TC(F(i,j),1));
|
|
|
+ }else if(TC.rows() == V.rows())
|
|
|
+ {
|
|
|
+ glTexCoord2d(TC(F(i,j),0),TC(F(i,j),1));
|
|
|
+ }else if(TC.rows() == F.rows()*2)
|
|
|
+ {
|
|
|
+ glTexCoord2d(TC(i*2+j,0),TC(i*2+j,1));
|
|
|
+ }else if(TC.rows() == F.rows())
|
|
|
+ {
|
|
|
+ glTexCoord2d(TC(i,0),TC(i,1));
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ assert(TC.size() == 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(C.rows() == 1)
|
|
|
+ {
|
|
|
+ glColor3d(C(0,0),C(0,1),C(0,2));
|
|
|
+ }else if(C.rows() == V.rows())
|
|
|
{
|
|
|
glColor3d(C(F(i,j),0),C(F(i,j),1),C(F(i,j),2));
|
|
|
}else if(C.rows() == F.rows()*3)
|
|
@@ -52,7 +118,11 @@ IGL_INLINE void igl::draw_mesh(
|
|
|
}else if(C.rows() == F.rows())
|
|
|
{
|
|
|
glColor3d(C(i,0),C(i,1),C(i,2));
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ assert(C.size() == 0);
|
|
|
}
|
|
|
+
|
|
|
if(N.rows() == V.rows())
|
|
|
{
|
|
|
glNormal3d(N(F(i,j),0),N(F(i,j),1),N(F(i,j),2));
|