Announcement

Collapse
No announcement yet.

Transparency in PoTriangleMesh2D

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transparency in PoTriangleMesh2D

    I am trying to make a PoTriangleMesh2D transparent - but it doesn't seem to be working.

    Code:
    [INDENT]PoTriangleMesh2D* mesh = new PoTriangleMesh2D;
    mesh->setGeometry(surface.points_.size(), x, y);
    
    // add a set of scalar values to this mesh
    if (zmin != zmax)
    mesh->addValuesSet(0, z);
    
    SbColor colors[5] = {SbColor(1.0,0.0,0.0), SbColor(1.0,1.0,0.0), SbColor(0.0,1.,0.), SbColor(0.0,1.0,1.0),
    SbColor(0.0,0.0,1.0)};
    
    float val[5];
    val[0] = zmin; for (int j = 1; j < 5; j++) val[j] = val[j - 1] + (zmax - zmin) / 4;
    PoNonLinearDataMapping2* dataMapping = new PoNonLinearDataMapping2;
    dataMapping->value.setValues(0, 5, val);
    dataMapping->color.setValues(0, 5, colors);
    dataMapping->type = PoNonLinearDataMapping2::LINEAR_PER_LEVEL;
    dataMapping->transparencyEnabled = true;
    dataMapping->transparency = 0.2;
    
    // define the mesh surface
    PoMeshFilled* meshFilled = new PoMeshFilled;
    meshFilled->valuesIndex.setValue(0);
    meshFilled->coloringType = PoMesh::COLOR_MAPPING;
    meshFilled->zValuesIndex = 0;[/INDENT]
    I am using OIV toolkit 9.8. Is it possible to obtain transparency of the mesh in this way?

  • #2
    Originally posted by lisamcgregor View Post
    I am trying to make a PoTriangleMesh2D transparent - but it doesn't seem to be working.
    Code:
    dataMapping->transparency = 0.2;
    I am using OIV toolkit 9.8. Is it possible to obtain transparency of the mesh in this way?
    Yes, that's definitely possible. There is just a small mistake in your code. Note the second sentence in the method description:
    Defines the list of transparencies for the data mapping.
    To be taken into account the number of transparencies must be equal to the number of colors, otherwise transparencies are ignored.

    Also, since this could be a complex surface, don't forget to request high quality transparency:
    Code:
    viewer->setTransparencyType(SoGLRenderAction::TransparencyType::SORTED_LAYERS_BLEND);
    Regards,
    Mike

    Comment

    Working...
    X