Jump to content

Custom VOP SHOP context in HDK


Recommended Posts

Hi all, 

 

This is a double post from the official forum because I got no response after one week there.

 

I want to make a custom SHOP in HDK. 
The SHOP should be able to accept a series of custom VOP (limited in this context) and retrieve the information from the network of children VOP.

Then the retrieved information could be acquired by SOHO program called by custom ROP.

 

In Short, it is like "Material Shader Builder" in Mantra. 

Is there any example or instruction on this topic? 
I have searched HDK and only find headers about SHOP, there are so many virtual function not fully explained inside. I really need some advises. 

Thanks.

Link to comment
Share on other sites

Hi all,
 

Let me start from scratch.
I made a simplest SHOP node.
 

-------- code start ---------
In header file test.h
 
    class My_Surface_Shader_Builder : public SHOP_Node
    {
    public:
 
        static OP_Node *myConstructor(
                        OP_Network *net,
                        const char *name,
                        OP_Operator *entry);
 
        static PRM_Template myTemplateList[];
 
        virtual OP_ERROR cookMe(OP_Context &context);
 
    protected:
        My_Surface_Shader_Builder(
            OP_Network *net,
            const char *name,
            OP_Operator *entry,
            SHOP_TYPE shop_type);
        
        virtual ~My_Surface_Shader_Builder();
 
    };
 
in test.C file
 
void
newShopOperator(OP_OperatorTable *table)
{
    cout<<"adding My_Surface_Shader_Builder to operator table\n";
 
    OP_Operator *op;
 
    op = new OP_Operator(
"my_vopsurface", // internal name
"My Surface Shader Builder", // UI label
My_Surface_Shader_Builder::myConstructor, // class factory
My_Surface_Shader_Builder::myTemplateList, // parm definitions
0, 0);
 
    table->addOperator(op);
 
    cout<<"My_Surface_Shader_Builder added\n";
}
 
 
 
 
// SHOP Implementation
OP_Node *
My_Surface_Shader_Builder::myConstructor(
OP_Network *net, const char *name, OP_Operator *entry)
{
    cout<<"In myConstructor of SHOP\n";
 
    return new My_Surface_Shader_Builder(net, name, entry, SHOP_SURFACE);
}
 
PRM_Template
My_Surface_Shader_Builder::myTemplateList[] = 
{
    PRM_Template() // List terminator
};
 
My_Surface_Shader_Builder::My_Surface_Shader_Builder(
OP_Network *net, const char *name, OP_Operator *entry, SHOP_TYPE shader_type)
    : SHOP_Node(net, name, entry, shader_type)
{
    myRenderMask = "*";
    cout<<"Constructing SHOP_Cycles_Surface_Shader_Builder\n";
 
}
 
My_Surface_Shader_Builder::~My_Surface_Shader_Builder()
{
    cout<<"In Destructor of SHOP\n";
}
 
OP_ERROR
My_Surface_Shader_Builder::cookMe(OP_Context &context)
{
    // Do evaluation of the custom VOP network here.
    return error();
}
 

-------- code end ---------

The code could be compiled successfully.

As usual, I put it into my dso path and start houdini, then I got messages below:

 

-------- message start ---------

The Houdini 12.5.469 environment has been initialized.

adding My_Surface_Shader_Builder to operator table <---- this means the registration of the SHOP begun
My_Surface_Shader_Builder added <----- this means the registration of the SHOP is done
 
Could not create the default HDA shelf tool for 'my_vopsurface':
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
  File "/opt/Houdini/hfs12.5.469/houdini/python2.6libs/defaulttools.py", line 253, in createDefaultHDATool
    keywords)
  File "/opt/Houdini/hfs12.5.469/houdini/python2.6libs/defaulttools.py", line 151, in addShopNodeTypeLocationsAndKeywords
    rendermask = nodetype.renderMask()
  File "/opt/Houdini/hfs12.5.469/houdini/python2.6libs/hou.py", line 29614, in renderMask
    return _hou.ShopNodeType_renderMask(*args)
ObjectWasDeleted: Attempt to access an object that no longer exists in Houdini.
 
-------- message end ---------
 
Anyone know how to solve this?
I don't even know where and how to give a right render mask?
The constructor of my SHOP not executed yet ......  
Thanks.
 
ps.
you can compile the attached file and test it. Just remove the .txt extension and execute
hcustom test.C

test.C.txt

test.h.txt

Edited by pyrochlore
Link to comment
Share on other sites

I think your installShopOperator might need to be more like this (untested):

void
newShopOperator(OP_OperatorTable *table)
{
    cout<<"adding My_Surface_Shader_Builder to operator table\n";
 
    SHOP_Operator *op;
 
    op = new SHOP_Operator(
"my_vopsurface", // internal name
"My Surface Shader Builder", // UI label
My_Surface_Shader_Builder::myConstructor, // class factory
My_Surface_Shader_Builder::myTemplateList, // parm definitions
0, 0);
 
    table->addOperator(op);
 
    SHOP_OperatorInfo *info = (SHOP_OperatorInfo *)shop->getOpSpecificData();
    info->setShaderType(SHOP_SURFACE);
    info->setRenderMask("*");

    cout<<"My_Surface_Shader_Builder added\n";
}
Link to comment
Share on other sites

  • 3 weeks later...
Guest mantragora

You can also set it in the constructor:

SHOP_Template::SHOP_Template(OP_Network* net, const char* name, OP_Operator* entry, SHOP_TYPE shader_type)
: SHOP_Node(net, name, entry, shader_type)
{
    entry->setIconName(SHOP_TEMPLATE_ICON_NAME);

    auto info = (SHOP_OperatorInfo *)entry->getOpSpecificData();
    info->setShaderType(SHOP_SURFACE);
    info->setRenderMask("*");
}

Thanks to this, if you register more than one SHOP in newShopOperator(), you will have cleaner and simpler code there. Why to put operator specific code in some outside function?

 

BTW: You don't need to specify SHOP_SURFACE there because you already specify it in you static creator method(in your case it's called "myConstructor") when you pass it to the constructor.

auto
SHOP_Template::CreateSHOP(OP_Network* net, const char* name, OP_Operator* entry)
-> OP_Node*
{ return new SHOP_Template(net, name, entry, SHOP_SURFACE); }
Edited by mantragora
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...