Interpolation demo¶
interpolate.py¶
1# © 2024 Autodesk, Inc. All rights reserved.
2
3print("Executing interpolate script!")
4
5newScene()
6loadGeometry("$VRED_EXAMPLES/geo/teddy.osb")
7loadGeometry("$VRED_EXAMPLES/geo/car.osb")
8updateScene()
9calcVertexNormals()
10
11# find teddy and convert it into a transform node
12teddy = findNode("Teddy_Bear");
13teddy.makeTransform()
14
15# create a interpolation object and add transformation slides to it
16teddyDuration = 1.0
17teddyInt = vrInterpolator()
18teddySlide1 = vrTranslationSlide(teddy, 0,0,0, 100,0,0, teddyDuration)
19teddySlide2 = vrRotationSlide(teddy, 0,0,0, 0,359,0, teddyDuration)
20teddySlide3 = vrTranslationSlide(teddy, 100,0,0, 0,0,0, teddyDuration)
21teddySlide4 = vrScaleSlide(teddy, 1,1,1, 2,2,2, teddyDuration)
22teddySlide5 = vrScaleSlide(teddy, 2,2,2, 1,1,1, teddyDuration)
23
24teddyInt.add(teddySlide1)
25teddyInt.add(teddySlide2)
26teddyInt.add(teddySlide3)
27teddyInt.add(teddySlide2, true)
28teddyInt.add(teddySlide4)
29teddyInt.add(teddySlide5)
30teddyInt.add(teddySlide2, true)
31teddyInt.setActive(true);
32
33# define key i to toggle interpolation on/off
34keyI = vrKey(Key_I)
35keyI.connect(teddyInt, SWITCH_TOGGLE)
36print("press i to toggle interpolation of teddy")
37
38# car
39car = findNode("speedshape")
40car.makeTransform()
41
42# the "true" means when all slides are done it ends.
43carInt = vrInterpolator(true)
44carSlide1 = vrTranslationSlide(car, 0,0,0, 0,100,0, 8.0)
45carSlide2 = vrTranslationSlide(car, 0,100,0, 0,0,0, 8.0)
46carInt.add(carSlide1)
47carInt.add(carSlide2)
48carInt.setActive(true)
49
50logo = findNode("chrome_logo")
51logo.makeTransform()
52
53logoInt = vrInterpolator(true)
54logoSlide = vrRotationSlide(logo, 0,0,0, 0,359,0, 8.0)
55logoInt.add(logoSlide)
56
57# now connect the two actions, this could also be done in one interpolator,
58# just shows the connection of actions.
59# when the car interpolation is finished it will activate the logo interpolation
60# when the logo interpolation is finished it will activate the car interpolation and so on ...
61carInt.connect(logoInt, SWITCH_ON)
62logoInt.connect(carInt, SWITCH_ON)
63
64# tail
65tail = findNode("Tail");
66tail.makeTransform()
67
68axis = createLine(0,0,0,0,0,1,0,0,0)
69hideNode(axis)
70
71tailInt = vrInterpolator()
72tailSlide = vrRotationAxisSlide(tail, axis, 0, 359, 8.0)
73
74tailInt.add(tailSlide)
75tailInt.setActive(true)
76
77print("End")