Skip to content

Commit

Permalink
Add spin
Browse files Browse the repository at this point in the history
  • Loading branch information
tuuzdu committed Jun 19, 2018
1 parent d873d5a commit be68734
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions scripts/c4d_animation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Animation.new(points_str, colors_str)
local tblUnpack = table.unpack
local strUnpack = string.unpack

local state = {stop = 0, idle = 1, takeoff = 2, flight = 3, landing = 4}
local state = {stop = 0, idle = 1, flight = 2, landed = 3}

local function getGlobalTime()
return time() + deltaTime()
Expand Down Expand Up @@ -61,7 +61,7 @@ function Animation.new(points_str, colors_str)
end

local Config = {}
Config.t_after_prepare = 1
Config.t_after_prepare = 2
Config.t_after_takeoff = 1
Config.init_index = 1
Config.last_index = points_count
Expand All @@ -74,7 +74,7 @@ function Animation.new(points_str, colors_str)
function obj.setConfig(init_index, last_index, time_after_prepare, time_after_takeoff)
Config.init_index = init_index or 1
Config.last_index = last_index or points_count
Config.t_after_prepare = time_after_prepare or 1
Config.t_after_prepare = time_after_prepare or 2
Config.t_after_takeoff = time_after_takeoff or 1
end

Expand All @@ -97,7 +97,7 @@ function Animation.new(points_str, colors_str)
end

function obj:animLoop(point_index)
if self.state == state.flight and point_index <= Config.last_index then
if self.state == state.flight and point_index < Config.last_index then
local _, x, y, z = Point.getPoint(point_index)
local _, r, g, b = Color.getColor(point_index)
local t = Point.getPoint(point_index + 1)
Expand All @@ -110,8 +110,13 @@ function Animation.new(points_str, colors_str)
end
end

function obj:spin()
self.state = state.idle
end

function obj:start()
self.state = state.idle
self:eventHandler(Ev.SYNC_START)
end

Animation.__index = Animation
Expand All @@ -124,7 +129,7 @@ end

anim = Animation.new(points, _)
anim.setConfig(3, 10)
anim:start()
anim:spin()
-- print (dump(anim))

callback(Ev.SYNC_START)

0 comments on commit be68734

Please sign in to comment.