Notifications
Clear all

[Closed] My First Controller Plug-in… Questions:

Thanks @Klvnk… that works!

So I have 4 references: pos, rot, scl, pblock

Also, should I add the following in the Copy method under the existing NotifyDedependents call?

NotifyDependents(FOREVER,0,REFMSG_SUBANIM_STRUCTURE_CHANGED);

So it would be:

*
*
*
	NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE);
	NotifyDependents(FOREVER,0,REFMSG_SUBANIM_STRUCTURE_CHANGED);
}

not needed the other notification would cover that.

So the parameter block is working (although aspects of it are not tied into the overall controller methods…) but what I’m trying to do now is properly tie my “Radius Unlocked” checkbox with the “Pivot Radius” control/Spinner.

Well, the checkbox does enable and disable the “Pivot Radius” control/spinner (as that is all setup within the pblock, but when I assign a On/Off controller to the “Radius Unlocked” parameter and a Bezier Float controller to the “Pivot Radius” and I animate them– here’s the issue:

…the Bezier Float values of the Pivot Radius are still varying from one key to the next key, even when it is disabled by the animating of the “Radius Unlocked” checkbox.

What I want to achieve is to have the “Pivot Radius” controller value remain frozen (or held constant) while it is disabled; and then allow it to once again vary when the checkbox re-enables it. It seems the easiest way to achieve this is to change the out-tangent type to “STEP” so that it holds the last key value while disabled… and then change it back to the standard out-tangent type when it is re-enabled.

But how? I believe I need to handle this within the PBAccessor method… but I’m having difficulty understanding how to code access to the pblock parameter’s Bezier float controller… I tried:

Control *tempRadius = Null;
tempRadius = p->pblock->GetController(paramID id,…)

but then trying to do: tempRadius-> doesn’t bring up intellisense
and I can’t figure out how to use: SetBezierDefaultTangentType(int, int)
to get to the Bezier Float tangent types to change them…

:banghead:

So I’m not sure if I’m reading/understanding the SDK literature correctly…

Am I correct to think that Bezier Tangents In/Out Types are a global setting that would impact all Bezier type controllers? Or does each Bezier Controller store it’s own tangent types?

…And it seems rather nasty to manage– having to go back after a key is created and set the tangent types; say it isn’t so… hopefully I’m wrong. Someone please enlighten me… :curious:

So, I’m still trying to figure out how to associate the “radius unlocked” checkbox with the radius Bezier float controller– in regards to causing a change to the radius Bezier float controller key’s tangent types based on the status of the checkbox (i.e., is the radius free to change or locked? And if locked it should hold last key value between keys– so it needs to change automatically to STEP type).

Here is the code I tried but when it gets down to the “key.outtan” it doesn’t effect any change in the Bezier controller key tangents.

//Global Method

int IsBezFltKeyAtTime(Control* cont, TimeValue t)
{
	IKeyControl *ikc = NULL;
	int keyIndex = 0;
	int numKeys = 0;
	if (cont->ClassID() == Class_ID(HYBRIDINTERP_FLOAT_CLASS_ID, 0))
	{
		ikc = GetKeyControlInterface(cont);
		//Get number of keys
		numKeys = ikc->GetNumKeys();
		if (numKeys > 0)
		{
			//cycle thru keys and see if any match current slider time
			for ( int i = 0; i < numKeys; i++)
			{
				IBezFloatKey key;
				ikc->GetKey(i, &key);
				if (key.time == t)
					return i;
			}
			return 0;
		}
		else {
			return 0;
		}
	}

	return 0;
}

//***************************
//***************************

				case WM_COMMAND:
					switch (LOWORD(wParam))
					{
						//*
						//*
						//*
						
						case IDC_PIVOT_RADIUS_UNLOCKED:

							BOOL l_unLocked;
							p->pblock->GetValue(animpivot_radius_unlocked,t,l_unLocked,FOREVER,0);
							if ( !l_unLocked )
							{	//radius is disabled , locked, and should hold value (i.e., hold last key value)
								//TODO:  How to change radius bezier float controller key out-tangent type to STEP???
								int l_keyIndex = 0;
								Control *l_tempRad = NULL;
								l_tempRad = p->pblock->GetController(animpivot_radius,0);
								if ( (l_tempRad != NULL ) )
								{	
									l_keyIndex = IsBezFltKeyAtTime(l_tempRad,t);
									if ( l_keyIndex > 0	)
									{
										IKeyControl *ikc = NULL;
										ikc = GetKeyControlInterface(l_tempRad);
										IBezFloatKey key;
										ikc->GetKey(l_keyIndex,&key);
										key.outtan = BEZKEY_STEP;
									}
								}
							}
						break;			
						
						//*
						//*
						//*
					}

Any suggestions? :banghead:

Regarding associating a Checkbox with another pblock parameter’s Bezier float controller tangent types…

…Maybe a simpler solution would be to use a Math Controller for the “Pivot Radius” and simply have the “Radius Unlocked” Checkbox’s Boolean controller multiply the Pivot Radius Bezier Float Controller value– this could achieve an automatic stepping effect.

Pseudo-code:

if (radius not unlocked)
{ //radius locked, Boolean value is 0
     radius value = (BezFloat Controller) * (Boolean Controller) + (prev BezFloat key value)
}
else
{ //radius is unlocked (free to vary), Boolean value is 1
     radius value = (BezFloat Controller) * (Boolean Controller)
}

…this way I don’t have to dick around with BezFloat key tangent types. Thoughts???

Page 3 / 3