VOP structs functions

   1744   2   1
User Avatar
Member
161 posts
Joined: May 2015
Offline
Greetings everyone,

I am looking at the “VOP structs” documentation [www.sidefx.com] and at the end of the page, they specify that :
The full format is defined in a “JSON schema” file in $HFS/houdini/vop/TypeDefinitions.json.schema.

Looking at this file, I see that there is a section for “definitionCode”.

Looking at the “VEX structured type” documentation [www.sidefx.com] I can also see that it is possible to add functions to vex structs.

So my question is, what is the relation between VOP structs and VEX structs. Can I define vex struct functions in a VOP struct that can be used in my vex code in VOPs?

I have tried adding a vex function in the “definitionCode”, but it does not get generated when I look at the VEX code generated by my VOP Network.

How could I achieve that?

Thanks in advance for any clues!
Edited by cval - Nov. 21, 2018 17:26:02
User Avatar
Staff
1448 posts
Joined: July 2005
Offline
Whatever you put in “definitionCode” should show up in the code generated by the VOP Network. Perhaps no Struct VOP is part of the generated code? Ie, the output of a Struct VOP should eventually lead to an exported output variable from the shader.

When the VOP type definition (in .json file) does not have a “definitionCode”, the Struct VOP generates a VEX struct definition automatically, based on the data members in the VOP struct type. But if there is a “definitionCode”, the Struct VOP just uses that string verbatim, in the outer code section (ie before the main shader function) of the generated VEX code for the VOP network.

So if “definitionCode” is “FOO”, then “FOO” should show up in there.

And if “definitionCode” is “struct FOO { float foo; float get() {return foo;}};”, then that full definition should show up in the generated code too.

Usually, however, users define the VEX “struct FOO” in some .h file, and then “definitionCode” just has “#include foo.h”. The advantage is that other .vfl and .h source files can also include that header and reuse the VEX struct definition.
User Avatar
Member
161 posts
Joined: May 2015
Offline
Thank you rafal!

By reading your reply I could understand my mistake. I was nesting the “definitionCode” item under the “methods” item in the json file. I thought it was a definitionCode per method, but it is for the whole struct!.

All right! Thank you! This helps me a lot
  • Quick Links