-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanimbase.lua
87 lines (71 loc) · 4.18 KB
/
animbase.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
-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-- * *
-- * Animation Base *
-- * TRICLYSM *
-- * *
-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-- * *
-- * This file contains the basic functions for initializing an animation, as well as *
-- * any constants that can be used with functions registered to the Lua animation. *
-- * *
-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-- * *
-- * Copyright (C) 2011 Brandon Castellano, Ryan Mantha. All rights reserved. *
-- * Triclysm is provided under the BSD-2-Clause license. This program uses the SDL *
-- * (Simple DirectMedia Layer) library, and the Lua scripting language. See the *
-- * included LICENSE file or <http://www.triclysm.com/> for more details. *
-- * *
-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-- * CONSTANTS *
-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
X_AXIS = 0 -- Represents the x-axis.
Y_AXIS = 1 -- Represents the y-axis.
Z_AXIS = 2 -- Represents the z-axis.
YZ_PLANE = 0 -- Represents the yz-plane.
ZX_PLANE = 1 -- Represents the zx-plane.
XY_PLANE = 2 -- Represents the xy-plane.
COLOR_R = 0 -- Represents the color red.
COLOR_G = 1 -- Represents the color green.
COLOR_B = 2 -- Represents the color blue.
RGB_VALS = -1 --
RGB_HEX = -2 --
sx = 0 -- The cube size in the x-dimension (set by InitSize).
sy = 0 -- The cube size in the y-dimension (set by InitSize).
sz = 0 -- The cube size in the z-dimension (set by InitSize).
sc = {} -- The cube size as an array (can be used with the axis constants).
_numColors = -1 -- The number of colors of the animation (set by SetNumColors).
_setColors = false -- Set to true after the call of SetNumColors.
OAXIS = {} -- The other axis helper. Allows you to retrieve the
OAXIS[YZ_PLANE] = {} -- constant representing the two axis given a specified
OAXIS[ZX_PLANE] = {} -- plane. For example, the value of OAXIS[XY_PLANE][0] is
OAXIS[XY_PLANE] = {} -- the X_AXIS, and OAXIS[XY_PLANE][1] is the Y_AXIS.
OAXIS[YZ_PLANE][0] = Y_AXIS
OAXIS[YZ_PLANE][1] = Z_AXIS
OAXIS[ZX_PLANE][0] = Z_AXIS
OAXIS[ZX_PLANE][1] = X_AXIS
OAXIS[XY_PLANE][0] = X_AXIS
OAXIS[XY_PLANE][1] = Y_AXIS
-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-- * FUNCTIONS *
-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-- Called when the animation is created, this stores the cube size in the above variables.
function _InitSize(sizeX, sizeY, sizeZ)
sx = sizeX
sy = sizeY
sz = sizeZ
sc[X_AXIS] = sizeX
sc[Y_AXIS] = sizeY
sc[Z_AXIS] = sizeZ
end
-- Sets the number of colors in the animation. Must be called at least once, and all
-- subsequent calls are simply ignored.
function SetNumColors(colors)
if not _setColors then
_numColors = colors
_setColors = true
end
end
function MaxSize()
return math.max(sx, sy, sz)
end