/* ------------------------------------------------------------------------------------ */ CPathFollower::CPathFollower() { m_PathFollowerCount = 0; geEntity_EntitySet *pSet; geEntity *pEntity; // Ok, check to see if there are path followers in this world pSet = geWorld_GetEntitySet(CCD->World(), "PathFollower"); if(!pSet) return; // No path followers // Ok, dig through 'em all. for(pEntity=geEntity_EntitySetGetNextEntity(pSet, NULL); pEntity; pEntity=geEntity_EntitySetGetNextEntity(pSet, pEntity)) { PathFollower *pFollower = (PathFollower*)geEntity_GetUserData(pEntity); pFollower->bMoving = GE_FALSE; // Not moving pFollower->bReady = GE_TRUE; // Ready for action! pFollower->bTriggered = GE_FALSE; // Not triggered pFollower->TimeInMotion = 0.0f; // Not in motion yet pFollower->bForward = GE_TRUE; // Will move FORWARD // Ok, we need to find the origin of the first pathpoint so we know // ..where to initially move our bound entity to... char *szType = CCD->EntityRegistry()->GetEntityType(pFollower->EntityName); if(szType == NULL) { // We'll consider this a modest error char szBug[132]; sprintf(szBug, "[WARNING] File %s - Line %d: Missing bound entity '%s' in registry\n", __FILE__, __LINE__, pFollower->EntityName); CCD->ReportError(szBug, false); continue; // Maybe the next one will be OK } // Ok, get the pathpoint name and retrieve the location of the // ..path head. This will be where we initially move the entity // ..to. Also, at this time, get the location of the next point // ..in the path (if any) and store that as our target point CCD->PathDatabase()->Locate(pFollower->PathFirstNode, &pFollower->CurrentNodeType, &pFollower->PathOrigin, &pFollower->PointRange); pFollower->CurrentPosition = pFollower->PathOrigin; if(pFollower->CurrentNodeType != RGF_POINT_TYPE_RANGED) { // Not a ranged point, get the location of our first target // ..node. pFollower->PathHandle = CCD->PathDatabase()->OpenPath(pFollower->PathFirstNode, &pFollower->PathOrigin); CCD->PathDatabase()->NextPoint(pFollower->PathHandle, &pFollower->CurrentTarget); } else { // For a ranged node, compute a random target to move towards inside // ..the range sphere. srand(CCD->FreeRunningCounter()); geVec3d RandomPosition; RandomPosition.X = (geFloat)(rand() % (int)pFollower->PointRange); if(rand()%2 == 1) RandomPosition.X = -(RandomPosition.X); RandomPosition.Y = (geFloat)(rand() % (int)pFollower->PointRange); if(rand()%2 == 1) RandomPosition.Y = -(RandomPosition.Y); RandomPosition.Z = (geFloat)(rand() % (int)pFollower->PointRange); if(rand()%2 == 1) RandomPosition.Z = -(RandomPosition.Z); pFollower->CurrentTarget = RandomPosition; } int nTypeID = TypeNameToIndex(szType); // Turn string to index # // At this point, we need to inform the appropriate component that one // ..of their entities will be bound to a motion path. The number of // ..bindable entities is relatively small, so we'll just do the old // ..'switch and call' method. switch(nTypeID) { // Effect case 0: // MorphingField if(CCD->MorphingFields()->BindToPath(pFollower->EntityName) != RGF_SUCCESS) { char szBug[128]; sprintf(szBug, "[WARNING] Failed to bind MorphingField entity '%s' to path '%s'\n", pFollower->EntityName, pFollower->PathFirstNode); CCD->ReportError(szBug, false); } break; case 1: // StaticEntityProxy if(CCD->Props()->BindToPath(pFollower->EntityName) != RGF_SUCCESS) { char szBug[128]; sprintf(szBug, "[WARNING] Failed to bind StaticEntityProxy entity '%s' to path '%s'\n", pFollower->EntityName, pFollower->PathFirstNode); CCD->ReportError(szBug, false); } break; case 2: // TeleportTarget if(CCD->Teleporters()->BindToPath(pFollower->EntityName) != RGF_SUCCESS) { char szBug[128]; sprintf(szBug, "[WARNING] Failed to bind TeleportTarget entity '%s' to path '%s'\n", pFollower->EntityName, pFollower->PathFirstNode); CCD->ReportError(szBug, false); } break; default: { char szBug[128]; sprintf(szBug, "[WARNING] Attempt to bind nonbindable entity '%s' type '%s' to path\n", pFollower->EntityName, szType); CCD->ReportError(szBug, false); } break; } // If there are no triggers for the motion, auto-start it when we load. if((pFollower->Trigger == NULL) && (pFollower->RangeTrigger == 0.0f)) { pFollower->bTriggered = GE_TRUE; // Auto-start motion on load pFollower->LastMotionTick = CCD->FreeRunningCounter_F(); pFollower->bMoving = GE_TRUE; } m_PathFollowerCount++; } return; }
PdfAction::PdfAction( const PdfAction & rhs ) : PdfElement( "Action", rhs.GetNonConstObject() ) { m_eType = static_cast<EPdfAction>(TypeNameToIndex( this->GetObject()->GetDictionary().GetKeyAsName( "S" ).GetName().c_str(), s_names, s_lNumActions, ePdfAction_Unknown )); }
PdfAnnotation::PdfAnnotation( PdfObject* pObject, PdfPage* pPage ) : PdfElement( "Annot", pObject ), m_eAnnotation( ePdfAnnotation_Unknown ), m_pAction( NULL ), m_pFileSpec( NULL ), m_pPage( pPage ) { m_eAnnotation = static_cast<EPdfAnnotation>(TypeNameToIndex( m_pObject->GetDictionary().GetKeyAsName( PdfName::KeySubtype ).GetName().c_str(), s_names, s_lNumActions )); }
PdfAction::PdfAction( PdfObject* pObject ) // The typename /Action is optional for PdfActions : PdfElement( NULL, pObject ) { m_eType = static_cast<EPdfAction>(TypeNameToIndex( this->GetObject()->GetDictionary().GetKeyAsName( "S" ).GetName().c_str(), s_names, s_lNumActions, ePdfAction_Unknown )); }