-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathof.icosphere.pd
50 lines (50 loc) · 2.8 KB
/
of.icosphere.pd
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
#N canvas 260 62 978 716 12;
#X obj 31 14 inlet;
#X obj 31 740 outlet;
#X obj 90 12 inlet;
#X obj 170 12 inlet;
#X msg 170 38 res \$1;
#X text 923 661 RI;
#X msg 90 38 radius \$1;
#X obj 31 65 ofelia d icosphere-\$0 \; local c = ofCanvas(this) \;
local args = c:getArgs() \; local radius \, res \, drawmode \, strokeweight
\, primode \, debug \, normalsize = args[1] \, args[2] \, args[3] \,
args[4] \, args[5] \, 0 \, 1 \; local position \, orientation \, scale
\, lookat = ofVec3f() \, ofVec3f() \, ofVec3f(1 \, 1 \, 1) \, ofVec3f()
\; \; function M.new() \; ofWindow.addListener("setup" \, this) \;
if args[1] == nil then radius = 100 end \; if args[2] == nil then res
= 1 end \; if args[3] == nil then drawmode = "fill" end \; if args[4]
== nil then strokeweight = 1 end \; M.setup() \; end \; \; function
M.free() \; ofWindow.removeListener("setup" \, this) end \; \; function
M.setup() \; icosphere\$0 = ofIcoSpherePrimitive() \; icosphere\$0:set(radius
\, math.min(math.abs(res) \, 6)) \; icosphere\$0:setPosition(position:vec3())
icosphere\$0:setOrientation(orientation:vec3()) icosphere\$0:setScale(scale:vec3())
end \; \; function M.list(l) M.radius(l[1]) M.res(math.min(math.abs(l[2])
\, 6)) M.primode(l[3]) M.draw(l[4]) M.stroke(l[5])end \; function M.radius(f)
radius=f icosphere\$0:setRadius(f) end \; function M.res(f) res=f icosphere\$0:setResolution(math.min(math.abs(f)
\, 6)) end \; function M.primode(f) primode=f icosphere\$0:setMode(f)
end \; function M.draw(s) drawmode=s end \; function M.normalsize(float)
normalsize=float end \; function M.stroke(f) strokeweight=f end \;
function M.debug(f) debug = f*100 end \; function M.position(l) position.x=l[1]
position.y=l[2] position.z=l[3] icosphere\$0:setPosition(position:vec3())
end \; function M.orientation(l) orientation.x=l[1] orientation.y=l[2]
orientation.z=l[3] icosphere\$0:setOrientation(orientation:vec3())
end \; function M.scale(l) scale.x=l[1] scale.y=l[2] scale.z=l[3] icosphere\$0:setScale(scale:vec3())
end \; function M.lookat(l) lookat.x=l[1] lookat.y=l[2] lookat.z=l[3]
icosphere\$0:lookAt(lookat:vec3()) end \; function M.texture(f) if
f > 0 then icosphere\$0:enableTextures() else icosphere\$0:disableTextures()
end end \; function M.texturemap(l) icosphere\$0:mapTexCoords(l[1]
\, l[2] \, math.max(l[3] \, 0.01) \, math.max(l[4] \, 0.01)) end \;
\; function M.bang() \; ofSetLineWidth(strokeweight) \; if drawmode
== "fill" then icosphere\$0:drawFaces() end \; if drawmode == "point"
then icosphere\$0:drawVertices() end \; if drawmode == "line" then
icosphere\$0:drawWireframe() end \; if drawmode == "normal" then icosphere\$0:drawNormals(normalsize)
end \; if debug > 0 then icosphere\$0:drawAxes(debug) end \; return
anything \; end \;;
#X f 136;
#X connect 0 0 7 0;
#X connect 2 0 6 0;
#X connect 3 0 4 0;
#X connect 4 0 7 0;
#X connect 6 0 7 0;
#X connect 7 0 1 0;