本文整理汇总了C++中CKBehavior::GetInputParameterValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CKBehavior::GetInputParameterValue方法的具体用法?C++ CKBehavior::GetInputParameterValue怎么用?C++ CKBehavior::GetInputParameterValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKBehavior
的用法示例。
在下文中一共展示了CKBehavior::GetInputParameterValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TextureSinus
int TextureSinus(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
// we get the amount value
float xamp=0.1f;
beh->GetInputParameterValue(0, &xamp);
// we get the amount value
float yamp=0.1f;
beh->GetInputParameterValue(1, &yamp);
float l= 1.0f;
beh->GetInputParameterValue(2, &l);
// we get the saved uv's
VxUV* savedUV = (VxUV*) beh->GetLocalParameterReadDataPtr(0);
// we get the interpolated mesh
CKMesh *mesh = (CKMesh*) beh->GetInputParameterObject(4);
int channel = -1;
beh->GetInputParameterValue(3, &channel);
int channelcount = mesh->GetChannelCount();
if (channel < -1 || channel >= channelcount) {
beh->ActivateInput(0, FALSE);
beh->ActivateOutput(0);
return CKBR_PARAMETERERROR;
}
CKDWORD Stride;
VxUV *uvarray = (VxUV*) mesh->GetModifierUVs(&Stride,channel);
int pointsNumber = mesh->GetModifierUVCount(channel);
float time;
beh->GetLocalParameterValue(1, &time);
float t;
for( int i=0 ; i<pointsNumber ; i++, uvarray =(VxUV *)((BYTE *)uvarray + Stride)) {
t = ((float)i/pointsNumber-0.5f)*4.0f+time*l;
uvarray->u = savedUV[i].u + ( 0.5f - savedUV[i].u ) * xamp * cosf(t);
uvarray->v = savedUV[i].v + ( 0.5f - savedUV[i].v ) * yamp * sinf(t);
}
mesh->ModifierUVMove(channel);
float pi = 3.1415926535f;
time += behcontext.DeltaTime * 0.001f;
if(l*time > 2*pi)
time -= (2*pi / l);
beh->SetLocalParameterValue(1, &time);
beh->ActivateInput(0, FALSE);
beh->ActivateOutput(0);
return CKBR_OK;
}
示例2: 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;
}
示例3: NeoSetMousePos
int NeoSetMousePos(const CKBehaviorContext& BehContext)
{
CKBehavior* beh = BehContext.Behavior;
int x, y;
beh->GetInputParameterValue(0,&x);
beh->GetInputParameterValue(1,&y);
SetCursorPos(x,y);
beh->ActivateOutput(0);
CKBOOL keepActive;
beh->GetInputParameterValue(2,&keepActive);
if(keepActive)return CKBR_ACTIVATENEXTFRAME;
return CKBR_OK;
}
示例4: AddNodalLink
int AddNodalLink(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
CKAttributeManager* attman = ctx->GetAttributeManager();
beh->ActivateInput(0,FALSE);
beh->ActivateOutput(0);
CKGroup* group = (CKGroup*)beh->GetInputParameterObject(0);
CKParameterOut* param = group->GetAttributeParameter(attman->GetAttributeTypeByName(Network3dName));
if(!param) throw "Given Group isn't a Network";
N3DGraph* graph;
param->GetValue(&graph);
CK3dEntity* s = (CK3dEntity*)beh->GetInputParameterObject(1);
CK3dEntity* e = (CK3dEntity*)beh->GetInputParameterObject(2);
float b;
beh->GetInputParameterValue(3,&b);
graph->InsertEdge(s,e,b);
beh->ActivateOutput(0);
return CKBR_OK;
}
示例5: BehaviourFunction
/*
*******************************************************************
* Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext )
*
* Description : The execution function is the function that will be called
* during the process loop of the behavior engine, if the behavior
* is defined as using an execution function. This function is not
* called if the behavior is defined as a graph. This function is the
* heart of the behavior: it should compute the essence of the behavior,
* in an incremental way. The minimum amount of computing should be
* done at each call, to leave time for the other behaviors to run.
* The function receives the delay in milliseconds that has elapsed
* since the last behavioral process, and should rely on this value to
* manage the amount of effect it has on its computation, if the effect
* of this computation relies on time.
*
* Paramters :
* behaviourContext r Behavior context reference, which gives access to
* frequently used global objects ( context, level, manager, etc... )
*
* Returns : int, If it is done, it should return CKBR_OK. If it returns
* CKBR_ACTIVATENEXTFRAME, the behavior will again be called
* during the next process loop.
*
*******************************************************************
*/
int CGBLLAESetLoadState::BehaviourFunction( const CKBehaviorContext& behaviorContext )
{
CKBehavior* beh = behaviorContext.Behavior;
CKContext* ctx = behaviorContext.Context;
CGBLLAEManager *laeManager = (CGBLLAEManager *)ctx->GetManagerByGuid(GBLLAEManagerGUID);
if (laeManager)
{
int state = 0;
beh->GetInputParameterValue(0, &state);
laeManager->SetLoadState(state);
beh->ActivateInput(0, FALSE);
beh->ActivateOutput(0);
}
else
{
beh->ActivateInput(0, FALSE);
CKParameterOut *parameterOutError = beh->GetOutputParameter(0);
TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_CANTSETLAEIDENTITY,GBLLAE_ERROR_CANTSETLAEIDENTITY_DESC);
beh->ActivateOutput(1);
}
return CKBR_OK;
}
示例6: SetCIConnectionDetails
int SetCIConnectionDetails(const CKBehaviorContext& behcontext)
{
/************************************************************************/
/* collecting data : */
/* */
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
GBLConfigurationManager* cman=(GBLConfigurationManager*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID);
CGBLSyncInterface *CINetworkInterface = cman->GetSynInterface();
/************************************************************************/
/* check interface : */
/* */
if (!CINetworkInterface->isValidInterface())
{
//try to init the network interface :
if (!CINetworkInterface->Init(ctx))
{
return CKBR_BEHAVIORERROR;
}
}
/************************************************************************/
/* process building block events : */
/* */
if( beh->IsInputActive(0) )
{
beh->ActivateInput(0,FALSE);
XString message((CKSTRING) beh->GetInputParameterReadDataPtr(0));
int connectionID = -1;
beh->GetInputParameterValue(1,&CINetworkInterface->connectionID);
CKAttributeManager *aMan = static_cast<CKAttributeManager*>(ctx->GetAttributeManager());
//////////////////////////////////////////////////////////////////////////
//store connection details in the scipt dummies attribute :
CKAttributeType gblNetworkAtt = aMan->GetAttributeTypeByName( GBL_API_ENTRY("NetworkDetails"));
if (!CINetworkInterface->messageDummy->HasAttribute(gblNetworkAtt) )
{
CINetworkInterface->messageDummy->SetAttribute(gblNetworkAtt);
}
GBLCommon::ParameterTools::SetParameterStructureValue<int>(CINetworkInterface->messageDummy->GetAttributeParameter(gblNetworkAtt),0,CINetworkInterface->connectionID);
GBLCommon::ParameterTools::SetParameterStructureValue<CKSTRING>(CINetworkInterface->messageDummy->GetAttributeParameter(gblNetworkAtt),1,CINetworkInterface->messageName.Str());
//////////////////////////////////////////////////////////////////////////
//activate and execute the script :
behcontext.CurrentScene->Activate(CINetworkInterface->synchronizeScript,true);
behcontext.CurrentScene->Activate(CINetworkInterface->messageDummy,FALSE);
CINetworkInterface->synchronizeScript->Execute(1);
beh->ActivateOutput(0);
}
return CKBR_OK;
}
示例7: BehaviourFunction
/*
*******************************************************************
* Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext )
*
* Description : The execution function is the function that will be called
* during the process loop of the behavior engine, if the behavior
* is defined as using an execution function. This function is not
* called if the behavior is defined as a graph. This function is the
* heart of the behavior: it should compute the essence of the behavior,
* in an incremental way. The minimum amount of computing should be
* done at each call, to leave time for the other behaviors to run.
* The function receives the delay in milliseconds that has elapsed
* since the last behavioral process, and should rely on this value to
* manage the amount of effect it has on its computation, if the effect
* of this computation relies on time.
*
* Paramters :
* behaviourContext r Behavior context reference, which gives access to
* frequently used global objects ( context, level, manager, etc... )
*
* Returns : int, If it is done, it should return CKBR_OK. If it returns
* CKBR_ACTIVATENEXTFRAME, the behavior will again be called
* during the next process loop.
*
*******************************************************************
*/
int CGBLCHChatMoveHomogeneous::BehaviourFunction( const CKBehaviorContext& behaviorContext )
{
CKBehavior *beh = behaviorContext.Behavior;
CKContext *ctx = behaviorContext.Context;
CK2dEntity *chatFrame = (CK2dEntity *)beh->GetInputParameterObject(0);
if (chatFrame)
{
float left, top, right, bottom;
beh->GetInputParameterValue(3, &left);
beh->GetInputParameterValue(3, &top);
beh->GetInputParameterValue(2, &right);
right += left;
beh->GetInputParameterValue(1, &bottom);
bottom += top;
VxRect rect(left, top, right, bottom);
chatFrame->SetHomogeneousCoordinates ( 1 );
int res = chatFrame->SetHomogeneousRect ( rect );
if (res == 0)
{
beh->ActivateInput (0, 0);
beh->ActivateOutput (0);
}
else
{
beh->ActivateInput (0, 0);
beh->ActivateOutput (1);
}
}
else
{
beh->ActivateInput (0, 0);
beh->ActivateOutput (1);
}
return CKBR_OK;
}
示例8: DirToArray
int DirToArray(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
XString filename((CKSTRING) beh->GetInputParameterReadDataPtr(0));
XString Mask((CKSTRING) beh->GetInputParameterReadDataPtr(1));
int rec;
beh->GetInputParameterValue(2,&rec);
if( beh->IsInputActive(0) ){
beh->ActivateInput(0,FALSE);
flist.erase(flist.begin(),flist.end());
CKDirectoryParser MyParser(filename.Str(),Mask.Str(),rec);
char* str = NULL;
while(str = MyParser.GetNextFile())
flist.push_back(XString(str));
counter = 0;
beh->ActivateInput(1,TRUE);
}
if( beh->IsInputActive(1) ){
beh->ActivateInput(1,FALSE);
if ( counter < flist.size() ){
XString entry = flist.at(counter);
CKParameterOut * pout = beh->GetOutputParameter(0);
pout->SetStringValue(entry.Str() );
counter++;
beh->SetOutputParameterValue(1,&counter);
beh->ActivateOutput(1);
}else{
beh->SetOutputParameterValue(1,&counter);
counter = 0 ;
beh->ActivateOutput(0);
}
}
return 0;
}
示例9: FTPLogin
int FTPLogin(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
if( beh->IsInputActive(0)){
beh->ActivateInput(0,FALSE);
HWND win = (HWND)ctx->GetMainWindow();
FtpInit(win);
//HFILE hLogFile = _lcreat (LOG_FILE, 0);
//FtpLogTo (hLogFile);
FtpSetDefaultTimeOut (30);
FtpSetPassiveMode(TRUE);
FtpSetAsynchronousMode();
int Port;
beh->GetInputParameterValue(3,&Port);
XString Host((CKSTRING) beh->GetInputParameterReadDataPtr(0));
XString User((CKSTRING) beh->GetInputParameterReadDataPtr(1));
XString Pw((CKSTRING) beh->GetInputParameterReadDataPtr(2));
int Login = FtpLogin(Host.Str(),User.Str(),Pw.Str(),win,0);
beh->SetOutputParameterValue(0,&Login);
if (Login == 0)beh->ActivateOutput(0);
else{
beh->ActivateOutput(2);
return CKBR_OK;
}
return CKBR_ACTIVATENEXTFRAME;
}
if( beh->IsInputActive(1)){
beh->ActivateInput(1,FALSE);
FtpCloseConnection();
FtpRelease ();
beh->ActivateOutput(1);
return CKBR_OK;
}
return CKBR_ACTIVATENEXTFRAME;
}
示例10: SetZoom
int SetZoom(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKCamera *cam = (CKCamera *) beh->GetTarget();
if( !cam ) return CKBR_OWNERERROR;
float zoom = 50; // Zoom in mm
beh->GetInputParameterValue(0, &zoom);
float fov = 2.0f * atanf(18.0f / zoom);
cam->SetFov( fov );
beh->ActivateInput(0, FALSE);
beh->ActivateOutput(0);
return CKBR_OK;
}
示例11: BehaviourFunction
/*
*******************************************************************
* Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext )
*
* Description : The execution function is the function that will be called
* during the process loop of the behavior engine, if the behavior
* is defined as using an execution function. This function is not
* called if the behavior is defined as a graph. This function is the
* heart of the behavior: it should compute the essence of the behavior,
* in an incremental way. The minimum amount of computing should be
* done at each call, to leave time for the other behaviors to run.
* The function receives the delay in milliseconds that has elapsed
* since the last behavioral process, and should rely on this value to
* manage the amount of effect it has on its computation, if the effect
* of this computation relies on time.
*
* Paramters :
* behaviourContext r Behavior context reference, which gives access to
* frequently used global objects ( context, level, manager, etc... )
*
* Returns : int, If it is done, it should return CKBR_OK. If it returns
* CKBR_ACTIVATENEXTFRAME, the behavior will again be called
* during the next process loop.
*
*******************************************************************
*/
int CGBLLAESetLAEData::BehaviourFunction( const CKBehaviorContext& behaviorContext )
{
CKBehavior* beh = behaviorContext.Behavior;
CKContext* ctx = behaviorContext.Context;
IGBLSMProfileAccess* pin = NULL;
CGBLSMStorageManager *storageManager = (CGBLSMStorageManager *)ctx->GetManagerByGuid(GBLSMStorageManagerGUID);
IGBLSMLAEAccess *laeInterface = storageManager->GetLAEInterface();
int cisid;
CGBLLAID laid;
XString xlaid;
XString laeName;
int laeState = 0;
CKDataArray *userIDList = NULL;
CGBLLAEID laeid = 0;
int dlaeid;
beh->GetInputParameterValue(1, &dlaeid);
laeid = dlaeid;
GBLLAEDataType::GetGBLLAEData(beh->GetInputParameter(0)->GetRealSource(), cisid, laeName, laeState, xlaid, &userIDList );
laid.FromString(xlaid);
CGBLCOError res = laeInterface->StoreLAE (laeState, cisid, laid, laeName, &laeid);
if ( res == CGBLCOError::EGBLCOErrorType::GBLCO_OK)
{
beh->ActivateInput(0, FALSE);
beh->ActivateOutput(0);
}
else
{
CKParameterOut *parameterOutError = beh->GetOutputParameter(0);
TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_STORELAE,GBLLAE_ERROR_STORELAE_DESC);
beh->ActivateOutput(1);
}
return CKBR_OK;
}
示例12: BehaviourFunction
/*
*******************************************************************
* Function: BehaviourFunction()
*
* Description : Is called every frame from Virtools. Executes the behaviour of the BB.
*
* Parameters :
* behContext, r: Passed in from Virtools
*
* Returns : A CKBR_... return value
*
*******************************************************************
*/
int CGBLListBox::BehaviourFunction(const CKBehaviorContext& behContext)
{
static VxRect fullUVRect(0.0f, 0.0f, 1.0f, 1.0f);
// The default return code is CKBR_ACTIVATENEXTFRAME which forces BehaviourFunction() to be called next frame
CK_BEHAVIOR_RETURN behReturn = CKBR_ACTIVATENEXTFRAME;
CKBehavior* beh = behContext.Behavior;
// Call the helper class to implement our base class functionality
// If it returns FALSE, we must return the error code and not perform any behavioural functionality
CKBOOL isFocussed = FALSE;
if (!CGBLWidget::ExecuteBaseBehaviour(behContext, &isFocussed, &behReturn))
{
return behReturn;
}
// Check for mouse and keyboard inputs
CKInputManager* inputManager = (CKInputManager*)behContext.Context->GetManagerByGuid(INPUT_MANAGER_GUID);
if (!inputManager)
{
assert(NULL);
return CKBR_OK;
}
// Get material
CKMaterial* material = (CKMaterial*)beh->GetInputParameterObject(eParamInputMaterial);
if (!material)
{
// Output an error - we need a material
CGBLWidget::OutputBBErrorMsg(beh, "Please attach a material to the building block");
return CKBR_OK;
}
// Get font
VirtoolsSource::CKTextureFont* font = CGBLWidget::GetFont(behContext.Context, beh);
if (!font)
{
// Output an error - we need a font attached
CGBLWidget::OutputBBErrorMsg(beh, "Please attach a font to the building block");
return CKBR_OK;
}
// Are we using proportional scaling?
CKBOOL isPropScaling = CGBLWidget::IsProportionalScaling(beh);
// Get the font height
CKRenderContext* renderContext = behContext.Context->GetPlayerRenderContext();
float fontHeight = CGBLWidget::GetFontHeight(font, renderContext, isPropScaling);
// Get columns array, doesn't matter if we can't get it
CKDataArray* columnsArray = static_cast<CKDataArray*>(beh->GetInputParameterObject(eParamInputColumnsArray));
int numColumns = columnsArray ? columnsArray->GetRowCount() : 1;
CKSTRING errMsg = ValidateColumnsArray(columnsArray);
if (errMsg)
{
CGBLWidget::OutputBBErrorMsg(beh, errMsg);
return CKBR_OK;
}
// Get the string list array and check it's of the right type
CKDataArray* stringListArray = static_cast<CKDataArray*>(beh->GetInputParameterObject(eParamInputStringListArray));
errMsg = CGBLWidget::ValidateStringListArray(stringListArray, numColumns - 1);
if (errMsg)
{
CGBLWidget::OutputBBErrorMsg(beh, errMsg);
return CKBR_OK;
}
CKBeObject* beObject = beh->GetTarget();
CKRenderObject* renderObject = CKRenderObject::Cast(beObject);
// Add a render callback to allow our widget to render itself next frame
renderObject->AddPostRenderCallBack(RenderCallback, (void *)behContext.Behavior->GetID(), TRUE);
CK2dEntity* ent = CK2dEntity::Cast(renderObject);
VxRect clientRect;
ent->GetExtents(fullUVRect, clientRect);
// Check for Select b-in
if (beh->IsInputActive(eBehInputSelect))
{
// Reset b-in
beh->ActivateInput(eBehInputSelect, FALSE);
int select = 0;
beh->GetInputParameterValue(eParamInputSelectedItem, &select);
//.........这里部分代码省略.........
示例13: ARTPlusPatternTransformation
int ARTPlusPatternTransformation(const CKBehaviorContext& BehContext)
{
CKBehavior* beh = BehContext.Behavior;
CKBOOL detected = FALSE;
int patternID = -1;
int markerId = -1;
float buffer[16];
float patternWidth = 8.0f;
CK3dEntity* Object = NULL;
VxQuaternion quat = VxQuaternion();
VxVector pos = VxVector();
VxVector scale = VxVector();
float gl_para[4][4] = { {1.0f, 0.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 1.0f} };
float gl_tmp[4][4] = { {0.0f, 0.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 0.0f} };
float koordSys[4][4] = { {1.0f, 0.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 1.0f, 0.0f},
{0.0f, 1.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 1.0f} };
float koordSys2[4][4] = { {1.0f, 0.0f, 0.0f, 0.0f},
{0.0f, -1.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 1.0f} };
beh->ActivateInput(0, FALSE);
beh->ActivateOutput(0);
if(ARTPlusInitialized == true)
{
// get object
Object = CK3dEntity::Cast(beh->GetInputParameterObject(IN_OBJECT));
if(Object==NULL) return CKBR_BEHAVIORERROR;
if(markerInfo!=NULL && numMarkers>0)
{
// Get pattern id
beh->GetInputParameterValue(IN_PATTERN_NUMBER, &patternID);
// Get pattern width
beh->GetInputParameterValue(IN_PATTERN_WIDTH, &patternWidth);
// define size of the marker
tracker->setPatternWidth(patternWidth);
markerId = findMarker(patternID);
if( markerId>=0 && markerInfo[markerId].id==patternID)
{
ARFloat patt_center[2] = {0.0f, 0.0f};
tracker->calcOpenGLMatrixFromMarker(&markerInfo[markerId], patt_center, patternWidth, (float *)buffer);
detected = TRUE;
for( int j = 0; j < 4; j++ )
{
for( int i = 0; i < 4; i++ )
{
gl_para[j][i] = buffer[j*4+i];
}
}
for( int j = 0; j < 4; j++ )
{
for( int i = 0; i < 4; i++ )
{
gl_tmp[j][i] = 0.0;
for(int k=0 ; k<4 ; k++)
{
gl_tmp[j][i] += koordSys[j][k]*gl_para[k][i];
}
}
}
for( int j = 0; j < 4; j++ )
{
for( int i = 0; i < 4; i++ )
{
gl_para[j][i] = 0.0;
for(int k=0 ; k<4 ; k++)
{
gl_para[j][i] += gl_tmp[j][k]*koordSys2[k][i];
}
}
}
}
}
VxMatrix mat = VxMatrix(gl_para);
Vx3DDecomposeMatrix(mat, quat, pos, scale);
// Set true, if marker is detected
beh->SetOutputParameterValue(OUT_DETECTED, &detected, 0);
//.........这里部分代码省略.........
示例14: CallPythonFunc2
int CallPythonFunc2(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
XString File((CKSTRING) beh->GetInputParameterReadDataPtr(0));
XString Func((CKSTRING) beh->GetInputParameterReadDataPtr(1));
int reload=false; //= BehaviorTools::GetInputParameterValue<bool>(beh,2);
beh->GetInputParameterValue(2,&reload);
vt_python_man *pm = (vt_python_man*)ctx->GetManagerByGuid(INIT_MAN_GUID);
CKParameterManager *pam = static_cast<CKParameterManager *>(ctx->GetParameterManager());
Python *py = pm->py;
if (!pm->pLoaded)
{
pm->m_Context->OutputToConsoleEx("You must load Python before !");
beh->ActivateOutput(1,false);
return CKBR_BEHAVIORERROR;
}
//////////////////////////////////////////////////////////////////////////
if( beh->IsInputActive(0) )
{
try
{
PyObject *module = pm->InsertPModule(beh->GetID(),File,reload);
PyObject* val = PyInt_FromLong(beh->GetID());
PyObject_SetAttrString( module , "bid", val);
pm->CallPyModule(beh->GetID(),Func);
}
catch (Python_exception ex)
{
pm->m_Context->OutputToConsoleEx("PyErr : \t %s",(CKSTRING)ex.what());
std::cout << ex.what() << "pyexeption in beh : " << beh->GetName();
PyErr_Clear();
beh->ActivateOutput(1,false);
}
beh->ActivateInput(0,false);
}
//////////////////////////////////////////////////////////////////////////
else
{
for (int i = 1 ; i < beh->GetOutputCount() ; i++ )
{
try
{
PyObject *module = pm->GetPModule(beh->GetID());
if(module)
pm->CallPyModule(beh->GetID(),Func);
}
catch (Python_exception ex)
{
pm->m_Context->OutputToConsoleEx("PyErr : \t %s",(CKSTRING)ex.what());
std::cout << ex.what() << "pyexeption in beh : " << beh->GetName();
beh->ActivateOutput(1,TRUE);
return CKBR_BEHAVIORERROR;
}
beh->ActivateInput(i,false);
}
}
return CKBR_OK;
}
示例15: BehaviourFunction
/*
*******************************************************************
* Function: int BehaviourFunction()
*
* Description :
*
* Paramters :
* CKBehaviorContext& r The virtools behaviour context
*
* Returns : One of the many virtools return values
*
*******************************************************************
*/
int CGBLLOStringBuilder::BehaviourFunction(const CKBehaviorContext& behContext)
{
CKBehavior* beh = behContext.Behavior;
CKBeObject* beObject = beh->GetTarget();
CKBOOL error = FALSE;
XString outString = NULL;
// error check to ensure virtools is working ok
if (!beObject)
{
error = TRUE;
CKParameterOut *parameterOutError = beh->GetOutputParameter(EGBLStringBuilderParamOutputs::eParamGetError);
TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_FATAL,LOI_ERROR_NO_BEHAVIOUR_STATE,LOI_ERROR_NO_BEHAVIOUR_DESC);
beh->SetOutputParameterValue(eParamGetError, parameterOutError);
beh->ActivateOutput(eBehOutputError, TRUE);
}
int lengthOfSource = 0;
int lengthOfInsert = 0;
int insertPosition = 0;
if (!error)
{
// Reset On input, if active
if (beh->IsInputActive(eBehInputOn))
{
beh->ActivateInput(eBehInputOn, FALSE);
}
// get the BB params into variables to work with
XString sourceString = NULL;
sourceString = (CKSTRING)(beh->GetInputParameterReadDataPtr(eParamSetSourceString));
XString insertString = NULL;
insertString = (CKSTRING)(beh->GetInputParameterReadDataPtr(eParamSetInsertString));
beh->GetInputParameterValue(eParamSetInsertPosition,&insertPosition);
lengthOfSource = strlen(sourceString.Str());
lengthOfInsert = strlen(insertString.Str());
// Simple bounds checking and error recovery
if (insertPosition<0)
{
insertPosition=0;
}
if (insertPosition>lengthOfSource)
{
outString = sourceString;
outString += insertString;
}
else
{
// a little more error checking and simple recovery
// deal with the special cases first
if (lengthOfSource<=0)
{
// an empty source
outString = insertString;
}
else if (insertPosition == 0)
{
outString = insertString;
outString += sourceString;
}
else
{
// build up the new string
XString start = NULL;
XString end = NULL;
start = sourceString.Substring(0,insertPosition);
end = sourceString.Substring(insertPosition,lengthOfSource);
outString = start ;
outString += insertString;
outString += end;
}
}
}
if (!error)
{
int newCartPos = insertPosition+lengthOfInsert;
beh->SetOutputParameterValue(eParamGetCarretPosition,&newCartPos);
beh->SetOutputParameterValue(eParamGetNewText, outString.CStr(), outString.Length() + 1);
beh->ActivateOutput(eBehOutputDone, TRUE);
//.........这里部分代码省略.........