License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-adaptor.git] / plugins / dynamics / bullet / bullet-dynamics-body.h
1 #ifndef __DALI_PLUGIN_BULLET_DYNAMICS_BODY_H__
2 #define __DALI_PLUGIN_BULLET_DYNAMICS_BODY_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 // INTERNAL INCLUDES
23 #include <dali/integration-api/dynamics/dynamics-body-intf.h>
24
25 class btCollisionObject;
26
27 namespace Dali
28 {
29
30 namespace Integration
31 {
32
33 struct DynamicsBodySettings;
34 class DynamicsShape;
35
36 } // namespace Integration
37
38 namespace Plugin
39 {
40
41 class BulletDynamicsWorld;
42
43 /*
44  *
45  */
46 class BulletDynamicsBody : public Integration::DynamicsBody
47 {
48 public:
49   BulletDynamicsBody();
50   virtual ~BulletDynamicsBody();
51
52 public: // From Dali::Integration::DynamicsBody
53
54   ///@ copydoc Dali::DynamicsBody::Initialize
55   void Initialize( const Integration::DynamicsBodySettings& bodySettings, Integration::DynamicsShape* shape,
56                    Integration::DynamicsWorld& dynamicsWorld,
57                    const Vector3& startPosition, const Quaternion& startRotation );
58
59   ///@ copydoc Dali::DynamicsBody::SetMass
60   void SetMass( float mass );
61
62   ///@ copydoc Dali::DynamicsBody::SetElasticity
63   void SetElasticity( float elasticity );
64
65   /// @copydoc Dali::DynamicsBody::SetLinearVelocity
66   void SetLinearVelocity( const Vector3& velocity );
67
68   /// @copydoc Dali::DynamicsBody::GetLinearVelocity
69   Vector3 GetLinearVelocity() const;
70
71   /// @copydoc Dali::DynamicsBody::SetAngularVelocity
72   void SetAngularVelocity( const Vector3& velocity );
73
74   /// @copydoc Dali::DynamicsBody::GetAngularVelocity
75   Vector3 GetAngularVelocity() const;
76
77   /// @copydoc Dali::DynamicsBody::SetKinematic
78   void SetKinematic( bool flag );
79
80   /// @copydoc Dali::DynamicsBody::IsKinematic
81   bool IsKinematic() const;
82
83   /// @copydoc Dali::DynamicsBody::SetSleepEnabled
84   void SetSleepEnabled( bool flag );
85
86   /// @copydoc Dali::DynamicsBody::WakeUp
87   void WakeUp();
88
89   /// @copydoc Dali::DynamicsBody::AddAnchor
90   void AddAnchor( unsigned int index, const Integration::DynamicsBody* anchorBody, bool collisions );
91
92   /// @copydoc Dali::DynamicsBody::ConserveVolume
93   void ConserveVolume( bool flag );
94
95   /// @copydoc Dali::DynamicsBody::ConserveShape
96   void ConserveShape( bool flag );
97
98   /// @copydoc Dali::DynamicsBody::GetCollisionGroup
99   short int GetCollisionGroup() const;
100
101   /// @copydoc Dali::DynamicsBody::SetCollisionGroup
102   void SetCollisionGroup( short int collisionGroup );
103
104   /// @copydoc Dali::DynamicsBody::GetCollisionMask
105   short int GetCollisionMask() const;
106
107   /// @copydoc Dali::DynamicsBody::SetCollisionMask
108   void SetCollisionMask( short int collisionMask );
109
110   int GetType() const;
111
112   /// @copydoc Dali::DynamicsBody::IsActive
113   bool IsActive() const;
114
115   /// @copydoc Dali::Integration::DynamicsBody::SetTransform
116   void SetTransform( const Vector3& position, const Quaternion& rotation );
117
118   /// @copydoc Dali::Integration::GetTransform
119   void GetTransform( Vector3& position, Quaternion& rotation );
120
121   /// @copydoc Dali::Integration::GetSoftVertices
122   void GetSoftVertices( MeshData::VertexContainer& vertices ) const;
123
124 public:
125
126   btCollisionObject* GetBody() const;
127
128 private:
129   /**
130    * Create a rigid body
131    */
132   void CreateRigidBody( const Integration::DynamicsBodySettings& bodySettings, Dali::Integration::DynamicsShape* shape,
133                         const Vector3& startPosition, const Quaternion& startRotation );
134
135   /**
136    * Create a soft body
137    */
138   void CreateSoftBody( const Integration::DynamicsBodySettings& bodySettings, Dali::Integration::DynamicsShape* shape,
139                        const Vector3& startPosition, const Quaternion& startRotation );
140
141 private:
142   Dali::Integration::DynamicsBodySettings* mSettings;
143   btCollisionObject* mBody;
144   bool mConserveVolume:1;
145   bool mConserveShape:1;
146   bool mKinematic:1;
147   bool mActivationState:1;
148
149   short int mCollisionGroup;
150   short int mCollisionMask;
151
152   BulletDynamicsWorld* mWorld;
153
154 }; // class BulletDynamicsBody
155
156 } // namespace Plugin
157
158 } // namespace Dali
159
160 #endif // __DALI_PLUGIN_BULLET_DYNAMICS_BODY_H__