void Sphere::drawImposterSphere(Vector3 position, double radius, prog3d::Color color) { glDisable(GL_COLOR_MATERIAL); // Set color float matColor[4]; matColor[0] = (float)color.r(); matColor[1] = (float)color.g(); matColor[2] = (float)color.b(); matColor[3] = (float)color.a(); glMaterialfv(GL_FRONT, GL_DIFFUSE, matColor); // Draw Imposter Shader Sphere glUseProgram(_program); glUniform1f(_uni_sphereRadius,radius); glUniform3f(_uni_spherePos,position.x(),position.y(),position.z()); glBegin(GL_TRIANGLE_STRIP); glVertexAttrib1f(_atr_vertexID,0.0); glVertexAttrib1f(_atr_vertexID,1.0); glVertexAttrib1f(_atr_vertexID,2.0); glVertexAttrib1f(_atr_vertexID,3.0); glEnd(); glUseProgram(0); glEnable(GL_COLOR_MATERIAL); }
void Texture::setAlpha(const prog3d::Color &c,double v,double radius) { if (_img!=NULL) { for(int i=0;i<_img->width();i++) { for(int j=0;j<_img->height();j++) { QColor cq=_img->pixel(i,j); double dist=Vector3(cq.redF()-c.r(),cq.greenF()-c.g(),cq.blueF()-c.b()).length(); if (dist<radius) cq.setAlphaF(v);//1.0-(radius-dist)/radius); _img->setPixel(i,j,cq.rgba()); } } toGL(); } }