本文整理汇总了C++中CKBehavior::GetTarget方法的典型用法代码示例。如果您正苦于以下问题:C++ CKBehavior::GetTarget方法的具体用法?C++ CKBehavior::GetTarget怎么用?C++ CKBehavior::GetTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKBehavior
的用法示例。
在下文中一共展示了CKBehavior::GetTarget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PClothDestroy
//************************************
// Method: PClothDestroy
// FullName: PClothDestroy
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PClothDestroy(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
using namespace vtTools::BehaviorTools;
if( beh->IsInputActive(0) )
{
beh->ActivateInput(0,FALSE);
//////////////////////////////////////////////////////////////////////////
//the object :
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) return CKBR_OWNERERROR;
//////////////////////////////////////////////////////////////////////////
pCloth *cloth = GetPMan()->getCloth(target->GetID());
if (!cloth)
{
beh->ActivateOutput(0);
return CKBR_PARAMETERERROR;
}
pWorld *world = cloth->getWorld();
world->destroyCloth(target->GetID());
beh->ActivateOutput(0);
}
return 0;
}
示例2: PCIgnorePair
//************************************
// Method: PCIgnorePair
// FullName: PCIgnorePair
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PCIgnorePair(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
using namespace vtTools::BehaviorTools;
if( beh->IsInputActive(0) )
{
//////////////////////////////////////////////////////////////////////////
//the object :
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) return CKBR_OWNERERROR;
CK3dEntity *targetA = (CK3dEntity *) beh->GetInputParameterObject(0);
CK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(1);
int ignore = GetInputParameterValue<int>(beh,2);
//////////////////////////////////////////////////////////////////////////
// the world :
pWorld *world=GetPMan()->getWorld(target);
if(world){
world->cIgnorePair(targetA,targetB,ignore);
}
beh->ActivateInput(0,FALSE);
beh->ActivateOutput(0);
}
return 0;
}
示例3: JDestroy
//************************************
// Method: JDestroy
// FullName: JDestroy
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int JDestroy(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
using namespace vtTools::BehaviorTools;
if( beh->IsInputActive(0) )
{
beh->ActivateInput(0,FALSE);
//////////////////////////////////////////////////////////////////////////
//the object A:
int jointType = GetInputParameterValue<int>(beh,1);
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
CK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(0);
if (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,jointType))
{
return CK_OK;
}
// the world :
pWorld *worldA=GetPMan()->getWorldByBody(target);
pWorld *worldB=GetPMan()->getWorldByBody(targetB);
if (!worldA)
{
worldA = worldB;
}
if (!worldA)
{
beh->ActivateOutput(0);
return 0;
}
// the physic object A :
pRigidBody*bodyA= worldA->getBody(target);
pRigidBody*bodyB= worldA->getBody(targetB);
if(bodyA || bodyB)
{
pJoint *joint = worldA->getJoint(target,targetB,(JType)jointType);
if (joint)
{
worldA->deleteJoint(joint);
}
}
beh->ActivateOutput(0);
}
return 0;
}
示例4: PBSetTriggerMask
//************************************
// Method: PBSetTriggerMask
// FullName: PBSetTriggerMask
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PBSetTriggerMask(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
using namespace vtTools::BehaviorTools;
if( beh->IsInputActive(0) )
{
beh->ActivateInput(0,FALSE);
//////////////////////////////////////////////////////////////////////////
//the object :
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) return CKBR_OWNERERROR;
//////////////////////////////////////////////////////////////////////////
// the world :
pWorld *world = GetPMan()->getWorldByShapeReference(target);
if (!world)
{
beh->ActivateOutput(0);
return 0;
}
if (world)
{
NxShape *shape = world->getShapeByEntityID(target->GetID());
if (shape)
{
int onEnter = GetInputParameterValue<int>(beh,bbI_OnEnter);
int onStay = GetInputParameterValue<int>(beh,bbI_OnStay);
int onLeave = GetInputParameterValue<int>(beh,bbI_OnLeave);
shape->setFlag(NX_TRIGGER_ON_ENTER,onEnter);
shape->setFlag(NX_TRIGGER_ON_STAY,onStay);
shape->setFlag(NX_TRIGGER_ON_LEAVE,onLeave);
}
}
beh->ActivateOutput(0);
}
return 0;
}
示例5: PClothDetachFromShape
//************************************
// Method: PClothDetachFromShape
// FullName: PClothDetachFromShape
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PClothDetachFromShape(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
using namespace vtTools::BehaviorTools;
if( beh->IsInputActive(0) )
{
beh->ActivateInput(0,FALSE);
//////////////////////////////////////////////////////////////////////////
//the object :
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) return CKBR_OWNERERROR;
//////////////////////////////////////////////////////////////////////////
CK3dEntity*shapeReference = (CK3dEntity *) beh->GetInputParameterObject(bbI_ShapeReference);
if (!shapeReference)
{
beh->ActivateOutput(0);
return CKBR_PARAMETERERROR;
}
pCloth *cloth = GetPMan()->getCloth(target->GetID());
if (!cloth)
{
beh->ActivateOutput(0);
return CKBR_PARAMETERERROR;
}
NxShape *shape = cloth->getWorld()->getShapeByEntityID(shapeReference->GetID());
if(shape)
{
cloth->detachFromShape((CKBeObject*)shapeReference);
}
beh->ActivateOutput(0);
beh->ActivateOutput(0);
}
return 0;
}
示例6: PClothAttachVertexToPosition
//************************************
// Method: PClothAttachVertexToPosition
// FullName: PClothAttachVertexToPosition
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PClothAttachVertexToPosition(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
using namespace vtTools::BehaviorTools;
if( beh->IsInputActive(0) )
{
beh->ActivateInput(0,FALSE);
//////////////////////////////////////////////////////////////////////////
//the object :
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) return CKBR_OWNERERROR;
//////////////////////////////////////////////////////////////////////////
pWorld *world = GetPMan()->getDefaultWorld();
if (!world)
{
beh->ActivateOutput(0);
return CKBR_PARAMETERERROR;
}
pCloth *cloth = world->getCloth(target);
if (!cloth)
{
beh->ActivateOutput(0);
return CKBR_PARAMETERERROR;
}
int vertexIndex = GetInputParameterValue<int>(beh,bbI_VertexIndex);
VxVector localPosition = GetInputParameterValue<VxVector>(beh,bbI_GlobalPosition);
cloth->attachVertexToGlobalPosition(vertexIndex,localPosition);
beh->ActivateOutput(0);
}
return 0;
}
示例7: 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;
}
示例8: PClothAddForceAtVertex
//************************************
// Method: PClothAddForceAtVertex
// FullName: PClothAddForceAtVertex
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PClothAddForceAtVertex(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
using namespace vtTools::BehaviorTools;
if( beh->IsInputActive(0) )
{
beh->ActivateInput(0,FALSE);
//////////////////////////////////////////////////////////////////////////
//the object :
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) return CKBR_OWNERERROR;
//////////////////////////////////////////////////////////////////////////
pCloth *cloth = GetPMan()->getCloth(target->GetID());
if (!cloth)
{
beh->ActivateOutput(0);
return CKBR_PARAMETERERROR;
}
int vertexIndex = GetInputParameterValue<int>(beh,bbI_VertexIndex);
VxVector force = GetInputParameterValue<VxVector>(beh,bbI_Force);
int forceMode = GetInputParameterValue<int>(beh,bbI_ForceMode);
cloth->addForceAtVertex(force,vertexIndex,(ForceMode)forceMode);
beh->ActivateOutput(0);
}
return 0;
}
示例9: PVGet
//************************************
// Method: PVGet
// FullName: PVGet
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PVGet(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
using namespace vtTools::BehaviorTools;
if( beh->IsInputActive(0) )
{
beh->ActivateInput(0,FALSE);
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) bbErrorME("No Reference Object specified");
pRigidBody *body = NULL;
body = GetPMan()->getBody(target);
if (!body)
bbSErrorME(E_PE_NoBody);
pVehicle *v = body->getVehicle();
if (!v)
{
bbSErrorME(E_PE_NoVeh);
}
BB_DECLARE_PMAP;
/************************************************************************/
/* retrieve settings state */
/*****
*******************************************************************/
BBSParameter(O_StateFlags);
BBSParameter(O_Acceleration);
BBSParameter(O_Steering);
BBSParameter(O_MTorque);
BBSParameter(O_MPH);
BBSParameter(O_RPM);
BBSParameter(O_MRPM);
BBSParameter(O_WRPM);
BBSParameter(O_Gear);
/************************************************************************/
/* */
/************************************************************************/
BB_O_SET_VALUE_IF(int,O_StateFlags,v->getStateFlags());
BB_O_SET_VALUE_IF(float,O_Acceleration,v->_cAcceleration);
BB_O_SET_VALUE_IF(float,O_Steering,v->_cSteering);
BB_O_SET_VALUE_IF(float,O_MPH,v->getMPH());
float wRPM = v->_computeRpmFromWheels();
BB_O_SET_VALUE_IF(float,O_WRPM,wRPM);
//----------------------------------------------------------------
//
// output new engine values
//
if (v->isValidEngine())
{
BB_O_SET_VALUE_IF(float,O_MTorque,v->getEngine()->GetEngineTorque());
BB_O_SET_VALUE_IF(float,O_RPM,v->getRPM());
BB_O_SET_VALUE_IF(int,O_Gear,v->getGear());
}
示例10: PBPhysicalize
//************************************
// Method: PBPhysicalize
// FullName: PBPhysicalize
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PBPhysicalize(const CKBehaviorContext& behcontext)
{
using namespace vtTools::BehaviorTools;
using namespace vtTools;
using namespace vtTools::AttributeTools;
//////////////////////////////////////////////////////////////////////////
//basic parameters
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
//////////////////////////////////////////////////////////////////////////
//settings
int useDWorld; beh->GetLocalParameterValue(bbS_USE_DEFAULT_WORLD,&useDWorld);
// int useWorldSS; beh->GetLocalParameterValue(bbS_USE_WORLD_SLEEP_SETTINGS,&useWorldSS);
// int useWorldDS; beh->GetLocalParameterValue(bbS_USE_WORLD_DAMPING_SETTINGS,&useWorldDS);
int useWorldM; beh->GetLocalParameterValue(bbS_USE_WORLD_MATERIAL,&useWorldM);
int addAttributes; beh->GetLocalParameterValue(bbS_ADD_ATTRIBUTES,&addAttributes);
//////////////////////////////////////////////////////////////////////////
//the object :
CK3dEntity *referenceObject = (CK3dEntity *) beh->GetTarget();
if( !referenceObject ) return CKBR_OWNERERROR;
//////////////////////////////////////////////////////////////////////////
//the world :
CK3dEntity*worldRef = NULL;
if (!useDWorld)
{
worldRef = (CK3dEntity *) beh->GetInputParameterObject(bbI_TargetWorld);
}
// the world :
pWorld *world=GetPMan()->getWorld(worldRef,referenceObject);
if (!world)
{
beh->ActivateOutput(0);
return 0;
}
pRigidBody*result = world->getBody(referenceObject);
if (result)
{
beh->ActivateOutput(0);
return 0;
}
//////////////////////////////////////////////////////////////////////////
//pick up some parameters :
int flags = GetInputParameterValue<int>(beh,bbI_Flags);
int hType = GetInputParameterValue<int>(beh,bbI_HullType);
float density = GetInputParameterValue<float>(beh,bbI_Density);
float skinWidth = GetInputParameterValue<float>(beh,bbI_SkinWidth);
int hierarchy = GetInputParameterValue<int>(beh,bbI_Hierachy);
float newDensity = GetInputParameterValue<float>(beh,bbI_NewDensity);
float totalMass = GetInputParameterValue<float>(beh,bbI_TotalMass);
VxVector massOffset = GetInputParameterValue<VxVector>(beh,bbI_MassShift);
VxVector shapeOffset = GetInputParameterValue<VxVector>(beh,bbI_ShapeShift);
//////////////////////////////////////////////////////////////////////////
// we remove the old physic attribute :
if (referenceObject->HasAttribute(GetPMan()->GetPAttribute()))
{
referenceObject->RemoveAttribute(GetPMan()->GetPAttribute());
}
referenceObject->SetAttribute(GetPMan()->GetPAttribute());
SetAttributeValue<int>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_HIRARCHY,&hierarchy);
SetAttributeValue<int>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_HULLTYPE,&hType);
SetAttributeValue<int>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_BODY_FLAGS,&flags);
SetAttributeValue<float>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_DENSITY,&density);
SetAttributeValue<float>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_NEW_DENSITY,&newDensity);
SetAttributeValue<float>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_TOTAL_MASS,&totalMass);
SetAttributeValue<VxVector>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_MASS_OFFSET,&massOffset);
//SetAttributeValue<VxVector>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_MASS_OFFSET,&massOffset);
//.........这里部分代码省略.........
示例11: GeneralCameraOrbit
int GeneralCameraOrbit(const CKBehaviorContext& behcontext,INPUTPROCESSFUNCTION InputFunction)
{
// Get the behavior
CKBehavior* beh = behcontext.Behavior;
float delta = behcontext.DeltaTime;
// Current state of the behavior
CKBOOL stopping;
// Indicates the behavior we are stopping if returns, stop otherwise
CKBOOL Returns = TRUE;
beh->GetLocalParameterValue(LOCAL_RETURN,&Returns);
// Stop Entrance, we stop
if (beh->IsInputActive(1))
{
// Set IO State
beh->ActivateInput(1,FALSE);
// A protection in case we stop the behavior before having started it
VxVector InitialAngles;
beh->GetLocalParameterValue(LOCAL_INIT,&InitialAngles);
// Get current position
VxVector RotationAngles;
beh->GetLocalParameterValue(LOCAL_ROT,&RotationAngles);
// Stopping Now
stopping = TRUE;
beh->SetLocalParameterValue(LOCAL_STOPPING,&stopping);
if ( !Returns || ((RotationAngles.x == 0) && (RotationAngles.y == 0)) ) {
beh->ActivateOutput(1,TRUE);
return CKBR_OK;
}
}
// Gets the current camera
CKCamera *Camera = (CKCamera *) beh->GetTarget();
if( !Camera ) return CKBR_OWNERERROR;
// Gets the target informations
VxVector TargetPosition;
beh->GetInputParameterValue(IN_TARGET_POS,&TargetPosition);
CK3dEntity* TargetRef = (CK3dEntity*)beh->GetInputParameterObject(IN_TARGET_REF);
//////////////////////////////////////////////
// Gets the input parameters of the behavior
//////////////////////////////////////////////
VxVector InitialAngles(0,0,0), RotationAngles(0,0,0);
// First entrance, sets the initial values here only
if (beh->IsInputActive(0))
{
// Sets IO State
beh->ActivateInput(0,FALSE);
beh->ActivateOutput(0,TRUE);
// Not Stopping
stopping = FALSE;
beh->SetLocalParameterValue(LOCAL_STOPPING,&stopping);
// Compute the Initial Angles, the radius
VxVector InitialPosition;
Camera->GetPosition(&InitialPosition, TargetRef);
InitialPosition -= TargetPosition;
InitialAngles.z = Magnitude(InitialPosition);
if ( InitialAngles.z == 0.0f ) {
InitialAngles.x = 0.0f;
InitialAngles.y = 0.0f;
}
else {
// Vertical Polar Angle
float d;
InitialPosition.Normalize();
d = DotProduct(InitialPosition,VxVector::axisY());
// bound the value of d to avoid errors due to precision.
if (d < -1)
d = -1;
else if (d > 1)
d = 1;
InitialAngles.y = acosf(d);
// Horizontal Polar Angle
InitialPosition.y = 0;
if ( (InitialPosition.x == 0.0f) && (InitialPosition.y == 0.0f) && (InitialPosition.z == 0.0f) )
InitialAngles.x = PI/2;
else {
InitialPosition.Normalize();
d = DotProduct(InitialPosition,VxVector::axisX());
// bound the value of d to avoid eroors due to precision.
if (d < -1)
d = -1;
else if (d > 1)
d = 1;
InitialAngles.x = acosf(d);
d = DotProduct(InitialPosition,VxVector::axisZ());
//.........这里部分代码省略.........
示例12: PVSetMotorValues
int PVSetMotorValues(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
if( beh->IsInputActive(0) )
{
beh->ActivateInput(0,FALSE);
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) bbSErrorME(E_PE_REF);
pRigidBody *body = GetPMan()->getBody(target);
if (!body) bbSErrorME(E_PE_NoBody);
pVehicle *v = body->getVehicle();
if (!v) bbSErrorME(E_PE_NoVeh);
if (!v->isValidEngine())
bbErrorME("Vehicle is not complete");
pEngine *engine = v->getEngine();
if (!engine) bbErrorME("No valid engine");
CK2dCurve* pOCurve = NULL; //optional
BB_DECLARE_PIMAP;//retrieves the parameter input configuration array
BBSParameter(I_XML);//our bb settings concated as s##I_XML
BBSParameter(I_Flags);
BBSParameter(I_Clutch);
BBSParameter(I_tList);
BBSParameter(I_maxRPM);
BBSParameter(I_minRPM);
BBSParameter(I_maxTorque);
BBSParameter(I_intertia);
BBSParameter(I_engineFriction);
BBSParameter(I_breakCoeff);
BBSParameter(I_GroundForceFeedBackScale);
if (sI_XML){
int xmlLink = GetInputParameterValue<int>(beh,BB_IP_INDEX(I_XML));
}
if (sI_GroundForceFeedBackScale)
engine->setForceFeedbackScale(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_GroundForceFeedBackScale)));
if (sI_Flags)
engine->setFlags(GetInputParameterValue<int>(beh,BB_IP_INDEX(I_Flags)));
if (sI_Clutch)
engine->setClutch(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_Clutch)));
if (sI_maxTorque)
engine->setMaxTorque(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_maxTorque)));
if (sI_maxTorque)
engine->setMaxTorque(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_maxTorque)));
if (sI_maxRPM)
engine->setMaxRPM(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_maxRPM)));
if (sI_minRPM)
engine->setIdleRPM(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_minRPM)));
if (sI_engineFriction)
engine->setFriction(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_engineFriction)));
if (sI_intertia)
engine->SetInertia(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_intertia)));
if (sI_breakCoeff)
engine->setBrakingCoeff(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_breakCoeff)));
if (sI_tList){
CKParameterIn *inP = beh->GetInputParameter(BB_IP_INDEX(I_tList));
CKParameter *pout= inP->GetDirectSource();
if (pout)
{
if (engine->getTorqueCurve())
{
pLinearInterpolation &curve = *engine->getTorqueCurve();
curve.clear();
IParameter::Instance()->copyTo(curve,pout);
engine->preStep();
}
}
//engine->setTorqueCurve();
}
//.........这里部分代码省略.........
示例13: BehaviourFunction
/*
*******************************************************************
* Function: int BehaviourFunction()
*
* Description : Returns the number of plugins in this DLL
*
* Paramters :
* CKBehaviorContext& r The virtools behaviour context
*
* Returns : One of the many virtools return values
*
*******************************************************************
*/
int CGBLFileSystem::BehaviourFunction(const CKBehaviorContext& behContext)
{
BOOL error = FALSE;
// Quick bit of error checking
CKBehavior* beh = behContext.Behavior;
CKBeObject* beObject = beh->GetTarget();
int fileSystemBrowseMode = 0;
if (!beObject)
{
error = TRUE;
}
if (!error)
{
// Reset On input, if active
if (beh->IsInputActive(eBehInputOn))
{
beh->ActivateInput(eBehInputOn, FALSE);
// Clear error message output
beh->SetOutputParameterValue(eParamOutputErrorMsg, EMPTY_STRING);
}
// see which mode we are in
beh->GetInputParameterValue(eParamInputMode, &fileSystemBrowseMode);
}
if (!error)
{
// See if we have the special case
char *currentFolder = NULL;
currentFolder = (char*)(beh->GetInputParameterReadDataPtr(eParamInputCurrentFolder));
XString scannedFolder = currentFolder;
if (currentFolder)
{
// special case takes priority over FILES / FOLDER mode
if (strcmp(currentFolder,SPECIAL_CASE)==0)
{
beh->SetOutputParameterValue(eParamOutputScannedFolder, scannedFolder.CStr(),scannedFolder.Length()+1 );
if (fileSystemBrowseMode == eFolder)
{
if (GetLogicalDrives(beh))
{
// Everythings gone ok we have a list of the logical drives
beh->ActivateOutput(eBehOutputDone, TRUE);
}
else
{
// Something went wrong
beh->SetOutputParameterValue(eParamOutputErrorMsg, "Failed To Scan The Logical Drives");
beh->ActivateOutput(eBehOutputError, TRUE);
}
}
else
{
// Cant scan for files in the SPECIAL_CASE
// Get the destination data array and clear it out
CKDataArray* dataArray = static_cast<CKDataArray*>(beh->GetInputParameterObject(eParamInputDataArray));
if (!dataArray)
{
CGBLWidget::OutputBBErrorMsg(beh, "Please attatch an array to the BB");
}
else
{
dataArray->Clear();
dataArray->AddRow();
int currentRow = dataArray->GetRowCount()-1; // 0 index
dataArray->SetElementStringValue(currentRow,NAME_COLUMN,NOT_FOUND);
beh->ActivateOutput(eBehOutputDone, TRUE);
}
}
}
else
{
// add a "\" to the end, it makes the ouput consistent.
int len = strlen (scannedFolder.CStr());
if ((scannedFolder[len-1])!=SINGLE_SEPERATOR)
{
scannedFolder << SINGLE_SEPERATOR;
}
// Try to scan the passed folder
//.........这里部分代码省略.........
示例14: PBGet2
//************************************
// Method: PBGet2
// FullName: PBGet2
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PBGet2(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
using namespace vtTools::BehaviorTools;
if( beh->IsInputActive(0) )
{
//////////////////////////////////////////////////////////////////////////
//the object :
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) return CKBR_OWNERERROR;
//////////////////////////////////////////////////////////////////////////
// the world :
pWorld *world=GetPMan()->getWorldByBody(target);
if (!world)
{
beh->ActivateOutput(0);
return 0;
}
// body exists already ? clean and delete it :
pRigidBody*result = world->getBody(target);
if(result)
{
//////////////////////////////////////////////////////////////////////////
//linear damp :
DWORD cGroup;
beh->GetLocalParameterValue(bbI_CollisionGroup,&cGroup);
if (cGroup)
{
int val = result->getCollisionsGroup();
SetOutputParameterValue<int>(beh,bbI_CollisionGroup,val);
}
DWORD kine;
beh->GetLocalParameterValue(bbI_Kinematic,&kine);
if (kine)
{
int val = result->isKinematic();
SetOutputParameterValue<int>(beh,bbI_Kinematic,val);
}
DWORD gravity;
beh->GetLocalParameterValue(bbI_Gravity,&gravity);
if (gravity)
{
int val = result->getActor()->readBodyFlag(NX_BF_DISABLE_GRAVITY);
SetOutputParameterValue<int>(beh,bbI_Gravity,!val);
}
DWORD col;
beh->GetLocalParameterValue(bbI_Collision,&col);
if (col)
{
int val = result->isCollisionEnabled();
SetOutputParameterValue<int>(beh,bbI_Collision,val);
}
DWORD mass;
beh->GetLocalParameterValue(bbI_MassOffset,&mass);
if (mass)
{
VxVector val = result->getMassOffset();
SetOutputParameterValue<VxVector>(beh,bbI_MassOffset,val);
}
DWORD pivot;
beh->GetLocalParameterValue(bbI_ShapeOffset,&pivot);
if (mass)
{
// VxVector val = result->getPivotOffset();
// SetOutputParameterValue<VxVector>(beh,bbI_ShapeOffset,val);
}
}
beh->ActivateInput(0,FALSE);
beh->ActivateOutput(0);
}
return 0;
}
示例15: PJRevolute
//************************************
// Method: PJRevolute
// FullName: PJRevolute
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PJRevolute(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
using namespace vtTools::BehaviorTools;
if( beh->IsInputActive(0) )
{
beh->ActivateInput(0,FALSE);
//////////////////////////////////////////////////////////////////////////
//the object A:
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
CK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(bI_ObjectB);
if (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_Revolute))
{
return CK_OK;
}
// the world :
pWorld *worldA=GetPMan()->getWorldByBody(target);
pWorld *worldB=GetPMan()->getWorldByBody(targetB);
if (!worldA && ! worldB )
{
return 0;
}
if (!worldA)
{
worldA = worldB;
}
if (!worldA)
{
beh->ActivateOutput(0);
return 0;
}
// the physic object A :
pRigidBody*bodyA= worldA->getBody(target);
pRigidBody*bodyB= worldA->getBody(targetB);
//anchor :
VxVector anchor = GetInputParameterValue<VxVector>(beh,bI_Anchor);
VxVector anchorOut = anchor;
CK3dEntity*anchorReference = (CK3dEntity *) beh->GetInputParameterObject(bI_AnchorRef);
if (anchorReference)
{
anchorReference->Transform(&anchorOut,&anchor);
}
//swing axis
VxVector Axis = GetInputParameterValue<VxVector>(beh,bI_Axis);
VxVector axisOut = Axis;
CK3dEntity*axisReference = (CK3dEntity *) beh->GetInputParameterObject(bI_AxisRef);
if (axisReference)
{
VxVector dir,up,right;
axisReference->GetOrientation(&dir,&up,&right);
axisReference->TransformVector(&axisOut,&up);
}
//////////////////////////////////////////////////////////////////////////
//limit high :
pJointLimit limitH;
pJointLimit limitL;
DWORD limit;
beh->GetLocalParameterValue(1,&limit);
if (limit)
{
CKParameterIn *par = beh->GetInputParameter(bbI_HighLimit);
if (par)
{
CKParameter *rPar = par->GetRealSource();
if (rPar)
{
limitH = pFactory::Instance()->createLimitFromParameter(rPar);
}
}
}
//.........这里部分代码省略.........