-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathof.meshcircle.pd
47 lines (47 loc) · 2.52 KB
/
of.meshcircle.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
#N canvas 438 50 842 640 12;
#X obj 31 14 inlet;
#X obj 31 765 outlet;
#X obj 93 14 inlet;
#X obj 163 14 inlet;
#X text 785 656 RI;
#X msg 163 40 res \$1;
#X msg 93 40 size \$1;
#X obj 31 65 ofelia d circle-\$0 \; local c = ofCanvas(this) \; local
args = c:getArgs() \; local size \, res \, drawmode \, strokeweight
\, rectmode \, mode \, debug = args[1] \, args[2] \, args[3] \, args[4]
\, "center" \, 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 size = 50 end \; if args[2] == nil then res = 20 end \;
if args[3] == nil then drawmode = "fill" end \; if args[4] == nil then
strokeweight = 1 end \; if ofWindow.exists then M.setup() end \; end
\; function M.free() ofWindow.removeListener("setup" \, this) end \;
function M.setup() path\$0 = ofPath() mesh\$0 = ofMesh() node\$0 =
ofNode() M.makeshape() \; end \; \; function M.size(f) size = f M.makeshape()
end \; function M.res(f) res = f M.makeshape() end \; function M.draw(s)
drawmode = s end \; function M.stroke(f) strokeweight = f end \; function
M.list(l) size \, res \, drawmode \, strokeweight = (table.unpack(l))
end \; function M.mode(f) mode = f end \; function M.debug(f) debug
= f end \; function M.position(l) position:set (table.unpack(l)) node\$0:setPosition(position:vec3())
end \; function M.orientation(l) orientation:set (table.unpack(l))
node\$0:setOrientation(orientation:vec3()) end \; function M.scale(l)
scale:set (table.unpack(l)) node\$0:setScale(scale:vec3()) end \; function
M.lookat(l) lookat:set (table.unpack(l)) node\$0:lookAt(lookat:vec3())
end \; function M.makeshape() \; path\$0:clear() path\$0:setCircleResolution(math.abs(res))
path\$0:circle(0 \, 0 \, size) \; mesh\$0=path\$0:getTessellation()
\; for i = 0 \, mesh\$0:getNumVertices() do \; local v=ofVec2f(mesh\$0:getVertex(i))
\; mesh\$0:addTexCoord((v:normalize()*ofVec2f(0.5 \, -0.5)+0.5):vec2())
end end \; \; function M.bang() \; mesh\$0:setMode(mode) \; ofSetLineWidth(strokeweight)
\; node\$0:transformGL() \; if drawmode == "fill" then mesh\$0:drawFaces()
end \; if drawmode == "point" then mesh\$0:drawVertices() end \; if
drawmode == "line" then mesh\$0:drawWireframe() end \; if drawmode
== "normal" then mesh\$0:enableNormals() end \; node\$0:restoreTransformGL()
\; if debug == 1 then node\$0:draw() end \; return anything \; end
\;;
#X f 111;
#X connect 0 0 7 0;
#X connect 2 0 6 0;
#X connect 3 0 5 0;
#X connect 5 0 7 0;
#X connect 6 0 7 0;
#X connect 7 0 1 0;