Repeat

sceneplates/switch.py
 1# © 2024 Autodesk, Inc. All rights reserved.
 2#
 3# Example to show how to insert one back plate
 4# This plate will cover the whole window
 5#
 6# vrSceneplateService is used to create new scene plates
 7# vrdSceneplateNode is used to change scene plate properties
 8#
 9
10# We introduce this types to make the code more readable
11NodeType = vrSceneplateTypes.NodeType
12ContentType = vrSceneplateTypes.ContentType
13SizeType = vrSceneplateTypes.SizeType
14RepeatType = vrSceneplateTypes.RepeatMode
15
16# This function summarizes all necessary steps to create a scene plate and set its properties.
17# First we have to create a node using the scene plate service and convert this to an plate.
18# Then we set different properties of the new created plate. 
19def createPlate(root, image): 
20    theNode = vrSceneplateService.createNode(root, NodeType.Backplate, "plate")
21    thePlate = vrdSceneplateNode(theNode)
22    thePlate.setContentType(ContentType.Image)
23    thePlate.setImage(image) 
24    thePlate.setSizeMode(SizeType.Absolute)
25    thePlate.setSize(512)
26    thePlate.setRepeatMode(RepeatType.Repeat)
27
28# Load an image
29# Get the example directory
30# Dive in to the texture directory
31# Make path windows like with back slashes
32# Load image with help of image service
33def createVREDImage():
34    theDir = vrFileIO.getVREDExamplesDir()
35    theFile = theDir + "/textures/vred.png"
36    theFile = theFile.replace('\\', '/');
37    theImage = vrImageService.loadImage(theFile)
38    return theImage
39
40# Query parent object for all scene plate creation
41theRoot = vrSceneplateService.getRootNode()
42
43# Read an image
44theImage = createVREDImage()
45
46# Create image plate repeat all over the window
47createPlate(theRoot, theImage)