the verts property in this structure doesn’t make sense… or do you want to collect all verts with a specific color? is it map verts or geo verts?
Well the example data I wrote was just made up.
But for example say I have a sphere in the scene which has all its verts and what not assigned with colors using your method of
“–for v in (polyop.getmapface obj 99 face) do polyop.setmapvert obj 99 v (col[c] as point4) – FASTER!!!”
I want to have a function that gathers all of the geos data putting it into a struct which contains all the verts along with the face’s those verts make up, along with the verts colors.
So if you had assigned R,G,B, to an object and then collected all its data you would be left with a struct along the lines of
Polygroups =
#(
(data color:[255,0,0] faces:#{1…} verts:#(1…)), –red
(data color:[0,255,0] faces:#{8…} verts:#(24…)), –green
(data color:[0,0,255] faces:#{24…} verts:#(60…)) –blue
)
I’m assuming some verts would be in multiple groups as they would lie on the edge which would be the dividing line of two different colors.
Does this make sense?
If not I have gmail’s google chat and/or skype and i can explain through there.
something like this:
(
delete objects
obj = convertToPoly (sphere segments:8)
polyop.deleteFaces obj #{1..8,25..32}
obj.displayByLayer = false
obj.vertexColorType = 5
obj.vertexColorMapChannel = 99
obj.showVertexColors = on
polyop.setmapsupport obj 99 on
polyop.applyuvwmap obj #face channel:99
seed 0
fn setColor node face =
(
col = #(red,green,blue)
c = random 1 col.count
for v in (polyop.getmapface obj 99 face) do polyop.setmapvert obj 99 v (col[c] as point4)
)
t1 = timestamp()
for f in obj.faces as bitarray do setColor obj f
update obj
format "time:%
" (timestamp() - t1)
struct colorData (color = [0,0,0], faces = #{}, verts = #{}, tverts = #{})
data = #()
fn findItemByColor list color =
(
local n = 0
for k=1 to list.count while n == 0 where list[k].color == color do n = k
n
)
for f=1 to (polyop.getnummapfaces obj 99) do
(
vv = polyop.getfaceverts obj f
tv = polyop.getmapface obj 99 f
for k=1 to tv.count do
(
c = polyop.getmapvert obj 99 tv[k]
if (i = findItemByColor data c) == 0 do
(
append data (colorData color:c)
i = data.count
)
append data[i].tverts tv[k]
append data[i].verts vv[k]
if k == 1 do append data[i].faces f
)
)
data
)
of course it might be optimized. but i hope the idea is clear.
Awwww sheeeet nice. Yeah this is what I was after and I was not really grasping how that was to be achieved. I’ll get this all together and into a working dialog with everything we have got here and I’ll share it on here.
Now this may seem amateur but what is the different between tVerts and Verts?
tverts are map verts, verts are geo verts.
by analogy to:
$.mesh.num[b]verts[/b]
$.mesh.num[b]tverts[/b]
All in the same relm of this project. I’m currently putting together a link by distance script. I’ll have a new post on there here soon.
Sort by distance?
(
parents = for o in objects where classof o == point collect o
children = for o in objects where classof o == Editable_Poly collect o
struct data (node, dist)
for o in children do
(
results = #()
for p in parents do
(
append results (data node:p dist:(distance p.center o.center))
)
fn fnSortValues a b = if (a.dist < b.dist) then -1 else if (a.dist > b.dist) then 1 else 0 --sort distance from smallest to largest
qsort results fnSortValues
o.wirecolor = results[1].node.wirecolor
)
)
Sort by distance?
(
parents = for o in objects where classof o == point collect o
children = for o in objects where classof o == Editable_Poly collect o
struct data (node, dist)
for o in children do
(
results = #()
for p in parents do
(
append results (data node:p dist:(distance p.center o.center))
)
fn fnSortValues a b = if (a.dist < b.dist) then -1 else if (a.dist > b.dist) then 1 else 0 --sort distance from smallest to largest
qsort results fnSortValues
o.wirecolor = results[1].node.wirecolor
)
)
I noticed that I need to add this in order to not have soft gradients across polygons
polyop.applyuvwmap obj #face channel:99