// IFINDAGMOD (sceneObject) // See if there's an ag modifier on this sceneobject. // Doesn't check for multiples; just returns the first one. plAGModifier * plAGMasterMod::IFindChannelMod(const plSceneObject *SO, const plString &name) const { const plCoordinateInterface * CI = SO->GetCoordinateInterface(); const plAGModifier * constMod = static_cast<const plAGModifier *>(FindModifierByClass(SO, plAGModifier::Index())); plAGModifier * mod = const_cast<plAGModifier *>(constMod); if(mod) { plString modName = mod->GetChannelName(); if(modName.Compare(name, plString::kCaseInsensitive) == 0) return mod; } if(CI) { int childCount = CI->GetNumChildren(); for (int i = 0; i < childCount; i++) { const plSceneObject * subChild = CI->GetChild(i)->GetOwner(); plAGModifier * mod = IFindChannelMod(subChild, name); if(mod) return mod; } } return nil; }
void plAvBrainSwim::IStartSwimming(bool is2D) { // if we *were* wading, the next brain will be running as well. turn it off // if we weren't wading, there's no harm in suspending it redundantly. plArmatureBrain *nextBrain = fAvMod->GetNextBrain(this); nextBrain->Suspend(); if (!fSwimStrategy) { plSceneObject * avObj = fArmature->GetTarget(0); plAGModifier *agMod = const_cast<plAGModifier*>(plAGModifier::ConvertNoRef(FindModifierByClass(avObj, plAGModifier::Index()))); plPhysicalControllerCore *controller = fAvMod->GetController(); fSwimStrategy = new plSwimStrategy(agMod->GetApplicator(kAGPinTransform), controller); } fSwimStrategy->Reset(false); if (is2D) fMode = kSwimming2D; else fMode = kSwimming3D; if (fAvMod->IsLocalAvatar()) { plCameraMsg* pMsg = new plCameraMsg; pMsg->SetBCastFlag(plMessage::kBCastByExactType); pMsg->SetBCastFlag(plMessage::kNetPropagate, false); pMsg->SetCmd(plCameraMsg::kResponderSetThirdPerson); pMsg->Send(); } }
void plAvBrainRideAnimatedPhysical::Activate(plArmatureModBase *avMod) { plArmatureBrain::Activate(avMod); IInitAnimations(); if (!fCallbackAction) { plSceneObject* avObj = fArmature->GetTarget(0); plAGModifier* agMod = const_cast<plAGModifier*>(plAGModifier::ConvertNoRef(FindModifierByClass(avObj, plAGModifier::Index()))); plPhysicalControllerCore* controller = avMod->GetController(); fCallbackAction = new plRidingAnimatedPhysicalController(avObj, agMod->GetApplicator(kAGPinTransform), controller); fCallbackAction->ActivateController(); } }
// this is a little gross...the armature component shouldn't know that the subclasses // actually exist....it's a hard-to-detect implementation detail that breaks new subclasses.... bool plArmatureComponent::Convert(plMaxNode* node, plErrorMsg *pErrMsg) { // plHKPhysical *physical = plHKPhysical::ConvertToPhysical(node->GetSceneObject()); // physical->SetProperty(plSimulationInterface::kUpright, true); IAttachModifiers(node, pErrMsg); ISetupClothes(node, fArmMod, pErrMsg); // ArmatureEffects plArmatureEffectsMgr *effects = new plArmatureEffectsMgr(); hsgResMgr::ResMgr()->NewKey(IGetUniqueName(node), effects, node->GetLocation()); plGenRefMsg *msg = new plGenRefMsg(fArmMod->GetKey(), plRefMsg::kOnCreate, -1, -1); hsgResMgr::ResMgr()->AddViaNotify(effects->GetKey(), msg, plRefFlags::kActiveRef); // Attach effects plSceneObject *obj = node->GetSceneObject(); node->MakeCharacterHierarchy(pErrMsg); const plAGModifier *temp = static_cast<const plAGModifier *>(FindModifierByClass(obj, plAGModifier::Index())); plAGModifier *agMod = const_cast<plAGModifier *>(temp); hsAssert(agMod, "Armature root didn't get a agmod. I'll make one for you."); if( ! agMod) { // MakeCharacterHierarchy will attach agmodifiers to all the bones in the hierarchy; // have to manually add any for non-bone objects... agMod = new plAGModifier("Handle"); // the player root is known as the handle node->AddModifier(agMod, IGetUniqueName(node)); } agMod->SetChannelName("Handle"); // Get the position and radius of the head and torso physicals if (ClassID() == AVATAR_CLASS_ID || ClassID() == LOD_AVATAR_CLASS_ID) { bool isLOD = ((ClassID() == LOD_AVATAR_CLASS_ID) != 0); float height = fCompPB->GetFloat(isLOD ? plLODAvatarComponent::kPhysicsHeight : plAvatarComponent::kPhysicsHeight); float width = fCompPB->GetFloat(isLOD ? plLODAvatarComponent::kPhysicsWidth : plAvatarComponent::kPhysicsWidth); fArmMod->SetPhysicalDims(height, width); } // node->SetupBonesAliasesRecur(node->GetKey()->GetName()); return true; }
void plAvBrainCritter::Activate(plArmatureModBase* avMod) { plArmatureBrain::Activate(avMod); // initialize our base "Run" and "Idle" behaviors IInitBaseAnimations(); // create the controller if we haven't done so already if (!fCallbackAction) { plSceneObject* avObj = fArmature->GetTarget(0); plAGModifier* agMod = const_cast<plAGModifier*>(plAGModifier::ConvertNoRef(FindModifierByClass(avObj, plAGModifier::Index()))); plPhysicalControllerCore* controller = avMod->GetController(); fCallbackAction = new plWalkingController(avObj, agMod->GetApplicator(kAGPinTransform), controller); fCallbackAction->ActivateController(); } // tell people that care that we are good to go plAIBrainCreatedMsg* brainCreated = new plAIBrainCreatedMsg(fArmature->GetKey()); plgDispatch::MsgSend(brainCreated); }