Subversion Repositories gelsvn

Rev

Rev 368 | Rev 373 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 368 Rev 372
Line 171... Line 171...
171
	template <class BoxType>
171
	template <class BoxType>
172
	void draw(const Geometry::BoundingTree<BoxType>& tree, int max_level)
172
	void draw(const Geometry::BoundingTree<BoxType>& tree, int max_level)
173
	{
173
	{
174
		draw(*tree.root, 0, max_level);
174
		draw(*tree.root, 0, max_level);
175
	}
175
	}
176
 
-
 
177
	void draw(const Geometry::TriMesh& tm, bool per_vertex_norms, bool draw_wire)
-
 
178
	{
-
 
179
    if(!draw_wire)
-
 
180
    {
-
 
181
      draw(tm, per_vertex_norms);
-
 
182
      return;
-
 
183
    }
-
 
184
 
-
 
185
		int old_mat_idx = -1;
-
 
186
		for(int i=0;i<tm.geometry.no_faces();i++)
-
 
187
		{
-
 
188
			int new_mat_idx = i<tm.mat_idx.size() ? tm.mat_idx[i] : -1;
-
 
189
			if(new_mat_idx != old_mat_idx)
-
 
190
			{
-
 
191
				set_material(tm.materials[tm.mat_idx[i]]);
-
 
192
				old_mat_idx = new_mat_idx;
-
 
193
			}
-
 
194
			Vec3i n_face = tm.normals.face(i);
-
 
195
			Vec3i g_face = tm.geometry.face(i);
-
 
196
			Vec3i t_face = tm.texcoords.face(i);
-
 
197
			
-
 
198
			if(!per_vertex_norms)
-
 
199
			{
-
 
200
				Vec3f vert0 = tm.geometry.vertex(g_face[0]);
-
 
201
				Vec3f vert1 = tm.geometry.vertex(g_face[1]);
-
 
202
				Vec3f vert2 = tm.geometry.vertex(g_face[2]);
-
 
203
				Vec3f norm = normalize(cross(vert1-vert0, vert2-vert0));
-
 
204
				glNormal3fv(norm.get());
-
 
205
			}
-
 
206
		  glBegin(GL_LINE_LOOP);
-
 
207
      for(int j=0;j<3;j++)
-
 
208
			{
-
 
209
				if(per_vertex_norms && n_face != Geometry::NULL_FACE)
-
 
210
				{
-
 
211
					Vec3f norm = tm.normals.vertex(n_face[j]);
-
 
212
					glNormal3fv(norm.get());
-
 
213
				}
-
 
214
				if(t_face != Geometry::NULL_FACE)
-
 
215
				{
-
 
216
					Vec3f texc = tm.texcoords.vertex(t_face[j]);
-
 
217
					glTexCoord2fv(texc.get());
-
 
218
				}
-
 
219
				Vec3f vert = tm.geometry.vertex(g_face[j]);
-
 
220
				glVertex3fv(vert.get());
-
 
221
			}
-
 
222
  		glEnd();
-
 
223
		}
-
 
224
		glDisable(GL_TEXTURE_2D);
-
 
225
	}
-
 
226
}
176
}