-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
134 lines (107 loc) · 3.23 KB
/
main.lua
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
-- This is a Demo for the star wars death star
-- by: John Danielson
require("Text")
require("AddAppDirectory")
AddAppDirectory()
runfile[[lights.lua]]
runfile[[ScrollingText.lua]]
runfile[[solarSystem.lua]]
runfile[[Navigation.lua]]
myNav = FlyOrWalkNavigation{
start = "flying",
switchButton = gadget.DigitalInterface("WMButtonPlus"),
initiateRotationButton1 = gadget.DigitalInterface("WMButtonRight"),
initiateRotationButton2 = gadget.DigitalInterface("WMButtonLeft"),
}
local function CenterTransformAtPosition(xform, pos)
local bound = xform:getBound()
return Transform{
position = -bound:center() + Vec(unpack(pos)),
xform,
}
end
big = Transform{
position = {8,10,-25},
scale = .00005,
orientation = AngleAxis(Degrees(25), Axis{1.0, 0.0, 0.0}),
CenterTransformAtPosition(Transform{Model[[models/big.ive]]}, {0,0,0})
}
RelativeTo.World:addChild(big)
ships3 = Transform{
position = {-3,7,-15},
scale = .005,
orientation = AngleAxis(Degrees(90), Axis{0.0, 1.0, 0.0}),
CenterTransformAtPosition(Transform{Model[[models/3ships.ive]]}, {0,0,0})
}
RelativeTo.World:addChild(ships3)
tie1 = Transform{
position = {0,0,-10},
scale = .1,
orientation = AngleAxis(Degrees(90), Axis{0.0, 1.0, 0.0}),
CenterTransformAtPosition(Transform{Model[[models/tie.ive]]}, {0,0,0})
}
RelativeTo.World:addChild(tie1)
tie2 = Transform{
position = {2,0,-8},
scale = .1,
orientation = AngleAxis(Degrees(90), Axis{0.0, 1.0, 0.0}),
CenterTransformAtPosition(Transform{Model[[models/tie.ive]]}, {0,0,0})
}
RelativeTo.World:addChild(tie2)
tie3 = Transform{
position = {1,0,-5},
scale = .1,
orientation = AngleAxis(Degrees(90), Axis{0.0, 1.0, 0.0}),
CenterTransformAtPosition(Transform{Model[[models/tie.ive]]}, {0,0,0})
}
RelativeTo.World:addChild(tie3)
tie4 = Transform{
position = {1,5,-4},
scale = .1,
orientation = AngleAxis(Degrees(90), Axis{0.0, 1.0, 0.0}),
CenterTransformAtPosition(Transform{Model[[models/tie.ive]]}, {0,0,0})
}
RelativeTo.World:addChild(tie4)
shootable_objects = {tie1,tie2,tie3,tie4}
runfile[[shoot_and_explode.lua]]
--define a table called "shootable_objects" and list our objects we want to be shootable
dome = Transform{
position = {0, 0, 0},
Model("models/dome.osg"),
scale=100,
}
RelativeTo.World:addChild(dome)
local shuttle_sw = Transform{
Transform{
Model("models/shuttle_sw.ive"),
orientation = AngleAxis(Degrees(-90), Axis{1.0, 0.0, 0.0}),
},
orientation = AngleAxis(Degrees(180), Axis{0.0, 1.0, 0.0}),
scale = .00005,
}
shuttle_sw = CenterTransformAtPosition(shuttle_sw,{4, -2, -10})
RelativeTo.World:addChild(shuttle_sw)
starwars = Transform{
position = {4, -2, -25},
Model("models/deathstar.osg"),
scale=2.5,
orientation = AngleAxis(Degrees(180), Axis{0.0, 1.0, 0.0}),
}
RelativeTo.World:addChild(starwars)
lightsaber = Transform{
position = {1.35, 0.0, 0.45},
Model("models/lightsaber.osg"),
scale = 0.5,
}
local xform = osg.MatrixTransform()
RelativeTo.Room:addChild(xform)
xform:addChild(lightsaber)
Actions.addFrameAction(
function()
local device = gadget.PositionInterface("VJWand")
while true do
xform:setMatrix(device.matrix)
Actions.waitForRedraw()
end
end
)