// Set up double-sided lights void lights() { using namespace std; using namespace Eigen; glEnable(GL_LIGHTING); //glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE); glEnable(GL_LIGHT0); float WHITE[4] = {1,1,1,1.}; float GREY[4] = {0.4,0.4,0.4,1.}; float BLACK[4] = {0.,0.,0.,1.}; float NEAR_BLACK[4] = {0.1,0.1,0.1,1.}; Vector4f pos = light_pos; glLightfv(GL_LIGHT0,GL_AMBIENT,BLACK); glLightfv(GL_LIGHT0,GL_DIFFUSE,WHITE); glLightfv(GL_LIGHT0,GL_SPECULAR,BLACK); glLightfv(GL_LIGHT0,GL_POSITION,pos.data()); //glEnable(GL_LIGHT1); //pos(0) *= -1; //pos(1) *= -1; //pos(2) *= -1; //glLightfv(GL_LIGHT1,GL_AMBIENT,BLACK); //glLightfv(GL_LIGHT1,GL_DIFFUSE,NEAR_BLACK); //glLightfv(GL_LIGHT1,GL_SPECULAR,BLACK); //glLightfv(GL_LIGHT1,GL_POSITION,pos.data()); }
inline void vertex(const Vector4d& v, const Vector4f& color) { #if USE_VERTEX_BUFFER data[currentPosition++] = v.cast<float>(); ++currentStripLength; if (currentPosition == capacity) { flush(); data[0] = v.cast<float>(); currentPosition = 1; currentStripLength = 1; } #else glColor4fv(color.data()); glVertex3dv(v.data()); #endif }
void Splitter::draw_self() const { using namespace igl; using namespace std; using namespace Eigen; glEnable(GL_NORMALIZE); double eff_alpha = alpha; const Vector4f HAND_COLOR(1.0,0.7,0.7,1.0); const float * color = (is_hand?HAND_COLOR.data(): (Node::color_parts? Node::part_color[SPLITTER_C_PART]: this->color.data())); pickles[max_children].activate_pickle_or_diffuse_material(color,eff_alpha); // Draw plug to parent glPushMatrix(); glTranslated(0,0,-radius/0.65*0.34); // http://stackoverflow.com/a/6506716/148668 bool some_child_is_hover = find(child_is_hover.begin(), child_is_hover.end(), true) != child_is_hover.end(); bool some_child_is_selected = find(child_is_selected.begin(), child_is_selected.end(), true) != child_is_selected.end(); // Dim if hovered over if(is_hover && ! some_child_is_hover) { dim_lights(0.25); }else if (is_selected && !some_child_is_selected) { dim_lights(0.365); } Node::part[TBT_PLUG_PART].draw_and_cache(); glPopMatrix(); // Draw sphere GLUquadricObj * sphere = gluNewQuadric(); assert(sphere); gluQuadricNormals(sphere, GLU_SMOOTH); //gluQuadricDrawStyle(sphere, GLU_SILHOUETTE); gluQuadricDrawStyle(sphere, GLU_FILL); gluQuadricTexture(sphere, GL_TRUE); // Tried both GL_TRUE and GL_FALSE gluSphere(sphere,radius/0.65*0.57,20,20); // Dim if hovered over if(is_hover && ! some_child_is_hover) { dim_lights(1./0.25); }else if (is_selected && !some_child_is_selected) { dim_lights(1./0.365); } // Draw outlets to children for(int i =0;i<max_children;i++) { glPushMatrix(); Quat q; Vec3 v; rigid_to_child(i,q,v); glTranslatef(v(0),v(1),v(2)); glMultMatrixd(Affine3d(q).data()); glTranslated(0,0,radius + radius/0.65 * 0.34); const float * color = (is_hand?HAND_COLOR.data(): (Node::color_parts? Node::part_color[TERMINATOR_PART]: this->color.data())); pickles[i].activate_pickle_or_diffuse_material(color,eff_alpha=alpha); // Dim if hovered over float ld[4]; glGetLightfv(GL_LIGHT0,GL_DIFFUSE,ld); if(child_is_hover[i]) { dim_lights(0.25); }else if (child_is_selected[i]) { dim_lights(0.365); } Node::part[TBT_SOCKET_PART].draw_and_cache(); // Reset lighting if(child_is_hover[i]) { dim_lights(1./0.25); }else if (child_is_selected[i]) { dim_lights(1./0.365); } glPopMatrix(); } }