HDA class plan.
HDA class.
Date Created:Sunday March 11th, 2007 05:18 PM
Date Modified:Saturday August 02nd, 2008 04:17 PM
Derivative Project of HDA Class
|
Plan: * What is the difference between HDA and OTL?
* Operator Type Library(OTL) * What are some benefits of using HDA's?
* Ease of use Create: Basic light HDA
* Promoting parameters directly from a node. DEMO: Impact Chop Lights
* This HDA can look at any DOP network, and create lights based on impacts from RBD Objects. Create: Curve / Sweep HDA:
* Load MakeCurves.hip file. Jump into Curve_Example Geometry.
/obj/MyHDA/profile_curve/coords: `chs("../profile")`
/obj/MyHDA/base_curve/coords: `chs("../curve")`
* These will be hidden parameters in the HDA.
* The following script will make an array out of all the points in a given SOP.
set OP = $arg1/curve
set zed=""
for i = 0 to `npoints("$OP")-1`
set zed = $zed `point($OP,$i,P,0)`,`point($OP,$i,P,1)`,`point($OP,$i,P,2)`
end
opparm $arg1 curve ("$zed")
set OP = $arg1/profile
set zed=""
for i = 0 to `npoints("$OP")-1`
set zed = $zed `point($OP,$i,P,0)`,`point($OP,$i,P,1)`,`point($OP,$i,P,2)`
end
opparm $arg1 profile ("$zed")
* Create a reload button, with the following callback for recooking when not changing inputs:
source opdef:.?OnInputChanged `oppwf()`
* Promote switch, resample, and carve controls. DEMO: City HDA
* This HDA uses arrays to generate curves, and procedurally generates geometry.
# referencing a script from an HDA:
source opdef:Object/HDA_Name?scriptname
# referencing a script from within and HDA:
source opdef:.?scriptname
CREATE: Dynamic dropdown menu listing mantra nodes with a menu script.
* This dropdown menu will allow us to control any mantra nodes dynamically.
# Basic menu script to understand using two values:
# One value for Token, and the second value for Label:
echo 1 on
echo 0 off
# Menu script using foreach():
foreach x(`("object light shadow")`)
echo $x $x
end
# Lists all nodes of type "mantra", within the path "/out"
foreach x(`run("opfind -p /out -t mantra")`)
echo $x `strreplace($x,"/out/","")`
end
* Create a string parameter, change the name to "parameter", Label to "Select Parameter:"
# Lists all the parameters of the selected node:
set OP = `chs("node")`
foreach z(`run("opparm -l $OP *")`)
echo $z $z
end
# This is used as a callback on the parameter string to "get" the values:
opparm `oppwf()` value ("`chsraw(chs("node") + "/" + chs("parameter"))`")
# This is used as callback on the value string to "give" the values.
opparm `chs("node")` `chs("parameter")` ("`chsraw("value")`")
* The difference between `chs()` and `chsraw()`:
echo `chs("mantra1/picture")`
/home/prisms/test.jpg
echo `chsraw("mantra1/picture")`
$HOME/test.jpg
source opdef:.?`chs("button")`
* Disabling parameters
# if parm is 0 or parm1 is 0 and parm2 is 1
{ parm 0 } { parm1 0 parm2 1 }
DEMO: Generate Instance HDA
* This HDA allows a user to use instancing with objects, shaders, lights and shadows. DEMO: Mantra Manager HDA
* This HDA allows a user to manage all mantra nodes in a project. * Adding contents to HDAs and saving contents to disk from HDAs.
# this defines the table/label of the current otl
set table = `optypeinfo(oppwf(),"T")`
set label = `optype(oppwf())`
set OTL = ${table}/${label}
# this deletes a section named array
otcontentdelete $OTL array
otcontentdelete Object/MyHDA array
# this adds a section named array from $TEMP/$file
otcontentadd $OTL array $TEMP/$file
otcontentadd Object/MyHDA array $TEMP/array.txt
# this does a loop an all the content in an HDA and dumps it to disk.
foreach content(`run("otcontentls $OTL")`)
otcontentsave -o $TEMP/$content $OTL $content
end
# this would make a file executable and run it, if you dump a shell script.
unix chmod + x $file
unix ./$file
# pass an argument into a script
unix ./$file $arg1
* Use opscript, it will help you!
# this echos the commands necessary to re-create the operator.
opscript nodename
# if node contains networks, recursively applies to the entire operator hierarchy.
opscript -r nodename
Other Example HDAs *Globe, and 3d Text |
