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

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

raviraj_v
Not applicable
81 Views
4 Replies
Message 1 of 5

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

raviraj_v
Not applicable

[ FlexSim 19.2.4 ]

Accepted solutions (1)
82 Views
4 Replies
Replies (4)
Message 2 of 5

joerg_vogel_HsH
Mentor
Mentor
@Raviraj V, you want to visualize a street?
0 Likes
Message 3 of 5

raviraj_v
Not applicable

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

0 Likes
Message 4 of 5

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

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.location.project(current.outObjects.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);
}
0 Likes
Message 5 of 5

ryan_c10
Not applicable

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