// CS3451 Computer Graphics // P3 - Triangle Mesh // Catherine Herrington // http://www-static.cc.gatech.edu/grads/c/catyarr/Tmesh // Modified on June 15, 2006 // Triangle mesh viewer with support for corner table // Written by Jarek Rossignac June 2006 // OpenGL version //import processing.opengl.*; // VERTICES int w=6; // size of initial Tmesh-grid made in setup int nv = w*w, maxnv = 100;; // current and max number of vertices int nt = 2*(w-1)*(w-1), maxnt = maxnv*2; // current and max number of triangles pt[] G = new pt [maxnv]; // geometry table (vertices) float[][] UV = new float [maxnv][2]; // texture coordinates for the vertices vec[] Nv = new vec [maxnv]; // vectors associated with vertices for normal or laplace vec[] Nt = new vec [maxnt]; // vectors associated with triangles for normal int [] valence = new int [maxnv]; // valence (count of incident triangles) for the vertices pt Cbox = new pt(0,0,0); // box center float Rbox; // box radius int[] rgb = new int [maxnt]; // color for each triangle int iMesh = -1; // toggle between mesh files to load int iNegHit = -1; int iEdgeHit = 0; int iPosHit = 1; int iNoHit = 2; int iTriHit = 1; // CORNERS int nc = nt*3; // current number of corners int[] V = new int [3*maxnt]; // V table (triangle/vertex indices) int[] O = new int [3*maxnt]; // O table (opposite corner indices) int c = 0; // corner // GUI int bi=-1; // index of selected vertex, -1 if none selected pt Mouse = new pt(0,0,0); // current mouse position float xr, yr = 0; // mouse coordinates relative to center of window int px=0, py=0, dz=0, oz=0; vec labelD=new vec(-10,-10, 2); // offset vector for labels boolean showNormals=false; color grey = color(200, 200, 210), red = color(200, 10, 10), blue = color(10, 10, 200), lightblue = color(150, 150, 255), green = color(10, 200, 20), black = color(10, 10, 10), magenta = color(250, 50, 100), brown = color(150, 100, 50), yellow = color(245, 238, 80), lightgreen = color(150, 255, 150), lightpink = color(255, 160, 160), lightpurple = color(220, 150, 220); void setup() { size(750, 750, P3D); // void setup() { size(750, 750, OPENGL); PFont font = loadFont("Courier-14.vlw"); textFont(font, 12); for (int i=0; i