Hi, this is an example to manage clipplanes position. Once setup you can use some constraints to move the refNode or directly manage the clipplane position
# This Script is an example to manage the position of clipplanes
# involved Nodes
clipPlane = vrNodeService.findNode("ClipPlane")
refNode = vrNodeService.findNode("Plane")
sphere = vrNodeService.findNode("Sphere")
# creation of test nodes if tare not presents
theRoot = vrScenegraphService.getRootNode()
if not refNode.isValid():
refNode = vrGeometryService.createPlane(theRoot, QVector2D(2000,2000), resolutionX=10, resolutionY=10, color=QColor.fromRgbF(1.0, 0.0, 0.0))
refNode.setTranslation(QVector3D(0,0,1000))
refNode.setRotationAsEuler(QVector3D(0,90,0))
if not clipPlane.isValid():
clipPlane = vrScenegraphService.createNode(vrScenegraphTypes.ClipPlaneNode, parent=theRoot, name='ClipPlane', forceUniqueName=True)
if not sphere.isValid():
sphere = vrGeometryService.createSphere(clipPlane, 500, latres=50, longres=50, color=QColor.fromRgbF(1.0, 1.0, 1.0))
sphere.setTranslation(QVector3D(1000,0,1000))
print(clipPlane)
print(refNode)
print(sphere)
# enable the clipPlane
clipPlane.setEnabled(True)
# Main update function
# customize for your needs
def clipPlanePosition():
refNodePosition = refNode.getWorldTransform()
clipPlane.setTransform(refNodePosition)
# add to main loop
class clipPlanePositionUpdate(vrAEBase):
def __init__(self):
vrAEBase.__init__(self)
self.addLoop()
def recEvent(self, state):
vrAEBase.recEvent(self, state)
def loop(self):
if self.isActive():
clipPlanePosition()
clipPlanePosition_Update = clipPlanePositionUpdate()
# start and stop manager
# Use those to start the update on scene open
#clipPlanePosition_Update.setActive(True)
#clipPlanePosition_Update.setActive(False)
# use those to start and stop the update on user command
keyStartClipUpdate = vrKey(Key_D)
keyStartClipUpdate.connect("clipPlanePosition_Update.setActive(True);print('ClipPlaneUpdate Started')")
keyStopClipUpdate = vrKey(Key_E)
keyStopClipUpdate.connect("clipPlanePosition_Update.setActive(False);print('ClipPlaneUpdate Ended')")
To test it just paste the code in an empty scene
Best
Chris