Rotate

sceneplates/rotate.py
 1# © 2024 Autodesk, Inc. All rights reserved.
 2#
 3# Example to show how to rotate a scene plate
 4# This example is more complex as simple.py and create.py
 5# Please study this first
 6#
 7# vrSceneplateService is used to create and query a scene plate
 8# vrdSceneplateNode is used to rotate the scene plate
 9#
10
11# We introduce this types to make the code more readable
12NodeType = vrSceneplateTypes.NodeType
13ContentType = vrSceneplateTypes.ContentType
14PositionType = vrSceneplateTypes.Position
15SizeType = vrSceneplateTypes.SizeType
16
17# Current angle for rotation animation
18theAngle = 0.0;
19
20# This function summarizes all necessary steps to create a scene plate and set its properties.
21# First we have to create a node using the scene plate service and convert this to an plate.
22# Then we set different properties of the new created plate. 
23def createPlate(root, image): 
24    theNode = vrSceneplateService.createNode(root, NodeType.Frontplate, "plate")
25    thePlate = vrdSceneplateNode(theNode)
26    thePlate.setContentType(ContentType.Image)
27    thePlate.setImage(image) 
28    thePlate.setSizeMode(SizeType.Absolute)
29    thePlate.setSize(512)
30    thePlate.setPosition(PositionType.Center)
31
32# Rotate the plate clockwise
33def nextStep():
34    global theAngle
35    theAngle = theAngle + 0.1
36    if theAngle > 360.0:
37        theAngle = 0.0
38
39    theNode = vrSceneplateService.findNode("plate");
40    thePlate = vrdSceneplateNode(theNode)
41    thePlate.setRotation(theAngle)
42
43# Query parent object for all scene plate creation
44theRoot = vrSceneplateService.getRootNode()
45
46# Read an image
47theDir = vrFileIO.getVREDExamplesDir()
48theFile = theDir + "/textures/vred.png"
49theFile = theFile.replace('\\', '/');
50theImage = vrImageService.loadImage(theFile)
51
52# Create image back plates in the middle of the window
53createPlate(theRoot, theImage)
54
55# Start a timer and make each second the next step in this animation
56timer = vrTimer(0.1)
57timer.connect(nextStep)
58timer.setActive(true)