diff --git a/build b/build index b6377e04..3f4ee975 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit b6377e0477014e8dbec14d73e7be86e062fb8065 +Subproject commit 3f4ee97584169819c4fbe95dea80ba83508fce15 diff --git a/sources/ewol/game/BoundingAABB.cpp b/sources/ewol/game/BoundingAABB.cpp deleted file mode 100644 index 0cdfed90..00000000 --- a/sources/ewol/game/BoundingAABB.cpp +++ /dev/null @@ -1,300 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#include -#include -#include -#include - - -game::BoundingAABB::BoundingAABB(void) : - m_PointStart(-1,-1,-1), - m_PointStop(1,1,1), - m_hasContact(false) -{ - #ifdef DEBUG - if (false == ewol::resource::Keep(m_displayBounding) ) { - EWOL_DEBUG("Can not keep ewol::Colored3DObject ..."); - } - vec3 tmpPos(0,0,0); - for(int32_t iii=0; iii<36; iii++) { - m_vertices.PushBack(tmpPos); - } - #endif -} - -game::BoundingAABB::~BoundingAABB(void) -{ - #ifdef DEBUG - ewol::resource::Release(m_displayBounding); - #endif -} - - -void game::BoundingAABB::Update(game::MeshObject& object, mat4& transformMatrix) -{ - for (int32_t iii=0; iii point.x) { - m_PointStart.x = point.x; - } else if (m_PointStop.x < point.x) { - m_PointStop.x = point.x; - } - - if (m_PointStart.y > point.y) { - m_PointStart.y = point.y; - } else if (m_PointStop.y < point.y) { - m_PointStop.y = point.y; - } - - if (m_PointStart.z > point.z) { - m_PointStart.z = point.z; - } else if (m_PointStop.z < point.z) { - m_PointStop.z = point.z; - } - } - } - #ifdef DEBUG - vec3 tmpBB(0.001,0.001,0.001); - vec3 tmpStart = m_PointStart - tmpBB; - vec3 tmpStop = m_PointStop + tmpBB; - // (start) X / Y - vec3 tmpPos = tmpStart; - m_vertices[0] = tmpStart; - tmpPos.x = tmpStop.x; - m_vertices[1] = tmpPos; - tmpPos.y = tmpStop.y; - m_vertices[2] = tmpPos; - - m_vertices[3] = tmpStart; - m_vertices[4] = tmpPos; - tmpPos.x = tmpStart.x; - m_vertices[5] = tmpPos; - - // (start) Y / Z - tmpPos = tmpStart; - m_vertices[6] = tmpStart; - tmpPos.z = tmpStop.z; - m_vertices[7] = tmpPos; - tmpPos.y = tmpStop.y; - m_vertices[8] = tmpPos; - - m_vertices[9] = tmpStart; - m_vertices[10] = tmpPos; - tmpPos.z = tmpStart.z; - m_vertices[11] = tmpPos; - - // (start) X / Z - tmpPos = tmpStart; - m_vertices[12] = tmpStart; - tmpPos.x = tmpStop.x; - m_vertices[13] = tmpPos; - tmpPos.z = tmpStop.z; - m_vertices[14] = tmpPos; - - m_vertices[15] = tmpStart; - m_vertices[16] = tmpPos; - tmpPos.x = tmpStart.x; - m_vertices[17] = tmpPos; - - - // (stop) X / Y - tmpPos = tmpStop; - m_vertices[18] = tmpStop; - tmpPos.x = tmpStart.x; - m_vertices[19] = tmpPos; - tmpPos.y = tmpStart.y; - m_vertices[20] = tmpPos; - - m_vertices[21] = tmpStop; - m_vertices[22] = tmpPos; - tmpPos.x = tmpStop.x; - m_vertices[23] = tmpPos; - - // (stop) Y / Z - tmpPos = tmpStop; - m_vertices[24] = tmpStop; - tmpPos.z = tmpStart.z; - m_vertices[25] = tmpPos; - tmpPos.y = tmpStart.y; - m_vertices[26] = tmpPos; - - m_vertices[27] = tmpStop; - m_vertices[28] = tmpPos; - tmpPos.z = tmpStop.z; - m_vertices[29] = tmpPos; - - // (stop) X / Z - tmpPos = tmpStop; - m_vertices[30] = tmpStop; - tmpPos.x = tmpStart.x; - m_vertices[31] = tmpPos; - tmpPos.z = tmpStart.z; - m_vertices[32] = tmpPos; - - m_vertices[33] = tmpStop; - m_vertices[34] = tmpPos; - tmpPos.x = tmpStop.x; - m_vertices[35] = tmpPos; - #endif -} - - -void game::BoundingAABB::Draw(void) -{ - #ifdef DEBUG - draw::Colorf color(0.0, 1.0, 0.0, 0.2); - if (true == m_hasContact) { - color = draw::Colorf(1.0, 0.0, 0.0, 0.2); - } - if (0 != m_vertices.Size()) { - if (NULL != m_displayBounding) { - m_displayBounding->Draw(m_vertices, color, false); - } - } else { - EWOL_DEBUG("Bounding size is not correct..."); - } - #endif -} - - -bool game::BoundingAABB::HasContact(game::BoundingAABB& obj) -{ - if( m_PointStart.x > obj.m_PointStop.x - || m_PointStop.x < obj.m_PointStart.x - || m_PointStart.y > obj.m_PointStop.y - || m_PointStop.y < obj.m_PointStart.y - || m_PointStart.z > obj.m_PointStop.z - || m_PointStop.z < obj.m_PointStart.z) { - return false; - } - return true; -} - - -vec3 game::BoundingAABB::CalculatePetetration(game::BoundingAABB& bbb, vec3& movingVect) -{ - float tmin = 0; - // note : We considere the AAA has this is the moving element... - // B is condered has a fixed element ... - vec3 penetration(0,0,0); - // X - if (movingVect.x >= 0) { - // case 1 : - // ==> - // AAAAAAAAAAAAAA - // BBBBBBBBBBBBB - // case 2 : - // ==> - // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - // BBBBBBBBBBBBB - // case 3 : - // ==> - // AAAAAAAAAAAAA - // BBBBBBBBBBBBBBB - // case 4 : - // ==> - // AAAAAAAAAAAAA - // BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB - penetration.x = m_PointStop.x - bbb.m_PointStart.x; - } else { - // case 1 : - // <== - // AAAAAAAAAAAAAA - // BBBBBBBBBBBBB - // case 2 : - // <== - // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - // BBBBBBBBBBBBB - // case 3 : - // <== - // AAAAAAAAAAAAA - // BBBBBBBBBBBBBBB - // case 4 : - // <== - // AAAAAAAAAAAAA - // BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB - penetration.x = m_PointStart.x - bbb.m_PointStop.x; - } - // Y - if (movingVect.y >= 0) { - penetration.y = m_PointStop.y - bbb.m_PointStart.y; - } else { - penetration.y = m_PointStart.y - bbb.m_PointStop.y; - } - // Z - if (movingVect.z >= 0) { - penetration.z = m_PointStop.z - bbb.m_PointStart.z; - } else { - penetration.z = m_PointStart.z - bbb.m_PointStop.z; - } - return penetration; - - -/* - // note : We considere the AAA has this is the moving element... - // B is condered has a fixed element ... - vec3 penetration(0,0,0); - // X - if (movingVect.x >= 0) { - // case 1 : - // ==> - // AAAAAAAAAAAAAA - // BBBBBBBBBBBBB - // case 2 : - // ==> - // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - // BBBBBBBBBBBBB - // case 3 : - // ==> - // AAAAAAAAAAAAA - // BBBBBBBBBBBBBBB - // case 4 : - // ==> - // AAAAAAAAAAAAA - // BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB - penetration.x = m_PointStop.x - bbb.m_PointStart.x; - } else { - // case 1 : - // <== - // AAAAAAAAAAAAAA - // BBBBBBBBBBBBB - // case 2 : - // <== - // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - // BBBBBBBBBBBBB - // case 3 : - // <== - // AAAAAAAAAAAAA - // BBBBBBBBBBBBBBB - // case 4 : - // <== - // AAAAAAAAAAAAA - // BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB - penetration.x = m_PointStart.x - bbb.m_PointStop.x; - } - // Y - if (movingVect.y >= 0) { - penetration.y = m_PointStop.y - bbb.m_PointStart.y; - } else { - penetration.y = m_PointStart.y - bbb.m_PointStop.y; - } - // Z - if (movingVect.z >= 0) { - penetration.z = m_PointStop.z - bbb.m_PointStart.z; - } else { - penetration.z = m_PointStart.z - bbb.m_PointStop.z; - } - return penetration; -*/ -} - diff --git a/sources/ewol/game/BoundingAABB.h b/sources/ewol/game/BoundingAABB.h deleted file mode 100644 index d97d4376..00000000 --- a/sources/ewol/game/BoundingAABB.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __GAME_BOUNDING_AABB_H__ -#define __GAME_BOUNDING_AABB_H__ - -#include "etk/math/Vector3D.h" -#include "etk/math/Matrix4.h" -#include "ewol/renderer/resources/Colored3DObject.h" - -namespace game -{ - class BoundingAABB - { - private : - vec3 m_PointStart; - vec3 m_PointStop; - bool m_hasContact; //!< this bounding is on contact with something else ... - vec3 m_oldUserPosition; // this is due to the fact object are never centered ... - #ifdef DEBUG - ewol::Colored3DObject* m_displayBounding; - etk::Vector m_vertices; - #endif - public: - /** - * @biref Main constructor. - */ - BoundingAABB(void); - /** - * @biref Main constructor. - */ - virtual ~BoundingAABB(void); - /** - * @brief Update Bounding properties. - */ - virtual void Update(game::MeshObject& object, mat4& transformMatrix); - /** - * @brief Draw the bounding ==> for test ... - */ - virtual void Draw(void); - /** - * @brief Detect the colision positions. - */ - virtual bool HasContact(game::BoundingAABB& otherbounding); - /** - * @brief Calculate the penetration size in 2 bounding. - */ - virtual vec3 CalculatePetetration(game::BoundingAABB& otherbounding, vec3& movingVect); - /** - * @brief Set the contact property at a specific value ... - */ - void SetContactMode(bool newStatus) { m_hasContact=newStatus; }; - /** - * @brief Get the current contact status - */ - bool GetContactStatus(void) { return m_hasContact; }; - - vec3 Size(void) { return m_PointStop-m_PointStart; }; - }; -} - - -#endif diff --git a/sources/ewol/game/Contact.cpp b/sources/ewol/game/Contact.cpp deleted file mode 100644 index e5b0e72c..00000000 --- a/sources/ewol/game/Contact.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - - -#include - - - - -game::Contact::Contact(void) -{ - -} - - -game::Contact::~Contact(void) -{ - -} - - diff --git a/sources/ewol/game/Contact.h b/sources/ewol/game/Contact.h deleted file mode 100644 index 9e7cff69..00000000 --- a/sources/ewol/game/Contact.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __GAME_CONTACT_H__ -#define __GAME_CONTACT_H__ - - -#include -#include -#include - -namespace game -{ - class Contact - { - protected: - vec3 m_position; - game::Element* m_element[2]; - public: - /** - * @brief Basic constructor. - */ - Contact(void); - /** - * @brief Basic destructor. - */ - virtual ~Contact(void); - - /** - * Recopy operator. - */ - const Contact& operator= (const Contact& obj ) { - if( this == &obj ) { - return *this; - } - // recopy all the element ... - m_position = obj.m_position; - m_element[0] = obj.m_element[0]; - m_element[1] = obj.m_element[1]; - return *this; - } - }; -}; - - -#endif diff --git a/sources/ewol/game/Element.cpp b/sources/ewol/game/Element.cpp deleted file mode 100644 index 61c33515..00000000 --- a/sources/ewol/game/Element.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - - -#include -#include -#include - -static int32_t uniqueId = 0; - - -game::Element::Element(etk::UString meshResource) : - m_engine(NULL), - m_resource(NULL), - m_scale(1,1,1), - m_speedMax(2000000, 2000000, 2000000), - m_mass(0.0f), - m_uniqueId(uniqueId), - m_groupId(0), - m_type(0), - m_visible(true), - m_static(false) -{ - ewol::MeshObj* tmpObject = NULL; - // get a resources : - if (meshResource != "") { - ewol::resource::Keep(meshResource, tmpObject); - m_resource = tmpObject; - } - uniqueId++; - UpdateMatrix(); -} - -game::Element::~Element(void) -{ - if (NULL != m_resource) { - ewol::MeshObj* tmpObject = static_cast(m_resource); - ewol::resource::Release(tmpObject); - m_resource = NULL; - } -} - -void game::Element::Draw(void) -{ - if (NULL != m_resource) { - //EWOL_DEBUG("draw " << m_uniqueId); - m_resource->Draw(GetMatrix()); - } -} - -void game::Element::DrawDebug(void) -{ - //EWOL_DEBUG("draw bounding" << m_uniqueId); - m_bounding.Draw(); -} - - -bool game::Element::ArtificialIntelligence(float deltaMicroSecond) -{ - return false; -} - - -void game::Element::ProcessGravityClear(void) -{ - m_gravityForce = vec3(0,0,0); -} - - -void game::Element::ProcessGravity(float delta, game::Gravity& gravity) -{ - if (0==m_mass) { - return; - } - if (gravity.m_uniform==true) { - m_gravityForce += gravity.m_vect;//*m_mass; - } else { - vec3 vectSeparation = m_position - gravity.m_vect; - float squareDistance = vectSeparation.GetSquaredLength(); - // calculate gravity equation : - float force = game::GravityConst * gravity.m_mass * m_mass / squareDistance; - vectSeparation.Normalize(); - // generate the force vector - vectSeparation *= force; - m_gravityForce += vectSeparation; - } -} - - -void game::Element::ProcessPosition(float delta) -{ - if(true == m_bounding.GetContactStatus()) { - //EWOL_DEBUG("[" << m_uniqueId << "] ==> colisionDetection"); - return; - } - vec3 m_speed0(m_speed); - vec3 curentAcceleration(m_gravityForce + m_userAcceleration); - m_speed += curentAcceleration*delta; - vec3 tmpPos = m_position +m_speed*delta; - if (m_position != tmpPos) { - //EWOL_DEBUG("[" << m_uniqueId << "] pos=" << m_position << "m ==>" << tmpPos << "m"); - // TODO : Detect collision of other elements ... - vec3 size = m_bounding.Size(); - vec3 move = tmpPos - m_position; - vec3 moveAbs = move; - moveAbs.Abs(); - if( ( 0 < size.x - && moveAbs.x > size.x*0.75 ) - || ( 0 < size.y - && moveAbs.y > size.y*0.75 ) - || ( 0 < size.z - && moveAbs.z > size.z*0.75 )) { - int32_t maxIterations = 0; - // generate a subdivide channel to prevent tunel effects ... - // Get the smallest axis to test : - if( moveAbs.x >= moveAbs.y - && moveAbs.x >= moveAbs.z) { - //Test on X : - //estimate the number of subdivision needed in recursive mode : - maxIterations = moveAbs.x/abs(size.x); - //EWOL_DEBUG("[" << m_uniqueId << "] XXX move with dist=" << move << "m <" << size*0.75 << "m"); - } else if ( moveAbs.y >= moveAbs.x - && moveAbs.y >= moveAbs.z) { - //Test on Y : - //estimate the number of subdivision needed in recursive mode : - maxIterations = moveAbs.y/abs(size.y); - //EWOL_DEBUG("[" << m_uniqueId << "] YYY move with dist=" << move << "m <" << size*0.75 << "m"); - } else { - //Test on Z : - //estimate the number of subdivision needed in recursive mode : - maxIterations = moveAbs.z/abs(size.z); - //EWOL_DEBUG("[" << m_uniqueId << "] ZZZ move with dist=" << move << "m <" << size*0.75 << "m"); - } - vec3 deltaMove = move/maxIterations; - vec3 tmppppPos = m_position; - game::BoundingAABB tmpBounding; - - // linear test : - for (int32_t iii=0; iiim_object, transformMatrix); - if (true == m_engine->HasCollision(tmpBounding, this)) { - tmpPos = tmppppPos; - // the tunnel effect is catch ... - EWOL_CRITICAL("[" << m_uniqueId << "] Tunel effect catch : (" << iii << "/" << maxIterations-1 << ") ==> " << tmppppPos); - break; - } - } - } - //EWOL_DEBUG("[" << m_uniqueId << "] New pos:" << tmpPos << "m"); - vec3 moving = tmpPos - m_position; - m_position = tmpPos; - UpdateMatrix(); - m_engine->ObjectMove(this, moving); - } -} - -void game::Element::UpdateMatrix(void) -{ - m_matrix = etk::matTranslate(m_position) - * etk::matScale(m_scale) - * m_displayRotation; - m_bounding.Update(m_resource->m_object, m_matrix); -} - -void game::Element::Identity(void) -{ - m_position = vec3(0,0,0); - m_speed = vec3(0,0,0); - m_displayRotation.Identity(); - m_matrix.Identity(); -} - -void game::Element::Translate(etk::Vector3D vect) -{ - m_position += vect; - UpdateMatrix(); -} - -void game::Element::Scale(etk::Vector3D vect) -{ - m_scale = vect; - UpdateMatrix(); -} - -void game::Element::Scale(float proportion) -{ - m_scale = vec3(proportion,proportion,proportion); - UpdateMatrix(); -} - -void game::Element::Rotate(etk::Vector3D vect, float angleRad) -{ - m_displayRotation = etk::matRotate(vect, angleRad) * m_displayRotation; - UpdateMatrix(); -} - -mat4& game::Element::GetMatrix(void) -{ - return m_matrix; -} - - -void game::Element::CollisionDetected(game::Element* elementCollide, vec3& penetrate) -{ - m_position -= penetrate; - UpdateMatrix(); -} - diff --git a/sources/ewol/game/Element.h b/sources/ewol/game/Element.h deleted file mode 100644 index 28068830..00000000 --- a/sources/ewol/game/Element.h +++ /dev/null @@ -1,157 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __GAME_ELEMENT_H__ -#define __GAME_ELEMENT_H__ - - -#include -#include -#include -#include -#include -#include -#include - -namespace game -{ - class Engine; - class Element - { - protected: - game::Engine* m_engine; - ewol::Mesh* m_resource; //!< Resource to display the element. - game::BoundingAABB m_bounding; //!< Bounding of this element - private: - mat4 m_matrix; //!< generated display matrix. - vec3 m_scale; //!< scale of the element. (change the size in dynamic from the loaded model) - mat4 m_displayRotation; //!< Associated matrix of totation associated with m_displayAngle. - - protected: - // specific for the physical engine : - vec3 m_position; //!< position of the element. (in m) - vec3 m_speed; //!< Speed of the element. (in m/s) - vec3 m_speedMax; //!< Speed maximum limitation. (in m/s) - float m_mass; //!< object mass (in kg) - vec3 m_gravityForce; //!< curent gravity force in newton of the object (m/s^2) - vec3 m_userAcceleration; //!< the only one parameter that the user can change (m/s^2), if the coder want that the equation do not take stipid things ... - - protected: - uint32_t m_uniqueId; //!< General element ID (uint16_t, because all is reference with the groupId like this only a uint32_t reference an element) - uint32_t m_groupId; //!< General group Id More than 65000 group can be really interesting to create supid game ... - int32_t m_type; //!< type of this element - bool m_visible; //!< This is to know if the element is displayed or not ==> TODO : check if usefull ... - bool m_static; //!< This element is static... - public: - /** - * @brief Basic constructor. - * @param[in] meshResource Resource name. - */ - Element(etk::UString meshResource); - /** - * @brief Basic destructor. - */ - virtual ~Element(void); - /** - * @brief Link with a specific engine. - * @param[in] engine Engine pointer - */ - void SetEngine(game::Engine* engine) { m_engine = engine; }; - /** - * @brief Draw the element. - */ - virtual void Draw(void); - /** - * @brief Draw Debug information of the element. - */ - virtual void DrawDebug(void); - /** - * @brief Process IA of this element. - * @param[in] deltaMicroSecond delta from the last call. - * @return true if this element must be destroyed - */ - virtual bool ArtificialIntelligence(float delta); - /** - * @brief Clear the current gravity reference - */ - void ProcessGravityClear(void); - /** - * @brief Update the gravity properties. - * @param[in] delta delta from the last call. - * @param[in] gravity reference on all the gravity point. - */ - virtual void ProcessGravity(float delta, game::Gravity& gravity); - /** - * @brief Update the position of the element - * @param[in] delta delta from the last call. - */ - virtual void ProcessPosition(float delta); - /** - * @param reset the position / speed / angle / and result matrix - */ - void Identity(void); - /** - * @brief Translate The curent element to a new position - * @param[in] vect new position - */ - void Translate(etk::Vector3D vect); - /** - * @brief Scale the element to an other size - * @param[in] vect new object scaling - */ - void Scale(etk::Vector3D vect); - /** - * @brief Scale the element to an other size - * @param[in] proportion scale value in all direction ... - */ - void Scale(float proportion); - /** - * @brief Rotate the current object - * @param[in] vect rotation angle - * @param[in] angleRad radian angle - */ - void Rotate(etk::Vector3D vect, float angleRad=0.0); - /** - * @brief Get the Current matrix of the element (never access it directly, it might be sometime updated) - * @return the reference on the matrix (updated if needed) - */ - mat4& GetMatrix(void); - private: - /** - * @brief when position or rotation is set, the system call this function ... - */ - void UpdateMatrix(void); - public: - void SetSpeed(vec3 newSpeed) - { - m_speed = newSpeed; - } - - game::BoundingAABB& GetBounding(void) - { - return m_bounding; - } - /** - * @brief Set this element Static or not - */ - void SetStaticMode(bool newMode) { m_static = newMode; }; - /** - * @brief Get the current static or dynamic mode - */ - bool GetStaticMode(void) { return m_static; }; - /** - * @brief A collision has bee detected ... - * @param[in] elementCollide the element that has been collided - * @param[in] penetrate The size of the penetration ... - */ - virtual void CollisionDetected(game::Element* elementCollide, vec3& penetrate); - }; -}; - - -#endif diff --git a/sources/ewol/game/Engine.cpp b/sources/ewol/game/Engine.cpp deleted file mode 100644 index 04b9a93d..00000000 --- a/sources/ewol/game/Engine.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - - -#include - - - - -game::Engine::Engine(void) -{ - -} - -game::Engine::~Engine(void) -{ - for (int32_t iii=0; iiiProcessGravity(deltaTime, m_gravity[jjj]); - } - m_elements[iii]->ProcessPosition(deltaTime); - } - } -} - -void game::Engine::ProcessIA(float deltaTime) -{ - //EWOL_DEBUG("Artificial Intelligence management"); - for (int32_t iii=0; iiiArtificialIntelligence(deltaTime); - } - } -} - -void game::Engine::ProcessCollision(float deltaTime) -{ - //EWOL_DEBUG("Collision management"); - m_contacts.Clear(); - for (int32_t iii=0; iiiGetBounding(); - bounding1.SetContactMode(false); - } - } - // Brut force bounding detection : - for (int32_t iii=0; iiiGetStaticMode()) { - game::BoundingAABB& bounding1 = m_elements[iii]->GetBounding(); - for (int32_t jjj=iii+1; jjjGetBounding(); - if (true == bounding2.HasContact(bounding1)) { - bounding2.SetContactMode(true); - bounding1.SetContactMode(true); - } - } - } - } - } - } -} - - -bool game::Engine::HasCollision(game::BoundingAABB& bounding, game::Element* currentElement) -{ - if (NULL == currentElement) { - return false; - } - // Brut force bounding detection : - for (int32_t iii=0; iiiGetBounding())) { - return true; - } - } - } - return false; -} - -void game::Engine::ObjectMove(game::Element* currentElement, vec3& movingVect) -{ - if (NULL == currentElement) { - return; - } - game::BoundingAABB& bounding = currentElement->GetBounding(); - // Brut force bounding detection : - for (int32_t iii=0; iiiGetBounding())) { - vec3 penetrate = bounding.CalculatePetetration(m_elements[iii]->GetBounding(), movingVect); - currentElement->CollisionDetected(m_elements[iii], penetrate); - } - } - } -} - - -void game::Engine::Draw(ewol::DrawProperty& displayProp) -{ - //EWOL_DEBUG("Drawing the system"); - for (int32_t iii=0; iiiDraw(); - } - } - #ifdef DEBUG - for (int32_t iii=0; iiiDrawDebug(); - } - } - #endif -} - - -void game::Engine::AddElement(game::Element* newElement) -{ - bool find=false; - if (NULL == newElement) { - EWOL_ERROR("try to set a NULL pointer game::Element"); - } - for (int32_t iii=0 ; iiiSetEngine(this); - } -} - - -void game::Engine::AddGravity(game::Gravity gravity) -{ - m_gravity.PushBack(gravity); -} - diff --git a/sources/ewol/game/Engine.h b/sources/ewol/game/Engine.h deleted file mode 100644 index 287a0292..00000000 --- a/sources/ewol/game/Engine.h +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __GAME_ENGINE_H__ -#define __GAME_ENGINE_H__ - - -#include -#include -#include -#include -#include -#include - - - -namespace game -{ - class Engine - { - private: - etk::Vector m_gravity; //!< list of gravity element - etk::Vector m_elements; //!< List of the game element - etk::Vector m_contacts; //!< list of all contact that existe in the system - public: - /** - * @brief Basic constructor. - */ - Engine(void); - /** - * @brief Basic destructor. - */ - ~Engine(void); - /** - * @brief periodic call for processing. - * @param[in] lastTime Previous call time (if the system is in pause this time does restart at the same time the next time. - * @param[in] deltaTime delta time in µs from the previous call. - */ - void Process(double lastTime, float deltaTime); - /** - * @brief Processing the gravity properties. - * @param[in] deltaTime delta time in µs from the previous call. - */ - void ProcessGravity(float deltaTime); - /** - * @brief Processing the Artificial Intelligence. - * @param[in] deltaTime delta time in µs from the previous call. - */ - void ProcessIA(float deltaTime); - /** - * @brief Processing the collision. - * @param[in] deltaTime delta time in µs from the previous call. - */ - void ProcessCollision(float deltaTime); - /** - * @brief parse all the element to know if a bounding has a contact with some other elements ... - * @param[in] bounding the reference bounding - * @param[in] currentElement The element that request the detection ==> permit to not detect itself... - */ - bool HasCollision(game::BoundingAABB& bounding, game::Element* currentElement); - /** - * @brief : this object has move, we need to update some collition, and some other things ... - * @param[in] currentElement The element that request the detection ==> permit to not detect itself... - * @param[in] movingVect : the vector that has move the current element. - */ - void ObjectMove(game::Element* currentElement, vec3& movingVect); - /** - * @brief Display the environement. - */ - void Draw(ewol::DrawProperty& displayProp); - /** - * @brief Add an element on the system. - * @param[in] newElement element to display. - */ - void AddElement(game::Element* newElement); - /** - * @brief Add a gravity on the system. - * @param[in] gravity The gravity to add. - */ - void AddGravity(game::Gravity gravity); - }; -}; - - -#endif - diff --git a/sources/ewol/game/Gravity.cpp b/sources/ewol/game/Gravity.cpp deleted file mode 100644 index cb940780..00000000 --- a/sources/ewol/game/Gravity.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#include -#include -#include - - - -game::Gravity::Gravity(void) : - m_uniform(false), - m_mass(0), - m_vect(0,0,0) -{ - -} - -game::Gravity::Gravity(bool uniform, float mass, vec3 vect) : - m_uniform(uniform), - m_mass(mass), - m_vect(vect) -{ - -} - -// gravity force is : -// F = G*m1*m2 / radius^2. - -extern const float game::GravityConst = 0.0000000000667f; -// Earth -extern const float game::earthMass = 5973600000000000000000000.0f; // in kg -extern const float game::earthRadius = 6378137.0f; // in meter -extern const game::Gravity game::gravityEarth(true, earthMass, vec3(0, 0, -(float)((GravityConst*earthMass)/(earthRadius*earthRadius))) ); -// Mars -extern const float game::marsMass = 25000000000000000.0f; // in kg -extern const float game::marsRadius = 3396200.0f; // in meter -extern const game::Gravity game::gravityMars(true, marsMass, vec3(0, 0, -(float)((GravityConst*marsMass)/(marsRadius*marsRadius))) ); - - - diff --git a/sources/ewol/game/Gravity.h b/sources/ewol/game/Gravity.h deleted file mode 100644 index 759bbe7a..00000000 --- a/sources/ewol/game/Gravity.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __GAME_GRAVITY_H__ -#define __GAME_GRAVITY_H__ - - -#include -#include - - - -namespace game -{ - class Gravity - { - public: - bool m_uniform; //!< The gravity is not a stelar object - float m_mass; //!< Masse of the stelar object. - vec3 m_vect; //!< Position of the stelar object or gravity(acceleration) force when it is uniform. - Gravity(void); - Gravity(bool uniform, float mass, vec3 vect); - }; - extern const float GravityConst; - // Earth - extern const float earthMass; - extern const float earthRadius; - extern const Gravity gravityEarth; - // Mars - extern const float marsMass; - extern const float marsRadius; - extern const Gravity gravityMars; - -}; - -#endif - diff --git a/sources/ewol/game/Map.cpp b/sources/ewol/game/Map.cpp deleted file mode 100644 index 4b6d4347..00000000 --- a/sources/ewol/game/Map.cpp +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ diff --git a/sources/ewol/game/Map.h b/sources/ewol/game/Map.h deleted file mode 100644 index e56700f9..00000000 --- a/sources/ewol/game/Map.h +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __GAME_MAP_H__ -#define __GAME_MAP_H__ - -#include "ewol/debug.h" - - -#endif diff --git a/sources/ewol/game/Mass.cpp b/sources/ewol/game/Mass.cpp deleted file mode 100644 index 4b6d4347..00000000 --- a/sources/ewol/game/Mass.cpp +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ diff --git a/sources/ewol/game/Mass.h b/sources/ewol/game/Mass.h deleted file mode 100644 index d069287c..00000000 --- a/sources/ewol/game/Mass.h +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __GAME_MASS_H__ -#define __GAME_MASS_H__ - -#include "ewol/debug.h" - - - -namespace game -{ - class Mass - { - - }; -}; - - -#endif diff --git a/sources/ewol/game/MeshObject.h b/sources/ewol/game/MeshObject.h deleted file mode 100644 index 9be0e914..00000000 --- a/sources/ewol/game/MeshObject.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __GAME_MESH_OBJECT_H__ -#define __GAME_MESH_OBJECT_H__ - -#include -#include -#include -#include - -namespace game -{ - class MeshObject - { - public: - etk::Vector m_indices; - etk::Vector m_vertices; - etk::Vector m_uvTextures; - etk::Vector m_normals; - public: - MeshObject(void) {}; - virtual ~MeshObject(void) {}; - }; -}; - - -#endif - - diff --git a/sources/ewol/game/Sky.cpp b/sources/ewol/game/Sky.cpp deleted file mode 100644 index 4b6d4347..00000000 --- a/sources/ewol/game/Sky.cpp +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ diff --git a/sources/ewol/game/Sky.h b/sources/ewol/game/Sky.h deleted file mode 100644 index 334a607b..00000000 --- a/sources/ewol/game/Sky.h +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __EPHYSICS_SKY_H__ -#define __EPHYSICS_SKY_H__ - -#include "ewol/debug.h" - - -#endif diff --git a/sources/ewol/renderer/resources/Colored3DObject.h b/sources/ewol/renderer/resources/Colored3DObject.h index a82a9d5e..383ba397 100644 --- a/sources/ewol/renderer/resources/Colored3DObject.h +++ b/sources/ewol/renderer/resources/Colored3DObject.h @@ -14,7 +14,6 @@ #include #include #include -#include namespace ewol { diff --git a/sources/ewol/renderer/resources/Mesh.cpp b/sources/ewol/renderer/resources/Mesh.cpp index 395efd7b..4d8ec169 100644 --- a/sources/ewol/renderer/resources/Mesh.cpp +++ b/sources/ewol/renderer/resources/Mesh.cpp @@ -39,7 +39,7 @@ ewol::Mesh::~Mesh(void) void ewol::Mesh::Draw(mat4& positionMatrix) { - if (m_object.m_vertices.Size()<=0) { + if (m_vertices.Size()<=0) { return; } if (NULL == m_texture1) { @@ -61,13 +61,13 @@ void ewol::Mesh::Draw(mat4& positionMatrix) // TextureID m_GLprogram->SetTexture0(m_GLtexID, m_texture1->GetId()); // position : - m_GLprogram->SendAttribute(m_GLPosition, 3/*x,y,z*/, &m_object.m_vertices[0]); + m_GLprogram->SendAttribute(m_GLPosition, 3/*x,y,z*/, &m_vertices[0]); // Texture : - m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_object.m_uvTextures[0]); + m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_uvTextures[0]); // color : m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); // Request the draw od the elements : - glDrawArrays(GL_TRIANGLES, 0, m_object.m_vertices.Size()); + glDrawArrays(GL_TRIANGLES, 0, m_vertices.Size()); m_GLprogram->UnUse(); glDisable(GL_DEPTH_TEST); } diff --git a/sources/ewol/renderer/resources/Mesh.h b/sources/ewol/renderer/resources/Mesh.h index 8f20b41e..d2e2c21e 100644 --- a/sources/ewol/renderer/resources/Mesh.h +++ b/sources/ewol/renderer/resources/Mesh.h @@ -14,7 +14,6 @@ #include #include #include -#include namespace ewol { @@ -28,7 +27,10 @@ namespace ewol int32_t m_GLtexture; int32_t m_GLtexID; public: - game::MeshObject m_object; + etk::Vector m_indices; + etk::Vector m_vertices; + etk::Vector m_uvTextures; + etk::Vector m_normals; protected: ewol::TextureFile* m_texture1; etk::Vector m_coordColor; //!< internal color of the different point diff --git a/sources/ewol/renderer/resources/MeshObj.cpp b/sources/ewol/renderer/resources/MeshObj.cpp index 60b01fe2..73a76822 100644 --- a/sources/ewol/renderer/resources/MeshObj.cpp +++ b/sources/ewol/renderer/resources/MeshObj.cpp @@ -180,15 +180,17 @@ ewol::MeshObj::MeshObj(etk::UString _fileName) : uint32_t uvIndex = indicesUv[iii]; // Put the attributes in buffers - m_object.m_vertices.PushBack(vertices[vertexIndex-1]); - m_object.m_uvTextures.PushBack(uvTextures[uvIndex-1]); + m_vertices.PushBack(vertices[vertexIndex-1]); + m_uvTextures.PushBack(uvTextures[uvIndex-1]); draw::Color tmpppp(0xFFFFFFFF); draw::Colorf tmppppp(tmpppp); m_coordColor.PushBack(tmppppp); if (indicesNormal.Size()>iii) { uint32_t normalIndex = indicesNormal[iii]; - m_object.m_normals.PushBack(normals[normalIndex-1]); + m_normals.PushBack(normals[normalIndex-1]); } } } + + diff --git a/sources/ewol/widget/Scene.h b/sources/ewol/widget/Scene.h index ea0117f2..4a8e8273 100644 --- a/sources/ewol/widget/Scene.h +++ b/sources/ewol/widget/Scene.h @@ -14,8 +14,6 @@ #include #include #include -#include -#include #include #include #include @@ -45,7 +43,6 @@ namespace widget { //keep the collision shapes, for deletion/cleanup etk::Vector m_collisionShapes; game::Camera m_camera; //!< Display point of view - //game::Engine* m_gameEngine; //!< display engine system bool m_isRunning; //!< the display is running (not in pause) double m_lastCallTime; //!< previous call Time float m_ratioTime; //!< Ratio time for the speed of the game ... diff --git a/sources/file.mk b/sources/file.mk index 6454509f..9759862e 100644 --- a/sources/file.mk +++ b/sources/file.mk @@ -82,15 +82,7 @@ FILE_LIST+= ewol/widget/Widget.cpp \ # game mode area : FILE_LIST+= ewol/widget/Scene.cpp \ - ewol/game/Engine.cpp \ - ewol/game/Element.cpp \ - ewol/game/BoundingAABB.cpp \ - ewol/game/Gravity.cpp \ - ewol/game/Camera.cpp \ - ewol/game/Contact.cpp \ - ewol/game/Map.cpp \ - ewol/game/Mass.cpp \ - ewol/game/Sky.cpp + ewol/game/Camera.cpp LOCAL_COPY_FILES := ../data/textured3D.prog:textured3D.prog \