SOXTMATERIALEDITOR(3iv)

πŸ’– SoXtMaterialEditor πŸ’–

okay bestie, gather round, because today we're talking about SoXtMaterialEditor(3IV) β€” and no, it's not a manual about your fave eyeshadow palette (though honestly? the vibe is similar). It lives in section 3IV of the manual, and it's the component that lets you edit a material interactively. Like, drag a slider, watch a sphere change. Iconic behaviour fr fr.


✨ NAME ✨

SoXtMaterialEditor β€” a Component which lets you edit a material interactively. that's it, that's the whole job, and it does it gorgeously πŸ’…


πŸ¦‹ INHERITS FROM πŸ¦‹

SoXtComponent > SoXtMaterialEditor

so it's a whole lineage situation. SoXtComponent is the parent, SoXtMaterialEditor is the main character offspring ✨


πŸŽ€ SYNOPSIS πŸŽ€

first things first, you gotta let it in:

#include <Inventor/Xt/SoXtMaterialEditor.h>

now, the callback type. this is the little function signature you write yourself if you wanna be notified when stuff changes:

typedef void        SoXtMaterialEditorCB(void *userData, const SoMaterial
                         *mtl)

and here's the enum that controls when those callbacks fire. two moods only:

enum UpdateFrequency {
     SoXtMaterialEditor::CONTINUOUS
                         send updates with every mouse motion
     SoXtMaterialEditor::AFTER_ACCEPT
                         only send updates after user hits accept button
}

like, do you want play-by-play commentary (CONTINUOUS) or the final verdict (AFTER_ACCEPT)? both valid, no judgment 🫢


🌸 Methods from class SoXtMaterialEditor 🌸

these are your methods, the ones this class brings to the group chat:

                    SoXtMaterialEditor(Widget parent = NULL, const char
                         *name = NULL, SbBool buildInsideParent = TRUE)
                    ~SoXtMaterialEditor()
void                attach(SoMaterial *material, int index = 0)
void                detach()
SbBool              isAttached()
void                addMaterialChangedCallback(SoXtMaterialEditorCB *f,
                         void *userData = NULL)
void                removeMaterialChangedCallback(SoXtMaterialEditorCB *f,
                         void *userData = NULL)
void                setUpdateFrequency(SoXtMaterialEditor::UpdateFrequency
                         freq)
SoXtMaterialEditor::UpdateFrequency
                    getUpdateFrequency()
void                setMaterial(const SoMaterial &mtl)
const SoMaterial &  getMaterial() const

πŸ’œ Methods from class SoXtComponent πŸ’œ

inherited from the parent, but still serving:

virtual void            show()
virtual void            hide()
SbBool                  isVisible()
Widget                  getWidget() const
SbBool                  isTopLevelShell() const
Widget                  getShellWidget() const
Widget                  getParentWidget() const
void                    setSize(const SbVec2s &size)
SbVec2s                 getSize()
Display *               getDisplay()
void                    setTitle(const char *newTitle)
const char *            getTitle() const
void                    setIconTitle(const char *newIconTitle)
const char *            getIconTitle() const
void                    setWindowCloseCallback(SoXtComponentCB *func, void
                              *data = NULL)
static SoXtComponent *  getComponent(Widget w)
const char *            getWidgetName() const
const char *            getClassName() const

🌈 DESCRIPTION 🌈

okay so here's the tea. this class edits the material properties of an SoMaterial node. but here's the twist β€” you can also just use the editor directly with callbacks, no attaching required. it doesn't need to be in a situationship with a node to be useful, iykyk.

so what does the component actually look like? it's giving:

  • a render area showing a test sphere
  • some sliders
  • a set of radio buttons
  • and a menu

the sphere displays the current material being edited. so you literally see your choices in real time. gorgeous.

there's one slider for each material coefficient. those fields are:

  • ambient, diffuse, specular, emissive β€” all of which are colors
  • transparency and shininess β€” which are scalar values

a color editor can be opened to edit the color slider base color. and a material list displays palettes of predefined materials from which to choose. so you got options, bestie 🎨

lowkey important: the editor can currently be attached to only one material at a time. attaching two different materials will automatically detach the first one before attaching the second. it's not cheating, it's just serial monogamy 😭

πŸ‘‘ METHODS πŸ‘‘

                    SoXtMaterialEditor(Widget parent = NULL, const char
                         *name = NULL, SbBool buildInsideParent = TRUE)
                    ~SoXtMaterialEditor()

Constructor and destructor. the hello and the goodbye. πŸ’–


  • void attach(SoMaterial *material, int index = 0)
  • void detach()

attach/detach the editor to a material node and edit the material of the given index. so you're like "hey material, you're mine now" and then later "okay we're done here" πŸ’…


  • SbBool isAttached()

Returns TRUE if the editor is attached. are we in a relationship? yes or no, no maybes 🫢


void addMaterialChangedCallback(SoXtMaterialEditorCB *f,
                         void *userData = NULL)
void removeMaterialChangedCallback(SoXtMaterialEditorCB *f,
                         void *userData = NULL)

Additional way of using the material editor, by registering a callback which will be called whenever the material changes (check the UpdateFrequency to find when the callbacks will be called). so if you don't wanna attach it to a node, you just subscribe to the drama instead ✨


void setUpdateFrequency(SoXtMaterialEditor::UpdateFrequency freq)
SoXtMaterialEditor::UpdateFrequency getUpdateFrequency()

Sets/gets the update frequency. See the UpdateFrequency enum declaration. it's literally right up there in the synopsis, go look πŸ‘€


void setMaterial(const SoMaterial &mtl)
const SoMaterial & getMaterial() const

Set a new material value, and get the current material value. give and take, the circle of life 🌸


πŸ“ RESOURCES πŸ“

these are the X resources you can set to customize the look. defaults included, don't come for me:

  • *SoXtMaterialEditor.tile1Color: #4c4c4c (color name or hex value)
  • *SoXtMaterialEditor.tile2Color: #999999 (color name or hex value)
  • *SoXtMaterialEditor.light1Color: white (color name or hex value)
  • *SoXtMaterialEditor.light2Color: white (color name or hex value)
  • *SoXtMaterialEditor.updateFrequency: continuous (continuous | manual)

🧚 SEE ALSO 🧚

go read these next, bestie, they're all in the same friend group:

  • SoXtComponent
  • SoXtMaterialList
  • SoXtDirLightEditor
  • SoMaterial

that's the whole page!! you ate that πŸ’…βœ¨

cute lil sign-off: this was SoXtMaterialEditor(3IV), and yeah the source/version and date fields at the bottom are literally the exact same string as the top β€” SoXtMaterialEditor(3IV)() β€” so I'm just telling you here instead of copy-pasting it like a robot. periodt. πŸŽ€πŸ¦‹