Notifications
Clear all

[Closed] Collecting Vertices controlled by a bone

How do you collect all the vertices that a bone controls into an array? I looked at all skinops options and none fits the bill.

10 Replies

You usually do it on the ‘skin’ modifier, meaning that you get the skin modifier, get the bones from the list there, then loop through each vert that that bone affects.

Yeah i think you need to get the total verts then loop through them and using the getVertInfluences skinops function (theres one something like that if memory serves), you can then test if this vert is affected by your bone.

Hey take a look at this script I posted a while back, you can quickly modify it to return an array of the verts. It already does that, but it might not be in the exact way that you want.

Look at the selectedVerts array.

http://felipenogueira3d.com/node/45

cheers,

Thanks guys. I will try that script out Felipe . It looks like what I want. One other thing – what’s the quickest way to determine what verts lie near a given point, rather than looping through every vert in the mesh, is there an algorithim which makes it a quick process? Thanks in advance.

PS: I’m trying to write a script that can automatically exclude verts from lip skin envelopes in case you’re wondering or in case such a script already exists someone knows of

i can’t say it’s the quickest algorithm but i posted some on this forum… the algorithm uses 2D or 3D grid-buffer

Are you talking about this Denis?:


try destroydialog VertexDistance catch ()
global testSettings = if testSettings == undefined then #(1.0,10.,32) else testSettings
rollout VertexDistance "Vertex Distance"
( 
 group "Create: "
 (
  button create "Create Test Mesh" width:120 align:#left across:3 
  spinner radius "Radius: " range:[0,1e9,testSettings[2]] scale:0.01 fieldwidth:60 align:#right offset:[-12,3]  
  spinner segments "Segments: " range:[1,1e9,testSettings[3]] scale:1 type:#integer fieldwidth:60 align:#right offset:[0,3] 
 )
 group "Vertices: "
 (
  spinner threshold "Distance: " range:[0,1e9,testSettings[1]] scale:0.001 fieldwidth:60 align:#left offset:[2,0] across:3 
  edittext amount "Amount:" fieldwidth:70 readonly:on align:#right offset:[-12,0]
  edittext selected "Selected:" fieldwidth:70 readonly:on align:#right offset:[0,0]
 )
 group "Algorithms: "
 (
  button bt1 "by Thorn444" width:120 align:#left across:3 
  edittext tt1 "Execution Time:" fieldwidth:70 readonly:on align:#right offset:[-12,2]
  edittext mm1 "Memory Leak:" fieldwidth:70 readonly:on align:#right offset:[0,2] 
  button bt2 "by denisT" width:120 align:#left across:3 
  edittext tt2 "Execution Time:" fieldwidth:70 readonly:on align:#right offset:[-12,2] 
  edittext mm2 "Memory Leak:" fieldwidth:70 readonly:on align:#right offset:[0,2]
 )
 
 on bt1 pressed do if iskindof (obj = selection[1]) Editable_Mesh do with undo off
 (
  sfc = testSettings[1]
  a = 1
  c = 2
  t1 = timestamp()
  h1 = heapfree
  vertlist = #{}
  VertSet = #()
  vertCount = meshop.getNumVerts $
  vertlist = obj.verts as bitarray
  for i =2 to vertcount while not keyboard.escpressed do 
  (
   for j=a to vertcount-1 do 
   (
	b = meshop.minVertexDistanceFrom $ a c
	if b < sfc then (appendIfUnique vertSet a) 
	if b < sfc then (appendIfUnique vertSet c) 
	c = c + 1
   )
   c = i + 1
   a = a +1
  )
  tt1.text = (timestamp() - t1) as string
  mm1.text = ((h1 - heapfree) as integer) as string
  obj.selectedverts = vertSet
  selected.text = obj.selectedverts.count as string
  subobjectlevel = 1
  gc light:on
 )
 on bt2 pressed do if iskindof (obj = selection[1]) Editable_Mesh do with undo off
 (
  fn sortByZ v1 v2 = if v1[2].z < v2[2].z then -1 else if v1[2].z > v2[2].z then 1 else 0
   
  dist = testSettings[1]
  
  t1 = timestamp()
  h1 = heapfree
  verts = obj.verts as bitarray
  
  vlist = for v in verts collect #(v, getvert obj v)
  qsort vlist sortByZ
  klist = deepcopy vlist
  
  list = #{}
  
  for i=1 to vlist.count while not keyboard.escpressed do 
  (
   v = vlist[i]
   out = off
   for j=i+1 to klist.count while not out where (k = klist[j]) != undefined do
   (
	if (distance v[2] k[2]) < dist do 
	(
	 append list v[1]
	 append list k[1]
	 klist[j] = undefined
	)
	out = abs (v[2].z - k[2].z) > dist
   )
  )
  tt2.text = (timestamp() - t1) as string
  mm2.text = ((h1 - heapfree) as integer) as string
  obj.selectedverts = list
  selected.text = obj.selectedverts.count as string
  setselectionlevel obj #vertex
  gc light:on
 )
 
 on threshold changed value do testSettings[1] = value
 on radius changed value do testSettings[2] = value
 on segments changed value do testSettings[3] = value
  
 on create pressed do undo "Create Test" on
 (
  suspendEditing()
  if objects.count > 0 do delete objects
  converttomesh (obj = sphere name:"findVerts" radius:testSettings[2] segs:testSettings[3] isSelected:on)
  if getCommandPanelTaskMode() != #modify do setCommandPanelTaskMode mode:#modify
  setselectionlevel obj #vertex
  amount.text = obj.numverts as string
  selected.text = obj.selectedverts.count as string
  resumeEditing()
 )
 on VertexDistance open do if iskindof (obj = selection[1]) Editable_Mesh do 
 (
  amount.text = obj.numverts as string
  selected.text = obj.selectedverts.count as string
 )
)
createdialog VertexDistance width:480 height:200

check this one
http://forums.cgsociety.org/showpost.php?p=7032076&postcount=23

i couldn’t find the exact right example about vertex distance. probably it’s in the forum’s archive already.
i will search in my archive and try to find there

Great. Looks promising. Thanks for your time Denis.

Any luck with the archive Dennis?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0