How to hide content in a plane at a distance

How to hide content in a plane at a distance

lars_jacobsen_ScandiSim
Advocate Advocate
8 Views
3 Replies
Message 1 of 4

How to hide content in a plane at a distance

lars_jacobsen_ScandiSim
Advocate
Advocate

[ FlexSim 23.1.2 ]

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

0 Likes
Accepted solutions (1)
9 Views
3 Replies
Replies (3)
Message 2 of 4

philboboADSK
Autodesk
Autodesk
Accepted solution

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)



Phil BoBo
Sr. Manager, Software Development
0 Likes
Message 3 of 4

jason_lightfootVL7B4
Autodesk
Autodesk

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.

Message 4 of 4

Thanks!!!
0 Likes