📄 oasisjoint.h
字号:
/******************************************************************************
* 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.h
* DESCRIPTION : A physical joint
* AUTHOR : Zephie Greyvenstein
*****************************************************************************/
/// Avoid double inclusion
#ifndef __JOINT_H__
#define __JOINT_H__
/// Include common stuff
#include "oasisCommon.h"
/// Include the rest of the needed oasis stuff
#include "oasisVector3.h"
/// Forward declare ODE stuff
class dBody;
struct dJoint;
namespace Oasis {
/// This is a physical joint between objects that imposes constraints
/// on their movement
class _oasisExport joint {
public:
/// Joint axes
enum JointAxis {
/// Primary joint
JA_PRIMARY = 0,
JA_SECONDARY = 1
};
/// Joint types
enum JointType {
/// Ball and socket joint
JT_BALL = 0,
/// Sliding joint
JT_SLIDER = 1,
/// Hinge joint
JT_HINGE = 2,
/// 2 hinges in series
JT_HINGE2 = 3,
/// Universal joint( double joint )
JT_UNIVERSAL = 4
};
/// Joint parameters
enum JointParam {
/// Low stop angle/position
JP_LOSTOP = 0,
/// Hight stop angle/position
JP_HISTOP = 1,
/// Joint velocity
JP_VELOCITY = 2,
/// Mototr velocity
JP_VELOCITY2 = 3,
/// Max force or torque to achieve a velocity
JP_FMAX = 4,
/// Max force or torque to achieve a motor velocity
JP_FMAX2 = 5,
/// Suspension ERP
JP_SUSPENSIONERP = 6,
/// Suspension CFM
JP_SUSPENSIONCFM = 7
};
/// Destructor
virtual ~joint( );
/// A pair of physics
typedef std::pair< physics*, physics* > physicsPair;
/// A pair of vectors
typedef std::pair< vector3, vector3 > vectorPair;
/// Get the type of joint this is
const JointType getType( void ) const;
/** Set the anchor position
@remarks
This sets the anchor point for the joint. Usually this is the hinge,
but for slider, it doesnt mean anything
*/
void setAnchorPosition( real x, real y, real z );
/** Set the anchor position
@remarks
This sets the anchor point for the joint. Usually this is the hinge,
but for slider, it doesnt mean anything
*/
virtual void setAnchorPosition( const vector3 &origin ) = 0;
/// Get the anchor position
virtual const vector3 &getAnchorPosition( void ) const;
/// Get the attached physicals
virtual const physicsPair &getAttachments( void ) const;
/** Sets the axis for the joint
@remarks
For ball, this is not applicable. Only JT_UNIVERSAL and JT_HINGE2
need the second axis.
*/
virtual void setAxes( const vector3 &primary,
const vector3 &secondary = vector3::ZERO ) = 0;
/// Get the axes for the joint
virtual const vectorPair &getAxes( void ) const;
/// Get one of the axes
virtual const vector3 &getAxis( JointAxis axis ) const;
/// Set a parameter for a joint ( Useless for some joints )
virtual void setParameter( JointParam param, real value ) = 0;
/// Get a paramater for a joint ( Useless for some joints )
virtual const real getParameter( JointParam param ) = 0;
/// Get the angle of an axis( meaningless for some joints )
virtual const real getAxisAngle( JointAxis axis ) const = 0;
protected:
/// Constructor
joint( JointType thisType );
/// Joint type
JointType type;
/// Anchor position
vector3 anchor;
/// Attached physicals
physicsPair attachments;
/// Axes
vectorPair axes;
/// ODE joint
dJoint *odeJoint;
/// Set the actual attachments on the ODE level
void setBodies( physics *first, physics *second );
/// Maps a joint parameter to the ODE int
int _mapToODEParam( JointParam param );
};
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -