2015-08-26 17:24:36 +08:00
|
|
|
|
/****************************************************************************
|
2017-02-14 14:36:57 +08:00
|
|
|
|
Copyright (c) 2015-2017 Chukong Technologies Inc.
|
2015-05-08 15:49:33 +08:00
|
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
THE SOFTWARE.
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef __PHYSICS_3D_OBJECT_H__
|
|
|
|
|
#define __PHYSICS_3D_OBJECT_H__
|
|
|
|
|
|
|
|
|
|
#include "math/CCMath.h"
|
|
|
|
|
#include "base/CCRef.h"
|
|
|
|
|
#include "base/ccConfig.h"
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#if CC_USE_3D_PHYSICS
|
|
|
|
|
|
|
|
|
|
#if (CC_ENABLE_BULLET_INTEGRATION)
|
|
|
|
|
|
|
|
|
|
class btCollisionShape;
|
|
|
|
|
class btRigidBody;
|
|
|
|
|
class btPersistentManifold;
|
2015-06-29 10:26:09 +08:00
|
|
|
|
class btGhostObject;
|
2015-05-08 15:49:33 +08:00
|
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
/**
|
|
|
|
|
* @addtogroup _3d
|
|
|
|
|
* @{
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class Physics3DShape;
|
|
|
|
|
class Physics3DWorld;
|
|
|
|
|
class Physics3DConstraint;
|
|
|
|
|
class Physics3DObject;
|
|
|
|
|
/**
|
|
|
|
|
* @brief The collision information of Physics3DObject.
|
|
|
|
|
*/
|
|
|
|
|
struct CC_DLL Physics3DCollisionInfo
|
|
|
|
|
{
|
|
|
|
|
struct CollisionPoint
|
|
|
|
|
{
|
|
|
|
|
Vec3 localPositionOnA;
|
|
|
|
|
Vec3 worldPositionOnA;
|
|
|
|
|
Vec3 localPositionOnB;
|
|
|
|
|
Vec3 worldPositionOnB;
|
|
|
|
|
Vec3 worldNormalOnB;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Physics3DObject *objA;
|
|
|
|
|
Physics3DObject *objB;
|
|
|
|
|
std::vector<CollisionPoint> collisionPointList;
|
|
|
|
|
};
|
|
|
|
|
/**
|
|
|
|
|
* @brief Inherit from Ref, base class
|
|
|
|
|
*/
|
|
|
|
|
class CC_DLL Physics3DObject : public Ref
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
typedef std::function<void(const Physics3DCollisionInfo &ci)> CollisionCallbackFunc;
|
|
|
|
|
|
|
|
|
|
enum class PhysicsObjType
|
|
|
|
|
{
|
|
|
|
|
UNKNOWN = 0,
|
|
|
|
|
RIGID_BODY,
|
2015-06-29 10:26:09 +08:00
|
|
|
|
COLLIDER,
|
2015-05-08 15:49:33 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** Get the Physics3DObject Type. */
|
|
|
|
|
virtual PhysicsObjType getObjType() const { return _type; }
|
|
|
|
|
|
|
|
|
|
/** Set the user data. */
|
|
|
|
|
void setUserData(void* userData) { _userData = userData; }
|
|
|
|
|
|
|
|
|
|
/** Get the user data. */
|
|
|
|
|
void* getUserData() const { return _userData; }
|
|
|
|
|
|
|
|
|
|
/** Internal method. Set the pointer of Physics3DWorld. */
|
|
|
|
|
void setPhysicsWorld(Physics3DWorld* world) { _physicsWorld = world; };
|
|
|
|
|
|
|
|
|
|
/** Get the pointer of Physics3DWorld. */
|
|
|
|
|
Physics3DWorld* getPhysicsWorld() const { return _physicsWorld; }
|
|
|
|
|
|
|
|
|
|
/** Get the world matrix of Physics3DObject. */
|
|
|
|
|
virtual cocos2d::Mat4 getWorldTransform() const = 0;
|
|
|
|
|
|
|
|
|
|
/** Set the collision callback function. */
|
|
|
|
|
void setCollisionCallback(const CollisionCallbackFunc &func) { _collisionCallbackFunc = func; };
|
|
|
|
|
|
|
|
|
|
/** Get the collision callback function. */
|
|
|
|
|
const CollisionCallbackFunc& getCollisionCallback() const { return _collisionCallbackFunc; }
|
|
|
|
|
|
|
|
|
|
/** Check has collision callback function. */
|
|
|
|
|
bool needCollisionCallback() { return _collisionCallbackFunc != nullptr; };
|
|
|
|
|
|
|
|
|
|
/** Set the mask of Physics3DObject. */
|
|
|
|
|
void setMask(unsigned int mask) { _mask = mask; };
|
|
|
|
|
|
|
|
|
|
/** Get the mask of Physics3DObject. */
|
|
|
|
|
unsigned int getMask() const { return _mask; };
|
|
|
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
|
|
|
|
Physics3DObject()
|
|
|
|
|
: _type(PhysicsObjType::UNKNOWN)
|
|
|
|
|
, _userData(nullptr)
|
|
|
|
|
, _isEnabled(true)
|
|
|
|
|
, _physicsWorld(nullptr)
|
|
|
|
|
, _mask(-1)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
virtual ~Physics3DObject(){}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
bool _isEnabled;
|
|
|
|
|
PhysicsObjType _type;
|
|
|
|
|
void* _userData;
|
|
|
|
|
Physics3DWorld* _physicsWorld;
|
|
|
|
|
CollisionCallbackFunc _collisionCallbackFunc;
|
|
|
|
|
unsigned int _mask;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief The description of Physics3DRigidBody.
|
|
|
|
|
*/
|
|
|
|
|
struct CC_DLL Physics3DRigidBodyDes
|
|
|
|
|
{
|
|
|
|
|
float mass; //Note: mass equals zero means static, default 0
|
|
|
|
|
cocos2d::Vec3 localInertia; //default (0, 0, 0)
|
|
|
|
|
Physics3DShape* shape;
|
|
|
|
|
cocos2d::Mat4 originalTransform;
|
|
|
|
|
bool disableSleep; //it is always active if disabled
|
|
|
|
|
|
|
|
|
|
Physics3DRigidBodyDes()
|
|
|
|
|
: mass(0.f)
|
|
|
|
|
, localInertia(0.f, 0.f, 0.f)
|
|
|
|
|
, shape(nullptr)
|
|
|
|
|
, disableSleep(false)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Inherit from Physics3DObject, the main class for rigid body objects
|
|
|
|
|
*/
|
|
|
|
|
class CC_DLL Physics3DRigidBody : public Physics3DObject
|
|
|
|
|
{
|
|
|
|
|
friend class Physics3DWorld;
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a Physics3DRigidBody with Physics3DRigidBody.
|
|
|
|
|
*
|
|
|
|
|
* @return An autoreleased Physics3DRigidBody object.
|
|
|
|
|
*/
|
|
|
|
|
static Physics3DRigidBody* create(Physics3DRigidBodyDes* info);
|
|
|
|
|
|
2015-06-29 10:26:09 +08:00
|
|
|
|
/** Get the pointer of btRigidBody. */
|
2015-05-08 15:49:33 +08:00
|
|
|
|
btRigidBody* getRigidBody() const { return _btRigidBody; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Apply a force.
|
|
|
|
|
*
|
|
|
|
|
* @param force the value of the force
|
|
|
|
|
* @param rel_pos the position of the force
|
|
|
|
|
*/
|
|
|
|
|
void applyForce(const cocos2d::Vec3& force, const cocos2d::Vec3& rel_pos);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Apply a central force.
|
|
|
|
|
*
|
|
|
|
|
* @param force the value of the force
|
|
|
|
|
*/
|
|
|
|
|
void applyCentralForce(const cocos2d::Vec3& force);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Apply a central impulse.
|
|
|
|
|
*
|
|
|
|
|
* @param impulse the value of the impulse
|
|
|
|
|
*/
|
|
|
|
|
void applyCentralImpulse(const cocos2d::Vec3& impulse);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Apply a torque.
|
|
|
|
|
*
|
|
|
|
|
* @param torque the value of the torque
|
|
|
|
|
*/
|
|
|
|
|
void applyTorque(const cocos2d::Vec3& torque);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Apply a torque impulse.
|
|
|
|
|
*
|
|
|
|
|
* @param torque the value of the torque
|
|
|
|
|
*/
|
|
|
|
|
void applyTorqueImpulse(const cocos2d::Vec3& torque);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Apply a impulse.
|
|
|
|
|
*
|
|
|
|
|
* @param impulse the value of the impulse
|
|
|
|
|
* @param rel_pos the position of the impulse
|
|
|
|
|
*/
|
|
|
|
|
void applyImpulse(const cocos2d::Vec3& impulse, const cocos2d::Vec3& rel_pos);
|
|
|
|
|
|
|
|
|
|
/** Damps the velocity, using the given linearDamping and angularDamping. */
|
|
|
|
|
void applyDamping(float timeStep);
|
|
|
|
|
|
|
|
|
|
/** Set the linear velocity. */
|
|
|
|
|
void setLinearVelocity(const cocos2d::Vec3& lin_vel);
|
|
|
|
|
|
|
|
|
|
/** Get the linear velocity. */
|
|
|
|
|
cocos2d::Vec3 getLinearVelocity() const;
|
|
|
|
|
|
|
|
|
|
/** Set the linear factor. */
|
|
|
|
|
void setLinearFactor(const cocos2d::Vec3& linearFactor);
|
|
|
|
|
|
|
|
|
|
/** Get the linear factor. */
|
|
|
|
|
cocos2d::Vec3 getLinearFactor() const;
|
|
|
|
|
|
|
|
|
|
/** Set the angular factor. */
|
|
|
|
|
void setAngularFactor(const cocos2d::Vec3& angFac);
|
|
|
|
|
|
|
|
|
|
/** Set the angular factor, use unified factor. */
|
|
|
|
|
void setAngularFactor(float angFac);
|
|
|
|
|
|
|
|
|
|
/** Get the angular factor. */
|
|
|
|
|
cocos2d::Vec3 getAngularFactor() const;
|
|
|
|
|
|
|
|
|
|
/** Set the angular velocity. */
|
|
|
|
|
void setAngularVelocity(const cocos2d::Vec3& ang_vel);
|
|
|
|
|
|
|
|
|
|
/** Get the angular velocity. */
|
|
|
|
|
cocos2d::Vec3 getAngularVelocity() const;
|
|
|
|
|
|
|
|
|
|
/** Set the center of mass. */
|
|
|
|
|
void setCenterOfMassTransform(const cocos2d::Mat4& xform);
|
|
|
|
|
|
|
|
|
|
/** Get the center of mass. */
|
|
|
|
|
cocos2d::Mat4 getCenterOfMassTransform() const;
|
|
|
|
|
|
|
|
|
|
/** Set linear damping and angular damping. */
|
|
|
|
|
void setDamping(float lin_damping, float ang_damping);
|
|
|
|
|
|
|
|
|
|
/** Get linear damping. */
|
|
|
|
|
float getLinearDamping() const;
|
|
|
|
|
|
|
|
|
|
/** Get angular damping. */
|
|
|
|
|
float getAngularDamping() const;
|
|
|
|
|
|
|
|
|
|
/** Set the acceleration. */
|
|
|
|
|
void setGravity(const cocos2d::Vec3& acceleration);
|
|
|
|
|
|
|
|
|
|
/** Get the acceleration. */
|
|
|
|
|
cocos2d::Vec3 getGravity() const;
|
|
|
|
|
|
|
|
|
|
/** Set the inverse of local inertia. */
|
|
|
|
|
void setInvInertiaDiagLocal(const cocos2d::Vec3& diagInvInertia);
|
|
|
|
|
|
|
|
|
|
/** Get the inverse of local inertia. */
|
|
|
|
|
cocos2d::Vec3 getInvInertiaDiagLocal() const;
|
|
|
|
|
|
|
|
|
|
/** Set mass and inertia. */
|
|
|
|
|
void setMassProps(float mass, const cocos2d::Vec3& inertia);
|
|
|
|
|
|
|
|
|
|
/** Get inverse of mass. */
|
|
|
|
|
float getInvMass() const;
|
|
|
|
|
|
|
|
|
|
/** Get total force. */
|
|
|
|
|
cocos2d::Vec3 getTotalForce() const;
|
|
|
|
|
|
|
|
|
|
/** Get total torque. */
|
|
|
|
|
cocos2d::Vec3 getTotalTorque() const;
|
|
|
|
|
|
|
|
|
|
/** Set restitution. */
|
|
|
|
|
void setRestitution(float rest);
|
|
|
|
|
|
|
|
|
|
/** Get restitution. */
|
|
|
|
|
float getRestitution() const;
|
|
|
|
|
|
|
|
|
|
/** Set friction. */
|
|
|
|
|
void setFriction(float frict);
|
|
|
|
|
|
|
|
|
|
/** Get friction. */
|
|
|
|
|
float getFriction() const;
|
|
|
|
|
|
|
|
|
|
/** Set rolling friction. */
|
|
|
|
|
void setRollingFriction(float frict);
|
|
|
|
|
|
|
|
|
|
/** Get rolling friction. */
|
|
|
|
|
float getRollingFriction() const;
|
|
|
|
|
|
|
|
|
|
/** Set hit friction. */
|
|
|
|
|
void setHitFraction(float hitFraction);
|
|
|
|
|
|
|
|
|
|
/** Get hit friction. */
|
|
|
|
|
float getHitFraction() const;
|
|
|
|
|
|
|
|
|
|
/** Set motion threshold, don't do continuous collision detection if the motion (in one step) is less then ccdMotionThreshold */
|
|
|
|
|
void setCcdMotionThreshold(float ccdMotionThreshold);
|
|
|
|
|
|
|
|
|
|
/** Get motion threshold. */
|
|
|
|
|
float getCcdMotionThreshold() const;
|
|
|
|
|
|
|
|
|
|
/** Set swept sphere radius. */
|
|
|
|
|
void setCcdSweptSphereRadius(float radius);
|
|
|
|
|
|
|
|
|
|
/** Get swept sphere radius. */
|
|
|
|
|
float getCcdSweptSphereRadius() const;
|
|
|
|
|
|
|
|
|
|
/** Set kinematic object. */
|
|
|
|
|
void setKinematic(bool kinematic);
|
|
|
|
|
|
|
|
|
|
/** Check rigid body is kinematic object. */
|
|
|
|
|
bool isKinematic() const;
|
|
|
|
|
|
|
|
|
|
/** override. */
|
|
|
|
|
virtual cocos2d::Mat4 getWorldTransform() const override;
|
|
|
|
|
|
|
|
|
|
/** Get constraint by index. */
|
|
|
|
|
Physics3DConstraint* getConstraint(unsigned int idx) const;
|
|
|
|
|
|
|
|
|
|
/** Get the total number of constraints. */
|
|
|
|
|
unsigned int getConstraintCount() const;
|
|
|
|
|
|
|
|
|
|
/** Active or inactive. */
|
|
|
|
|
void setActive(bool active);
|
|
|
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
|
|
|
|
Physics3DRigidBody();
|
|
|
|
|
virtual ~Physics3DRigidBody();
|
|
|
|
|
|
|
|
|
|
bool init(Physics3DRigidBodyDes* info);
|
|
|
|
|
|
|
|
|
|
void addConstraint(Physics3DConstraint *constraint);
|
|
|
|
|
void removeConstraint(Physics3DConstraint *constraint);
|
|
|
|
|
void removeConstraint(unsigned int idx);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
btRigidBody* _btRigidBody;
|
|
|
|
|
Physics3DShape *_physics3DShape;
|
|
|
|
|
std::vector<Physics3DConstraint *> _constraintList;
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-30 14:16:05 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief The description of Physics3DCollider.
|
|
|
|
|
*/
|
|
|
|
|
struct CC_DLL Physics3DColliderDes
|
|
|
|
|
{
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/**shape pointer*/
|
|
|
|
|
Physics3DShape* shape;
|
|
|
|
|
/**original world Transform*/
|
2015-06-30 14:16:05 +08:00
|
|
|
|
cocos2d::Mat4 originalTransform;
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/**Is collider a trigger?*/
|
|
|
|
|
bool isTrigger;
|
|
|
|
|
/**the friction*/
|
2015-06-30 14:16:05 +08:00
|
|
|
|
float friction;
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/**the rolling friction*/
|
2015-06-30 14:16:05 +08:00
|
|
|
|
float rollingFriction;
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/**the restitution*/
|
2015-06-30 14:16:05 +08:00
|
|
|
|
float restitution;
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/**the hit fraction*/
|
2015-06-30 14:16:05 +08:00
|
|
|
|
float hitFraction;
|
2015-09-22 16:08:23 +08:00
|
|
|
|
/**the swept sphere radius*/
|
2015-06-30 14:16:05 +08:00
|
|
|
|
float ccdSweptSphereRadius;
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/**the motion threshold*/
|
2015-06-30 14:16:05 +08:00
|
|
|
|
float ccdMotionThreshold;
|
|
|
|
|
|
|
|
|
|
Physics3DColliderDes()
|
|
|
|
|
: shape(nullptr)
|
|
|
|
|
, isTrigger(false)
|
|
|
|
|
, friction(0.5f)
|
|
|
|
|
, rollingFriction(0.0f)
|
|
|
|
|
, restitution(0.0f)
|
|
|
|
|
, hitFraction(1.0f)
|
|
|
|
|
, ccdSweptSphereRadius(0.0f)
|
|
|
|
|
, ccdMotionThreshold(0.0f)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-29 10:26:09 +08:00
|
|
|
|
/**
|
2015-08-26 16:19:30 +08:00
|
|
|
|
* @brief Inherit from Physics3DObject, the main class for Colliders.
|
2015-06-29 10:26:09 +08:00
|
|
|
|
*/
|
|
|
|
|
class CC_DLL Physics3DCollider : public Physics3DObject
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2015-08-26 16:19:30 +08:00
|
|
|
|
/**
|
|
|
|
|
* Creates a Physics3DCollider with Physics3DColliderDes.
|
|
|
|
|
*
|
|
|
|
|
* @return An autoreleased Physics3DCollider object.
|
|
|
|
|
*/
|
2015-06-30 14:16:05 +08:00
|
|
|
|
static Physics3DCollider* create(Physics3DColliderDes *info);
|
2015-06-29 10:26:09 +08:00
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Get the pointer of btGhostObject.
|
|
|
|
|
* @return The pointer of btGhostObject.
|
|
|
|
|
*/
|
2015-06-29 17:20:28 +08:00
|
|
|
|
btGhostObject* getGhostObject() const { return _btGhostObject; }
|
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Set trigger.
|
|
|
|
|
* @param isTrigger Is a trigger.
|
|
|
|
|
*/
|
2015-06-30 14:16:05 +08:00
|
|
|
|
void setTrigger(bool isTrigger);
|
2015-06-29 17:20:28 +08:00
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Check is a trigger.
|
|
|
|
|
* @return Is a trigger.
|
|
|
|
|
*/
|
2015-07-30 18:14:46 +08:00
|
|
|
|
bool isTrigger() const;
|
2015-06-29 10:26:09 +08:00
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Set restitution.
|
|
|
|
|
* @param rest The restitution.
|
|
|
|
|
*/
|
2015-06-29 17:20:28 +08:00
|
|
|
|
void setRestitution(float rest);
|
2015-06-29 10:26:09 +08:00
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Get restitution.
|
|
|
|
|
* @return The restitution.
|
|
|
|
|
*/
|
2015-06-29 17:20:28 +08:00
|
|
|
|
float getRestitution() const;
|
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Set friction.
|
2016-07-03 23:42:10 +08:00
|
|
|
|
* @param frict The friction.
|
2015-08-26 17:24:36 +08:00
|
|
|
|
*/
|
2015-06-29 17:20:28 +08:00
|
|
|
|
void setFriction(float frict);
|
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Get friction.
|
|
|
|
|
* @return The friction.
|
|
|
|
|
*/
|
2015-06-29 17:20:28 +08:00
|
|
|
|
float getFriction() const;
|
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Set rolling friction.
|
|
|
|
|
* @param frict The rolling friction.
|
|
|
|
|
*/
|
2015-06-29 17:20:28 +08:00
|
|
|
|
void setRollingFriction(float frict);
|
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Get rolling friction.
|
|
|
|
|
* @return The rolling friction.
|
|
|
|
|
*/
|
2015-06-29 17:20:28 +08:00
|
|
|
|
float getRollingFriction() const;
|
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Set hit friction.
|
|
|
|
|
* @param hitFraction The hit friction.
|
|
|
|
|
*/
|
2015-06-29 17:20:28 +08:00
|
|
|
|
void setHitFraction(float hitFraction);
|
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Get hit friction.
|
|
|
|
|
* @return The hit friction.
|
|
|
|
|
*/
|
2015-06-29 17:20:28 +08:00
|
|
|
|
float getHitFraction() const;
|
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Set motion threshold, don't do continuous collision detection if the motion (in one step) is less then ccdMotionThreshold.
|
|
|
|
|
* @param ccdMotionThreshold The motion threshold.
|
|
|
|
|
*/
|
2015-06-29 17:20:28 +08:00
|
|
|
|
void setCcdMotionThreshold(float ccdMotionThreshold);
|
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Get motion threshold.
|
|
|
|
|
* @return The motion threshold.
|
|
|
|
|
*/
|
2015-06-29 17:20:28 +08:00
|
|
|
|
float getCcdMotionThreshold() const;
|
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Set swept sphere radius.
|
|
|
|
|
* @param radius The swept sphere radius.
|
|
|
|
|
*/
|
2015-06-29 17:20:28 +08:00
|
|
|
|
void setCcdSweptSphereRadius(float radius);
|
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** Get swept sphere radius.
|
|
|
|
|
* @return The swept sphere radius.
|
|
|
|
|
*/
|
2015-06-29 17:20:28 +08:00
|
|
|
|
float getCcdSweptSphereRadius() const;
|
2015-06-29 10:26:09 +08:00
|
|
|
|
|
2015-08-26 17:24:36 +08:00
|
|
|
|
/** override. */
|
2015-06-29 10:26:09 +08:00
|
|
|
|
virtual cocos2d::Mat4 getWorldTransform() const;
|
|
|
|
|
|
2015-08-26 16:19:30 +08:00
|
|
|
|
/** Set a callback when trigger enter. */
|
2015-06-29 17:20:28 +08:00
|
|
|
|
std::function<void(Physics3DObject *otherObject)> onTriggerEnter;
|
2015-08-26 16:19:30 +08:00
|
|
|
|
|
|
|
|
|
/** Set a callback when trigger exit. */
|
2015-06-29 17:20:28 +08:00
|
|
|
|
std::function<void(Physics3DObject *otherObject)> onTriggerExit;
|
|
|
|
|
|
2015-06-29 10:26:09 +08:00
|
|
|
|
CC_CONSTRUCTOR_ACCESS :
|
|
|
|
|
Physics3DCollider();
|
|
|
|
|
virtual ~Physics3DCollider();
|
|
|
|
|
|
2015-06-30 14:16:05 +08:00
|
|
|
|
bool init(Physics3DColliderDes *info);
|
2015-06-29 10:26:09 +08:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
btGhostObject *_btGhostObject;
|
|
|
|
|
Physics3DShape *_physics3DShape;
|
|
|
|
|
};
|
|
|
|
|
|
2015-05-08 15:49:33 +08:00
|
|
|
|
// end of 3d group
|
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
|
|
#endif // CC_ENABLE_BULLET_INTEGRATION
|
|
|
|
|
|
|
|
|
|
#endif //CC_USE_3D_PHYSICS
|
|
|
|
|
|
|
|
|
|
#endif // __PHYSICS_3D_OBJECT_H__
|