-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcorazon.lua
More file actions
109 lines (90 loc) · 2.56 KB
/
corazon.lua
File metadata and controls
109 lines (90 loc) · 2.56 KB
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
require"anima"
local GL = GLcanvas{H=600,aspect=1,DORENDER=false,RENDERINI=0,RENDEREND=25,vsync=true,profile="CORE"}
GL.rootdir = path.this_script_path()
GL:setMovie(GL.rootdir.."/pelicorazon")
GL.use_presets = true
local MI,ME
local camera,tex,mask
local object
local MVinv
local function make_mesh()
print"makemesh"
---[[
local vec3 = mat.vec3
local vec2 = mat.vec2
local meshE = ME.mesh or mesh.mesh{triangles={0,2,1}, points={vec3(-1,-1,0), vec3(0,1,0), vec3(1,-1,0)}, tcoords={vec2(0,0.5),vec2(0.5,1),vec2(1,1)}}
--]]
local meshW = meshE:clone()
meshW:M4(MVinv)
meshW:calc_centroid()
local minb,maxb = meshW:bounds()
local center = vec3(meshW.centroid.x,meshW.centroid.y,minb.z)
if NM.gentex then MI:MeshRectify(meshE,nil,glc.GL_NEAREST) end
local frame = {X=vec3(1,0,0),Y=vec3(0,1,0),Z=vec3(0,0,1),center=center}
object:setMesh(meshW,MI.texR, frame)
end
NM = GL:Dialog("test",{
{"make_mesh",0,gui.types.button,function() make_mesh() end},
{"draw_image",true,gui.types.toggle},
{"gentex",false,gui.types.toggle},
})
function REPEAT(n,...)
local T = {}
for i=1,n do
for j=1,select('#',...) do
local t = select(j,...)
T[#T+1]=t
end
end
return unpack(T)
end
local Dbox
local mssa
local mblur
function GL:init()
tex = GL:Texture():Load("heart.png")
GL:set_WH(tex.width, tex.height)
mssa = GL:initFBOMultiSample()
camera = Camera(GL,"tps")
MVinv = camera:MV().inv
ME = require"anima.modeling.SpHeight"(GL,camera,make_mesh)
-- this would allow spHeight serialization
--local plugin = require"anima.plugins.plugin"
--ME.SE.fb = plugin.serializer(ME.SE)
object = require"anima.Object3D"(GL,camera)
MI = require"anima.modeling.mesh_image"(GL,camera,tex)
mblur = require"anima.plugins.motion_blur".make(GL)
Dbox = GL:DialogBox("corazon",true) --true for allow saving-loading
Dbox:add_dialog(NM)
Dbox:add_dialog(camera.NM)
Dbox:add_dialog(ME.NM)
Dbox:add_dialog(object.NM)
GL:preset_load("corazon.preset")
local vec3 = mat.vec3
local gr = 1.7
local gr2 = gr
---[[ comment this to avoid animation (allows user to change scale)
local zval = pointer()
local hook = function()
object.NM.vars.scale:set(vec3(1,1,zval[0]))
object:make_model_mat()
end
local aaa = spl_anim:new(zval,{{1,3},REPEAT(40,{1,0.25},{gr,0.3},{1.3,0.4},{1.45,0.1},{gr2,0.3})},hook)
GL.animation:add_animatable(aaa)
--]]
end
local NN = {}
function NN:draw(t,w,h)
mssa:Bind()
ut.Clear()
if NM.draw_image then
tex:drawcenter()
ut.ClearDepth()
end
object:draw()
mssa:Dump()
end
function GL.draw(t,w,h)
mblur:draw(t,w,h,{clip={NN}})
end
GL:start()