HDK : Multi output

   160   1   0
User Avatar
Member
55 posts
Joined: Dec. 2010
Offline
Hi everyone. I'm trying to export something from the second output but with no luck.

I found a sample file "SOP_dualStar" that seems to be having what I need but I can't figure out the logic completely.

In a header file we should have
GU_DetailHandle cookMySopOutput(
OP_Context &context,
int outputidx,
SOP_Node *interest
) override;

It also has void buildStar(GU_Detail *dst,
OP_Context &context);

As far as I understand the logic happens inside the

cookMySop that runs "buildStar" logic

But then what is happening in cookMySopOutput ?

GU_DetailHandle result;
GU_Detail *dst = new GU_Detail();

result.allocateAndSet(dst);

buildStar(dst, context);

Is there any chance someone could explain to me how that works ?

I need to do some logic on input geo, create an attribute and write it for the first output, for the second output I want to create some points based on array that has been created when doing logic for the first output.

I kind of made it working at some point but looks like array was empty.
User Avatar
Member
55 posts
Joined: Dec. 2010
Offline
So I made it working. Not sure that is the right way though.

In a header file we declare

GU_DetailHandle cookMySopOutput(OP_Context& context, int outputidx, SOP_Node* interests) override;

Also we declare some struct to use later for the second output

struct point_data
{
UT_Vector3 pos;
fpreal total_length;
};
private:
UT_Array<point_data> point_data;

All logic happens in cookMySop and I keep values in point_data variable.

Then in

GU_DetailHandle SOP_groom_segmentation_data::cookMySopOutput(OP_Context& context, int outputidx, SOP_Node* interests)
{
GU_DetailHandle handle;
...

if (outputidx == 1)
{

some logic here where using variable from main cook.

}

Is it okay to use if (outputidx == 1) ? And is it safe to keep and use point_data variable in this case ? Can someone confirm ?
Is this the legit way of doing it in general ?
  • Quick Links