Creating a local clipping plane¶
clipPlane.py¶
1# © 2024 Autodesk, Inc. All rights reserved.
2
3# This example creates a clipped sphere geometry with API v2.
4# Shortcut to toggle the clipping plane on and off is key C.
5
6# Create sphere and move it up
7root = vrScenegraphService.getRootNode()
8sphere = vrGeometryService.createSphere(root, 500, 32, 32, QColor.fromRgbF(1.0, 1.0, 1.0))
9sphere.setTranslation(QVector3D(0 ,0 ,500))
10
11# Create local clip plane
12clipPlane = vrScenegraphService.createNode(vrScenegraphTypes.ClipPlaneNode, root)
13# The transformation of the clip plane node only changes the transformation
14# of the plane but does not transform its children
15clipPlane.setTranslation(QVector3D(0, 0, 500))
16
17# Add sphere as child of clip plane. All children are clipped by the plane.
18clippedObjects = [sphere]
19clipPlane.children.append(clippedObjects)
20
21# Function to activate and deactivate the clip plane
22def toggleClipPlane():
23 if clipPlane.isValid():
24 clipPlane.setEnabled(not clipPlane.getEnabled())
25
26# Connect toggle to key 'c'
27keyC = vrKey(Key_C)
28keyC.connect(toggleClipPlane)
29
30print("Press key 'c' to toggle the clip plane.")