void IVP_Controller_Raycast_Airboat::do_steering( IVP_FLOAT steering_angle_in ) { // Check for a change. if ( m_SteeringAngle == steering_angle_in) return; // Set the new steering angle. m_SteeringAngle = steering_angle_in; // Make sure the simulation is awake - we just go input. m_pAirboatBody->get_environment()->get_controller_manager()->ensure_controller_in_simulation( this ); // Steer each wheel. for ( int iWheel = 0; iWheel < wheels_per_axis; ++iWheel ) { do_steering_wheel( IVP_POS_WHEEL( iWheel ), m_SteeringAngle ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void IVP_Controller_Raycast_Airboat::InitRaycastCarWheels( const IVP_Template_Car_System *pCarSystemTemplate ) { IVP_U_Matrix m_core_f_object; m_pAirboatBody->calc_m_core_f_object( &m_core_f_object ); // Initialize the car wheel system. for ( int iWheel = 0; iWheel < n_wheels; iWheel++ ) { // Get and clear out memory for the current raycast wheel. IVP_Raycast_Airboat_Wheel *pRaycastWheel = get_wheel( IVP_POS_WHEEL( iWheel ) ); P_MEM_CLEAR( pRaycastWheel ); // Put the wheel in car space. m_core_f_object.vmult4( &pCarSystemTemplate->wheel_pos_Bos[iWheel], &pRaycastWheel->hp_cs ); m_core_f_object.vmult4( &pCarSystemTemplate->trace_pos_Bos[iWheel], &pRaycastWheel->raycast_start_cs ); // Add in the raycast start offset. pRaycastWheel->raycast_length = AIRBOAT_RAYCAST_DIST; pRaycastWheel->raycast_dir_cs.set_to_zero(); pRaycastWheel->raycast_dir_cs.k[index_y] = gravity_y_direction; // Spring (Shocks) data. pRaycastWheel->spring_len = -pCarSystemTemplate->spring_pre_tension[iWheel]; pRaycastWheel->spring_direction_cs.set_to_zero(); pRaycastWheel->spring_direction_cs.k[index_y] = gravity_y_direction; pRaycastWheel->spring_constant = pCarSystemTemplate->spring_constant[iWheel]; pRaycastWheel->spring_damp_relax = pCarSystemTemplate->spring_dampening[iWheel]; pRaycastWheel->spring_damp_compress = pCarSystemTemplate->spring_dampening_compression[iWheel]; // Wheel data. pRaycastWheel->friction_of_wheel = 1.0f;//pCarSystemTemplate->friction_of_wheel[iWheel]; pRaycastWheel->wheel_radius = pCarSystemTemplate->wheel_radius[iWheel]; pRaycastWheel->inv_wheel_radius = 1.0f / pCarSystemTemplate->wheel_radius[iWheel]; do_steering_wheel( IVP_POS_WHEEL( iWheel ), 0.0f ); pRaycastWheel->wheel_is_fixed = IVP_FALSE; pRaycastWheel->max_rotation_speed = pCarSystemTemplate->wheel_max_rotation_speed[iWheel>>1]; pRaycastWheel->wheel_is_fixed = IVP_TRUE; } }