// rotation of ship around y axis --------------------------------------------- // INLINE void User_ShipYaw() { if ( DepressedKeys->key_TurnLeft ) { bams_t c_angle = MyShip->YawPerRefFrame * CurScreenRefFrames; INP_UserRotY( c_angle ); } else if ( DepressedKeys->key_TurnRight ) { bams_t c_angle = MyShip->YawPerRefFrame * CurScreenRefFrames; INP_UserRotY( -c_angle ); } }
// do the desired object control ---------------------------------------------- // int OCT_DoControl( object_control_s* objctl ) { ASSERT( objctl != NULL ); ASSERT( ( objctl->rot_x >= -1.0f ) && ( objctl->rot_x <= 1.0f ) ); ASSERT( ( objctl->rot_y >= -1.0f ) && ( objctl->rot_y <= 1.0f ) ); ASSERT( ( objctl->rot_z >= -1.0f ) && ( objctl->rot_z <= 1.0f ) ); ASSERT( ( objctl->accel >= -1.0f ) && ( objctl->accel <= 1.0f ) ); // check whether we have a valid object to control if ( objctl->pShip == NULL ) { CON_AddMessage( "OCT: not object to control is set." ); return FALSE; } //FIXME: for now we only support ship objects if ( !OBJECT_TYPE_SHIP( objctl->pShip ) ) { CON_AddMessage( "OCT: controlled object is not a ship." ); return FALSE; } int ship_controlled = FALSE; // check for rotation around x axis - PITCH - ( -1 = pullup, +1 = divedown ) if ( objctl->rot_x != 0.0f ) { bams_t _angle = (bams_t)(objctl->rot_x * objctl->pShip->PitchPerRefFrame * CurScreenRefFrames); //ObjRotX( objctl->pShip->ObjPosition, _angle ); INP_UserRotX( _angle ); ship_controlled = TRUE; } // check for rotation around y axis - YAW - ( -1 = right, +1 = left ) if ( objctl->rot_y != 0.0f ) { bams_t _angle = (bams_t)(objctl->rot_y * objctl->pShip->YawPerRefFrame * CurScreenRefFrames); //ObjRotY( objctl->pShip->ObjPosition, _angle ); INP_UserRotY( _angle ); ship_controlled = TRUE; } // check for rotation around z axis - ROLL - ( -1 = right, +1 = left ) if ( objctl->rot_z != 0.0f ) { bams_t _angle = (bams_t)(objctl->rot_z * objctl->pShip->RollPerRefFrame * CurScreenRefFrames); //ObjRotZ( objctl->pShip->ObjPosition, _angle ); INP_UserRotZ( _angle ); ship_controlled = TRUE; } // check for accel control ( +1 accelerate, -1 decelerate ) if ( objctl->accel != 0.0f ) { //fixed_t _accel = FLOAT_TO_FIXED( objctl->accel * (float)(objctl->pShip->SpeedIncPerRefFrame) * CurScreenRefFrames ); fixed_t _accel = (fixed_t)(objctl->accel * objctl->pShip->SpeedIncPerRefFrame * CurScreenRefFrames); INP_UserAcceleration( _accel ); /* // alter accel objctl->pShip->CurSpeed += c_speed; // check against speed constraints if ( objctl->pShip->CurSpeed > objctl->pShip->MaxSpeed ) { objctl->pShip->CurSpeed = objctl->pShip->MaxSpeed; } else if ( objctl->pShip->CurSpeed < 0 ) { objctl->pShip->CurSpeed = 0; } */ ship_controlled = TRUE; } //// we always move the controlled ship according to the speed //if ( objctl->pShip->CurSpeed != 0 ) { // // // actually move the ship // Vector3 dirvec; // fixed_t speed = objctl->pShip->CurSpeed * CurScreenRefFrames; // DirVctMUL( objctl->pShip->ObjPosition, FIXED_TO_GEOMV( speed ), &dirvec ); // objctl->pShip->ObjPosition[ 0 ][ 3 ] += dirvec.X; // objctl->pShip->ObjPosition[ 1 ][ 3 ] += dirvec.Y; // objctl->pShip->ObjPosition[ 2 ][ 3 ] += dirvec.Z; //} return ship_controlled; }