HDK : How to use the new Ramp?

   9772   17   2
User Avatar
Member
12 posts
Joined:
Offline
Hi guys,
anyone with an example of how to use the new Ramp (i'm interested in the float ones). I was able to use the old ramp, but while i was ale to put in the interface of my sop the new ramp (using the PRM_MULTITYPE_RAMP_FLOAT), i'm not able to access the values from the ramp spline. Also can we use now more than one ramp parameter in the same sop?
Thanks in advance.
User Avatar
Staff
2597 posts
Joined: July 2005
Offline
DoctorBuzz
Hi guys,
anyone with an example of how to use the new Ramp (i'm interested in the float ones). I was able to use the old ramp, but while i was ale to put in the interface of my sop the new ramp (using the PRM_MULTITYPE_RAMP_FLOAT), i'm not able to access the values from the ramp spline. Also can we use now more than one ramp parameter in the same sop?
Thanks in advance.

Try OP_Parameters::updateRampFromMultiParm(). You can then look up values from the ramp using the UT_Ramp. I believe you still have to pass in the 4 floats to getColor(). For a scalar ramp, I think you just pull out the first float.

There should be no problem using more than one ramp per SOP.
User Avatar
Member
12 posts
Joined:
Offline
Hi Mark,
thank you, i'll try your suggestions.
User Avatar
Member
380 posts
Joined: July 2005
Offline
How would you create PRM_MULTITYPE_RAMP_RGB (or FLT)
such that all the control parameters are initially hidden?

I cant seem to find a method that allows you to toggle the
controls button so its initially in the hide state rather than
the show state.

thanks.
User Avatar
Member
7760 posts
Joined: July 2005
Online
Untested:


PRM_SpareData rampSpareData(PRM_SpareData::getRampShowControlsDefaultToken(), “0”, NULL);


Then pass this object's address into the PRM_Template for the ramp.
User Avatar
Member
380 posts
Joined: July 2005
Offline
thanks Ed, just gave that a shot. no luck.

to recap..right under the multiparm (remove)
button there is a controls drop down. Is it
possible to programmatically invoke the code
attached to this ‘show/hide’ controls button?
User Avatar
Member
128 posts
Joined: July 2005
Offline
Sorry, may you provide code snippet for ramp-parameter declairng in template list?
Thank you!
Anything that flies
User Avatar
Member
12 posts
Joined:
Offline
Hi guys,
this worked for me:

static PRM_Name Ramp (“ramp”, “Ramp Values”);

static PRM_Template RampTemplates = {
PRM_Template (PRM_FLT_J, 1, &SpOffset, PRMzeroDefaults),
PRM_Template (PRM_FLT_J, 1, &SpValue, PRMzeroDefaults),
PRM_Template (PRM_INT, 1, &SpInterp, PRMtwoDefaults),
PRM_Template (),
};

PRM_Template
SOP_YourSOP::myTemplateList = {
PRM_Template (PRM_MULTITYPE_RAMP_FLT, theTwistTemplates, 1, &Ramp, PRMtwoDefaults),
PRM_Template (),
};

UT_Ramp myramp;

UT_Ramp*
SOP_YourSOP::getRamp (void)
{
PRM_Template *rampTemplate = PRMgetRampTemplate (“ramp”, PRM_MULTITYPE_RAMP_FLT, NULL);

if (myramp.getNodeCount () < 2)
{
myramp.addNode (0, UT_FRGBA (0, 0, 0, 1));
myramp.addNode (1, UT_FRGBA (1, 1, 1, 1));
}

return &myramp;
}

Then add the other node to the ramp and with the rampLookup method read their values.
Hope this can help you.
User Avatar
Member
128 posts
Joined: July 2005
Offline
Thank You VERY MUCH !
Anything that flies
User Avatar
Member
7760 posts
Joined: July 2005
Online
DoctorBuzz
PRM_Template
SOP_YourSOP::myTemplateList = {
PRM_Template (PRM_MULTITYPE_RAMP_FLT, theTwistTemplates, 1, &Ramp, PRMtwoDefaults),

I recommend NOT supplying theTwistTemplates, replacing it with NULL instead.
User Avatar
Member
128 posts
Joined: July 2005
Offline
Hm….

SpOffset, SpValue, SpInterp - what are they?
Anything that flies
User Avatar
Member
12 posts
Joined:
Offline
Hi JOEMI,
those are parameters.

static PRM_Name SpValue (“spvalue”, “Point value”);
static PRM_Name SpOffset (“spoffset”, “Point offset”);
static PRM_Name SpInterp (“spinterp”, “Point interpolation”);
static PRM_Name Ramp (“ramp”, “Ramp Values”);
User Avatar
Member
128 posts
Joined: July 2005
Offline
Thank you!
Anything that flies
User Avatar
Member
128 posts
Joined: July 2005
Offline
What for You declare
static PRM_Template RampTemplates ?

It is not in use at code privided.

And to fullness - may you describe how to USE this parameter at cooking of node' data?

Thank you!
Anything that flies
User Avatar
Member
128 posts
Joined: July 2005
Offline
Oh, I understood - getRamp-method returns all required structure to use ramp

Thank you!
Anything that flies
User Avatar
Member
128 posts
Joined: July 2005
Offline
Hm… I look at that method - I don't understand, do we really obtain ramp-data with its help. Can you insert clearness ?
Thank you!
Anything that flies
User Avatar
Member
7 posts
Joined: July 2005
Offline
Hate resurrecting a very old thread like this, but I'm struggling with this. I have something similar to the code above, and have tried other variations of it, but I keep getting a crash within updateRampFromMultiParm().

updateRampFromMultiParm( 0.0, getParm( “ramp” ), *r, NULL );

#1 0x00007f0422491e99 in PRM_Parm::getMultiType ()
from /packages/vendor/sidefx/linux_64/hfs10.0/dsolib/libHoudiniPRM.so
(gdb)
#2 0x00007f04225c1429 in OP_Parameters::updateRampFromMultiParm ()
from /packages/vendor/sidefx/linux_64/hfs10.0/dsolib/libHoudiniPRM.so

Just cannot figure out what's killing me here.
User Avatar
Member
7760 posts
Joined: July 2005
Online
Ensure that “ramp” is a valid parameter.
  • Quick Links