Get Grow function

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  03 March 2013
Get Grow function

Hi everyone,

I'm currently working on a script, where each vertex of a selected object are running in a for loop to calculate their Normal vector. I would like to get the surrounding vertex to calculate the distance between the vertex of the loop and the surrounding ( it's the easiest way i found to get the polygon density locally).

Here is a piece of the script :

 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 objetSourcePoly = $ 
 objetSource = snapshotasmesh$ 
 model = #($Brush_01,$Brush_02,$Brush_03,$Brush_04)
 for vertIndex = 1 to objetSource.numverts do
 	vertFaces = meshop.getFacesUsingVert objetSource vertIndex 
 	vertNorm = point3 0 0 0
 	for face = 1 to vertFaces.count do
 		if vertFaces[face] then 
 			faceNormal = getFaceNormal objetSource face
 			vertNorm = vertNorm + faceNormal
 	vertNorm = normalize vertNorm
 	r = random 1 (model.count)
 	localModel = instance model[r]
 	localModel.dir = vertNorm 
 	in coordsys local rotate localModel (angleaxis -90 [0,1,0]) 
 	localModel.pos = getVert objetSource vertIndex
 	 -- I need to select the vertex "vertIndex" in the Poly object
 	VertPoly = polyop.setVertSelection objetSourcePoly vertIndex
 	objetSourcePoly.EditablePoly.SetSelection #Vertex #{vertIndex}

       -- Then grow the selection
       VertAround = objetSourcePoly.EditablePoly.GrowSelection ()
 	-- Finaly delete from selection the "VertIndex" to get only the surrounding vertex
       AroundVertPoly = AroundVertPoly - VertPoly
   -- After that i need a for loop for each surrounding vertex to calculate distance between each of them and the "vertIndex"

I hope you'll be able to help me, i think i just missed an easy part to call the Grow button in the command panel, or an other function

Thank you
  03 March 2013
I found an other way to do it, slower but it works

vertDistanceArray = #() --create an empty array for distance

	for i = 1 to objetSource.numVerts do
		vertDistanceArray[i] = distance (getVert objetSource i) (getVert objetSource vertIndex)

--till here, the distance of all the vertices has been stored in the array.

vertDistanceArray = sort vertDistanceArray

-- Calculate the medium lenght
VertDistance = vertDistanceArray[2] + vertDistanceArray[3] + vertDistanceArray[4] + vertDistanceArray[5] + vertDistanceArray[6]
VertMoy = VertDistance / 5 
  04 April 2013
everything is much easier... because you already have a snapshot mesh (i will call it mesh in my sample) the neighbors of a vertex (v) are:
by edges:
(meshop.getvertsusingedge mesh (meshop.getedgesusingvert mesh v)) - #{v}

by faces:
(meshop.getvertsusingface mesh (meshop.getfacesusingvert mesh v)) - #{v}

ps. polyop.getfacenormal is much faster then getfacenormal (mesh method)

Last edited by denisT : 04 April 2013 at 10:32 AM.
  04 April 2013
btw... who can show the fastest way how to get all neighbors of every mesh vertex?
  04 April 2013
Thank you, i was sure there was an other way to write it faster. Testing it
  04 April 2013
Originally Posted by GreySize: Thank you, i was sure there was an other way to write it faster. Testing it

if you need to compute all vertices the way that i showed above is not fastest.
  04 April 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 06:40 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.