void pEngine::setToDefault() { char buf[128],fname[128]; position.Set(0,0,0); size = 0.0f; maxRPM = 8000; idleRPM = 1110; mass = 0.0f; // Physical attribs #ifdef OBS sprintf(buf,"%s.rolling_friction_coeff",path); rollingFrictionCoeff=info->GetFloat(buf); #endif torqueReaction=1.0f; maxTorque=468; SetInertia(0.35f); #ifdef OBS sprintf(buf,"%s.inertia.final_drive",path); inertiaDriveShaft=info->GetFloat(buf); #endif friction=0.0f; brakingCoeff=3.3f; //flags|=HAS_STARTER; // if(info->GetInt(buf,1)) // flags|=START_STALLED; // sprintf(buf,"%s.starter_torque",path); starterTorque=90.0f; stallRPM=400.0f; stallRPM=1250.0f; autoClutchRPM=1250.0f; //flags|=AUTOMATIC; flags|=AUTOCLUTCH_ACTIVE; PreCalculate(); }
void CPhysicsObject::InitFromTemplate( CPhysicsEnvironment *pEnvironment, void *pGameData, const vphysics_save_cphysicsobject_t &objectTemplate ) { m_collideType = objectTemplate.collideType; IVP_Template_Real_Object ivpObjectTemplate; IVP_U_Quat rotation; IVP_U_Point pos; ConvertRotationToIVP( objectTemplate.angles, rotation ); ConvertPositionToIVP( objectTemplate.origin, pos ); ivpObjectTemplate.mass = objectTemplate.mass; if ( objectTemplate.materialIndex >= 0 ) { ivpObjectTemplate.material = physprops->GetIVPMaterial( objectTemplate.materialIndex ); } else { ivpObjectTemplate.material = physprops->GetIVPMaterial( physprops->GetSurfaceIndex( "default" ) ); } Assert( ivpObjectTemplate.material ); // HACKHACK: Pass this name in for debug ivpObjectTemplate.set_name(objectTemplate.pName); ivpObjectTemplate.set_nocoll_group_ident( NULL ); ivpObjectTemplate.physical_unmoveable = objectTemplate.isStatic ? IVP_TRUE : IVP_FALSE; ivpObjectTemplate.rot_inertia_is_factor = IVP_TRUE; ivpObjectTemplate.rot_inertia.set( 1,1,1 ); ivpObjectTemplate.rot_speed_damp_factor.set( objectTemplate.rotSpeedDamping, objectTemplate.rotSpeedDamping, objectTemplate.rotSpeedDamping ); ivpObjectTemplate.speed_damp_factor = objectTemplate.speedDamping; IVP_U_Matrix massCenterMatrix; massCenterMatrix.init(); const Vector *massOverride = 0; if ( objectTemplate.massCenterOverride != vec3_origin ) { IVP_U_Point center; ConvertPositionToIVP( objectTemplate.massCenterOverride, center ); massCenterMatrix.shift_os( ¢er ); ivpObjectTemplate.mass_center_override = &massCenterMatrix; massOverride = &objectTemplate.massCenterOverride; } IVP_Real_Object *realObject = NULL; if ( m_collideType == COLLIDE_BALL ) { IVP_Template_Ball ballTemplate; ballTemplate.radius = ConvertDistanceToIVP( objectTemplate.sphereRadius ); realObject = pEnvironment->GetIVPEnvironment()->create_ball( &ballTemplate, &ivpObjectTemplate, &rotation, &pos ); } else { const IVP_Compact_Surface *pSurface = (const IVP_Compact_Surface *)objectTemplate.pCollide; IVP_SurfaceManager_Polygon *surman = new IVP_SurfaceManager_Polygon( pSurface ); realObject = pEnvironment->GetIVPEnvironment()->create_polygon(surman, &ivpObjectTemplate, &rotation, &pos); } Init( realObject, objectTemplate.materialIndex, objectTemplate.volume, objectTemplate.dragCoefficient, objectTemplate.dragCoefficient, massOverride ); SetInertia( objectTemplate.rotInertia ); // will wake up the object if ( objectTemplate.velocity.LengthSqr() != 0 || objectTemplate.angVelocity.LengthSqr() != 0 ) { Assert( !objectTemplate.isAsleep ); SetVelocity( &objectTemplate.velocity, &objectTemplate.angVelocity ); } SetCallbackFlags( (unsigned short) objectTemplate.callbacks ); SetGameFlags( (unsigned short) objectTemplate.gameFlags ); SetGameData( pGameData ); SetContents( objectTemplate.contentsMask ); if ( objectTemplate.dragEnabled ) { Assert( !objectTemplate.isStatic ); EnableDrag( true ); } if ( !objectTemplate.motionEnabled ) { Assert( !objectTemplate.isStatic ); EnableMotion( false ); } if ( objectTemplate.isTrigger ) { BecomeTrigger(); } if ( !objectTemplate.gravityEnabled ) { EnableGravity( false ); } if ( objectTemplate.collisionEnabled ) { EnableCollisions( true ); } if ( !objectTemplate.isAsleep ) { Assert( !objectTemplate.isStatic ); Wake(); } m_pShadow = NULL; }