⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oasisjoint.cpp

📁 使用stl技术,(还没看,是听说的)
💻 CPP
字号:
/******************************************************************************

 * This source file is part of Bad Camel Gaming

 * Copyright (C) 2003  Zephie Greyvenstein

 * See Readme.html for acknowledgements

 *

 * This library is free software; you can redistribute it and/or

 * modify it under the terms of the GNU Lesser General Public

 * License as published by the Free Software Foundation; either

 * version 2.1 of the License, or (at your option) any later version.

 *

 * This library is distributed in the hope that it will be useful,

 * but WITHOUT ANY WARRANTY; without even the implied warranty of

 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

 * Lesser General Public License for more details.

 *

 * You should have received a copy of the GNU Lesser General Public

 * License along with this library; if not, write to the Free Software

 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

 *****************************************************************************/



/******************************************************************************

 * FILENAME    : oasisJoint.cpp

 * DESCRIPTION : A physical joint

 * AUTHOR      : Zephie Greyvenstein

 *****************************************************************************/



#include "oasisJoint.h"

#include "oasisPhysical.h"

#include "oasisPhysics.h"

#include "oasisException.h"

#include "oasisPhysicsCommon.h"



namespace Oasis {

  

  joint::joint( JointType thisType ) {

    /// Set some defaults

    type = thisType;

    anchor = vector3::ZERO;

    odeJoint = NULL;



    /// Init the axes

    axes.first = vector3::UNITX;

    axes.second = vector3::UNITZ;

  }



  joint::~joint( ) {



  }



  const joint::JointType joint::getType( void ) const {

    return type;

  }

  

  void joint::setAnchorPosition( real x, real y, real z ) {

    setAnchorPosition( vector3( x, y, z ) );

  }



  const vector3 &joint::getAnchorPosition( void ) const {

    return anchor;

  }



  const joint::physicsPair &joint::getAttachments( void ) const {

    return attachments;

  }



  const joint::vectorPair &joint::getAxes( void ) const {

    return axes;

  }



  const vector3 &joint::getAxis( JointAxis axis ) const {

    if ( axis == JA_PRIMARY ) {

      return axes.first;

    } else if ( axis == JA_SECONDARY ) {

      return axes.second;

    }



    oasisError( exception::ET_ITEM_NOT_FOUND,

    "Axis was not found",

    "joint::getAxis" );

  }



  void joint::setBodies( physics *first, physics *second ) {

    // The joint body id's

    dBodyID one, two;

    // Assume no physical attachment

    one = two = 0;



    if ( first ) {     

      one = first->getODEBody( )->id( );   

    }



    if ( second ) {     

      two = second->getODEBody( )->id( );   

    }

    

    /// Setup the joint

    odeJoint->attach( one, two );



    // Store the attached physical objects

    attachments.first = first;

    attachments.second = second;

  }



  int joint::_mapToODEParam( JointParam param ) {

    switch ( param ) {

    case JP_LOSTOP:

      return dParamLoStop;

      break;

    case JP_HISTOP:

      return dParamHiStop;

      break;

    case JP_VELOCITY:

      return dParamVel;

      break;

    case JP_VELOCITY2:

      return dParamVel2;

      break;

    case JP_FMAX:

      return dParamFMax;

      break;

    case JP_FMAX2:

      return dParamFMax2;

      break;

    case JP_SUSPENSIONERP:

      return dParamSuspensionERP;

      break;

    case JP_SUSPENSIONCFM:

      return dParamSuspensionCFM;

      break;

    default:

      oasisError( exception::ET_INTERNAL_ERROR,

      "Unknown joint parameter",

      "joint::_mapToODEParam" );

    }

  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -