Jump to content

Creating VEX libraries


Christian S

Recommended Posts

Hi,

I've tried to find information about this but it's hard to come by or maybe I'm not looking in the right spot. After all I'm an improvise programmer.

I want to create VEX libraries of functions and possibly structs (but let's start with functions). You know, functions I would use often and that I would not have to copy paste from AttribWrangle to AttribWrangle nodes.

These functions should be accessible using #include (I think). So here is a few questions to get me started...

1) How to structure the inside of the file? I don't want to compile them into an asset. For example if I put this straight into a .vfl file and compile it will it work or it needs a header?

// Function to Round at specified intervals
int roundToInterval(float val; int interval) {
    float new_val = ceil(val / interval) * interval;
    return int(new_val);
}

2) How to compile those files? Seriously I don't understand any of the compiler stuff... Do I even have to compile them??? What is a .h and do I need to use it? :(

3) Where to put the files? I want a common location that is not inside any of Houdini folder structure. Where do you specify that Houdini should look in an external folder for these extra functions? You know like adding HOUDINI_OTLSCAN_PATH to the houdini.env file. Is there a HOUDINI_VEX_PATH that I could use???

4) Finally, is using the files as simple as doing #include?

It would be nice that this was written somewhere because some of us don't have the programming background necessary to understand these easily.

Any help would be appreciated.

Thx!

Christian

Link to comment
Share on other sites

Hi

1. Just like that.
2. You don't have to compile these files. Vfl-files will be compiled at runtime so if your function is huge it can be a good solution to compile them first. To compile vfl-files you use "C:\Program Files\Side Effects Software\Houdini 15.5.535\bin\vcc.exe" More info int the doc's
3. The files has to be placed in the "HOUDINI_VEX_PATH". So either set up a custom path to store your files or make a "vex" folder with an "include" folder inside in your preference folder, and place your files there.
4. Yes.

-b

Edited by bonsak
  • Like 4
Link to comment
Share on other sites

Looks like there is a problem after all :(

Some of the default Houdini VEX libraries are missing when we define a HOUDINI_VEX_PATH.

The AttribFromMap node doesnt work for instance. Saying some files are missing (voplib.h I think). It can be fixed by including the path where these are located into the HOUDINI_VEX_PATH value but the Mantra render node doesnt work even with this fix.

I'll contact Side FX. For now the only solution is to put my .vfl files in vex\include in my document folder.

Still, thx for you help!

C

 

Link to comment
Share on other sites

Ok so here is what I ended up doing after writting to Side FX.

If you want to have files for you project outside the main Houdini folder structure, you need to add the path to the HOUDINI_PATH environment variable. the "&" character will tell Houdini to use the default path too.

In houdini.env I ended up just adding this like only (notice the & at the end):

HOUDINI_PATH = R:/PROJECTNAME/tools/dcc/houdini;&

Then, you project folder structure should copy the Houdini one. So:

houdini/otls      (for assets, otl or hda files)

houdini/vex      (for ??? VEX assets?)

houdini/vex/include       (for vex library)

Hope it helps.

Christian

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Resurrecting an old thread;

So I have this all working (made a documents/houdini16.0/vex/includes folder, put my stuff in foo.h, can call it from a wrangle), but stuck on a simple thing; how do I tell houdini to refresh the file?

At the moment it seems it only detects changes to my foo.h if I restart houdini, which seems a little unwieldy.

 

 

Link to comment
Share on other sites

Ah, spinynormal pointed to a fix in chat:

I thought toggling the bypass flag would be enough to trigger a refresh, but apparently not. Turns out you have to make a change to the code, and hit ctrl-enter, that'll force vex to recompile, and detect the updated header. Luckily that can be as simple as adding a space within a comment, so its quick to trigger (once you know how).

 

Link to comment
Share on other sites

  • 2 weeks later...

You can normally include in wrangles:

#include "mylib.h"

Assuming that $HIP/vex/include/mylib.h is where the lib is located now. If you are editing mylib.h and not the wrangle itself, Houdini doesn't track the file's changes, and you need to force compile manually. Adding spaces in wrangle is quickest and default way.

Using Force Recompile button on inside Attribute VOP also works. You could also promote it for convenience. If you see the ch("../vop_forcecompile") expression reference set on the original Attribute VOP's button (RMB / Expression / Edit Expression), everything should work.

vex_library.zip

Edited by f1480187
  • Like 1
  • Thanks 2
Link to comment
Share on other sites

F1 Thank you very much! Also thank you for the PRO wrangle in the file! Now I understand the system much more!

I thought that we need some header of the wrangle SOP, for it to be able to evaluate the button, I was disoriented.

Link to comment
Share on other sites

  • 2 years later...

Resurrecting again:

I was playing with VS Code the other day. There's a VEX extentsion for it (which seems to have not been updated in a while, but it works ok). There's one for Sublime Text which is more up to date and you can configure Sublime to compile your vfl.

Would anybody have a clue how to configure a task in VS Code for that?

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...