Jump to content

Set parameters on my node

Recommended Posts

How do I get the node I'm actually writing?


I haven't been able to find an example or anything specific in the docs about it.


I want to set the parameters I created in the node, I used OPgetDirector->getCwd() but I know thats wrong as it breaks everytime I jump into a vop network.


I tried to catch the OP_Node from the constructor but i can't get it to work.  Do I need to write a function that actually finds the created node? or is there a better way to set the parameters?    I also tried to getInstanceObject but then it crashes. 


As im testing I see that its the node->setFloat function that appears to be causing the crash, I guess my question should be how do i set the parameters?  Or how do i get the proper parameter indices?



Link to comment
Share on other sites

I think you need to explain more of what you're trying to do. If you want to provide some different default values for your node's parameters, just create some static PRM_Default objects and pass their pointers to the PRM_Template objects. The best thing to do probably is to skim the HDK samples for SOPs/OBJs. I don't see why you need to ever set parameter values upon node construction unless you're trying to do some backwards compatibility stuff. In which case, there are defined hooks where you should do this.

Link to comment
Share on other sites

Okay so basically I have a rig with hundreds of bones and I need to caluculate the change in rotation and translation over each timestep then pass that into a sop sovler.  Its a rig so my only choice is to build it within the OBJ context, then jump into sops pass the data to chops then pull it back (I couldn't pull the data at the object level and have it calculate in chops without using tx0 tx1 tx2 etc etc for each frame).


That all worked but I couldn't see how to properly calculate rotation as the OBJ_node gets parented into the rig without any parameter transform and I didn't see a simple way to get the world rotation matrix through sops and pass it to chops then back and then add it to the velocity then multiply point positions, plus at that point my null node was like 15 sops nodes long and my brain started to hurt. 


So I figured it would simpilfy my life immensly to have the OBJnode itself calculate what I need... So then to get the data out of the OBJ node my first thought was to just push it out through parameters so I could atleast check my math, its just the way I got accustomed to checking my work with python.  But using opgetDirector->getCwd() does work for simple tests and your definelty right there probably isnt ever a real need to set parameters like that, I just assumed it was simple and commonplace and I was just too dumb to see how to do it.


I guess a better question is can I build and write out .bclip data from a OBJNode? And better yet write one .bclip file from lets say hundreds of different nodes? Then read it through sops?  Or should I just write out some simple ascii file? 


edit to be more specific:   I'm trying to write out to a .clip or .bclip do I need clips and tracks? Am i writing to a track adding that to a clip then saving that out?  Or Should I be looking at buffers and ostreams?   

Edited by captain
Link to comment
Share on other sites

To write out a .clip (or binary .bclip) file, you can just create one using a CL_Clip, add your tracks and populate the tracks. Then call save("some_name.clip") on it when done. To check your math in the HDK, you can just use std::cerr. If you're gonna save something for this, I recommend using clips over regular ASCII since then you have the full CHOPs arsenal to manipulate and visualize it afterwards.


I don't know if it's the best idea to create custom OBJ_Node for this. You can also consider creating a custom SOP node for this since you need to do this in a solve solver anyhow. But if you do this, why bother writing out .clips when your SOP can just evaluate the obj transforms. Just be careful to evaluate all the *previous* frames first, before evaluating the current frame values. To get the world transform of an object, I recommend using OBJ_Node::getLocalToWorldTransform(), although the OP_Node::getWorldTransform() virtual can also be used (it calls the other one at the subclass level). To get the value a different time, just pass it an OP_Context object with a different time set into it.


Once in your custom SOP, you can easily find the objects you need. eg. OP_Node* node = OPgetDirector()->findNode("/obj/geo1");

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.

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