#include "rts_glOBJ.h" #include "gl\glut.h" OBJint rts_glOBJ::f_RenderTexCoord(vertex_texture &texcoord) { if(texcoord.mask & OBJ_VT_W) glTexCoord3f(texcoord.u, texcoord.v, texcoord.w); else if(texcoord.mask & OBJ_VT_V) glTexCoord2f(texcoord.u, texcoord.v); else glTexCoord1f(texcoord.u); return OBJ_OK; } OBJint rts_glOBJ::f_RenderNormal(vertex_normal &normal) { if(normal.mask & OBJ_VN_K) glNormal3f(normal.i, normal.j, normal.k); else return OBJ_ERROR; return OBJ_OK; } OBJint rts_glOBJ::f_RenderVertex(vertex_position &v) { if(v.mask & OBJ_V_W) glVertex4f(v.x, v.y, v.z, v.w); else if(v.mask & OBJ_V_Z) glVertex3f(v.x, v.y, v.z); else if(v.mask & OBJ_V_Y) glVertex2f(v.x, v.y); else //glVertex1f(v.x); return OBJ_ERROR; return OBJ_OK; } inline void rts_glOBJ::f_RenderPointList(unsigned int id) { glBegin(GL_POINTS); unsigned int num_vertices = primitives[id].p.size(); for(unsigned int v = 0; v 4) glBegin(GL_POLYGON); else if(primitives[id].p.size() == 4) glBegin(GL_QUADS); else if(primitives[id].p.size() == 3) glBegin(GL_TRIANGLES); else return; //now run through each vertex unsigned int num_vertices = primitives[id].p.size(); for(unsigned int v=0; v::iterator p; for(p = selected_primitives.begin(); p!=selected_primitives.end(); p++) f_RenderPrimitive(*p); } return OBJ_OK; } void rts_glOBJ::SelectPrimitive(unsigned int primitive) { //adds a primitive to the selection list selected_primitives.push_back(primitive); selected_primitives.unique(); } void rts_glOBJ::UnselectPrimitive(unsigned int primitive) { selected_primitives.remove(primitive); } void rts_glOBJ::SelectMultipleHits(GLuint* buffer, unsigned int num_hits) { GLuint* hit_entry = buffer; GLuint num_names; GLuint nearest_name; GLuint minZ = 0xffffffff; //push the hits into the selection buffer for(int h=0; h::iterator p; for(p = selected_primitives.begin(); p != selected_primitives.end(); p++) { primitive selected_prim = primitives[(*p)]; //create a new primitive primitive new_prim; new_prim.mask = selected_prim.mask; new_prim.type = selected_prim.type; //for each vertex in the primitive int num_vertices = selected_prim.p.size(); for(int v = 0; v selected_v; list::iterator p; //selected primitive vector::iterator v; //vertex //insert all selected vertex indices into selected_v for(p = selected_primitives.begin(); p!=selected_primitives.end(); p++) { for(v=primitives[(*p)].p.begin(); v!=primitives[(*p)].p.end(); v++) { selected_v.push_back((*v).v); } } selected_v.unique(); //remove redundant entries //now find all primitives connected to these vertices int num_primitives = primitives.size(); int prim; list::iterator s_v; for(prim =0; prim* vertex_to_prim = new vector[v_list.size()]; int num_primitives = primitives.size(); int p; int num_vertices, v; int vertex; for(p=0; p selected_verts; list::iterator sel; for(sel = selected_primitives.begin(); sel != selected_primitives.end(); sel++) { num_vertices = primitives[(*sel)].p.size(); for(v=0; v::iterator s_v; for(s_v = selected_verts.begin(); s_v != selected_verts.end(); s_v++) { num_primitives = vertex_to_prim[(*s_v)].size(); for(p=0; p