Subversion Repositories gelsvn

Rev

Rev 299 | Rev 341 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 299 Rev 337
Line 24... Line 24...
24
#endif
24
#endif
25
#include <string.h>
25
#include <string.h>
26
#include <stdlib.h>
26
#include <stdlib.h>
27
 
27
 
28
#include <iostream>
28
#include <iostream>
29
#include <CGLA/Vec2i.h>
-
 
30
#include <CGLA/Vec2f.h>
-
 
-
 
29
 
31
#include <IL/il.h>
30
#include <IL/il.h>
32
#include <IL/ilu.h>
31
#include <IL/ilu.h>
33
 
32
 
-
 
33
#include <CGLA/Vec2i.h>
-
 
34
#include <CGLA/Vec2f.h>
34
#include <CGLA/Vec3f.h>
35
#include <CGLA/Vec3f.h>
35
#include <CGLA/Mat4x4f.h>
36
#include <CGLA/Mat4x4f.h>
36
#include "GLGraphics/gel_glut.h"
37
#include "GLGraphics/gel_glut.h"
37
#include "GLGraphics/QuatTrackBall.h"
38
#include "GLGraphics/QuatTrackBall.h"
38
#include "GLGraphics/draw.h"
39
#include "GLGraphics/draw.h"
39
#include "Geometry/TriMesh.h"
40
#include "Geometry/TriMesh.h"
40
#include "Geometry/obj_load.h"
41
#include "Geometry/obj_load.h"
41
 
42
 
-
 
43
#include "ply_load.h"
-
 
44
 
42
using namespace std;
45
using namespace std;
43
using namespace CGLA;
46
using namespace CGLA;
44
using namespace Geometry;
47
using namespace Geometry;
45
using namespace GLGraphics;
48
using namespace GLGraphics;
46
 
49
 
47
namespace
50
namespace
48
{
51
{
49
int win_size_x = 800;
52
	int win_size_x = 800;
50
int win_size_y = 800;
53
	int win_size_y = 800;
51
 
-
 
52
QuatTrackBall* ball;
54
	QuatTrackBall* ball;
53
int spin_timer = 20;
55
	int spin_timer = 20;
54
void spin(int x);
56
	void spin(int x);
55
 
-
 
56
int main_window;
57
	int main_window;
-
 
58
	TriMesh mesh;
-
 
59
	
57
 
60
	
58
bool load_image_into_texture(const std::string& name, GLuint& id)
61
	bool load_image_into_texture(const std::string& name, GLuint& id)
59
{
62
	{
60
    unsigned char* image = 0;
63
		unsigned char* image = 0;
61
    unsigned int bpp = 0;
64
		unsigned int bpp = 0;
Line 219... Line 222...
219
 
222
		
220
    return true;
223
		return true;
221
}
224
	}
222
 
225
	
223
 
226
 
224
TriMesh mesh;
-
 
225
 
227
 
226
void mouse_motion(int x, int y)
228
void mouse_motion(int x, int y)
227
{
229
{
228
    ball->roll_ball(Vec2i(x,y));
230
    ball->roll_ball(Vec2i(x,y));
229
}
231
}
Line 247... Line 249...
247
{
249
{
248
  ball->do_spin();
250
	ball->do_spin();
249
  glutTimerFunc(spin_timer, spin, 0);  
251
	glutTimerFunc(spin_timer, spin, 0);  
250
  glutPostRedisplay();
252
	glutPostRedisplay();
251
}
253
}
252
/*
-
 
253
void idle()
-
 
254
{
254
 
255
    if ( glutGetWindow() != main_window )
-
 
256
        glutSetWindow(main_window);
-
 
257
    glutPostRedisplay();
-
 
258
}
-
 
259
*/
-
 
260
void display()
255
void display()
261
{
256
{
262
    static bool washere = false;
257
    static bool washere = false;
263
    static unsigned int l;
258
    static unsigned int l;
264
    if(!washere)
259
    if(!washere)
Line 317... Line 312...
317
    if(argc>1)
312
    if(argc>1)
318
        fn = argv[1];
313
        fn = argv[1];
319
    else
314
    else
320
        fn = "../../data/head.obj";
315
        fn = "../../data/head.obj";
321
 
316
		
322
    cout << "Loading " << fn << endl;
317
	if(fn.substr(fn.length()-4,fn.length())==".obj")
323
    if(fn == "") exit(0);
-
 
324
 
318
	{
325
    obj_load(fn, mesh);
319
		obj_load(fn, mesh);
-
 
320
	}
-
 
321
	else if(fn.substr(fn.length()-4,fn.length())==".ply")
-
 
322
	{
-
 
323
		ply_load(fn, mesh);
-
 
324
	}	
-
 
325
	else
-
 
326
	{
-
 
327
		cout << "Either the format was unrecognized or the file did not have the appropriate extension" << endl;
-
 
328
		exit(0);
-
 
329
	}		
326
    enable_textures(mesh);
330
/*    enable_textures(mesh);	
327
    if(!mesh.has_normals())
331
    if(!mesh.has_normals())
328
    {
332
    {
329
        cout << "Computing normals" << endl;
333
        cout << "Computing normals" << endl;
330
        mesh.compute_normals();
334
        mesh.compute_normals();
331
    }
335
    }
332
 
336
*/	
333
    // Initialize Trackball
337
    // Initialize Trackball
334
    Vec3f c;
338
    Vec3f c;
335
    float r;
339
    float r;
336
    mesh.get_bsphere(c,r);
340
    mesh.get_bsphere(c,r);
337
    r *= 1.5;
341
    r *= 1.5;