adding a custom vex function to houdini

   1546   5   1
User Avatar
Member
98 posts
Joined: July 2005
Offline
I'd like to add a new generically accessible custom function that I've been including in attributewrangle expressions.
This new function needs to be accessible in transform channel expressions as well.
Is there a way to do this without creating a plugin?

As is described here:

https://www.sidefx.com/docs/hdk/_h_d_k__intro__creating_plugins.html [www.sidefx.com]
User Avatar
Member
7801 posts
Joined: Sept. 2011
Offline
WillA
Is there a way to do this without creating a plugin?

I'm gonna guess no
User Avatar
Member
98 posts
Joined: July 2005
Offline
Yeah, I've started exploring creating a plugin so I can share a custom sin wave cycle function I'm working on.
It's basically a sin wave but can flatten the peaks.

Here is the python code.
I will add the VEX code to this post which can be used in an attributewrangle sop.


import numpy as np

def sinflatten(t, amplitude, frequency, flattenamount):
bsquared = flattenamount * flattenamount
sinval = np.sin(2 * np.pi * (t/frequency))
sinvalsquared = sinval * sinval
sqrtval = np.sqrt( (1.0 + bsquared) / (1.0 + bsquared * sinvalsquared) )
yval = sqrtval * sinval
return amplitude * yval

t = np.linspace(0, 60, 600)

init_amplitude = 5
init_frequency = 10.0
init_flattenamount = 0


sinflatten(t, init_amplitude, init_frequency, init_flattenamount)

Attachments:
out3_crop.gif (2.8 MB)

User Avatar
Member
8584 posts
Joined: July 2007
Online
what's wrong with #include?
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
98 posts
Joined: July 2005
Offline
tamte
what's wrong with #include?

Well, the text file referred to by #include would have to be placed in a convenient path location.
Also, I don't think #include can be used in channel expressions for transform sops.
User Avatar
Member
8584 posts
Joined: July 2007
Online
WillA
Well, the text file referred to by #include would have to be placed in a convenient path location.
So would your compiled plugin
However it's quite straightforward to make a package containing all the files for your extension, so as long as your .h files are in vex/include folder of your package you will be fine

WillA
Also, I don't think #include can be used in channel expressions for transform sops.
No, but they are also not VEX, so may need to be treated as a separate codepath anyway
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links