Jump to content

Getting Parameters On Grid Input To A Custom Sop


Recommended Posts

this is my first post ... so here i go!!

How do I get the resolution ( Rows, Columns) as well as the Size of a Grid SOP

from a custom SOP that has the Grid connected to it as its input?

i hope that made sense!!

jeff

Link to comment
Share on other sites

If I understand you correctly you would use opinputpath to get the full path to the node plugged into whichever input and then wrap a channel reference around it to get the value you want. For example if your grid was plugged into the first input you could get the four values you want with these expressions:

ch(opinputpath(".",0)/rows)

ch(opinputpath(".",0)/cols)

ch(opinputpath(".",0)/sizex)

ch(opinputpath(".",0)/sizey)

Inputs are numbered from 0 so if your grid is plugged into the second input you would use

ch(opinputpath(".",1)/rows)

:

etc

- john

Link to comment
Share on other sites

If I understand you correctly you would use opinputpath to get the full path to the node plugged into whichever input and then wrap a channel reference around it to get the value you want.  For example if your grid was plugged into the first input you could get the four values you want with these expressions:

    ch(opinputpath(".",0)/rows)

    ch(opinputpath(".",0)/cols)

    ch(opinputpath(".",0)/sizex)

    ch(opinputpath(".",0)/sizey)

Inputs are numbered from 0 so if your grid is plugged into the second input you would use

    ch(opinputpath(".",1)/rows)

          :

          etc

- john

18522[/snapback]

Sorry... i should have been more specfic. I'm looking to exactly that, however, from within the HDK!

Right now my setup is such that i have the parameters duplicated in my custom SOP, and your solution works great to reference the parameters on my custom SOP.

What would be nice is to eliminate those duplicated parameters from my custom SOP and just get at them directly... and thats where I'm stuck!!

Link to comment
Share on other sites

Sorry... i should have been more specfic. I'm looking to exactly that, however, from within the HDK!

18525[/snapback]

After you do a duplicateSource() in cookMySop(), the gdp pointer will contain the geometry from your input (whichever one you specify in duplicateSource()). From your gdp, you have several ways to get at this information. If the input Grid is a mesh type (e.g. mesh, NURBS surface, etc...) you're in luck, you can call GEO_Hull::getNumRows(), getNumCols() on each of the mesh primitives (if the direct input is a Grid SOP, then there'll only be one). Now if your Grid is generating polygons, you have a harder problem. Basically, the polygons are stored as individuals, each referencing several points, which are stored in a linear array. So the information about whether or not they are arranged in a grid pattern (and how many grids they form) is not immediately available. The GQ library offers a winged-edge type structure which can be used to determine such things as connectivity and order, but my guess is that is overkill.

Hope that helps.

George.

Link to comment
Share on other sites

Thanks George... that certainly did the trick!!

18545[/snapback]

hmm... well... i'm getting the rows and cols just fine.

but my custom SOP needs to know the Size( sizex, sizey) of the Grid as well.

How do I go about getting at those values?

jeff

Link to comment
Share on other sites

hmm... well... i'm getting the rows and cols just fine.

but my custom SOP needs to know the Size( sizex, sizey)  of the Grid as well.

How do I go about getting at those values?

jeff

18547[/snapback]

You're probably going to have to climb the tree and extract the parameters, probably. I'll see if I can find some code from a SOP of ours that does it.

Link to comment
Share on other sites

...

but my custom SOP needs to know the Size( sizex, sizey)  of the Grid as well.

How do I go about getting at those values?

18547[/snapback]

On your GEO_Hull primitive, you can call prim->getBBox(&bbox) to get the bounding box of the grid. From there you should be able to figure out sizex and sizey.

Take care,

George.

Link to comment
Share on other sites

  • 2 months later...
On your GEO_Hull primitive, you can call prim->getBBox(&bbox) to get the bounding box of the grid.  From there you should be able to figure out sizex and sizey.

Take care,

George.

18562[/snapback]

sorry the late reply, i just wanted to thank you for the solution

so thanks!! :D

jeff

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...