-
Notifications
You must be signed in to change notification settings - Fork 0
/
animation.py
60 lines (50 loc) · 1.71 KB
/
animation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#元output.py
def route_animation(filename_o):
print("\n========================================")
print(" animation ver. 1.1")
print("========================================\n")
print("経路データ(route.txt)を読み込んでいます... ")
f = open("route.txt", "r")
lines = f.readlines()
orgdata = []
for i in lines:
orgdata.append(list(map(float, i.split())))
f.close()
size_org = len(orgdata)
print("読込完了 (", size_org, "行)")
with open('UFO.txt', 'r') as f:
p = f.read()
q = ""
q += "DEF UFO Transform{\n"
q += " translation "
q += str(orgdata[0][0])+" "+str(orgdata[0][1])+" "+str(orgdata[0][2])+"\n"
q += " scale 0.5 0.5 0.5\n"
q += " rotation 1 0 0 1.570796326794897\n"
q += p
out = ("\n")
out += q
out += str("\n")
out += ("DEF TS3 TimeSensor{\n")
out += (" cycleInterval 10\n")
out += (" loop TRUE\n")
out += ("}\n")
out += ("DEF PI2 PositionInterpolator{\n")
out += (" key[")
for i in range(size_org-1):
out += (str(i/(size_org-1))+",")
out += ("1]\n")
out += (" keyValue[")
for i in range(size_org):
print("\r", i, end=" ")
out += str(orgdata[i][0])+" "
out += str(orgdata[i][1])+" "
out += str(orgdata[i][2])+","
out += ("]\n")
out += ("}\n")
out += ("ROUTE TS3.fraction_changed TO PI2.set_fraction\n")
out += ("ROUTE PI2.value_changed TO UFO.set_translation\n")
#filename_o = input("適用先ファイル名(拡張子は不要):")
f = open(filename_o + ".wrl", "a")
f.write(out)
f.close()
print(filename_o + ".wrl に経路情報を適用しました")