question

Hao Zhou avatar image
0 Likes"
Hao Zhou asked Hao Zhou commented

Drawing Order

Assume I have a machine. I draw a box (12 gl triangles) around the machine with grey transparent color {0.5f, 0.5f, 0.5f, 0.5f} through mesh API. I test it, it is transparent and I can see any objects behind it. The problem is that the machine has a few moving mechanical parts, the moving parts' treenodes are directly under the machine's treenode in the FlexSim tree. These moving parts are not visible. Is there a way of making these parts visible through the transparent surface.

FlexSim 19.0.0
draw order
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Phil BoBo avatar image
3 Likes"
Phil BoBo answered Hao Zhou commented

Rather than putting your code in the OnDraw trigger of the main object, you can put it in an OnDraw trigger of a surrogate object component. This will cause it to draw after the main object's content.

  1. Right-click the object and select Edit > Animations... to open the Animations and Components window.
  2. Press the + button to add a new surrogate object component.
  3. In the tree view, navigate to that component and explicitly create an OnDraw node within its object data.
  4. Give that OnDraw node string data, toggle it as FlexScript, and paste your draw code into it.
  5. Execute the following script for the surrogate object component so that OnDraw is fired for it:
treenode Object1 = Model.find("MainObj>visual/drawsurrogate/Object1");

set(drawflags(Object1),get(drawflags(Object1)) &~ DRAW_FLAG_NO_ON_DRAW); 

See the attached sample model. draw-order.fsm


transparent-box.png (340.4 KiB)
draw-order.fsm (18.0 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Hao Zhou avatar image Hao Zhou commented ·

Thanks for the solution Phil. I really appreciate it.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.