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.

Joerg Vogel avatar image Joerg Vogel commented ·
@Raviraj V, you want to visualize a street?
0 Likes 0 ·
Raviraj V avatar image Raviraj V Joerg Vogel commented ·

Create a wide using OnDraw in network nodes wide-path.png

0 Likes 0 ·
wide-path.png (84.8 KiB)
Ryan Clark avatar image Ryan Clark commented ·

Hi @Raviraj V, was Jason Lightfoot's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

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 :

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

and then the angle from one node to another will be

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


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

double pathwidth=2;
drawtomodelscale(current);
for (int n=current.outObjects.length;n>0;n--) {
Vec3 otherloc = current.outObjects[n].location.project(current.outObjects[n].up,current);
Vec2 other2=Vec2(otherloc.x,otherloc.y);
Vec2 unit=other2/other2.magnitude*pathwidth/2;
Vec2 leftoff=unit.rotate(90);
Vec2 p1=leftoff;
Vec2 p2=-leftoff;
Vec2 p3=p2+other2;
Vec2 p4=p3+leftoff*2;
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);
}
5 |100000

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