Subversion Repositories gelsvn

Rev

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

Rev 339 Rev 362
Line 1... Line 1...
1
#include "CGLA/Mat4x4f.h"
1
#include "CGLA/Mat4x4f.h"
2
 
-
 
-
 
2
#include "CGLA/Vec3d.h"
3
#include "gel_gl.h"
3
#include "gel_glu.h"
4
#include "draw.h"
4
#include "draw.h"
5
#include "HMesh/FaceCirculator.h"
5
#include "HMesh/FaceCirculator.h"
6
 
6
 
7
using namespace CGLA;
7
using namespace CGLA;
8
using namespace HMesh;
8
using namespace HMesh;
Line 29... Line 29...
29
 
29
 
30
}
30
}
31
 
31
 
32
namespace GLGraphics
32
namespace GLGraphics
33
{
33
{
34
	
34
 
35
	void draw(Manifold& m, bool per_vertex_norms)
35
void draw(Manifold& m, bool per_vertex_norms)
36
	{
36
	{
37
		for(FaceIter f=m.faces_begin(); f != m.faces_end(); ++f)
37
		for(FaceIter f=m.faces_begin(); f != m.faces_end(); ++f)
38
		{
38
		{
39
			FaceCirculator fc(f);
39
			FaceCirculator fc(f);
40
			if(!per_vertex_norms) 
40
			if(!per_vertex_norms) 
41
				glNormal3fv(normal(f).get());
41
				glNormal3fv(normal(f).get());
-
 
42
			if(no_edges(f)== 3) 
-
 
43
				glBegin(GL_TRIANGLES);
-
 
44
			else 
42
			glBegin(GL_POLYGON);
45
				glBegin(GL_POLYGON);
43
			while(!fc.end())
46
			while(!fc.end())
44
			{
47
			{
45
				Vec3f n = normal(fc.get_vertex());
48
				Vec3f n = normal(fc.get_vertex());
-
 
49
				if(per_vertex_norms) 
46
				glNormal3fv(n.get());
50
					glNormal3fv(n.get());
47
				glVertex3fv(fc.get_vertex()->pos.get());
51
				glVertex3fv(fc.get_vertex()->pos.get());
48
				++fc;
52
				++fc;
49
			}
53
			}
50
			glEnd();
54
			glEnd();
51
		}
55
		}
Line 56... Line 60...
56
	{
60
	{
57
		int old_mat_idx = -1;
61
		int old_mat_idx = -1;
58
		glBegin(GL_TRIANGLES);
62
		glBegin(GL_TRIANGLES);
59
		for(int i=0;i<tm.geometry.no_faces();i++)
63
		for(int i=0;i<tm.geometry.no_faces();i++)
60
		{
64
		{
-
 
65
			int new_mat_idx = i<tm.mat_idx.size() ? tm.mat_idx[i] : -1;
61
			if(tm.mat_idx[i] != old_mat_idx)
66
			if(new_mat_idx != old_mat_idx)
62
			{
67
			{
63
				glEnd();
68
				glEnd();
64
				set_material(tm.materials[tm.mat_idx[i]]);
69
				set_material(tm.materials[tm.mat_idx[i]]);
65
				glBegin(GL_TRIANGLES);
70
				glBegin(GL_TRIANGLES);
66
				old_mat_idx = tm.mat_idx[i];
71
				old_mat_idx = new_mat_idx;
67
			}
72
			}
68
			Vec3i n_face = tm.normals.face(i);
73
			Vec3i n_face = tm.normals.face(i);
69
			Vec3i g_face = tm.geometry.face(i);
74
			Vec3i g_face = tm.geometry.face(i);
70
			Vec3i t_face = tm.texcoords.face(i);
75
			Vec3i t_face = tm.texcoords.face(i);
71
			
76