本文整理汇总了C++中CKBehavior::GetInputParameterCount方法的典型用法代码示例。如果您正苦于以下问题:C++ CKBehavior::GetInputParameterCount方法的具体用法?C++ CKBehavior::GetInputParameterCount怎么用?C++ CKBehavior::GetInputParameterCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKBehavior
的用法示例。
在下文中一共展示了CKBehavior::GetInputParameterCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CISIteratorCB
/*
*******************************************************************
* Function: int CISIteratorCB( const CKBehaviorContext& behaviorContext )
*
* Description : The Behavior Callback function is called by Virtools when various events happen
* in the life of a BuildingBlock. Exactly which events trigger a call to the
* Behavior Callback function is defined in the Behavior Prototype, along with the
* declaration of the function pointer
*
* Parameters :
* behaviourContext r Behavior context reference, which gives
* access to frequently used global objects
* ( context, level, manager, etc... )
*
* Returns : int, The return value of the callback function should be one of the CK_BEHAVIOR_RETURN values.
*
*******************************************************************
*/
CKERROR CISIteratorCB(const CKBehaviorContext& behcontext)
{
/************************************************************************/
/* collecting data : */
/* */
CKBehavior *beh = behcontext.Behavior;
CKContext* ctx = beh->GetCKContext();
CKParameterManager *pm = static_cast<CKParameterManager*>(ctx->GetParameterManager());
CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID);
/************************************************************************/
/* process virtools callbacks : */
/* */
switch(behcontext.CallbackMessage)
{
case CKM_BEHAVIORRESET:
{
CKDataArray *array = NULL;
beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&array);
break;
}
case CKM_BEHAVIOREDITED:
case CKM_BEHAVIORSETTINGSEDITED :
{
assert(beh && ctx);
BOOL getFromDB = false;
beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_DB_MODE,&getFromDB);
if( getFromDB && ( beh->GetInputParameterCount() == BEH_IN_INDEX_MIN_COUNT ) )
{
beh->CreateInputParameter("CIS ID", CKPGUID_INT);
}
//////////////////////////////////////////////////////////////////////////
//remove all pIns :
int p_count = beh->GetInputParameterCount();
while( (getFromDB ? BEH_IN_INDEX_MAX_COUNT : BEH_IN_INDEX_MIN_COUNT ) < p_count )
{
CKDestroyObject( beh->RemoveInputParameter( --p_count) );
}
break;
}
}
return CKBR_OK;
}
示例2: MidiEventCallBack
CKERROR MidiEventCallBack(const CKBehaviorContext& behcontext){
CKBehavior *beh = behcontext.Behavior;
MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );
switch( behcontext.CallbackMessage ){
case CKM_BEHAVIOREDITED:
{
int c_pin = beh->GetInputParameterCount();
char name[20];
CKParameterIn *pin;
for( int a=2 ; a<c_pin ; a++){
pin = beh->GetInputParameter(a);
sprintf( name, "Note %d", a);
pin->SetName( name );
pin->SetGUID( CKPGUID_INT );
}
} break;
case CKM_BEHAVIORATTACH:
case CKM_BEHAVIORLOAD:
{
mm->AddMidiBBref();
} break;
case CKM_BEHAVIORDETACH:
{
mm->RemoveMidiBBref();
} break;
}
return CKBR_OK;
}
示例3: MidiEvent
int MidiEvent(const CKBehaviorContext& behcontext)
{
CKBehavior *beh = behcontext.Behavior;
if( beh->IsInputActive(1) ){ // OFF
beh->ActivateInput(1, FALSE);
return CKBR_OK;
}
CKBOOL combiWasOK = FALSE;
if( beh->IsInputActive(0) ){ // ON
beh->ActivateInput(0, FALSE);
beh->SetLocalParameterValue(0, &combiWasOK);
} else {
beh->GetLocalParameterValue(0, &combiWasOK);
}
MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );
// Channel
int channel=0;
beh->GetInputParameterValue(0, &channel);
int note, count = beh->GetInputParameterCount();
//--- test if all input notes are activated or not
for( int a=1 ; a<count ; a++ ){
beh->GetInputParameterValue(a, ¬e);
if( !mm->IsNoteActive(note, channel) ) break;
}
if( a==count ){ // All notes are pressed
if( !combiWasOK ){
beh->ActivateOutput(0);
combiWasOK = TRUE;
beh->SetLocalParameterValue(0, &combiWasOK);
return CKBR_ACTIVATENEXTFRAME;
}
} else { // Not all notes are pressed
if( combiWasOK ){
beh->ActivateOutput(1);
combiWasOK = FALSE;
beh->SetLocalParameterValue(0, &combiWasOK);
return CKBR_ACTIVATENEXTFRAME;
}
}
return CKBR_ACTIVATENEXTFRAME;
}
示例4: BehaviourFunction
int GBLCOBGWrapper::BehaviourFunction( const CKBehaviorContext& behContext )
{
CKBehavior *behaviour = behContext.Behavior;
CKContext *context = behContext.Context;
int iPin, nbPin;
CKBehavior* script = (CKBehavior*)behaviour->GetLocalParameterObject(EGBLCOBGWRAPPERPARAM_PARAMETER_SCRIPT);
if (script == NULL)
return CKBR_GENERICERROR;
// Activate the right inputs
nbPin = behaviour->GetInputCount();
for (iPin = 0; iPin < nbPin; iPin++)
{
if (behaviour->IsInputActive(iPin))
{
script->ActivateInput(iPin, TRUE);
behaviour->ActivateInput(iPin, FALSE);
}
}
// Deactivate all the outputs
nbPin = script->GetOutputCount();
for (iPin = 0; iPin < nbPin; iPin++)
{
behaviour->ActivateOutput(iPin, FALSE);
}
// Parameter In: Set Source
int nbPinBB = behaviour->GetInputParameterCount();
int nbPinBG = script->GetInputParameterCount();
if (nbPinBB != nbPinBG)
return CKBR_GENERICERROR;
for (iPin = 0; iPin < nbPinBB; iPin++)
{
CKParameterIn *pBin = behaviour->GetInputParameter(iPin);
CKParameter* pSource = pBin->GetDirectSource();
CKParameterIn *pSin = script->GetInputParameter(iPin);
pSin->SetDirectSource(pSource);
}
// Execute the contained script
CKERROR result = script->Execute(behContext.DeltaTime);
// The script loop on itself too much times
if (result == CKBR_INFINITELOOP)
{
context->OutputToConsoleExBeep("Execute Script : Script %s Executed too much times",script->GetName());
script->Activate(FALSE,FALSE);
return CKBR_OK;
}
// Activate the right outputs
nbPin = script->GetOutputCount();
for (iPin = 0; iPin < nbPin; iPin++)
{
if (script->IsOutputActive(iPin))
{
behaviour->ActivateOutput(iPin);
script->ActivateOutput(iPin, FALSE);
}
}
// Update Parameters Out
nbPin = behaviour->GetOutputParameterCount();
for (iPin = 0; iPin < nbPin; iPin++)
{
CKParameterOut *pBout = behaviour->GetOutputParameter(iPin);
CKParameterOut *pSout = script->GetOutputParameter(iPin);
pBout->CopyValue(pSout, TRUE);
}
// Test if there are any active sub-behaviors, restart the next frame if any
BOOL bActivateNextFrame = FALSE;
ActivateNextFrameSubBB(script,bActivateNextFrame);
if (bActivateNextFrame)
return CKBR_ACTIVATENEXTFRAME;
// return the execute value
return result;
}
示例5: err
//************************************
// Method: vt_GetInVal
// FullName: vt_GetInVal
// Access: public static
// Returns: PyObject *
// Qualifier:
// Parameter: PyObject * self
// Parameter: PyObject * args
//************************************
static PyObject *vt_GetInVal( PyObject * self, PyObject * args )
{
int size = PyTuple_Size(args);
int bid, index;
PyArg_ParseTuple(args, "ii", &bid, &index);
CK_ID cid = bid;
CKBehavior *beh = static_cast<CKBehavior*>(pym->m_Context->GetObject(cid));
if (size!=2)
{
pym->m_Context->OutputToConsole("PyError : This function needs 2 arguments : \n\t bid,index");
Py_RETURN_NONE;
}
using namespace vtTools;
using namespace vtTools::Enums;
CKParameterManager *pam = static_cast<CKParameterManager *>(pym->m_Context->GetParameterManager());
if (index < beh->GetInputParameterCount() )
{
CKParameterIn *ciIn = beh->GetInputParameter(index);
CKParameterType pType = ciIn->GetType();
vtTools::Enums::SuperType sType = ParameterTools::GetVirtoolsSuperType(pym->m_Context,pam->ParameterTypeToGuid(pType));
PyObject *val;
switch (sType)
{
case vtSTRING:
{
val = PyString_FromString( vtTools::BehaviorTools::GetInputParameterValue<CKSTRING>(beh,index ));
break;
}
case vtFLOAT:
{
val = PyFloat_FromDouble(static_cast<float>(vtTools::BehaviorTools::GetInputParameterValue<float>(beh,index )));
break;
}
case vtINTEGER:
{
val = PyInt_FromLong( static_cast<long>(vtTools::BehaviorTools::GetInputParameterValue<int>(beh,index )));
break;
}
default :
XString err("wrong input parameter type: ");
err << ciIn->GetName() << "Only Types derivated from Interger,Float or String are acceptable";
pym->m_Context->OutputToConsole(err.Str(),FALSE );
Py_RETURN_NONE;
}
if (!val)
{
Py_DECREF(val);
}
return val;
}
Py_RETURN_NONE;
}
示例6: DOUserValueModified
int DOUserValueModified(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKMessageManager* mm = behcontext.MessageManager;
CKContext* ctx = behcontext.Context;
//////////////////////////////////////////////////////////////////////////
//connection id :
int connectionID = vtTools::BehaviorTools::GetInputParameterValue<int>(beh,0);
if (beh->IsInputActive(1))
{
beh->ActivateInput(1,FALSE);
beh->ActivateOutput(1);
return 0;
}
//////////////////////////////////////////////////////////////////////////
//the object :
CK3dEntity *obj= (CK3dEntity*)beh->GetInputParameterObject(1);
if (!obj)
{
beh->ActivateOutput(3);
return CKBR_ACTIVATENEXTFRAME;
}
//////////////////////////////////////////////////////////////////////////
//network ok ?
xNetInterface *cin = GetNM()->GetClientNetInterface();
if (!cin)
{
CKParameterOut *pout = beh->GetOutputParameter(2);
XString errorMesg("distributed object creation failed,no network connection !");
pout->SetStringValue(errorMesg.Str());
beh->ActivateOutput(3);
return CKBR_ACTIVATENEXTFRAME;
}
//use objects name, if not specified :
CKSTRING name= obj->GetName();
IDistributedObjects*doInterface = cin->getDistObjectInterface();
IDistributedClasses*cInterface = cin->getDistributedClassInterface();
XString className((CKSTRING) beh->GetLocalParameterReadDataPtr(0));
XString parameterName((CKSTRING) beh->GetLocalParameterReadDataPtr(1));
xDistributedClass *_class = cInterface->get(className.CStr());
//////////////////////////////////////////////////////////////////////////
//dist class ok ?
if (_class==NULL)
{
beh->ActivateOutput(3);
ctx->OutputToConsoleEx("Distributed Class doesn't exists : %s",className.CStr());
return CKBR_ACTIVATENEXTFRAME;
}
const char * cNAme = _class->getClassName().getString();
int classType = _class->getEnitityType();
int bcount = beh->GetInputParameterCount();
//////////////////////////////////////////////////////////////////////////
//we come in by input 0 :
xDistributedObject *dobjDummy = NULL;
xDistributedObject *dobj = doInterface->getByEntityID(obj->GetID());
if (!dobj)
{
beh->ActivateOutput(3);
return CKBR_ACTIVATENEXTFRAME;
}
if (dobj)
{
xDistributedProperty * prop = dobj->getUserProperty(parameterName.CStr());
if (prop)
{
if ( dobj->getGhostUpdateBits().testStrict(1 << prop->getBlockIndex()))
{
CKParameterManager *pam = static_cast<CKParameterManager *>(ctx->GetParameterManager());
CKParameterOut *ciIn = beh->GetOutputParameter(1);
CKParameterType pType = ciIn->GetType();
int sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));
int userType = xDistTools::ValueTypeToSuperType(prop->getPropertyInfo()->mValueType);
if ( userType ==sType )
{
beh->ActivateOutput(2);
dobj->getGhostUpdateBits().set(1 << prop->getBlockIndex(),false);
switch(xDistTools::ValueTypeToSuperType(prop->getPropertyInfo()->mValueType))
//.........这里部分代码省略.........