Example usage of GU_PolyExtrude code

   2097   4   0
User Avatar
Staff
4177 posts
Joined: Sept. 2007
Offline
Does anyone have an example GU_PolyExtrude snippet of code, showing how to use the extrusion? I can't find anything apart from the HDK doc page in the forum, via Google, or on OdForce.

I'm a pretty poor programmer, but it's fun to learn and experiment

Thanks!
I'm o.d.d.
User Avatar
Member
7737 posts
Joined: July 2005
Offline
eg.

GU_PolyExtrudeParms parms;
// Insert code here to set public data members of parms.
// … see the PolyExtrude SOP's helpcard
gdp->polyExtrude(parms);
User Avatar
Staff
4177 posts
Joined: Sept. 2007
Offline
Ah, thanks for that nudge, Edward! I've got my code in an inlinecpp module, and it extrudes to no where, but it works!

When setting up a GU_PolyExtrudeXformCallback, I see *user_data is required, but I don't understand what that's supposed to be. Could you provide another bit of help for that?

Thank you!
I'm o.d.d.
User Avatar
Member
7737 posts
Joined: July 2005
Offline
When your callback is invoked, user_data is set to the value of parms.myCBUserData, which is NULL by default. This is to provide a means for the caller of polyExtrude() to pass data back into their callback function (if desired).
User Avatar
Staff
4177 posts
Joined: Sept. 2007
Offline
Ah, I see! I've got it working now, very basic, but it's a good start! Thank you!

Here's the little snippet of code that worked for me, in case anyone else could use it. I have it wrapped inside of an inlinecpp module:

import inlinecpp, hou

test = inlinecpp.createLibrary("test",
     includes="""#include <GU/GU_Detail.h>
#include <UT/UT_Matrix4.h>
#include <GU/GU_PolyExtrude.h>
""", 
function_sources=[
"""void extrudeFaces(GU_Detail *gdp, UT_DMatrix4 *xform)
{
    GU_PolyExtrudeParms     parms;
    UT_Matrix4              mat(*xform); 
    parms.setLocalXform(mat, NULL);
    gdp->polyExtrude(parms);
}""",])

The hip file has everything inside, you just need to make sure you can compile HDK code, and you should see what's in the attached image.

Thanks edward!
Edited by goldleaf - June 9, 2017 15:06:45

Attachments:
inlinecpp_polyextrude.hipnc (58.8 KB)
polyExtrude.png (33.2 KB)

I'm o.d.d.
  • Quick Links