//===========================================================================// // File: rp4lbe4.cc // // Project: MUNGA Brick: Red Planet LBE Application // // Contents: // //---------------------------------------------------------------------------// // Date Who Modification // // -------- --- ---------------------------------------------------------- // // // //---------------------------------------------------------------------------// // Copyright (C) 1994, Virtual World Entertainment, Inc. // // All Rights reserved worldwide // // This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL // //===========================================================================// #include #pragma hdrstop #if !defined(BTL4APP_HPP) # include #endif #if !defined(BTREG_HPP) # include #endif #if !defined(APPMGR_HPP) # include #endif #if !defined(BTL4VID_HPP) # include #endif #if !defined(BTL4ARND_HPP) # include #endif #if !defined(BTL4GRND_HPP) # include #endif #if !defined(BTL4MODE_HPP) # include #endif #if !defined(BTL4MSSN_HPP) # include #endif #if !defined(MECH_HPP) # include #endif #if !defined(CAMSHIP_HPP) # include #endif #if !defined(L4MPPR_HPP) # include #endif #if !defined(L4CTRL_HPP) # include #endif // //############################################################################# //############################################################################# // const Receiver::HandlerEntry BTL4Application::MessageHandlerEntries[]= { MESSAGE_ENTRY(BTL4Application, RunMission), MESSAGE_ENTRY(BTL4Application, StopMission) }; BTL4Application::MessageHandlerSet BTL4Application::MessageHandlers( ELEMENTS(BTL4Application::MessageHandlerEntries), BTL4Application::MessageHandlerEntries, L4Application::MessageHandlers ); // //############################################################################# //############################################################################# // Derivation BTL4Application::ClassDerivations( L4Application::ClassDerivations, "BTL4Application" ); BTL4Application::SharedData BTL4Application::DefaultData( BTL4Application::ClassDerivations, BTL4Application::MessageHandlers ); // //############################################################################# //############################################################################# // BTL4Application::BTL4Application( ResourceFile *resource_file, ClassID class_ID, SharedData &shared_data ): L4Application( resource_file, BTL4, class_ID, shared_data ) { DEBUG_STREAM << "BTL4Application::BTL4Application" << endl; } // //############################################################################# //############################################################################# // BTL4Application::~BTL4Application() { } // //############################################################################# // MakeRegistry //############################################################################# // Registry* BTL4Application::MakeRegistry() { Check(this); return new BTRegistry(GetResourceFile()); } // //############################################################################# // MakeVideoRenderer //############################################################################# // VideoRenderer* BTL4Application::MakeVideoRenderer() { Check(this); // // Only build a video renderer when there is a division card // if (!divisionParameters) { return NULL; } return new BTL4VideoRenderer( DefaultRendererRate, MaxRendererComplexity, DefaultRendererPriority, VisualInterestType, 1 ); } // //############################################################################# // MakeAudioRenderer //############################################################################# // AudioRenderer* BTL4Application::MakeAudioRenderer() { Check(this); // // Both sound cards must be present // if (!getenv("AWE_FRONT") || !getenv("AWE_REAR")) { return NULL; } return new BTL4AudioRenderer( GetApplicationManager()->GetFrameRate(), GetMissionReviewMode() ); } // //############################################################################# // MakeModeManager //############################################################################# // ModeManager* BTL4Application::MakeModeManager() { Check(this); return new BTL4ModeManager(BTL4ModeManager::ModeInitial); } // //############################################################################# // MakeControlsManager //############################################################################# // ControlsManager* BTL4Application::MakeControlsManager() { Check(this); LBE4ControlsManager *controls_manager = new LBE4ControlsManager; Check_Pointer(controls_manager); controls_manager->keyboardGroup[LBE4ControlsManager::KeyboardPC].Add( ModeManager::ModeAlwaysActive, this, KeyCommandMessageID, this ); return controls_manager; } // //############################################################################# // MakeGaugeRenderer //############################################################################# // GaugeRenderer* BTL4Application::MakeGaugeRenderer() { Check(this); // // Only build the gauge renderer on a machine with gauge hardware // if (!getenv("L4GAUGE")) { return NULL; } return new BTL4GaugeRenderer; } // //############################################################################# // MakeMission //############################################################################# // Mission* BTL4Application::MakeMission( NotationFile *notation_file, ResourceFile *resources ) { Check(this); return new BTL4Mission(notation_file, resources); } // //############################################################################# // MakeViewpointEntity //############################################################################# // Entity* BTL4Application::MakeViewpointEntity(Entity::MakeMessage *message) { Check(this); LBE4ControlsManager *controls_manager = GetControlsManager(); Entity *viewing_entity = NULL; char *primary_mapping_name = NULL; switch (message->classToCreate) { case CameraShipClassID: //=============================================================== // Create Camera ship //=============================================================== { CameraShip *viewing_camera = CameraShip::Make((CameraShip::MakeMessage*)message); Check(viewing_camera); viewing_entity = viewing_camera; //------------------------------------------------------------ // Create the controls mapping subsystem resource //------------------------------------------------------------ CameraControlsMapper::SubsystemResource control_subsystem_resource; Str_Copy( control_subsystem_resource.subsystemName, "ControlsMapper", sizeof(control_subsystem_resource.subsystemName) ); control_subsystem_resource.classID = TrivialSubsystemClassID; control_subsystem_resource.subsystemModelSize = sizeof(control_subsystem_resource); CameraControlsMapper *camera_mapper; switch (controls_manager->primaryControlType) { case LBE4ControlsManager::PrimaryThrustMaster: camera_mapper = new CameraThrustmasterMapper( viewing_camera, 0, &control_subsystem_resource ); primary_mapping_name = "Thrustmaster"; break; case LBE4ControlsManager::PrimaryRIO: camera_mapper = new CameraRIOMapper( viewing_camera, 0, &control_subsystem_resource ); primary_mapping_name = "L4"; break; default: camera_mapper = new CameraL4Mapper( viewing_camera, 0, &control_subsystem_resource ); break; } //------------------------------------------------------------ // Attach the mapping subsystem to the entity //------------------------------------------------------------ viewing_camera->SetMappingSubsystem(camera_mapper); } break; case MechClassID: //=============================================================== // Create Mech //=============================================================== { Mech *viewing_mech = Mech::Make((Mech::MakeMessage*)message); Check(viewing_mech); viewing_entity = viewing_mech; //------------------------------------------------------------ // Control deadbanding //------------------------------------------------------------ controls_manager->SetJoystickDeadBand(0.05f); controls_manager->SetThrottleDeadBand(0.05f); controls_manager->SetPedalsDeadBand(0.05f); MechControlsMapper *mech_mapper; switch (controls_manager->primaryControlType) { case LBE4ControlsManager::PrimaryThrustMaster: mech_mapper = new MechThrustmasterMapper( viewing_mech, 0, "ControlsMapper" ); primary_mapping_name = "Thrustmaster"; break; case LBE4ControlsManager::PrimaryRIO: mech_mapper = new MechRIOMapper( viewing_mech, 0, "ControlsMapper" ); primary_mapping_name = "L4"; break; default: DEBUG_STREAM << "*****Mech has no controls mapping!*****"; Fail("BTL4Application::MakeViewpointEntity"); mech_mapper = NULL; break; } //------------------------------------------------------------ // Attach the mapping subsystem to the entity //------------------------------------------------------------ viewing_mech->SetMappingSubsystem(mech_mapper); viewing_mech->StartCollisionAssistant(); } break; } //------------------------------------------------------------------- // Load the control mappings for the entity //------------------------------------------------------------------- if (primary_mapping_name) { ResourceDescription *description = application->GetResourceFile()->SearchList( viewing_entity->GetResourceID(), ResourceDescription::ControlMappingsListResourceType ); if (description) { description = GetResourceFile()->SearchList( description->resourceID, primary_mapping_name ); if (description) { description->Lock(); GetControlsManager()->CreateStreamedMappings( viewing_entity, (int*)description->resourceAddress ); description->Unlock(); } } } //------------------------------------------------------------------- // Configure the gauges for the entity //------------------------------------------------------------------- if (GetGaugeRenderer()) { GetGaugeRenderer()->ConfigureForModel("Init", viewing_entity); } return viewing_entity; } // //############################################################################# // RunMissionMessageHandler //############################################################################# // void BTL4Application::RunMissionMessageHandler(RunMissionMessage *message) { DEBUG_STREAM << "BTL4Application::RunMissionMessageHandler" << endl; GetModeManager()->AddModeMask(BTL4ModeManager::ModePlasmaDisplay); DEBUG_STREAM << "Turning Plasma Score Display On" << endl; L4Application::RunMissionMessageHandler(message); } // //############################################################################# // StopMissionMessageHandler //############################################################################# // void BTL4Application::StopMissionMessageHandler(StopMissionMessage *message) { GetModeManager()->RemoveModeMask(BTL4ModeManager::ModePlasmaDisplay); L4Application::StopMissionMessageHandler(message); DEBUG_STREAM << "Turning Plasma Score Display Off" << endl; }