Camera fixed object 1

To move a geometry with the camera, add the geometry as a child node to the camera node in the Scenegraph.

For another way to move an object with the camera, see “Camera fixed object 2”.

camera-fixed-object.py
 1# © 2024 Autodesk, Inc. All rights reserved.
 2
 3print("Executing demo script!")
 4
 5newScene()
 6
 7# All objects that are attached to the camera (fixed objects)
 8# need to be removed by the script. We define a special python
 9# function to clean up and tell vred to call this function when 
10# newScene is called or the users presses the new button in vred
11def newSceneCallback():
12    # remove object from camera.
13    camera_node.subChild(obj)
14
15setNewSceneCB(newSceneCallback)
16
17loadGeometry("$VRED_EXAMPLES/geo/teddy.osb")
18updateScene()
19calcVertexNormals()
20enableHeadlight(true)
21ignoreAutoHeadlight()
22
23obj = findNode("Teddy_Bear");
24obj.makeTransform()
25obj.setTranslation(0, 0, -200)
26
27camera_node = getCamNode(0)
28
29camera_node.addChild(obj)