123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- #ifndef __PHYSICS_3D_COMPONENT_H__
- #define __PHYSICS_3D_COMPONENT_H__
- #include "base/ccConfig.h"
- #include "math/CCMath.h"
- #include "2d/CCComponent.h"
- #if CC_USE_3D_PHYSICS
- #if (CC_ENABLE_BULLET_INTEGRATION)
- NS_CC_BEGIN
- class Physics3DObject;
- class Physics3DWorld;
- class CC_DLL Physics3DComponent : public cocos2d::Component
- {
- friend class Physics3DWorld;
- public:
- enum class PhysicsSyncFlag
- {
- NONE = 0,
- NODE_TO_PHYSICS = 1,
- PHYSICS_TO_NODE = 2,
- NODE_AND_NODE = NODE_TO_PHYSICS | PHYSICS_TO_NODE,
- };
-
- CREATE_FUNC(Physics3DComponent);
- virtual ~Physics3DComponent();
- virtual bool init() override;
-
- static Physics3DComponent* create(Physics3DObject* physicsObj, const cocos2d::Vec3& translateInPhysics = cocos2d::Vec3::ZERO, const cocos2d::Quaternion& rotInPhsyics = cocos2d::Quaternion::ZERO);
-
-
- void setPhysics3DObject(Physics3DObject* physicsObj);
-
-
- Physics3DObject* getPhysics3DObject() const { return _physics3DObj; }
-
-
- static std::string& getPhysics3DComponentName();
-
-
- virtual void setEnabled(bool b) override;
-
-
- virtual void onEnter() override;
- virtual void onExit() override;
-
-
- void addToPhysicsWorld(Physics3DWorld* world);
-
-
- void setTransformInPhysics(const cocos2d::Vec3& translateInPhysics, const cocos2d::Quaternion& rotInPhsyics);
-
-
- void setSyncFlag(PhysicsSyncFlag syncFlag);
-
-
- void syncNodeToPhysics();
-
-
- void syncPhysicsToNode();
-
- CC_CONSTRUCTOR_ACCESS:
- Physics3DComponent();
-
- protected:
- void preSimulate();
-
- void postSimulate();
-
- cocos2d::Mat4 _transformInPhysics;
- cocos2d::Mat4 _invTransformInPhysics;
-
- Physics3DObject* _physics3DObj;
- PhysicsSyncFlag _syncFlag;
- };
- NS_CC_END
- #endif
- #endif
- #endif
|