Jump to content

PRM_TOGGLE help


Recommended Posts

Hi! :)

Sorry if this is a basic question, I am very new to HDK and Houdini itself, I am starting to get the taste of it but I have some questions:

I want to create a custom SOP with a "built-in" switcher, here is my code:

 

//I tried to copy from the euclid/SOP_Euclid example, I have this func in my header(this should ask houdini if the checkbox is ticked):

bool SWITCH(fpreal t) { return (bool)evalInt(0, 0, t); }

...

//Here I set up the Toggle param

static PRM_Name names[] = {
	PRM_Name("switch","Switch"),
};

static PRM_Default  elevationDefault(500.0);

PRM_Template MySOP::myTemplateList[] = {
	PRM_Template(PRM_STRING,    1, &PRMgroupName, 0, &SOP_Node::pointGroupMenu,	0, 0, SOP_Node::getGroupSelectButton(GA_GROUP_POINT)),
	PRM_Template(PRM_TOGGLE,	1, &names[1]),
	PRM_Template(),
};

...

OP_ERROR MySOP::cookMySop(OP_Context& context)
{
	OP_AutoLockInputs inputs(this);
	if (inputs.lock(context) >= UT_ERROR_ABORT)
	{
		return error();
	}
	fpreal t = context.getTime();

	bool switcher = SWITCH(t);
	
	//Do something with my object...
	//Then here i want to make the switcher, my first idea was to make a PRM_TOGGLE param, and using it as a bool(like in the Euclid e.g), 
	//so for example if it's ticked, I want to move my object, if it isn't, I want to make it bigger (I know its a bad e.g: but I hope you get it)
	
	if(switcher)
	{
		//move my object
	}
	else
	{
		//make it bigger
	}

	//continue 

 

It compiles, but crashes Houdini with a seg. fault and I don't know what is the problem :(

Also, let me know if there is a better way of making a switcher :)

Daniel

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