-
Notifications
You must be signed in to change notification settings - Fork 2
/
of.cylinder.pd
68 lines (68 loc) · 3.4 KB
/
of.cylinder.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#N canvas 273 23 967 755 12;
#X obj 31 14 inlet;
#X obj 31 847 outlet;
#X obj 90 14 inlet;
#X obj 170 12 inlet;
#X obj 250 12 inlet;
#X obj 320 12 inlet;
#X obj 390 12 inlet;
#X msg 90 38 radius \$1;
#X msg 170 38 height \$1;
#X msg 250 38 rres \$1;
#X msg 320 38 hres \$1;
#X text 700 707 RI;
#X msg 390 38 cres \$1;
#X obj 31 70 ofelia d cylinder-\$0 \; local c = ofCanvas(this) \; local
args = c:getArgs() \; local radius \, height \, rres \, hres \, cres
\, drawmode \, strokeweight \, debug \, normalsize = args[1] \, args[2]
\, args[3] \, args[4] \, args[5] \, args[6] \, args[7] \, 0 \, 10 \;
local position \, orientation \, scale \, lookat = ofVec3f(0 \, 0 \,
0) \, ofVec3f(0 \, 0 \, 0) \, ofVec3f(1 \, 1 \, 1) \, ofVec3f(1 \,
1 \, 1) \; \; function M.new() \; ofWindow.addListener("setup" \, this)
\; if args[1] == nil then radius = 100 end \; if args[2] == nil then
height = 100 end \; if args[3] == nil then rres = 10 end \; if args[4]
== nil then hres = 10 end \; if args[5] == nil then cres = 10 end \;
if args[6] == nil then drawmode = "fill" end \; if args[7] == nil then
strokeweight = 1 end \; M.setup() \; end \; \; function M.free() \;
ofWindow.removeListener("setup" \, this) end \; \; function M.setup()
\; cylinder\$0 = ofCylinderPrimitive() \; cylinder\$0:set(radius \,
height \, rres \, hres \, cres \, true \, OF_PRIMITIVE_TRIANGLE_STRIP)
\; cylinder\$0:setPosition(position:vec3()) cylinder\$0:setOrientation(orientation:vec3())
cylinder\$0:setScale(scale:vec3()) \; end \; \; function M.list(l)
M.radius(l[1]) M.height(l[2]) M.rres(l[3]) M.hres(l[4]) M.cres(l[5])
M.draw(l[6]) M.stroke(l[7]) end \; function M.radius(f) radius=f cylinder\$0:setRadius(f)
end \; function M.height(f) height=f cylinder\$0:setHeight(f) end \;
function M.rres(f) rres=f cylinder\$0:setResolutionRadius(f) end \;
function M.hres(f) hres=f cylinder\$0:setResolutionHeight(f) end \;
function M.cres(f) cres=f cylinder\$0:setResolutionCap(f) end \; function
M.draw(s) drawmode=s end \; function M.stroke(float) strokeweight=float
end \; function M.normalsize(float) normalsize=float 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] cylinder\$0:setPosition(position:vec3())
end \; function M.orientation(l) orientation.x=l[1] orientation.y=l[2]
orientation.z=l[3] cylinder\$0:setOrientation(orientation:vec3()) end
\; function M.scale(l) scale.x=l[1] scale.y=l[2] scale.z=l[3] cylinder\$0:setScale(scale:vec3())
end \; function M.lookat(l) lookat.x=l[1] lookat.y=l[2] lookat.z=l[3]
cylinder\$0:lookAt(lookat:vec3()) end \; function M.texture(f) if f
> 0 then cylinder\$0:enableTextures() else cylinder\$0:disableTextures()
end end \; function M.texturemap(l) cylinder\$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 cylinder\$0:drawFaces() end \; if drawmode == "point" then
cylinder\$0:drawVertices() end \; if drawmode == "line" then cylinder\$0:drawWireframe()
end \; if drawmode == "normal" then cylinder\$0:drawNormals(normalsize)
end \; if debug > 0 then cylinder\$0:drawAxes(debug) end \; return
anything \; end \;;
#X f 130;
#X connect 0 0 13 0;
#X connect 2 0 7 0;
#X connect 3 0 8 0;
#X connect 4 0 9 0;
#X connect 5 0 10 0;
#X connect 6 0 12 0;
#X connect 7 0 13 0;
#X connect 8 0 13 0;
#X connect 9 0 13 0;
#X connect 10 0 13 0;
#X connect 12 0 13 0;
#X connect 13 0 1 0;