Notifications
Clear all

[Closed] how to get / set vertex color

what is the quickest way to get / set vertex color?
I used the meshop functions and found them very slow and got a big memory leak!
I had to add checks for free memory and call gc whenever it get’s close to zero.
It made my script even slower. I can post an example code on Sunday when I’ll be at work but I was wandering if anyone knows this problem and has a solution.
Thanks,
Matan.

6 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

i remember some problem of setting vertex color. but setMapVert without UNDO has to work well.

Thanks Denis!
I will be able to test it only on Sunday but I’m sure you know what you are talking about.

 lo1

In the past I’ve had good results with an unwrapUVW modifier, especially when there are large amounts of vertices that can be set at once (share the same color), but I can not say whether or not it’s faster/better than setMapVert.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it’s not faster. and it needs the unwrap modifier being open in the modifier panel.

setmapvert doesn’t take any time or memory:


  fn setVertexColor mesh: verts: color:#random channel:1 = 
  (
  	if mesh == unsupplied do mesh = snapshotasmesh selection[1]
  	if verts == unsupplied do verts = mesh.verts as bitarray
  		
  	setmapvert = meshop.setmapvert
  	for v in verts do setmapvert mesh channel v color
  	mesh
  )
  (
  	delete objects
  	sp = converttomesh (geosphere segments:64)
  
  	t1 = timestamp()
  	m1 = heapfree
  
  	setVertexColor mesh:sp color:red
  	format "verts:% time:% memory:%
" sp.numverts (timestamp() - t1) (m1 - heapfree)
  )
  

it might take some time to apply uvw mapping. but it has to be fast.

tested it and it works! no memory leak.
Thanks again Denis