Notifications
Clear all

[Closed] Pivot points >>> vertices >>> mesh object >>> surface follow

greetings all –

anyone heard of a script that can create a cloud of vertices according to an array of mesh objects?

What I need to do ideally is to take an array of objects that I’ve laboriously arranged in 3d space, and generate a Mesh object who’s vertices would correspond directly (position and normal orientaion) to the pivot point of each object in the array.

so basically generate an independent vertex for each object in the array according to pivotpoints, and then generate a trangulated mesh that links together all these free-floating points (according to their proximity to one another along one axis, i would guess, not being scripter myself)

finally I’d want to link each one of those objects in the array to its corresponding vertex and then deform that derived mesh without disturbing the geometry of any of those array objects ala SurfaceFollow feature. Think dragon skin!

any ideas?

big thnx
nikpfistar

2 Replies
 JHN

Well, I don’t think its all that easy…

I tried something, that only really works with 4 points…
It builds a mesh with a vert on all objects, but more objects and the way to extract faces from that is very difficult…

I tried


 -- Sort Function
 fn sortclose v1 v2 =
 (
 	dif = v1[2] - v2[2]
 	r = case of
 	(
 		(dif < 0.): -1
 		(dif > 0.): 1
 		default: 0
 	)
 )
 
 -- Get Closests objects in selection
 fn closest obj sel =
 (
 	distArr = for o in sel where o != obj collect #(o, (distance o obj))		-- Build array with node and distance arrays
 	qsort distArr sortclose																	-- Sort it
 	format "%
" distArr																		-- Debug
 	f1 = findItem sel obj 													   -- Get Node place in array to determine vert nr
 	f2 = findItem sel distArr[1][1]
 	f3 = findItem sel distArr[2][1]
 	point3 f1 f2 f3																				-- Return a point3 with face/vertice reference
 )
 
 
 -- Script
 s = selection as array									-- Get Selection
 objs = for o in s collect o.name						-- Make name array for sorting
 sort objs
 s = for o in objs collect (getNodeByname o)	-- Rebuild ordered obj array
 verts = for o in s collect o.pos						-- Get new Vert positions
 faces = #()												-- Collect faces in here
 for o in s do
 	append faces (closest o s)
 	
 mesh vertices:verts faces:faces						-- Build mesh object
 

If someone can take it further I’d be very interested.
-Johan

*edit: changed a small mistake in the script

 JHN

Some modifications… link all objects to their vertice


-- Sort Function
fn sortclose v1 v2 =
(
	dif = v1[2] - v2[2]
	r = case of
	(
		(dif < 0.): -1
		(dif > 0.): 1
		default: 0
	)
)

-- Get Closests objects in selection
fn closest obj sel =
(
	distArr = for o in sel where o != obj collect #(o, (distance o obj))		-- Build array with node and distance arrays
	qsort distArr sortclose																	-- Sort it
	format "%
" distArr																		-- Debug
	f1 = findItem sel obj																		-- Get Node place in array to determine vert nr
	f2 = findItem sel distArr[1][1]
	f3 = findItem sel distArr[2][1]
	point3 f1 f2 f3																				-- Return a point3 with face/vertice reference
)


-- Script
s = selection as array									-- Get Selection
objs = for o in s collect o.name						-- Make name array for sorting
sort objs
s = for o in objs collect (getNodeByname o)	-- Rebuild ordered obj array
verts = for o in s collect o.pos						-- Get new Vert positions
faces = #()												-- Collect faces in here
for o in s do
	append faces (closest o s)
	
m = mesh vertices:verts faces:faces						-- Build mesh object

c = 1
for o in s do
(
	s = position_script()
	script = "GetVert m " + c as string
	o.position.controller = s
	s.addNode "m" m
	s.script = script
	c += 1
)

/*
for obj in selection do obj.position.controller = position_XYZ()
*/