question

Lars Christian J2 avatar image
0 Likes"
Lars Christian J2 asked Lars Christian J2 commented

How to hide content in a plane at a distance

How can I hide the content (Show Contents off) of a plane when I zoom out? It is needed when the plane contains a lot of graphics objects.


1686139598764.png


1686139644316.png


HideContent_LOD.fsm

FlexSim 23.1.2
planehide and unhide objects
1686139598764.png (115.1 KiB)
1686139644316.png (50.0 KiB)
hidecontent-lod.fsm (42.9 KiB)
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
0 Likes"
Phil BoBo answered Lars Christian J2 commented

Use the On Draw pick option "Hide Shape and Contents at a Distance":

1686144044638.png

If you want to only hide the contents and not the shape itself, adjust the code of the pick option accordingly.

You can also use the Frustum Culling checkbox in your screenshot to hide to contents of the visual tool if it is outside the frustum of the view's camera. See Visuals (flexsim.com)


1686144044638.png (227.0 KiB)
· 2
5 |100000

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

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·

Here's a small improvement/alternative that considers the distance to the actual viewpoint of the frustum rather than the point on the ground on which the view is focussed:

// If this function returns a true, the default draw code of the object will not be executed.
Vec3 mgroundviewpoint=Vec3(viewpointx(view).value,viewpointy(view).value,viewpointz(view).value);
Vec3 mcurrcentre=current.getLocation(0.5,0.5,0.5).project(current.up,model());
Vec3 groundpath=mgroundviewpoint-mcurrcentre;
double azimuth=-1*viewpointrx(view).value;
double elevation=Math.radians(azimuth);
double viewradius=viewpointradius(view).value;
double groundradius=Math.cos(elevation)*viewradius;
double z=Math.sin(elevation)*viewradius;
double bearing=viewpointrz(view).value-90;
double rotation=Math.radians(bearing);
double y=Math.sin(rotation)*groundradius;
double x=Math.cos(rotation)*groundradius;
Vec3 topov=Vec3(x,y,z);
Vec3 mpov=mgroundviewpoint+topov;
Vec3 path=mpov-mcurrcentre;


//print("dist:",path.magnitude,"azimuth",azimuth,"groundRadius",groundradius,"height",z,"bearing",bearing,"x",x,"y",y,"flexdistfromview:",distfromviewpoint(current,view));
if (path.magnitude>20)
    switch_hidecontents(current,1);
else
    switch_hidecontents(current,0);

It probably still worth have frustum culling enabled with this because you could be very close but looking in the other direction.

1 Like 1 ·
Lars Christian J2 avatar image Lars Christian J2 Jason Lightfoot ♦ commented ·
Thanks!!!
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.