Advertisement
Guest User

Untitled

a guest
Sep 24th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.54 KB | None | 0 0
  1. void CCharacterMovement::Physicalize()
  2. {
  3.     IEntity &entity = *GetEntity();
  4.     // Physicalize the player as type Living.
  5.     // This physical entity type is specifically implemented for players
  6.     SEntityPhysicalizeParams physParams;
  7.     physParams.type = PE_RIGID;
  8.     physParams.nSlot = CCharacter::eGeometry_Character;
  9.     physParams.mass = m_pCharacter->GetCVars().m_mass;
  10.     //physParams.nFlagsAND = pef_log_collisions | pef_monitor_collisions;
  11.     //physParams.nFlagsOR = geom_collides | geom_colltype_player;
  12.  
  13.     //pe_player_dimensions playerDimensions;
  14.  
  15.     //// Prefer usage of a cylinder instead of capsule
  16.     //playerDimensions.bUseCapsule = 0;
  17.  
  18.     //// Specify the size of our cylinder
  19.     //playerDimensions.sizeCollider = Vec3(0.3f, 0.3f, 1.0f);
  20.  
  21.     //// Keep pivot at the player's feet (defined in player geometry)
  22.     //playerDimensions.heightPivot = 0.0f;
  23.     //// Offset collider upwards
  24.     //playerDimensions.heightCollider = 1.0f;
  25.     //playerDimensions.groundContactEps = 0.004f;
  26.  
  27.     //physParams.pPlayerDimensions = &playerDimensions;
  28.  
  29.  
  30.     //pe_player_dynamics playerDynamics;
  31.     //playerDynamics.kAirControl = 0.f;
  32.     //playerDynamics.mass = physParams.mass;
  33.     //playerDynamics.kInertia = 0.01f;
  34.     ////playerDynamics.collTypes = collision_class_game | collision_class_terrain;
  35.  
  36.     //physParams.pPlayerDynamics = &playerDynamics;
  37.  
  38.  
  39.     entity.Physicalize(physParams);
  40.     entity.EnablePhysics(true);
  41.    
  42.     pe_geomparams gp;
  43.     gp.flags = geom_colltype_solid;
  44.     gp.flagsCollider = geom_colltype1;
  45.     gp.mass = 10.0f;
  46.     gp.density = 0.0f;
  47.    
  48.  
  49.     primitives::capsule capsule;
  50.     capsule.center = Vec3(0.0f,0.0f,1.0f);
  51.     capsule.r = 0.5f;
  52.     capsule.hh = 0.5f;
  53.     capsule.axis = Vec3(0.0f, 0.0f, 1.0f);
  54.    
  55.  
  56.     IGeometry *pcaps = gEnv->pPhysicalWorld->GetGeomManager()->CreatePrimitive(primitives::capsule::type, &capsule);
  57.     phys_geometry *pGeom = gEnv->pPhysicalWorld->GetGeomManager()->RegisterGeometry(pcaps);
  58.     pcaps->Release();
  59.     entity.GetPhysics()->AddGeometry(pGeom, &gp);
  60.     pGeom->nRefCount--;
  61.  
  62.     pe_simulation_params pa;
  63.     pa.maxRotVel = 0.0f;
  64.     entity.GetPhysics()->SetParams(&pa);
  65.    
  66.  
  67.     //pe_action_add_constraint ic;
  68.     //ic.pBuddy = entity.GetPhysics();
  69.     //ic.flags = constraint_no_rotation;
  70.     //ic.pt[0].Set(0, 0, 0);
  71.     //ic.damping = 1.0f;
  72.     ////ic.pt[1].Set(0, 0, 1);
  73.     //ic.xlimits[0] = 0.0f;
  74.     //ic.xlimits[1] = 0.0f;
  75.     //ic.yzlimits[0] = 0.0f;
  76.     //ic.yzlimits[1] = 0.0f;
  77.  
  78.     //pe_action_update_constraint updateConst;
  79.     //updateConst.flagsAND = constraint_no_rotation;
  80.     //updateConst.idConstraint = 1;
  81.  
  82.     //entity.GetPhysics()->Action(&ic);
  83.     //entity.GetPhysics()->Action(&updateConst);
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement