How to color specific parts of an STL object in 3D World Editor

21 views (last 30 days)
Hi,
I am having trouble coloring a CAD model I designed in Fusion360 in the 3D World Editor (Simulink 3D Animation).
When I import an STL file, the 3D World Editor displays a completely grey model, but the original model has multiple colors in specific parts of the model. I followed the steps outlined here: https://www.mathworks.com/help/sl3d/import-stl-and-physical-modeling-xml-files.html
I found a way to color the model with only one color using the diffuseColor (SFColor) field, but I cannot find a way to color specific parts of the model with different colors.
If I need to import multiply CAD models, color them separately, and assemble them to make the whole model, how can I export multiple STL files and assemble them together in the editor?
Any assistance would be greatly appreciated.
Thank you in advance.

Accepted Answer

Jan Houska
Jan Houska on 17 Mar 2023
Hi Alex,
your geometry is most probably a hierarchical tree of Transform nodes that contain Shape nodes. These contain Geometry nodes that describe the body geometry and Appearance nodes that describe the body look. To add color, you create a Material node inside the Appearance node and set its diffuseColor field to the desired color. This is described in the X3D standard. You may also want to take a look at the vrmanipul_global shipping example and examine its node hierarchy. The example contains hierarchically organized individually colored objects, maybe similar to what you are trying to achieve.
Jan

More Answers (0)

Categories

Find more on Simulation in Help Center and File Exchange

Tags

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!