예제 #1
0
void ON_GL( const ON_Color& rc, GLfloat c[4] )
{
  c[0] = (GLfloat)rc.FractionRed();
  c[1] = (GLfloat)rc.FractionGreen();
  c[2] = (GLfloat)rc.FractionBlue();
  c[3] = (GLfloat)1.0;
}
예제 #2
0
void ON_GL( const ON_Color& rc, double alpha, GLfloat c[4] )
{
  c[0] = (GLfloat)rc.FractionRed();
  c[1] = (GLfloat)rc.FractionGreen();
  c[2] = (GLfloat)rc.FractionBlue();
  c[3] = (GLfloat)alpha;
}
예제 #3
0
void CRhGLShaderProgram::SetupMaterial(const ON_Material& mat)
{
  ON_Color dcolor  = mat.Diffuse();
  ON_Color scolor  = mat.Specular();
  ON_Color ecolor  = mat.Emission();
  
  GLfloat alpha    = (GLfloat)(1.0 - mat.Transparency());
  GLfloat shine    = 128.0*(mat.Shine() / ON_Material::MaxShine());
  GLfloat black[4] = {0.0,0.0,0.0,1.0};
  GLfloat ambi[4]  = { mat.Ambient().FractionRed(), mat.Ambient().FractionGreen(), mat.Ambient().FractionBlue(), mat.m_ambient.FractionAlpha() };
  GLfloat diff[4]  = { dcolor.FractionRed(), dcolor.FractionGreen(), dcolor.FractionBlue(), alpha };
  GLfloat spec[4]  = { scolor.FractionRed(), scolor.FractionGreen(), scolor.FractionBlue(), 1.0f };
  GLfloat emmi[4]  = { ecolor.FractionRed(), ecolor.FractionGreen(), ecolor.FractionBlue(), 1.0f };
  GLfloat* pspec   = shine?spec:black;
  
  if ( m_Uniforms.rglLightAmbient >= 0) {
    if (mat.m_ambient.Alpha() > 0)
      glUniform4fv( m_Uniforms.rglLightAmbient, 1, ambi );
    else
      glUniform4fv( m_Uniforms.rglLightAmbient, 1, black );
  }
  if ( m_Uniforms.rglDiffuse >= 0 )
    glUniform4fv( m_Uniforms.rglDiffuse, 1, diff );
  if ( m_Uniforms.rglSpecular >= 0 )
    glUniform4fv( m_Uniforms.rglSpecular, 1, pspec );
  if ( m_Uniforms.rglEmission >= 0 )
    glUniform4fv( m_Uniforms.rglEmission, 1, emmi );
  if ( m_Uniforms.rglShininess >= 0 )
    glUniform1f( m_Uniforms.rglShininess,  shine );
  if ( m_Uniforms.rglUsesColors >= 0 )
    glUniform1i( m_Uniforms.rglUsesColors,  0 );
  
  if (alpha < 1.0)
    glEnable( GL_BLEND );
  else
    glDisable( GL_BLEND );
}
예제 #4
0
bool gfxRhino3D::loadCAD(QString filename){
  int i, layer;
  ON_Color objCol;
     
  //Load geometry...
  if (filename.endsWith(".3dm")){
    load3dm(filename);
    for (i=0;i<model.m_object_table.Count();i++){
      layer=model.m_object_table[i].m_attributes.m_layer_index;
      if (model.m_layer_table[layer].IsVisible()){
        if (ON::color_from_object == model.m_object_table[i].m_attributes.ColorSource()){
          objCol=model.m_object_table[i].m_attributes.m_color; 
        }else{
          objCol=model.m_layer_table[layer].Color();
        }
        parentObject->actor.push_back( createActor(model.m_object_table[i].m_object, objCol.FractionRed(), objCol.FractionGreen(), objCol.FractionBlue()) );
      }
    }
  }
  for (i=0;i<parentObject->actor.size();i++) parentObject->renderer->AddActor(parentObject->actor[i]);
  return true;
}