question

Raviraj V avatar image
1 Like"
Raviraj V asked Ryan Clark commented

how to make a wide path to be showed using Network node OnDraw Trigger?

FlexSim 19.2.4
network nodestriggersondraw
· 3
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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

Some trig will be involved for this and the commands you will need are drawtomodelscale() and either drawrect, drawrectangle or drawquad(). (fglRotate() might also help)

You'll also want the other node coordinates relative to the current node for a given port :

  1. Vec3 otherloc = current.outObjects[port].location.project(current.outObjects[port].up,current);

and then the angle from one node to another will be

  1. Math.degrees(Math.atan2(otherloc.y,otherloc.x))


If you were using an up to date version the vector logic is much simpler:

  1. double pathwidth=2;
  2. drawtomodelscale(current);
  3. for (int n=current.outObjects.length;n>0;n--) {
  4. Vec3 otherloc = current.outObjects[n].location.project(current.outObjects[n].up,current);
  5. Vec2 other2=Vec2(otherloc.x,otherloc.y);
  6. Vec2 unit=other2/other2.magnitude*pathwidth/2;
  7. Vec2 leftoff=unit.rotate(90);
  8. Vec2 p1=leftoff;
  9. Vec2 p2=-leftoff;
  10. Vec2 p3=p2+other2;
  11. Vec2 p4=p3+leftoff*2;
  12. drawquad(view,p1.x,p1.y,0,p2.x,p2.y,0,p3.x,p3.y,0,p4.x,p4.y,0,0,1,0);
  13. }
5 |100000

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