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

📄 oasisproxy.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    : oasisProxy.cpp

 * DESCRIPTION : A collision proxy

 * AUTHOR      : Zephie Greyvenstein

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



#include "oasisProxy.h"

#include "oasisPhysics.h"

#include "oasisException.h"

#include "oasisConvert.h"

#include "oasisPhysicsCommon.h"



namespace Oasis {

  

  proxy::proxy( ProxyType thisType ) {

    /// Set some defaults

    odeProxy = NULL;

    type = thisType;

    thisParent = NULL;

    enabled = false;

    setOffset( 0, 0, 0, false );

  }



  proxy::~proxy( ) {

    if ( odeProxy ) {

      delete odeProxy;

      odeProxy = NULL;

    }

  }



  const proxy::ProxyType proxy::getType( void ) const {

    return type;

  }



  const vector3 &proxy::getOffset( void ) const {

    return offset;

  }

  

  void proxy::setOffset( real x, real y, real z, bool holdOffUpdate ) {

    setOffset( vector3( x, y, z ), holdOffUpdate );

  }



  void proxy::setOffset( const vector3 &newOffset, bool holdOffUpdate ) {

    offset = newOffset;



    if ( !holdOffUpdate && thisParent ) {

      thisParent->updateProxies( );

    }

  } 



  void proxy::setEnabled( bool newState ) {

    if ( newState ) {

      if ( !thisParent ) {

  oasisError( exception::ET_INTERNAL_ERROR,

        "You cannot enable a proxy that is not part of a physics",

        "proxy::setEnabled" );

      }

      

      odeProxy->enable( );

    } else {

      odeProxy->disable( );

    }



    enabled = newState;

  }



  const bool proxy::getEnabled( void ) const {

    return enabled;

  }



  void proxy::setPosition( const vector3 &newPosition ) {

    vector3 total = newPosition + offset;    

    odeProxy->setPosition( total.x, total.y, total.z );

  }



  void proxy::setOrientation( const quaternion &newOrientation ) {

    dQuaternion quat;

    convert::toODEQuaternion( quat, newOrientation );

    odeProxy->setQuaternion( quat );

  }



  void proxy::setParent( physics *parent ) {

    odeProxy->setData( parent );

    thisParent = parent;

  }

}

⌨️ 快捷键说明

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