Jump to content


Nearest Connected Neighbors


  • Please log in to reply
17 replies to this topic

#13 Macha

Macha

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,654 posts
  • Joined: 23-July 08
  • Location:The Small Big P
  • Name:Marc ♥

Posted 07 January 2010 - 05:39 PM

Yippi-oh, tatara! It seems to work! Thank you everybody.

I feel so clever now, thanks to your superbrains!

It's like Christmas all over again. The door to a new Houdini-world has opened.  :lol:

Here is an example:

    Point: [Neighbors]

      0:   [1, 3]
      1:   [2, 4, 0]
      2:   [4, 1]
      3:   [4, 5, 0]
      4:   [7, 6, 1, 2, 3]
      5:   [3, 6]
      6:   [4, 7, 5]
      7:   [6, 4]

Attached Files


My Vimeo

LinkedIn

improve side effects - use haskell


#14 Macha

Macha

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,654 posts
  • Joined: 23-July 08
  • Location:The Small Big P
  • Name:Marc ♥

Posted 08 January 2010 - 12:31 AM

Now the yellow numbers show the neighbors of the blue ones.

Attached Files


My Vimeo

LinkedIn

improve side effects - use haskell


#15 Symbolic

Symbolic

    Illusionist

  • Members
  • PipPipPip
  • 486 posts
  • Joined: 20-October 06
  • Location:London
  • Name:Orm Embar

Posted 16 January 2010 - 05:11 PM

Hi Macha,
Could you please post your latest Python script.

Thanks.
Live life in chunks!

#16 sibarrick

sibarrick

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,981 posts
  • Joined: 29-September 03

Posted 17 January 2010 - 03:28 AM

View PostMacha, on 06 January 2010 - 11:54 PM, said:

Hoho! I found the mistake! (vertex number != point number for one primitive)

I can now find all neighbors. Wohohoo! Now just need to find a way to put them properly into the dictionary!

They would be if you first add a sort sop and sort by vertex number, but by default there is no requirement for the 2 to match.
"The trick is finding just the right hammer for every screw"

#17 hyperforce

hyperforce

    Peon

  • Members
  • Pip
  • 34 posts
  • Joined: 07-November 10
  • Location:Heeze, Netherlands
  • Name:Erwin Heyms

Posted 10 April 2012 - 11:46 PM

Its also possible to do it with a vop-sop inside a foreach node.
It took me a while to figure it out but since I know nothing about python or how to work with VEX script, this is my solution.


step 1 - setting up the base:
Create a for-each node set to "Each Number" mode with an 0 & npoints("../previous node")-1 expression in the first two number range fields.
Turn off merge results to set the for-each node into a feedback loop.
Feed your geometry into the foreach sop.

step 2 - inside the foreach node:
Create a group node with point pattern: `stamp("../","FORVALUE",0)` to isolate the current point to check.
After this create a vopsop node and feed the groups output into its first input.

step 3 - inside the vop sop:
Create a for-loop node and a neighbourcount node.
Connect Global1's Point number to the neighbourcount nodes input slot as well as to the "Next Input" slot of the for_loop node.
Connect the neighbourcount1's output to the for_loop's "End Value" input slot.

step 4 - inside the for_loop vop
Create a add_point_to_group node and a neighbour node. (not neighbourcount like before)
Connect the subinput1's "initial value" output to the Neighbour node's "neighbour number" input.
Connect the subinput1's "point number" output to the Neighbour node's "point number" input.
Connect the Neighbour node's output to the add_point_to_group's "point number" input.

Inside the add_point_to_group node, promote the Group string input value to become a parameter.

Step 5 - back to the for_each node layer
select the vopsop and in its new Group_Name attribute, add: PG_`stamp("../","FORVALUE",0)`

The result:

For each point number you will now get a group called PG_# (with # the points number)
Each group will hold this points neighbouring point numbers.

Edited by hyperforce, 10 April 2012 - 11:55 PM.

My Procedural FPS level generator:
http://forums.odforc...vel-generation/

Email: erwinheyms@gmail.com

#18 glassman3d

glassman3d

    Peon

  • Members
  • Pip
  • 12 posts
  • Joined: 20-August 10
  • Location:London
  • Name:Sam Swift-Glasman

Posted 26 April 2012 - 06:30 AM

View PostMacha, on 06 January 2010 - 11:54 PM, said:

Hoho! I found the mistake! (vertex number != point number for one primitive)

I can now find all neighbors. Wohohoo! Now just need to find a way to put them properly into the dictionary!

if I may throw my two cents in here
I have found it always much quicker to iterate points and prims in the geometry object using the
iterpoints and iterprims functions. they create a generator rather than storing a list into memory
cheers




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users