void cf::GameSys::GameImplT::Initialize(bool AsClient, bool AsServer, ModelManagerT& ModelMan) { mWeapon = new WeaponT(&ModelMan, "DesertEagle", 0); RunningAsClient=AsClient; RunningAsServer=AsServer; if (RunningAsClient) { // We can initialize most MatSys-related resources only AFTER the global pointers have been set: // MatSys::Renderer, MatSys::TextureMapManager, and MaterialSystem. // These point to the implementations that are provided by the engine main exe module, // and are accessed e.g. by the models and particles constructors. ResMan.Init(); // Materials that should be pre-cached (as many as possible) must be registered with the MatSys *before* the engine triggers the MatSys's pre-caching. // On the other hand, registering materials can only be done *after* GetGame() was called. // So a good place for registering materials that we need within this DLL is for example at the end of GetGame(), or right here. // Registering the materials that our models will use is quite easy, because we just need to find them in the ModelMan each. // (Nothing breaks if the following list is simply deleted, these models just aren't pre-cached then.) // // It *is* however quite stupid that this list is not more tighly coupled to the relevant entity classes. // However, as the time of entity creation (and thus first model access and thus material registry time) is essentially unknown, // it seems simplest to list the models desired for pre-caching right here. // // Another curiosity that I just noticed: Not pre-caching here means not only to register the materials later (on first use), // but also to effectively load and initialize the models only at that later time, what might be very expensive, too! { // And the rest. Observe that static detail models are NOT mentioned (how could they?). ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_torso_1.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_torso_2.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_torso_3.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_head_1.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_head_2.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_weapon_1.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_weapon_2.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_movement_1.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_movement_2.cmdl"); } // Precache all sounds known to be used here. m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/9mm_Shot"))); m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/Shotgun_Shot"))); m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/GLauncher_Shot"))); } if (RunningAsServer) { } }
void NodeManagerPrimitive::EchoCoordinates (ModelManagerT& theInput) { iArrayT map; fCoordinates = theInput.Coordinates (); theInput.AllNodeIDs (map); fNumInitCoordinates = fCoordinates.MajorDim(); out << " Number of nodal points. . . . . . . . . . . . . = " << fNumInitCoordinates << '\n'; out << " Number of nodal degrees of freedom. . . . . . . = " << fCoordinates.MinorDim() << endl << endl; }
void NodeManagerPrimitive::EchoNodeSets (ModelManagerT& model, MakeCSE_IOManager& theInput) { /* read in nodes set that are to be transferred */ theInput.NodeSetsMapped (fNodeSetID, fTransMethods); fNodeSetData.Allocate (fNodeSetID.Length()); out << "\n N o d e S e t D a t a :\n\n"; out << " Number of Node Sets . . . . . . . . . . . . . . = " << fNodeSetData.Length() << endl; /* read node sets */ for (int i=0; i < fNodeSetData.Length(); i++) { fNodeSetData[i] = model.NodeSet (fNodeSetID[i]); out << " Node Set . . . . . . . . . . . . . . . . . . . = " << fNodeSetID[i] << '\n'; out << " Number of Nodes in Set. . . . . . . . . . . . = " << fNodeSetData[i].Length() << '\n'; } out << " Node Set Transfer Methods . . . . . . . . . . . = " << fTransMethods.Length() << '\n'; out << " Method Set ID\n"; for (int g=0; g < fNodeSetID.Length(); g++) out << setw (kIntWidth) << fTransMethods[g] << setw (kIntWidth) << fNodeSetID[g] << '\n'; /* checks */ bool okay = true; if (fTransMethods.Length() < 0) okay = false; for (int t=0; t < fTransMethods.Length() && okay; t++) if (fTransMethods[t] < CSEConstants::kSurface1 || fTransMethods[t] > CSEConstants::kSplit) okay = false; if (!okay) { cout << "Invalid Node Transfer Method" << endl; throw ExceptionT::kBadInputValue; } }
CarriedWeaponPistolT::CarriedWeaponPistolT(ModelManagerT& ModelMan) : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Beretta/Beretta_v.cmdl"), ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Beretta/Beretta_p.cmdl")) { }
CarriedWeapon357T::CarriedWeapon357T(ModelManagerT& ModelMan) : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/DesertEagle/DesertEagle_v.cmdl"), ModelMan.GetModel("Games/DeathMatch/Models/Weapons/DesertEagle/DesertEagle_p.cmdl")), FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/DesertEagle_Shot1"))) { }
/* accept parameter list */ void ThermomechanicalCouplingManagerT::TakeParameterList(const ParameterListT& list) { const char caller[] = "ThermomechanicalCouplingManagerT::TakeParameterList"; /* inherited */ // MultiManagerT::TakeParameterList(list); /* inherited - don't call direct base class method */ ParameterInterfaceT::TakeParameterList(list); /* path to parameters file */ StringT path; path.FilePath(fInputFile); TaskT task = kRun; /* parse/validate continuum input */ StringT continuum_input = list.GetParameter("continuum_input"); continuum_input.ToNativePathName(); continuum_input.Prepend(path); ParameterListT continuum_params; ParseInput(continuum_input, continuum_params, true, true, true, fArgv); /* construct continuum solver */ if (fCoarseComm->Size() != 1) ExceptionT::GeneralFail(caller, "parallel execution error"); if (Size() > 1) /* change file name so output files are unique */ { StringT suffix; suffix.Suffix(continuum_input); continuum_input.Root(); continuum_input.Append(".p", Rank()); continuum_input.Append(suffix); } StringT continuum_output_file; continuum_output_file.Root(continuum_input); continuum_output_file.Append(".out"); fCoarseOut.open(continuum_output_file); fCoarse = TB_DYNAMIC_CAST(FEManagerT_bridging*, FEManagerT::New(continuum_params.Name(), continuum_input, fCoarseOut, *fCoarseComm, fArgv, task)); if (!fCoarse) ExceptionT::GeneralFail(caller, "could not construct continuum solver"); fCoarse->TakeParameterList(continuum_params); /* parse/validate atomistic input */ StringT atom_input = list.GetParameter("atom_input"); atom_input.ToNativePathName(); atom_input.Prepend(path); ParameterListT atom_params; ParseInput(atom_input, atom_params, true, true, true, fArgv); /* construct atomistic solver */ if (Size() != fFineComm->Size()) ExceptionT::GeneralFail(caller, "parallel execution error"); StringT atom_output_file; atom_output_file.Root(atom_input); if (Size() > 1) atom_output_file.Append(".p", Rank()); atom_output_file.Append(".out"); fFineOut.open(atom_output_file); fFine = TB_DYNAMIC_CAST(FEManagerT_bridging*, FEManagerT::New(atom_params.Name(), atom_input, fFineOut, *fFineComm, fArgv, task)); if (!fFine) ExceptionT::GeneralFail(caller, "could not construct atomistic solver"); fFine->TakeParameterList(atom_params); /* check consistency between time managers */ TimeManagerT* atom_time = fFine->TimeManager(); TimeManagerT* continuum_time = fCoarse->TimeManager(); /* use parameters from coarse scale solver */ fTimeManager = fCoarse->TimeManager(); fOutputFormat = fCoarse->OutputFormat(); /* don't compute initial conditions */ fFine->SetComputeInitialCondition(false); fCoarse->SetComputeInitialCondition(false); /* resolve bridging fields */ const StringT& bridging_field = list.GetParameter("bridging_field"); fFineField = fFine->NodeManager()->Field(bridging_field); if (!fFineField) ExceptionT::GeneralFail(caller, "could not resolve fine scale \"%s\" field", bridging_field.Pointer()); fCoarseField = fCoarse->NodeManager()->Field(bridging_field); if (!fFineField) ExceptionT::GeneralFail(caller, "could not resolve coarse scale \"%s\" field", bridging_field.Pointer()); /* resolve integrator types */ // if (fFineField->Integrator().ImplicitExplicit() != fCoarseField->Integrator().ImplicitExplicit()) // ExceptionT::GeneralFail(caller, "time integrator mismatch"); fImpExp = fFineField->Integrator().ImplicitExplicit(); /* collect the ghost atom ID list */ ArrayT<StringT> ghost_atom_ID; const ParameterListT* ghosts = list.List("ghost_atom_ID_list"); if (ghosts) StringListT::Extract(*ghosts, ghost_atom_ID); /* configure projection/interpolation */ NodeManagerT& fine_node_manager = *(fFine->NodeManager()); int group = 0; int order1 = 0; bool make_inactive = true; bool node_to_node = false; fFine->InitGhostNodes(fFineField->FieldName(), ghost_atom_ID, fCoarse->ProjectImagePoints()); fCoarse->InitInterpolation(fFineField->FieldName(), fFine->GhostNodes(), fine_node_manager.InitialCoordinates()); fCoarse->InitProjection(fFineField->FieldName(), *(fFine->CommManager()), fFine->NonGhostNodes(), fine_node_manager, make_inactive, node_to_node); /* send coarse/fine output through the fFine output */ int ndof = fFine->NodeManager()->NumDOF(group); ArrayT<StringT> labels(2*ndof); const char* coarse_labels[] = {"UC_X", "UC_Y", "UC_Z"}; const char* fine_labels[] = {"UF_X", "UF_Y", "UF_Z"}; int dex = 0; for (int i = 0; i < ndof; i++) labels[dex++] = coarse_labels[i]; for (int i = 0; i < ndof; i++) labels[dex++] = fine_labels[i]; const iArrayT& non_ghost_nodes = fFine->NonGhostNodes(); fAtomConnectivities.Alias(non_ghost_nodes.Length(), 1, non_ghost_nodes.Pointer()); OutputSetT output_set(GeometryT::kPoint, fAtomConnectivities, labels, false); fOutputID = fFine->RegisterOutput(output_set); /* construct solver */ int n1 = fFine->NumGroups(); int n2 = fCoarse->NumGroups(); // if (n1 != n2) ExceptionT::GeneralFail(caller, "number of groups must match: %d != %d", n1, n2); const ParameterListT* multi_solver = list.ListChoice(*this, "multi_solver_choice"); if (multi_solver) { /* construct */ SolverT* solver = SolverT::New(*this, multi_solver->Name(), 0); if (!solver) ExceptionT::GeneralFail(caller, "could not construct solver \"%s\"", multi_solver->Name().Pointer()); solver->TakeParameterList(*multi_solver); /* store */ fSolvers.Dimension(1); fSolvers[0] = solver; } SetSolver(); /* default solver phases */ fMaxSolverLoops = 1; fSolverPhases.Dimension(1, 3); fSolverPhases(0,0) = 0; fSolverPhases(0,1) =-1; fSolverPhases(0,2) =-1; fSolverPhasesStatus.Dimension(fSolverPhases.MajorDim(), kNumStatusFlags); fSolverPhasesStatus = 0; /* terms to include in the equilibrium equations */ fFineToCoarse = list.GetParameter("fine_to_coarse"); fCoarseToFine = list.GetParameter("coarse_to_fine"); if (fCoarseToFine) /* enforce zero bond density in projected cells */ fCoarse->DeactivateFollowerCells(); /* needed to solve overlap */ const dArray2DT& fine_init_coords = fine_node_manager.InitialCoordinates(); const ParticlePairT* particle_pair = fFine->ParticlePair(); if (!particle_pair) ExceptionT::GeneralFail(caller, "could not resolve ParticlePairT"); /* overlap correction method */ StringT overlap_path; const ParameterT* overlap_file = list.Parameter("overlap_file"); if (overlap_file) { overlap_path = *overlap_file; overlap_path.ToNativePathName(); StringT path; path.FilePath(fInputFile); overlap_path.Prepend(path); } /* default name */ else { overlap_path.Root(fInputFile); overlap_path.Append(".overlap"); } const ParameterListT& overlap = list.GetListChoice(*this, "overlap_correction_choice"); if (overlap.Name() == "prescribe_overlap") { double density = overlap.GetParameter("bond_density"); cout << "\n " << caller << ": \"prescribe_overlap\" not implemented. p = 1.0" << endl; } else if (overlap.Name() == "by-bond_multiplier") { /* extract parameters */ double smoothing = overlap.GetParameter("smoothing"); double bind_1 = overlap.GetParameter("bind_to_1.0"); double reg = overlap.GetParameter("constraint_regularization"); int nip = overlap.GetParameter("density_nip"); double init_bound_width = overlap.GetParameter("init_bound_width"); /* compute overlap correction */ double bound_0 = init_bound_width/2.0; fCoarse->CorrectOverlap_2(particle_pair->Neighbors(), fine_init_coords, overlap_path, smoothing, bind_1, reg, bound_0, nip); } else if (overlap.Name() == "by-bond_penalty") { /* extract parameters */ double smoothing = overlap.GetParameter("smoothing"); double bind_1 = overlap.GetParameter("bind_to_1.0"); double bound_tol = overlap.GetParameter("bound_tolerance"); double stiffness_jump = overlap.GetParameter("stiffness_jump"); int nip = overlap.GetParameter("density_nip"); /* compute overlap correction */ fCoarse->CorrectOverlap_22(particle_pair->Neighbors(), fine_init_coords, overlap_path, smoothing, bind_1, bound_tol, stiffness_jump, nip); } else ExceptionT::GeneralFail(caller, "unrecognized overlap correction method \"%s\"", overlap.Name().Pointer()); /* output for kinetic temperature */ ModelManagerT* model = fCoarse->ModelManager(); ArrayT<StringT> vlabels(1); const char* label[] = {"kT"}; vlabels[0] = label[0]; /* specify output - "free set" */ const char* id = "1"; StringT ID ; // HACK ID = fCoarse->ElementGroup(0)->ElementBlockID(1); OutputSetT coarse_output_set(model->ElementGroupGeometry(ID), model->ElementGroup(ID), vlabels); fCoarseOutputID = fCoarse->RegisterOutput(coarse_output_set); /* find particle class */ for (int i = 0; i < fFine->NumElementGroups(); i++) { ElementBaseT* element_base = fFine->ElementGroup(i); ParticleT* particle = dynamic_cast<ParticleT*>(element_base); if (particle) { fParticles = particle; } } }
CarriedWeaponGaussT::CarriedWeaponGaussT(ModelManagerT& ModelMan) : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Gauss/Gauss_v.cmdl"), ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Gauss/Gauss_p.cmdl")) { }