2004-07-02 19:41:57 +02:00
|
|
|
/****************************************************************************
|
2005-01-17 18:35:48 +01:00
|
|
|
* VCGLib o o *
|
|
|
|
* Visual and Computer Graphics Library o o *
|
|
|
|
* _ O _ *
|
|
|
|
* Copyright(C) 2004 \/)\/ *
|
|
|
|
* Visual Computing Lab /\/| *
|
|
|
|
* ISTI - Italian National Research Council | *
|
|
|
|
* \ *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
|
|
|
* for more details. *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
2004-07-02 19:41:57 +02:00
|
|
|
/****************************************************************************
|
|
|
|
History
|
|
|
|
|
|
|
|
$Log: not supported by cvs2svn $
|
2005-02-10 10:18:20 +01:00
|
|
|
Revision 1.32 2005/02/03 12:35:01 ponchio
|
|
|
|
Patch cache -> heap
|
|
|
|
|
2005-02-03 13:35:01 +01:00
|
|
|
Revision 1.31 2005/02/01 16:42:30 ponchio
|
|
|
|
Trigger
|
|
|
|
|
2005-02-01 17:42:30 +01:00
|
|
|
Revision 1.30 2005/01/21 17:09:13 ponchio
|
|
|
|
Porting and debug.
|
|
|
|
|
2005-01-21 18:09:13 +01:00
|
|
|
Revision 1.29 2005/01/17 17:35:47 ponchio
|
|
|
|
Small changes and adding realtime extr.
|
|
|
|
|
2005-01-17 18:35:48 +01:00
|
|
|
Revision 1.28 2005/01/14 15:25:29 ponchio
|
|
|
|
Revolution.
|
|
|
|
|
2005-01-14 16:25:29 +01:00
|
|
|
Revision 1.27 2004/12/15 16:37:55 ponchio
|
|
|
|
Optimizing realtime vis.
|
|
|
|
|
2004-12-15 17:37:55 +01:00
|
|
|
Revision 1.26 2004/12/15 13:50:32 ponchio
|
|
|
|
Optimizing realtime vis.
|
|
|
|
|
2004-12-15 14:50:32 +01:00
|
|
|
Revision 1.25 2004/12/15 08:46:16 ponchio
|
|
|
|
Optimizing realtime vis.
|
|
|
|
|
2004-12-15 09:46:16 +01:00
|
|
|
Revision 1.24 2004/12/13 00:44:48 ponchio
|
|
|
|
Lotsa changes...
|
|
|
|
|
2004-12-13 01:44:48 +01:00
|
|
|
Revision 1.23 2004/12/01 18:46:21 ponchio
|
|
|
|
Microchanges.
|
|
|
|
|
2004-12-01 19:46:21 +01:00
|
|
|
Revision 1.22 2004/11/28 04:16:19 ponchio
|
|
|
|
*** empty log message ***
|
|
|
|
|
2004-11-28 05:16:19 +01:00
|
|
|
Revision 1.21 2004/11/28 01:23:26 ponchio
|
|
|
|
Fixing borders... let's hope.
|
|
|
|
|
2004-11-28 02:23:26 +01:00
|
|
|
Revision 1.20 2004/11/18 18:30:14 ponchio
|
|
|
|
Using baricenters... lotsa changes.
|
|
|
|
|
2004-11-18 19:30:15 +01:00
|
|
|
Revision 1.19 2004/10/30 20:17:03 ponchio
|
|
|
|
Fixed big patches problem.
|
|
|
|
|
2004-10-30 22:17:03 +02:00
|
|
|
Revision 1.18 2004/10/21 13:40:16 ponchio
|
|
|
|
Debugging.
|
|
|
|
|
2004-10-21 15:40:16 +02:00
|
|
|
Revision 1.17 2004/10/21 12:22:21 ponchio
|
|
|
|
Small changes.
|
|
|
|
|
2004-10-21 14:22:21 +02:00
|
|
|
Revision 1.16 2004/10/19 01:23:02 ponchio
|
|
|
|
Daily backup (fragment...)
|
|
|
|
|
2004-10-19 03:23:02 +02:00
|
|
|
Revision 1.15 2004/10/15 16:45:27 ponchio
|
|
|
|
Vbo added.
|
|
|
|
|
2004-10-15 18:45:27 +02:00
|
|
|
Revision 1.14 2004/10/14 13:52:02 ponchio
|
|
|
|
Small changes.
|
|
|
|
|
2004-10-14 15:52:02 +02:00
|
|
|
Revision 1.13 2004/10/14 13:41:34 ponchio
|
|
|
|
Added statistics.
|
|
|
|
|
2004-10-14 15:46:34 +02:00
|
|
|
Revision 1.12 2004/10/09 14:46:47 ponchio
|
|
|
|
Windows porting small changes.
|
|
|
|
|
2004-10-09 16:46:47 +02:00
|
|
|
Revision 1.11 2004/10/04 16:49:54 ponchio
|
|
|
|
Daily backup. Preparing for compression.
|
|
|
|
|
2004-10-04 18:49:54 +02:00
|
|
|
Revision 1.10 2004/10/01 16:54:57 ponchio
|
|
|
|
Daily backup.
|
|
|
|
|
2004-10-01 18:54:57 +02:00
|
|
|
Revision 1.9 2004/09/30 23:56:33 ponchio
|
|
|
|
Backup (added strips and normals)
|
|
|
|
|
2004-10-01 01:56:33 +02:00
|
|
|
Revision 1.8 2004/09/30 00:27:42 ponchio
|
|
|
|
Lot of changes. Backup.
|
|
|
|
|
2004-09-30 02:27:42 +02:00
|
|
|
Revision 1.7 2004/09/28 10:26:35 ponchio
|
|
|
|
Backup
|
|
|
|
|
2004-09-28 12:26:35 +02:00
|
|
|
Revision 1.6 2004/09/17 15:25:09 ponchio
|
|
|
|
First working (hopefully) release.
|
2004-09-17 17:25:59 +02:00
|
|
|
Revision 1.5 2004/09/16 14:25:16 ponchio
|
|
|
|
Backup. (lot of changes).
|
|
|
|
|
2004-09-16 16:25:16 +02:00
|
|
|
Revision 1.4 2004/08/27 00:38:34 ponchio
|
|
|
|
Minor changes.
|
|
|
|
|
2004-08-27 02:38:34 +02:00
|
|
|
Revision 1.3 2004/07/15 14:32:49 ponchio
|
|
|
|
Debug.
|
|
|
|
|
2004-07-15 16:32:49 +02:00
|
|
|
Revision 1.2 2004/07/05 15:49:39 ponchio
|
|
|
|
Windows (DevCpp, mingw) port.
|
|
|
|
|
2004-07-05 17:49:39 +02:00
|
|
|
Revision 1.1 2004/07/04 15:30:00 ponchio
|
|
|
|
Changed directory structure.
|
|
|
|
|
2004-07-04 17:30:22 +02:00
|
|
|
Revision 1.2 2004/07/04 15:16:01 ponchio
|
|
|
|
*** empty log message ***
|
|
|
|
|
2004-07-04 17:16:01 +02:00
|
|
|
Revision 1.1 2004/07/02 17:41:57 ponchio
|
|
|
|
Created.
|
|
|
|
|
2004-07-02 19:41:57 +02:00
|
|
|
Revision 1.3 2004/07/02 13:03:34 ponchio
|
|
|
|
*** empty log message ***
|
|
|
|
|
|
|
|
Revision 1.2 2004/07/01 21:33:46 ponchio
|
|
|
|
Added remap reading.
|
|
|
|
|
|
|
|
Revision 1.1 2004/06/23 00:10:38 ponchio
|
|
|
|
Created
|
|
|
|
|
|
|
|
|
|
|
|
****************************************************************************/
|
2005-02-03 13:35:01 +01:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <wrap/system/getopt.h>
|
|
|
|
#else
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2004-10-09 16:46:47 +02:00
|
|
|
|
2005-02-10 10:18:20 +01:00
|
|
|
#include <deque>
|
2004-07-02 19:41:57 +02:00
|
|
|
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include <SDL/SDL.h>
|
|
|
|
|
2004-10-09 16:46:47 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2004-07-02 19:41:57 +02:00
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glu.h>
|
2004-10-15 18:45:27 +02:00
|
|
|
#include <GL/glut.h>
|
2004-10-09 16:46:47 +02:00
|
|
|
|
2004-09-28 12:26:35 +02:00
|
|
|
#include <wrap/gui/trackball.h>
|
2004-10-21 14:22:21 +02:00
|
|
|
#include "watch.h"
|
2004-09-28 12:26:35 +02:00
|
|
|
|
2005-02-03 13:35:01 +01:00
|
|
|
#include <apps/nexus/nexusmt.h>
|
2004-07-02 19:41:57 +02:00
|
|
|
|
|
|
|
using namespace vcg;
|
|
|
|
using namespace nxs;
|
|
|
|
|
|
|
|
bool fullscreen = false;
|
|
|
|
int width =1024;
|
|
|
|
int height = 768;
|
|
|
|
|
2004-10-15 18:45:27 +02:00
|
|
|
void gl_print(float x, float y, char *str);
|
2004-07-02 19:41:57 +02:00
|
|
|
|
|
|
|
SDL_Surface *screen = NULL;
|
|
|
|
|
2004-10-01 18:54:57 +02:00
|
|
|
bool init(const string &str) {
|
2004-07-02 19:41:57 +02:00
|
|
|
|
|
|
|
if(SDL_Init(SDL_INIT_VIDEO) != 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SDL_VideoInfo *info = SDL_GetVideoInfo();
|
|
|
|
int bpp = info->vfmt->BitsPerPixel;
|
|
|
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
|
|
|
|
|
|
|
int flags = SDL_OPENGL;
|
|
|
|
if(fullscreen)
|
|
|
|
flags |= SDL_FULLSCREEN;
|
|
|
|
|
|
|
|
screen = SDL_SetVideoMode(width, height, bpp, flags);
|
|
|
|
if(!screen) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_WM_SetIcon(SDL_LoadBMP("inspector.bmp"), NULL);
|
2004-10-01 18:54:57 +02:00
|
|
|
SDL_WM_SetCaption(str.c_str(), str.c_str());
|
2004-07-02 19:41:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
glDisable(GL_DITHER);
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
glHint( GL_FOG_HINT, GL_NICEST );
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glDepthFunc( GL_LEQUAL );
|
|
|
|
glDisable(GL_LIGHTING);
|
|
|
|
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
2004-09-16 16:25:16 +02:00
|
|
|
int level = 0;
|
|
|
|
int apatch = -1;
|
2004-10-01 18:54:57 +02:00
|
|
|
float error = 4;
|
2004-09-28 12:26:35 +02:00
|
|
|
|
|
|
|
Trackball track;
|
2004-09-16 16:25:16 +02:00
|
|
|
|
2005-02-03 13:35:01 +01:00
|
|
|
if(argc < 2) {
|
|
|
|
cerr << "Usage: " << argv[0] << " <nexus file> [options]\n";
|
|
|
|
cerr << "-e <error>: set initial target error\n"
|
|
|
|
<< "-m <ram>: max ram used\n"
|
|
|
|
<< "-x <ram>: max extraction size\n"
|
|
|
|
<< "-r <ram>: max draw size\n"
|
|
|
|
<< "-d <ram>: max disk read per frame\n";
|
2005-02-01 17:42:30 +01:00
|
|
|
return -1;
|
2004-09-16 16:25:16 +02:00
|
|
|
}
|
2004-08-27 02:38:34 +02:00
|
|
|
|
2004-09-16 16:25:16 +02:00
|
|
|
NexusMt nexus;
|
2004-10-01 18:54:57 +02:00
|
|
|
if(!nexus.Load(argv[1])) {
|
2004-07-02 19:41:57 +02:00
|
|
|
cerr << "Could not load nexus file: " << argv[1] << endl;
|
|
|
|
return -1;
|
|
|
|
}
|
2005-01-14 16:25:29 +01:00
|
|
|
|
2004-07-02 19:41:57 +02:00
|
|
|
Sphere3f sphere = nexus.sphere;
|
2005-01-14 16:25:29 +01:00
|
|
|
Extraction extraction;
|
|
|
|
DrawContest contest;
|
|
|
|
Stats stats;
|
2004-07-02 19:41:57 +02:00
|
|
|
|
2004-10-01 18:54:57 +02:00
|
|
|
if(!init(argv[1])) {
|
2004-07-02 19:41:57 +02:00
|
|
|
cerr << "Could not init SDL window\n";
|
|
|
|
return -1;
|
|
|
|
}
|
2005-02-03 13:35:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
bool rotate = false;
|
|
|
|
bool show_borders = false;
|
|
|
|
bool show_colors = true;
|
|
|
|
bool show_normals = true;
|
|
|
|
bool show_statistics = true;
|
|
|
|
bool extract = true;
|
|
|
|
bool realtime = true;
|
|
|
|
bool preload = true;
|
|
|
|
bool step = true;
|
2004-09-28 12:26:35 +02:00
|
|
|
|
2005-02-03 13:35:01 +01:00
|
|
|
int option;
|
|
|
|
while((option = getopt(argc, argv, "e:m:x:r:d:")) != EOF) {
|
|
|
|
switch(option) {
|
|
|
|
case 'e': extraction.target_error = atof(optarg); break;
|
|
|
|
case 'm': nexus.MaxRam() = atoi(optarg); break;
|
|
|
|
case 'x': extraction.extr_max = atoi(optarg); break;
|
|
|
|
case 'r': extraction.draw_max = atoi(optarg); break;
|
|
|
|
case 'd': extraction.disk_max = atoi(optarg); break;
|
|
|
|
default:
|
|
|
|
cerr << "Unknow option.\n"; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-30 02:27:42 +02:00
|
|
|
// FrustumPolicy frustum_policy;
|
2004-10-01 18:54:57 +02:00
|
|
|
|
|
|
|
cerr << "Commands: \n"
|
|
|
|
" q: quit\n"
|
2005-02-03 13:35:01 +01:00
|
|
|
" t: toggle statistics\n"
|
2004-10-14 15:46:34 +02:00
|
|
|
" b: increase memory buffer\n"
|
|
|
|
" B: decrease memory buffer\n"
|
2004-12-15 09:46:16 +01:00
|
|
|
|
2004-10-01 18:54:57 +02:00
|
|
|
" d: debug mode (show patches colored)\n"
|
2005-02-03 13:35:01 +01:00
|
|
|
" f: flat shading mode\n"
|
2004-10-01 18:54:57 +02:00
|
|
|
" m: smooth mode\n"
|
2004-12-15 09:46:16 +01:00
|
|
|
" p: draw points\n"
|
|
|
|
|
2004-10-01 18:54:57 +02:00
|
|
|
" c: show colors\n"
|
|
|
|
" n: show normals\n"
|
2005-02-03 13:35:01 +01:00
|
|
|
" r: rotate model\n"
|
2004-10-01 18:54:57 +02:00
|
|
|
" -: decrease error\n"
|
|
|
|
" +: increase error (= too)\n";
|
2004-09-28 12:26:35 +02:00
|
|
|
|
2004-10-21 14:22:21 +02:00
|
|
|
Watch watch;
|
2004-09-28 12:26:35 +02:00
|
|
|
|
2004-10-15 18:45:27 +02:00
|
|
|
if(!nexus.InitGL()) {
|
|
|
|
cerr << "Could not init glew.\n";
|
2005-02-10 10:18:20 +01:00
|
|
|
return -1;
|
2004-10-15 18:45:27 +02:00
|
|
|
}
|
2004-10-01 18:54:57 +02:00
|
|
|
|
2004-07-02 19:41:57 +02:00
|
|
|
glClearColor(0, 0, 0, 0);
|
2004-07-15 16:32:49 +02:00
|
|
|
glEnable(GL_LIGHTING);
|
|
|
|
glEnable(GL_LIGHT0);
|
|
|
|
glEnable(GL_NORMALIZE);
|
|
|
|
glEnable(GL_COLOR_MATERIAL);
|
2004-10-01 01:56:33 +02:00
|
|
|
glEnable(GL_CULL_FACE);
|
2004-07-02 19:41:57 +02:00
|
|
|
int quit = 0;
|
2004-10-01 18:54:57 +02:00
|
|
|
SDL_Event event;
|
2004-07-02 19:41:57 +02:00
|
|
|
int x, y;
|
|
|
|
float alpha = 0;
|
2004-10-19 03:23:02 +02:00
|
|
|
float fps = 0;
|
2004-12-15 14:50:32 +01:00
|
|
|
unsigned int nave = 5;
|
|
|
|
unsigned int offset = 0;
|
2005-02-10 10:18:20 +01:00
|
|
|
deque<float> tframe;
|
|
|
|
deque<float> terror;
|
|
|
|
unsigned int tlen = 256;
|
2004-12-15 14:50:32 +01:00
|
|
|
|
2004-12-15 09:46:16 +01:00
|
|
|
bool keepdrawing = true;
|
2004-12-01 19:46:21 +01:00
|
|
|
|
2004-12-15 14:50:32 +01:00
|
|
|
watch.Start();
|
2004-12-15 09:46:16 +01:00
|
|
|
while( !quit ) {
|
2005-01-14 16:25:29 +01:00
|
|
|
unsigned int anything = SDL_PollEvent(&event);
|
|
|
|
if(!anything && !keepdrawing) {
|
|
|
|
SDL_WaitEvent(&event);
|
|
|
|
anything = true;
|
|
|
|
}
|
|
|
|
if(anything) {
|
|
|
|
switch( event.type ) {
|
2005-01-17 18:35:48 +01:00
|
|
|
case SDL_QUIT: quit = 1; break;
|
|
|
|
case SDL_KEYDOWN:
|
|
|
|
switch(event.key.keysym.sym) {
|
|
|
|
case SDLK_RCTRL:
|
|
|
|
case SDLK_LCTRL: track.ButtonDown(Trackball::KEY_CTRL); break;
|
|
|
|
case SDLK_q: exit(0); break;
|
|
|
|
case SDLK_k: keepdrawing = !keepdrawing; break;
|
|
|
|
case SDLK_e: extract = !extract; break;
|
|
|
|
case SDLK_c: show_colors = !show_colors; break;
|
|
|
|
case SDLK_n: show_normals = !show_normals; break;
|
2005-01-14 16:25:29 +01:00
|
|
|
|
2005-01-17 18:35:48 +01:00
|
|
|
case SDLK_LEFT: nexus.MaxRam() *= 0.8; break;
|
|
|
|
case SDLK_RIGHT: nexus.MaxRam() *= 1.3; break;
|
|
|
|
case SDLK_UP: extraction.draw_max *= 1.3; break;
|
|
|
|
case SDLK_DOWN: extraction.draw_max *= 0.8; break;
|
|
|
|
case SDLK_PAGEUP: extraction.disk_max *= 1.3; break;
|
|
|
|
case SDLK_PAGEDOWN: extraction.disk_max *= 0.8; break;
|
|
|
|
case SDLK_0: extraction.extr_max *= 1.3; break;
|
|
|
|
case SDLK_9: extraction.extr_max *= 0.8; break;
|
2004-12-01 19:46:21 +01:00
|
|
|
|
2005-01-17 18:35:48 +01:00
|
|
|
// case SDLK_s: metric = NexusMt::FRUSTUM; break;
|
|
|
|
case SDLK_p: contest.mode = DrawContest::POINTS; break;
|
|
|
|
case SDLK_d: contest.mode = DrawContest::PATCHES; break;
|
|
|
|
case SDLK_f: contest.mode = DrawContest::FLAT; break;
|
|
|
|
case SDLK_m: contest.mode = DrawContest::SMOOTH; break;
|
|
|
|
|
|
|
|
case SDLK_o: realtime = !realtime; break;
|
2005-02-01 17:42:30 +01:00
|
|
|
case SDLK_s: preload = !preload; nexus.SetPreload(preload); break;
|
|
|
|
case SDLK_t: show_statistics = !show_statistics; break;
|
2005-01-17 18:35:48 +01:00
|
|
|
case SDLK_r:
|
|
|
|
case SDLK_SPACE: rotate = !rotate; break;
|
|
|
|
|
|
|
|
case SDLK_MINUS:
|
|
|
|
extraction.target_error *= 0.9f;
|
|
|
|
cerr << "Error: " << extraction.target_error << endl;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDLK_EQUALS:
|
|
|
|
case SDLK_PLUS:
|
|
|
|
extraction.target_error *= 1.1f;
|
|
|
|
cerr << "Error: " << extraction.target_error << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SDL_KEYUP:
|
|
|
|
switch(event.key.keysym.sym) {
|
|
|
|
case SDLK_RCTRL:
|
|
|
|
case SDLK_LCTRL:
|
|
|
|
track.ButtonUp(Trackball::KEY_CTRL); break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SDL_MOUSEBUTTONDOWN:
|
|
|
|
x = event.button.x;
|
|
|
|
y = height - event.button.y;
|
|
|
|
#ifdef SDL_BUTTON_WHEELUP
|
|
|
|
if(event.button.button == SDL_BUTTON_WHEELUP)
|
|
|
|
track.MouseWheel(1);
|
|
|
|
else if(event.button.button == SDL_BUTTON_WHEELDOWN)
|
|
|
|
track.MouseWheel(-1);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if(event.button.button == SDL_BUTTON_LEFT)
|
|
|
|
track.MouseDown(x, y, Trackball::BUTTON_LEFT);
|
|
|
|
else if(event.button.button == SDL_BUTTON_RIGHT)
|
|
|
|
track.MouseDown(x, y, Trackball::BUTTON_RIGHT);
|
|
|
|
break;
|
|
|
|
case SDL_MOUSEBUTTONUP:
|
|
|
|
x = event.button.x;
|
|
|
|
y = height - event.button.y;
|
|
|
|
if(event.button.button == SDL_BUTTON_LEFT)
|
|
|
|
track.MouseUp(x, y, Trackball::BUTTON_LEFT);
|
|
|
|
else if(event.button.button == SDL_BUTTON_RIGHT)
|
|
|
|
track.MouseUp(x, y, Trackball::BUTTON_RIGHT);
|
|
|
|
break;
|
|
|
|
case SDL_MOUSEMOTION:
|
|
|
|
while(SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_MOUSEMOTIONMASK));
|
|
|
|
x = event.motion.x;
|
|
|
|
y = height - event.motion.y;
|
|
|
|
track.MouseMove(x, y);
|
|
|
|
break;
|
|
|
|
case SDL_VIDEOEXPOSE:
|
|
|
|
default: break;
|
2004-07-02 19:41:57 +02:00
|
|
|
}
|
2005-01-17 18:35:48 +01:00
|
|
|
}
|
2004-12-15 09:46:16 +01:00
|
|
|
|
2004-09-30 02:27:42 +02:00
|
|
|
|
2004-10-01 18:54:57 +02:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
|
|
|
gluPerspective(40, 1, 0.1, 100);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity();
|
|
|
|
gluLookAt(0,0,5, 0,0,0, 0,1,0);
|
2004-07-02 19:41:57 +02:00
|
|
|
|
2004-10-01 18:54:57 +02:00
|
|
|
glRotatef(alpha, 0, 1, 0);
|
|
|
|
if(rotate) {
|
|
|
|
alpha++;
|
|
|
|
if(alpha > 360) alpha = 0;
|
2004-12-15 09:46:16 +01:00
|
|
|
if(!keepdrawing) {
|
|
|
|
SDL_Event redraw;
|
|
|
|
redraw.type = SDL_VIDEOEXPOSE;
|
|
|
|
SDL_PushEvent(&redraw);
|
|
|
|
}
|
2004-09-30 02:27:42 +02:00
|
|
|
}
|
2004-10-01 18:54:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
track.GetView();
|
|
|
|
track.Apply();
|
|
|
|
|
|
|
|
float scale = 2/sphere.Radius();
|
|
|
|
|
|
|
|
glScalef(scale, scale, scale);
|
|
|
|
Point3f center = sphere.Center();
|
|
|
|
glTranslatef(-center[0], -center[1], -center[2]);
|
|
|
|
|
2004-10-04 18:49:54 +02:00
|
|
|
Point3f &p = nexus.sphere.Center();
|
|
|
|
float r = nexus.sphere.Radius();
|
|
|
|
|
2004-10-09 16:46:47 +02:00
|
|
|
glColor3f(0.8f, 0.8f, 0.8f);
|
2004-10-14 15:52:02 +02:00
|
|
|
|
2004-10-30 22:17:03 +02:00
|
|
|
if(extract) {
|
2005-01-14 16:25:29 +01:00
|
|
|
extraction.frustum.GetView();
|
|
|
|
extraction.metric->GetView();
|
2005-01-17 18:35:48 +01:00
|
|
|
if(!realtime) {
|
|
|
|
extraction.Extract(&nexus);
|
|
|
|
} else {
|
2005-02-01 17:42:30 +01:00
|
|
|
extraction.Update(&nexus);
|
2005-01-17 18:35:48 +01:00
|
|
|
}
|
2005-01-14 16:25:29 +01:00
|
|
|
}
|
|
|
|
nexus.Render(extraction, contest, &stats);
|
2004-10-14 15:46:34 +02:00
|
|
|
|
2004-12-13 01:44:48 +01:00
|
|
|
/* if(show_borders) {
|
2005-01-17 18:35:48 +01:00
|
|
|
for(unsigned int i = 0; i < cells.size(); i++) {
|
2005-01-21 18:09:13 +01:00
|
|
|
Border &border = nexus.GetBorder(cells[i]);
|
2005-01-17 18:35:48 +01:00
|
|
|
Patch &patch = nexus.GetPatch(cells[i]);
|
|
|
|
glPointSize(4);
|
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
|
|
|
glBegin(GL_POINTS);
|
|
|
|
for(unsigned int b = 0; b < border.Size(); b++) {
|
2004-11-18 19:30:15 +01:00
|
|
|
Link &link = border[b];
|
|
|
|
Point3f &p = patch.Vert(link.start_vert);
|
|
|
|
glVertex3f(p[0], p[1], p[2]);
|
2005-01-17 18:35:48 +01:00
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
glPointSize(1);
|
|
|
|
}
|
|
|
|
}*/
|
2004-11-18 19:30:15 +01:00
|
|
|
|
2005-02-10 10:18:20 +01:00
|
|
|
tframe.push_front(watch.Time());
|
|
|
|
if(tframe.size() > tlen) tframe.pop_back();
|
|
|
|
|
|
|
|
terror.push_front(extraction.max_error);
|
|
|
|
if(terror.size() > tlen) terror.pop_back();
|
|
|
|
|
2004-10-14 15:46:34 +02:00
|
|
|
if(show_statistics) {
|
2004-10-15 18:45:27 +02:00
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glPushMatrix();
|
|
|
|
glLoadIdentity();
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glPushMatrix();
|
|
|
|
glLoadIdentity();
|
|
|
|
gluOrtho2D(0, 1, 0, 1);
|
|
|
|
|
|
|
|
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
glDisable(GL_LIGHTING);
|
|
|
|
char buffer[1024];
|
2005-02-10 10:18:20 +01:00
|
|
|
glColor4f(0.0f, 0.0f, 0.6f, 0.5f);
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(unsigned int i = 0; i < tframe.size() -1; i++) {
|
|
|
|
double diff = (tframe[i] - tframe[i+1]);
|
|
|
|
glVertex2f(i/1024.0f,0);
|
|
|
|
glVertex2f(i/1024.0f,2*diff);
|
|
|
|
}
|
|
|
|
glEnd();
|
2004-10-15 18:45:27 +02:00
|
|
|
|
2005-02-10 10:18:20 +01:00
|
|
|
glColor4f(0.0f, 0.6f, 0.2f, 0.5f);
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(unsigned int i = 0; i < terror.size() -1; i++) {
|
|
|
|
glVertex2f(i/1024.0f,0);
|
|
|
|
glVertex2f(i/1024.0f,terror[i]/300);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glColor3f(1.0f, 1.0f, 1.0f);
|
2004-12-15 14:50:32 +01:00
|
|
|
|
2005-02-01 17:42:30 +01:00
|
|
|
sprintf(buffer, "Ram size : %.2f / %.2f Mb",
|
|
|
|
nexus.ram_used * nexus.chunk_size/(float)(1<<20),
|
|
|
|
nexus.ram_max * nexus.chunk_size/(float)(1<<20));
|
2005-01-14 16:25:29 +01:00
|
|
|
gl_print(0.03, 0.15, buffer);
|
2004-10-15 18:45:27 +02:00
|
|
|
|
2005-02-01 17:42:30 +01:00
|
|
|
sprintf(buffer, "Extr size: %.2f / %.2f Mb",
|
|
|
|
extraction.extr_used * nexus.chunk_size/(float)(1<<20),
|
|
|
|
extraction.extr_max * nexus.chunk_size/(float)(1<<20));
|
2005-01-14 16:25:29 +01:00
|
|
|
gl_print(0.03, 0.12, buffer);
|
|
|
|
|
2005-02-01 17:42:30 +01:00
|
|
|
sprintf(buffer, "Draw size: %.2f / %.2f Mb",
|
|
|
|
extraction.draw_used * nexus.chunk_size/(float)(1<<20),
|
|
|
|
extraction.draw_max * nexus.chunk_size/(float)(1<<20));
|
2004-10-15 18:45:27 +02:00
|
|
|
gl_print(0.03, 0.09, buffer);
|
2004-12-13 01:44:48 +01:00
|
|
|
|
2005-02-01 17:42:30 +01:00
|
|
|
sprintf(buffer, "Disk size: %.2f / %.2f Mb",
|
2005-01-14 16:25:29 +01:00
|
|
|
extraction.disk_max * nexus.chunk_size/(float)(1<<20),
|
|
|
|
extraction.disk_used * nexus.chunk_size/(float)(1<<20));
|
2004-10-15 18:45:27 +02:00
|
|
|
gl_print(0.03, 0.06, buffer);
|
|
|
|
|
2005-02-01 17:42:30 +01:00
|
|
|
sprintf(buffer, "%.2f KTri %.2f FPS %.0f M/s",
|
2005-01-14 16:25:29 +01:00
|
|
|
stats.ktri/(float)(1<<10),
|
2005-02-01 17:42:30 +01:00
|
|
|
stats.fps, stats.fps * stats.ktri/(float)(1<<20));
|
2004-10-15 18:45:27 +02:00
|
|
|
gl_print(0.03, 0.03, buffer);
|
2005-02-10 10:18:20 +01:00
|
|
|
|
2004-12-15 09:46:16 +01:00
|
|
|
|
2004-10-15 18:45:27 +02:00
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glEnable(GL_LIGHTING);
|
|
|
|
glPopMatrix();
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glPopMatrix();
|
2004-10-14 15:46:34 +02:00
|
|
|
}
|
2004-10-01 18:54:57 +02:00
|
|
|
|
|
|
|
SDL_GL_SwapBuffers();
|
2004-07-02 19:41:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SDL_Quit();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-10-15 18:45:27 +02:00
|
|
|
void gl_print(float x, float y, char *str) {
|
|
|
|
glRasterPos2f(x, y);
|
2004-10-21 15:40:16 +02:00
|
|
|
int len = (int)strlen(str);
|
2004-10-15 18:45:27 +02:00
|
|
|
for(int i = 0; i < len; i++)
|
|
|
|
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, str[i]);
|
|
|
|
}
|
|
|
|
|
2004-07-02 19:41:57 +02:00
|
|
|
|