Announcement

Collapse
No announcement yet.

how edit combination of material binding and material as "material editor" does

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

  • how edit combination of material binding and material as "material editor" does

    Dear Mike,
    Dear Forum Users,

    Please, i've the following 3D shape as in zip file:

    shape.zip

    having SoMaterialBinding PER_VERTEX setted and SoMaterial node having a diffuse color array with different values (green, cyano and blue)
    how i can edit the material using SoXtMaterialEditor?

    Is it possible?

    thank You very much in advance.

    Regards,
    Vincenzo



  • #2
    Originally posted by [email protected] View Post
    having SoMaterialBinding PER_VERTEX setted and SoMaterial node having a diffuse color array with different values (green, cyano and blue)
    how i can edit the material using SoXtMaterialEditor?
    Hi Vincenzo,
    Yes, it's possible.
    Disclaimer: The MaterialEditor is provided as a convenience for prototyping and demos. It may not be a good solution for a production application.

    The MaterialEditor works pretty well with a basic SoMaterial node that contains exactly one value in each field. In this case, you can (if desired) attach the MaterialEditor directly to the node in the scene graph.

    SoMaterial nodes are often not basic. For example, your material node contains 8000+ values in the 'diffuseColor' field. In this case we have to work around two limitations of the MaterialEditor:
    1. The MaterialEditor can only display one "slice" of the material node.
      I.e., the colors corresponding to a specific index value. You can specify the index value when you call the 'attach()' method, but there is no UI to allow the user to change the index value.
    2. The MaterialEditor will try to use the specified index for every field.
      This is a problem if only one of the material node fields contains multiple values, i.e., you can't specify index 1024.
    The usual solution is to create a separate SoMaterial node, attach it to the MaterialEditor, and set a materialChanged callback on the editor.
    When the user wants to edit the color of a face, copy the relevant field values into the separate SoMaterial node that is attached to the editor.
    When the user modifies the material in the editor, the callback will be called, then copy the relevant field values into the SoMaterial node in the scene graph.

    Since you only have diffuse colors in your material node, you could use the same solution but just create an SoXtColorEditor to modify the RGB values.

    Note that when the user picks a geometry, the SoPickedPoint::getMaterialIndex() method returns the index of the material for the picked face. However, if the geometry has per-vertex colors, then the returned value is the material index for the first vertex. Changing the color value for this index will only change the color of that vertex, not the whole face.
    Regards,
    Mike
    Attached Files

    Comment


    • #3
      Dear Mike,
      First of all thank You very much for the attached example;
      i very appreciate Your suggestions and help;
      I'll take a look at your example and in the meantime thank you very much again.
      Have a nice day.

      Regards,
      Vincenzo

      Comment

      Working...
      X