jgerstmayr / EXUDYN

Multibody Dynamics Simulation: Rigid and flexible multibody systems
https://www.youtube.com/channel/UCsQD2bIPBXB_4J23WtqKkVw/playlists
Other
166 stars 23 forks source link

Transparent #53

Closed MichaelUIBK closed 1 year ago

MichaelUIBK commented 1 year ago

In the GraphicsDataFromPointsAndTrigs(), I used a color with an alpha-transparency of 0.2, but the bodies behind the surface are not visible. Is there a workaround?

Screenshot 2023-07-11 145709

def UFgraphics(mbs, objectNum):
    gLine=[]
    for atc in tetList:        
        A=mbs.GetSensorValues(atc.node1.sensorCenterOfRotation,configuration=exu.ConfigurationType.Visualization)
        B=mbs.GetSensorValues(atc.node2.sensorCenterOfRotation,configuration=exu.ConfigurationType.Visualization)
        C=mbs.GetSensorValues(atc.node3.sensorCenterOfRotation,configuration=exu.ConfigurationType.Visualization)
        D=mbs.GetSensorValues(atc.node4.sensorCenterOfRotation,configuration=exu.ConfigurationType.Visualization)

        points=[A,B,C,D]       

        triangles=[0,1,2]
        gLine+=[GraphicsDataFromPointsAndTrigs(points,triangles,color=[0.41,0.41,0.41,1])]
        triangles=[0,2,3]
        gLine+=[GraphicsDataFromPointsAndTrigs(points,triangles,color=[0.83,0.83,0.83,0.2])]
    return gLine
ground = mbs.AddObject(ObjectGround(visualization=VObjectGround(graphicsDataUserFunction=UFgraphics)))
jgerstmayr commented 1 year ago

In the current form of OpenGL in Exudyn, this is not possible. The only way is to draw first background objects and hereafter foreground objects. The drawing is processed in the order in which you add objects to the system (object number). In your case, you may use a graphics user function for your surface, which is added after all other objects have been added. In addition to that, if you use graphicsDataUserFunction, these objects are not at all transparent, as they are drawn first. A workaround is, to use a second mbs, containing the graphics object with the user function.