diff --git a/Makefile.mk b/Makefile.mk index 1103a47f..f481f8ce 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -19,7 +19,6 @@ USER_PACKAGES+= $(TMP_DIR)/external/portaudio USER_PACKAGES+= $(TMP_DIR)/external/tinyxml USER_PACKAGES+= $(TMP_DIR)/external/z USER_PACKAGES+= $(TMP_DIR)/external/zip -USER_PACKAGES+= $(TMP_DIR)/external/ePhysics #include te generic toolchain : include $(TMP_DIR)/build/Makefile.mk diff --git a/external/etk b/external/etk index e6af555b..0b2050cf 160000 --- a/external/etk +++ b/external/etk @@ -1 +1 @@ -Subproject commit e6af555b152d01a561526bc8c5515338cec464fe +Subproject commit 0b2050cf687a0f698b838df781a8095a9e92939d diff --git a/sources/Linux.mk b/sources/Linux.mk index 182e50a9..6f6b1932 100644 --- a/sources/Linux.mk +++ b/sources/Linux.mk @@ -12,7 +12,7 @@ LOCAL_VERSION=$(shell cat $(LOCAL_PATH)/tag) $(info [TAG:$(LOCAL_MODULE)] $(LOCAL_VERSION)) # name of the dependency -LOCAL_LIBRARIES := etk freetype tinyxml libzip libpng parsersvg lua portaudio ephysics +LOCAL_LIBRARIES := etk freetype tinyxml libzip libpng parsersvg lua portaudio LOCAL_C_INCLUDES := diff --git a/sources/ewol/game/Bounding.cpp b/sources/ewol/game/Bounding.cpp new file mode 100644 index 00000000..c8b4250e --- /dev/null +++ b/sources/ewol/game/Bounding.cpp @@ -0,0 +1,24 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#include + + +game::Bounding::Bounding(boundingMode mode) : + m_markedToUpdate(true), + m_mode(mode) +{ + +} + +game::Bounding::~Bounding(void) +{ + +} + + diff --git a/sources/ewol/game/Bounding.h b/sources/ewol/game/Bounding.h new file mode 100644 index 00000000..5b03b83d --- /dev/null +++ b/sources/ewol/game/Bounding.h @@ -0,0 +1,59 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#ifndef __GAME_BOUNDING_H__ +#define __GAME_BOUNDING_H__ + +#include "ewol/debug.h" +#include "ewol/game/MeshObject.h" +#include "ewol/game/MeshProperty.h" + +namespace game +{ + typedef enum { + BoundingModeNone, //!< No Bounding. + BoundingModePlane, //!< plane Bounding. + BoundingModeAABB, //!< Anti-aligned Bounding Boxes. + BoundingModeSphere, //!< Sphere. + BoundingModeOBB, //!< Oriented Bounding Box. + // TODO : Add more if needed to implement + } boundingMode; + + class Bounding + { + protected : + bool m_markedToUpdate; //!< Marked to update the bounding properties. + boundingMode m_mode; //!< bounding mode of this system. + public: + /** + * @biref Main constructor. + * @param[in] mode Bounding mode. + */ + Bounding(boundingMode mode); + /** + * @biref Main constructor. + */ + virtual ~Bounding(void); + /** + * @brief Request the update of the bounding for the next step + */ + void NeedUpdate(void) { m_markedToUpdate = true; }; + /** + * @brief Get the bounding type + * @return the bounding type; + */ + boundingMode GetType(void) { return m_mode; }; + /** + * @brief Update Bounding properties. + */ + virtual void Update(game::MeshObject& object, game::MeshProperty& property) = 0; + }; + +}; + +#endif diff --git a/sources/ewol/game/BoundingAABB.cpp b/sources/ewol/game/BoundingAABB.cpp new file mode 100644 index 00000000..3e8cfebd --- /dev/null +++ b/sources/ewol/game/BoundingAABB.cpp @@ -0,0 +1,38 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#include +#include +#include + + +game::BoundingAABB::BoundingAABB(void) : + Bounding(game::BoundingModeAABB) +{ + +} + +game::BoundingAABB::~BoundingAABB(void) +{ + +} + +void game::BoundingAABB::Update(game::MeshObject& object, game::MeshProperty& property) +{ + if (true==m_markedToUpdate) { + mat4 transMat = etk::matRotate(property.m_angle) * etk::matTranslate(property.m_position); + m_markedToUpdate=false; + for (int32_t iii=0; iii +#include + + +game::BoundingOBB::BoundingOBB(game::MeshObject& object, game::MeshProperty& property) : + Bounding(game::BoundingModeOBB) +{ + +} + +game::BoundingOBB::~BoundingOBB(void) +{ + +} + +void game::BoundingOBB::Update(game::MeshObject& object, game::MeshProperty& property) +{ + +} + + + diff --git a/sources/ewol/game/BoundingOBB.h b/sources/ewol/game/BoundingOBB.h new file mode 100644 index 00000000..ffe920f5 --- /dev/null +++ b/sources/ewol/game/BoundingOBB.h @@ -0,0 +1,41 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#ifndef __GAME_BOUNDING_OBB_H__ +#define __GAME_BOUNDING_OBB_H__ + +#include "ewol/game/Bounding.h" +#include "etk/math/Vector3D.h" + +namespace game +{ + class BoundingOBB : public Bounding + { + private : + vec3 m_PointCenter; + vec3 m_radius; + vec3 m_angle; + public: + /** + * @biref Main constructor. + * @param[in] mode Bounding mode. + */ + BoundingOBB(game::MeshObject& object, game::MeshProperty& property); + /** + * @biref Main constructor. + */ + virtual ~BoundingOBB(void); + /** + * @brief Update Bounding properties. + */ + virtual void Update(game::MeshObject& object, game::MeshProperty& property); + }; +} + + +#endif diff --git a/sources/ewol/game/BoundingPlane.cpp b/sources/ewol/game/BoundingPlane.cpp new file mode 100644 index 00000000..4a67d91d --- /dev/null +++ b/sources/ewol/game/BoundingPlane.cpp @@ -0,0 +1,30 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#include +#include + + +game::BoundingPlane::BoundingPlane(void) : + Bounding(game::BoundingModePlane) +{ + +} + +game::BoundingPlane::~BoundingPlane(void) +{ + +} + +void game::BoundingPlane::Update(game::MeshObject& object, game::MeshProperty& property) +{ + +} + + + diff --git a/sources/ewol/game/BoundingPlane.h b/sources/ewol/game/BoundingPlane.h new file mode 100644 index 00000000..36c07aa5 --- /dev/null +++ b/sources/ewol/game/BoundingPlane.h @@ -0,0 +1,39 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#ifndef __GAME_BOUNDING_PLANE_H__ +#define __GAME_BOUNDING_PLANE_H__ + +#include "ewol/game/Bounding.h" +#include "etk/math/Vector3D.h" + +namespace game +{ + class BoundingPlane : public Bounding + { + private : + vec3 m_equation; + public: + /** + * @biref Main constructor. + * @param[in] mode Bounding mode. + */ + BoundingPlane(void); + /** + * @biref Main constructor. + */ + virtual ~BoundingPlane(void); + /** + * @brief Update Bounding properties. + */ + virtual void Update(game::MeshObject& object, game::MeshProperty& property); + }; +} + + +#endif diff --git a/sources/ewol/game/BoundingSphere.cpp b/sources/ewol/game/BoundingSphere.cpp new file mode 100644 index 00000000..c658631c --- /dev/null +++ b/sources/ewol/game/BoundingSphere.cpp @@ -0,0 +1,31 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#include +#include + + +game::BoundingSphere::BoundingSphere(void) : + Bounding(game::BoundingModeSphere) +{ + +} + +game::BoundingSphere::~BoundingSphere(void) +{ + +} + +void game::BoundingSphere::Update(game::MeshObject& object, game::MeshProperty& property) +{ + +} + + + + diff --git a/sources/ewol/game/BoundingSphere.h b/sources/ewol/game/BoundingSphere.h new file mode 100644 index 00000000..f6baffdb --- /dev/null +++ b/sources/ewol/game/BoundingSphere.h @@ -0,0 +1,40 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#ifndef __GAME_BOUNDING_SPHERE_H__ +#define __GAME_BOUNDING_SPHERE_H__ + +#include "ewol/game/Bounding.h" +#include "etk/math/Vector3D.h" + +namespace game +{ + class BoundingSphere : public Bounding + { + private : + vec3 m_position; //!< Position of the center of the bounding + float m_radius; //!< Radius of the Bounding + public: + /** + * @biref Main constructor. + * @param[in] mode Bounding mode. + */ + BoundingSphere(void); + /** + * @biref Main constructor. + */ + virtual ~BoundingSphere(void); + /** + * @brief Update Bounding properties. + */ + virtual void Update(game::MeshObject& object, game::MeshProperty& property); + }; +} + + +#endif diff --git a/sources/ewol/game/Element.cpp b/sources/ewol/game/Element.cpp index b38ceb88..98bac69b 100644 --- a/sources/ewol/game/Element.cpp +++ b/sources/ewol/game/Element.cpp @@ -29,6 +29,10 @@ game::Element::Element(etk::UString meshResource) : m_resource = tmpObject; } uniqueId++; + + m_property.Scale(vec3(100,100,100) ); + //m_property.Rotate(m_property.m_angle, rotx); + m_property.Translate(vec3(0.01,0.0,0.0)); } game::Element::~Element(void) @@ -43,10 +47,7 @@ game::Element::~Element(void) void game::Element::Draw(void) { if (NULL != m_resource) { - m_property.m_matrix = etk::matScale(vec3(100,100,100) ) - /* etk::matRotate(m_property.m_angle, rotx)*/ - * etk::matTranslate(vec3(0.01,0.0,0.0)); - m_resource->Draw(m_property.m_matrix); + m_resource->Draw(m_property.GetMatrix()); } } diff --git a/sources/ewol/game/Element.h b/sources/ewol/game/Element.h index 915a6f84..bdbb531b 100644 --- a/sources/ewol/game/Element.h +++ b/sources/ewol/game/Element.h @@ -14,16 +14,16 @@ #include #include #include -#include +#include #include namespace game { class Element { - private: - ewol::Mesh* m_resource; //!< Resource to display the element. - ephysics::MeshProperty m_property; //!< display property f the element. + protected: + ewol::Mesh* m_resource; //!< Resource to display the element. + game::MeshProperty m_property; //!< display property f the element. 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 ... @@ -39,17 +39,17 @@ namespace game /** * @brief Basic destructor. */ - ~Element(void); + virtual ~Element(void); /** * @brief Draw the element. */ - void Draw(void); + virtual void Draw(void); /** * @brief Process IA of this element. * @param[in] deltaMicroSecond delta from the last call. * @return true if this element must be destroyed */ - bool ArtificialIntelligence(int32_t deltaMicroSecond); + virtual bool ArtificialIntelligence(int32_t deltaMicroSecond); }; }; diff --git a/sources/ewol/game/Engine.cpp b/sources/ewol/game/Engine.cpp index 9129286e..89f0c268 100644 --- a/sources/ewol/game/Engine.cpp +++ b/sources/ewol/game/Engine.cpp @@ -39,7 +39,6 @@ void game::Engine::Process(int64_t lastTime, int32_t deltaTime) void game::Engine::Draw(ewol::DrawProperty& displayProp) { - EWOL_DEBUG("Draw ..."); for (int32_t iii=0; iiiDraw(); diff --git a/sources/ewol/game/Engine.h b/sources/ewol/game/Engine.h index 24e58e8f..bd0ce199 100644 --- a/sources/ewol/game/Engine.h +++ b/sources/ewol/game/Engine.h @@ -14,17 +14,14 @@ #include #include #include -#include namespace game { class Engine { private: - //game::Map* m_map; //!< basic system map (BSD or other ...) etk::Vector m_elementsStatic; etk::Vector m_elementsDynamic; - ephysics::World m_world; //!< physical world engine public: /** * @brief Basic constructor. diff --git a/sources/ewol/game/GameElement.cpp b/sources/ewol/game/GameElement.cpp deleted file mode 100644 index ceb14b70..00000000 --- a/sources/ewol/game/GameElement.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#include - - -#undef __class__ -#define __class__ "GameElement" - -ewol::GameElement::GameElement(SceneElement & sceneElement, etk::UString& tmpName) : m_fileNameConfig(tmpName), m_sceneElement(sceneElement) -{ - m_uniqueId = sceneElement.GetUniqueId(); - m_group = -1; - m_type = -1; - m_visible = true; - m_position.x = 0.0; - m_position.y = 0.0; - m_speed = 0.0; - m_size = 64.0; - m_sizeDisplay = 64.0; - m_angle = 0.0; - m_mass = 0.0; - m_fileNameConfig = tmpName; - m_canBeCibled = false; - m_canHaveImpact = true; - m_life = 0; - m_enable = true; -} - - - - -float quadDist(vec2 pos1, vec2 pos2) -{ - float tmpVal1 = pos1.x - pos2.x; - float tmpVal2 = pos1.y - pos2.y; - - return tmpVal1*tmpVal1 + tmpVal2*tmpVal2; -} - - -bool ewol::GameElement::HaveImpact(int32_t group, int32_t type, vec2 position, float size) -{ - if (true != m_canHaveImpact) { - return false; - } - // check if it was in the same group - if (group == m_group) { - return false; - } - float quadDistance = quadDist(m_position, position); - float radiusElement = m_size * m_size; - if (radiusElement < quadDistance) { - //distance is greten than expected - return false; - } - return true; -} - diff --git a/sources/ewol/game/GameElement.h b/sources/ewol/game/GameElement.h deleted file mode 100644 index 3fa8c9d4..00000000 --- a/sources/ewol/game/GameElement.h +++ /dev/null @@ -1,145 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __EWOL_GAME_ELEMENT_H__ -#define __EWOL_GAME_ELEMENT_H__ - -#include -#include -#include -#include -#include -#include - -#define CYCLIC_CALL_PERIODE_US (10000) -#define NB_SPECIAL_PARAM (5) - -namespace ewol { - - class GameElement - { - private: - etk::UString m_fileNameConfig; - protected: - SceneElement & m_sceneElement; //!< All element neede in the scene - uint16_t m_uniqueId; //!< General element ID (uint16_t, because all is reference with the groupId like this only a uint32_t reference an element) - uint16_t m_group; //!< General group Id More than 65000 group can be really interesting to create supid game ... - float m_life; //!< Current life of the element - int32_t m_type; //!< - float m_power; //!< Current power of the element - bool m_visible; //!< This is to know if the element is displayed or not ==> TODO : check if usefull ... - vec2 m_position; //!< Current position of the element - float m_speed; //!< Speed of the element (only one value, the angle is generated by the m_angle - float m_angle; //!< Angle of the speed - float m_mass; //!< Current element Mass ==> for the physical calculation - float m_size; //!< Current size of the element more specific size can be done in the under class => this is for simplify calculation ==> all is consider like sphere... - float m_sizeDisplay; //!< Current diplay size of the element - bool m_canBeCibled; //!< This is for automatic finding on an ennemy - bool m_canHaveImpact; //!< detection of impact is done with this ... - float m_specialParam[NB_SPECIAL_PARAM]; //!< specific game user parameter - bool m_enable; //!< Use to add element that can not be detected by the other when user select a place - public: - /** - * @brief Constructor : here are requested all the needed sprite and effect that can be used in the game - * @param --- - * @return --- - */ - GameElement(SceneElement & sceneElement, etk::UString& tmpName); - /** - * @brief Destructor : This does not remove the sprite requested, they will be supressed when the scene is removed ... - * @param --- - * @return --- - */ - virtual ~GameElement(void) { }; - - virtual void Init(void) { }; - virtual void UnInit(void) { }; - - uint16_t GetUniqueId(void) { return m_uniqueId; }; - - bool HasName(etk::UString tmpName) { return (tmpName == m_fileNameConfig); }; - bool IsVisible(void) { return m_visible; }; - void SetVisible(bool state) { m_visible = state; StatusUpdate();}; - bool IsEnable(void) { return m_enable; }; - void SetEnable(bool state) { m_enable = state; StatusUpdate();}; - vec2 PositionGet(void) { return m_position; }; - void PositionSet(vec2 state) { m_position = state; StatusUpdate();}; - void PositionSet(float xxx, float yyy) { m_position.x = xxx; m_position.y = yyy; StatusUpdate();}; - float SpeedGet(void) { return m_speed; }; - void SpeedSet(float state) { m_speed = state; StatusUpdate();}; - float MassGet(void) { return m_mass; }; - void MassSet(float state) { m_mass = state; StatusUpdate();}; - float SizeGet(void) { return m_size; }; - void SizeSet(float state) { m_size = state; StatusUpdate();}; - float DisplaySizeGet(void) { return m_sizeDisplay; }; - void DisplaySizeSet(float state) { m_sizeDisplay = state; StatusUpdate();}; - float AngleGet(void) { return m_angle; }; - void AngleSet(float state) - { - m_angle = state; - while (m_angle > M_PI) { - m_angle -= 2.0*M_PI; - } - while (m_angle < -M_PI) { - m_angle += 2.0*M_PI; - } - StatusUpdate(); - }; - float PowerGet(void) { return m_power; }; - void PowerSet(float state) { m_power = state; StatusUpdate();}; - bool CanBeCibledGet(void) { return m_canBeCibled; }; - void CanBeCibledSet(bool state) { m_canBeCibled = state; StatusUpdate();}; - bool CanHaveImpactGet(void) { return m_canHaveImpact; }; - void CanHaveImpactSet(bool state) { m_canHaveImpact = state; StatusUpdate();}; - - int32_t GetType(void) { return m_type; }; // TODO : DEPRECATED ... - int32_t TypeGet(void) { return m_type; }; - uint16_t GroupGet(void) { return m_group; }; - void GroupSet(uint16_t state) { m_group = state; StatusUpdate();}; - - float SpecialParamGet(int32_t id) { if (id<0 || id>=NB_SPECIAL_PARAM) {return 0.0;} return m_specialParam[id]; }; - void SpecialParamSet(int32_t id, float state) { if (id<0 || id>=NB_SPECIAL_PARAM) {return;} m_specialParam[id]=state; StatusUpdate();}; - - /** - * @brief Periodicly this fuction will be call tu change property of all the dynamic obbjects - * @param[in] time Current game time (start at 0) - * @param[in] deltaTime delta time before the previous call - * @param[in,out] listOfSprite Reference on the list where the display must be done for every sprite - * @param[in,out] listOfEffects Reference on the list where the display must be done for every effects - * @return true if the object must be remove - * @return false if the object must be keep - */ - virtual bool Process(int64_t time, int32_t deltaTime) { return false; }; - - /** - * @brief Requuest the draw of the current element, it will be done on the current Sprite list - * @param[in,out] listOfSprite Reference on the list where the display must be done for every sprite - * @param[in,out] listOfEffects Reference on the list where the display must be done for every effects - * @return --- - */ - virtual void Draw(void) { }; - /** - * @brief an element has been remove, just remove reference on it or ID on IT, it can be replace whith an other that have no link - * @param[in] idOfElement Id of the element that has been removed - * @return --- - */ - virtual void RemoveElement(int32_t idOfElement) { }; - virtual bool HaveImpact(int32_t group, int32_t type, vec2 position, float size); - virtual bool Explosion(int32_t group, int32_t type, vec2 position, float pxAtenuation, float power) { return false; } ; - - virtual etk::UString Message(etk::UString control, etk::UString message) { return ""; } ; - virtual void StatusUpdate(void) { }; - }; - -}; - -#include - -float quadDist(vec2 pos1, vec2 pos2); - -#endif diff --git a/sources/ewol/game/Geometry.cpp b/sources/ewol/game/Geometry.cpp new file mode 100644 index 00000000..5fd9b99d --- /dev/null +++ b/sources/ewol/game/Geometry.cpp @@ -0,0 +1,79 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#include +#include +#include +#include +#include +#include +#include + +game::Geometry::Geometry(game::MeshObject& object, game::MeshProperty& property) : + m_dynamic(false), + m_object(object), + m_property(property), + m_bounding(NULL), + m_mass(NULL) +{ + +} + +game::Geometry::~Geometry(void) +{ + +} + +void game::Geometry::SetStatic(void) +{ + m_dynamic = false; +} + +void game::Geometry::SetDynamic(void) +{ + m_dynamic = true; +} + +void game::Geometry::SetBoundingMode(game::boundingMode type) +{ + if (NULL != m_bounding) { + if (m_bounding->GetType() != type) { + delete(m_bounding); + m_bounding = NULL; + } else { + return; + } + } + switch(type) + { + default: + case BoundingModeNone: + break; + case BoundingModePlane: + EWOL_TODO("Implement plane..."); + break; + case BoundingModeAABB: + m_bounding = new game::BoundingAABB(); + break; + case BoundingModeSphere: + m_bounding = new game::BoundingSphere(); + break; + case BoundingModeOBB: + m_bounding = new game::BoundingOBB(m_object, m_property); + break; + } +} + +void game::Geometry::BoundingUpdate(void) +{ + if (NULL != m_bounding) { + m_bounding->Update(m_object, m_property); + } +} + + diff --git a/sources/ewol/game/Geometry.h b/sources/ewol/game/Geometry.h new file mode 100644 index 00000000..d716ccdf --- /dev/null +++ b/sources/ewol/game/Geometry.h @@ -0,0 +1,59 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#ifndef __GAME_GEOMETRY_H__ +#define __GAME_GEOMETRY_H__ + +#include +#include +#include + + +namespace game +{ + class Geometry + { + private : + bool m_dynamic; //!< Set at true if the Geometry can move or not (bounding can change) + game::MeshObject& m_object; //!< Object vertex/ normal and other properties + game::MeshProperty& m_property; //!< Display properties of this element. + game::Bounding* m_bounding; //!< Bounding interface. + game::Mass* m_mass; //!< Mass properties. + public: + /** + * @brief main constructor + * @param[in] object the reference mesh object (must not be NULL) + * @param[in] property the reference mesh property (must not be NULL) + */ + Geometry(game::MeshObject& object, game::MeshProperty& property); + /** + * @brief main destructor + */ + ~Geometry(void); + /** + * @brief Set this object static (the bounding does not change) + */ + void SetStatic(void); + /** + * @brief Set this object Dynamic (the bounding change...) + */ + void SetDynamic(void); + /** + * @brief Set bounding type + * @param[in] type Selected bounding methode (if no set, by default it does not have one) + */ + void SetBoundingMode(game::boundingMode type); + /** + * @brief Update the bounding properties. + */ + void BoundingUpdate(void); + }; +}; + + +#endif diff --git a/sources/ewol/game/Map.cpp b/sources/ewol/game/Map.cpp new file mode 100644 index 00000000..4b6d4347 --- /dev/null +++ b/sources/ewol/game/Map.cpp @@ -0,0 +1,7 @@ +/** + * @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 new file mode 100644 index 00000000..e56700f9 --- /dev/null +++ b/sources/ewol/game/Map.h @@ -0,0 +1,15 @@ +/** + * @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 new file mode 100644 index 00000000..4b6d4347 --- /dev/null +++ b/sources/ewol/game/Mass.cpp @@ -0,0 +1,7 @@ +/** + * @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 new file mode 100644 index 00000000..d069287c --- /dev/null +++ b/sources/ewol/game/Mass.h @@ -0,0 +1,25 @@ +/** + * @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 new file mode 100644 index 00000000..e7c8b10b --- /dev/null +++ b/sources/ewol/game/MeshObject.h @@ -0,0 +1,33 @@ +/** + * @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 \ No newline at end of file diff --git a/sources/ewol/game/MeshProperty.h b/sources/ewol/game/MeshProperty.h new file mode 100644 index 00000000..94499790 --- /dev/null +++ b/sources/ewol/game/MeshProperty.h @@ -0,0 +1,82 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#ifndef __GAME_MESH_PROPERTY_H__ +#define __GAME_MESH_PROPERTY_H__ + +#include +#include +#include +#include + +namespace game +{ + class MeshProperty + { + public: + vec3 m_scale; //!< scale of the element. + vec3 m_position; //!< position of the element. + vec3 m_speed; //!< Speed of the element. + vec3 m_angle; + mat4 m_rotation; //!< rotation matrix ... + bool needUpdate; + mat4 m_matrix; //!< generated dispaly matrix. + public: + MeshProperty(void) : + m_position(0,0,0), + m_speed(0,0,0), + needUpdate(true) + { + //m_matrix.Identity(); + }; + virtual ~MeshProperty(void) {}; + + void Identity(void) + { + m_position = vec3(0,0,0); + m_speed = vec3(0,0,0); + m_angle = vec3(0,0,0); + m_matrix.Identity(); + }; + void Translate(etk::Vector3D vect) + { + m_position += vect; + needUpdate = true; + } + void Scale(etk::Vector3D vect) + { + m_scale = vect; + needUpdate = true; + } + void Rotate(etk::Vector3D vect, float angleRad=0.0) + { + m_rotation *= etk::matRotate(vect, angleRad); + needUpdate = true; + } + mat4& GetMatrix(void) + { + if (needUpdate == true) { + m_matrix = etk::matScale(m_scale) * m_rotation * etk::matTranslate(m_position); + } + return m_matrix; + }; + vec3& GetSpeed(void) + { + return m_speed; + } + vec3& GetPosition(void) + { + return m_position; + } + }; +}; + + +#endif + + diff --git a/sources/ewol/game/SceneElement.cpp b/sources/ewol/game/SceneElement.cpp deleted file mode 100644 index 8749bce7..00000000 --- a/sources/ewol/game/SceneElement.cpp +++ /dev/null @@ -1,506 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#include -#include -#include -#include -#include - -static uint32_t createUniqueId(uint16_t uniqueID, uint16_t position) -{ - return ((uint32_t)uniqueID<< 16) + (uint32_t)position; -} - - -ewol::SceneElement::SceneElement(void) -{ - m_id = 1; - numberOfGroup = MAX_GROUP_NUMBER; - for (int32_t iii=0; iiiname = name; - tmpElement->userString = userString; - tmpElement->loadElement = loadElement; - listCreatorElement.PushBack(tmpElement); -} - - -void ewol::SceneElement::RmElement(int16_t group, int16_t idElement) -{ - if (group < 0 || group >= MAX_GROUP_NUMBER) { - EWOL_ERROR("group is wrong " << group << "!=[0," << MAX_GROUP_NUMBER << "]==> not rm at the system ..."); - return; - } - if (idElement < 0 || idElement >= listAnimatedElements[group].Size()) { - EWOL_ERROR("idElement is wrong " << idElement << "!=[0," << listAnimatedElements[group].Size() << "]==> not rm at the system ..."); - return; - } - if (NULL == listAnimatedElements[group][idElement]) { - return; - } - // inform remove system : - SendEventRemove(createUniqueId(listAnimatedElements[group][idElement]->GetUniqueId(), idElement) ); - - // try to find an empty slot : - for (int32_t iii=0; iiiUnInit(); - listGarbage.PushBack(listAnimatedElements[group][idElement]); - listAnimatedElements[group][idElement] = NULL; - return; -} - -void ewol::SceneElement::RmElement(int32_t idElement) -{ - if (0 == idElement) { - return; - } - uint16_t realUniqueId = (uint16_t)((idElement >> 16 ) & 0x0000FFFF); - uint16_t posInList = (uint16_t)(idElement & 0x0000FFFF); - for (int32_t iii=0; iiiGetUniqueId()) { - RmElement(iii, posInList); - return; - } - } -} - -uint32_t ewol::SceneElement::AddElement(int32_t group, ewol::GameElement* newElement) -{ - if (NULL == newElement) { - EWOL_ERROR("newElement is empty ==> not added at the system ..."); - return 0; - } - if (group < 0 || group >= MAX_GROUP_NUMBER) { - EWOL_ERROR("group is wrong " << group << "!=[0," << MAX_GROUP_NUMBER << "]==> not added at the system ..."); - return 0; - } - // for statistic - newElement->Init(); - newElement->GroupSet(group); - for (int32_t iii=0; iiiGetUniqueId(), iii); - } - } - //did not find empty slot : - listAnimatedElements[group].PushBack(newElement); - if (listAnimatedElements[group].Size()>0) { - return createUniqueId(newElement->GetUniqueId(), listAnimatedElements[group].Size()-1); - } else { - return 0; - } -} - -uint32_t ewol::SceneElement::AddElementNamed(int32_t group, etk::UString &elementName) -{ - // try to fined it in the garbase : - for (int32_t iii=0; iiiHasName(elementName)) { - // we find a previous element loaded ==> retreve it - int32_t idElementBackAdded = AddElement(group, listGarbage[iii]); - listGarbage[iii] = NULL; - retreviveElement++; - return idElementBackAdded; - } - } - } - ewol::GameElement* newElement=NULL; - // find in registered element - for (int32_t iii=0; iiiname == elementName) { - // create a new element : - allocatedElements ++; - newElement = (*listCreatorElement[iii]->loadElement)(*this, elementName, listCreatorElement[iii]->userString); - // we find a previous element loaded ==> retreve it - return AddElement(group, newElement); - } - } - } - allocatedElements++; - return AddElement(group, newElement); -} - - -ewol::GameElement* ewol::SceneElement::GetElement(uint32_t idElement) -{ - if (0 == idElement) { - return NULL; - } - uint16_t realUniqueId = (uint16_t)((idElement >> 16 ) & 0x0000FFFF); - uint16_t posInList = (uint16_t)(idElement & 0x0000FFFF); - for (int32_t iii=0; iiiGetUniqueId()) { - return listAnimatedElements[iii][posInList]; - } - } - return NULL; -} - - -uint32_t ewol::SceneElement::GetNearestEnemy(vec2 position, int32_t groupId, float maxRange) -{ - uint32_t result = 0; - float lastQuadDistance = 9999999999999999.0; - int32_t jjj=0; - if (groupId <0 || groupId >= MAX_GROUP_NUMBER) { - EWOL_ERROR("incorect group number : " << groupId); - return 0; - } - maxRange = maxRange*maxRange; - while (groupEnemy[groupId][jjj] != -1) { - int32_t gId = groupEnemy[groupId][jjj]; - if (gId == groupId) { - EWOL_ERROR("groupId=" << gId << " is ennemy of groupId:" << groupId); - } - for (int32_t iii=0; iiiIsEnable() - && true == listAnimatedElements[gId][iii]->CanBeCibledGet()) { - vec2 tmpPos = listAnimatedElements[gId][iii]->PositionGet(); - float distance = quadDist(position, tmpPos); - if( distance <= lastQuadDistance - && maxRange >= distance ) { - lastQuadDistance = distance; - result = createUniqueId(listAnimatedElements[gId][iii]->GetUniqueId(), iii); - } - } - } - } - jjj++; - } - return result; -} - -void ewol::SceneElement::GetNearestEnemy(vec2 position, int32_t groupId, float maxRange, etk::Vector& list) -{ - // remove all elements.. - list.Clear(); - int32_t jjj=0; - if (groupId <0 || groupId >= MAX_GROUP_NUMBER) { - EWOL_ERROR("incorect group number : " << groupId); - return; - } - maxRange = maxRange*maxRange; - while (groupEnemy[groupId][jjj] != -1) { - int32_t gId = groupEnemy[groupId][jjj]; - if (gId == groupId) { - EWOL_ERROR("groupId=" << gId << " is ennemy of groupId:" << groupId); - } - for (int32_t iii=0; iiiIsEnable() - && true == listAnimatedElements[gId][iii]->CanBeCibledGet()) { - vec2 tmpPos = listAnimatedElements[gId][iii]->PositionGet(); - float distance = quadDist(position, tmpPos); - if(maxRange >= distance) { - uint32_t tmpp = createUniqueId(listAnimatedElements[gId][iii]->GetUniqueId(), iii); - list.PushBack(tmpp); - } - } - } - } - jjj++; - } -} - -uint32_t ewol::SceneElement::GetNearestFriend(vec2 position, int32_t groupId, uint32_t us) -{ - uint32_t result = 0; - float lastQuadDistance = 9999999999999999.0; - if (groupId <0 || groupId >= MAX_GROUP_NUMBER) { - EWOL_ERROR("incorect group number : " << groupId); - return 0; - } - int32_t gId = groupId; - for (int32_t iii=0; iiiIsEnable() - && true == listAnimatedElements[gId][iii]->CanBeCibledGet()) { - vec2 tmpPos = listAnimatedElements[gId][iii]->PositionGet(); - float distance = quadDist(position, tmpPos); - if( distance <= lastQuadDistance - && us != listAnimatedElements[gId][iii]->GetUniqueId() ) { - lastQuadDistance = distance; - result = createUniqueId(listAnimatedElements[gId][iii]->GetUniqueId(), iii); - } - } - } - } - return result; -} - - -void ewol::SceneElement::GetNearestFriend(vec2 position, int32_t groupId, float maxRange, etk::Vector& list, uint32_t us) -{ - // remove all elements.. - list.Clear(); - if (groupId <0 || groupId >= MAX_GROUP_NUMBER) { - EWOL_ERROR("incorect group number : " << groupId); - return; - } - maxRange = maxRange*maxRange; - for (int32_t iii=0; iiiIsEnable() - && true == listAnimatedElements[groupId][iii]->CanBeCibledGet()) { - vec2 tmpPos = listAnimatedElements[groupId][iii]->PositionGet(); - float distance = quadDist(position, tmpPos); - if( maxRange >= distance - && us != listAnimatedElements[groupId][iii]->GetUniqueId() ) { - uint32_t tmpp = createUniqueId(listAnimatedElements[groupId][iii]->GetUniqueId(), iii); - list.PushBack(tmpp); - } - } - } - } -} - -bool ewol::SceneElement::HaveImpact(int32_t group, int32_t type, vec2 position, float size) -{ - for (int32_t jjj=0; jjjIsEnable() - && true == listAnimatedElements[jjj][iii]->HaveImpact(group, type, position, size )) { - return true; - } - } - } - } - } - return false; -} - -void ewol::SceneElement::Explosion(int32_t group, int32_t type, vec2 position, float pxAtenuation, float power) -{ - for (int32_t jjj=0; jjjIsEnable() - && true == listAnimatedElements[jjj][iii]->Explosion(group, type, position, pxAtenuation, power) ) { - RmElement(jjj, iii); - } - } - } - } -} - - -uint32_t ewol::SceneElement::GetElementAtPos(vec2 position, int32_t maxDistanceDetection) -{ - uint32_t result = 0; - float lastQuadDistance = 9999999999999999.0; - for (int32_t jjj=0; jjjIsEnable()) { - vec2 tmpPos = listAnimatedElements[jjj][iii]->PositionGet(); - float distance = quadDist(position, tmpPos); - if (distance <= lastQuadDistance) { - lastQuadDistance = distance; - result = createUniqueId(listAnimatedElements[jjj][iii]->GetUniqueId(), iii); - } - } - } - } - } - if (lastQuadDistance > maxDistanceDetection*maxDistanceDetection) { - return 0; - } - return result; -} - -void ewol::SceneElement::SetEventInput(uint32_t id, vec2 position) -{ - EWOL_TODO("but when ..."); -} - -void ewol::SceneElement::SetEventExternButton(uint32_t id, int32_t btId, int32_t state) -{ - EWOL_TODO("but when ..."); -} - -void ewol::SceneElement::SetEventExternJoystick(uint32_t id, int32_t joyId, float angle, float distance, int32_t state) -{ - EWOL_TODO("but when ..."); -} - - -/** - * @brief Load or get a previous loaded sprite, it will be done on the current Sprite list - * @param[in,out] listOfElement Reference on the list of sprite that we need to find if it exist or added a new one - * @param[in] fileName Sprite name - * @param[in] maxSize maximum size of the sprite - * @return the id of the sprite requested or -1 if it does not existed - */ -int32_t ewol::SceneElement::LoadSprite(etk::UString fileName, float maxSize) -{ - for (int32_t iii=0; iiiHasName(fileName) == true) { - // count the number of element registered ... - animated[iii]->IncreaseLoadedTime(); - return iii; - } - } - } - // we did not find the sprite ==> created it ... - ewol::Sprite* tmpSprite = new ewol::Sprite(fileName, maxSize, maxSize); - if (NULL == tmpSprite) { - EWOL_ERROR("Allocation error on the sprite : " << fileName); - return -1; - } - // add it : - animated.PushBack(tmpSprite); - - return animated.Size() -1; -} - -/** - * @brief UnLoad or not(if needed) the sprite selected, it will be done on the current Sprite list - * @param[in,out] listOfElement Reference on the list of sprite that we need to find if it exist or added a new one - * @param[in] spriteId Sprite registered id - * @return --- - */ -void ewol::SceneElement::UnLoadSprite(int32_t spriteId) -{ - if (spriteId >= 0 && spriteId < animated.Size()) { - if (animated[spriteId] != NULL) { - // count the number of element registered ... - if (true == animated[spriteId]->DecreaseLoadedTime() ) { - // must remove the sprite ==> pb with the double buffer ... - delete(animated[spriteId]); - animated[spriteId] = NULL; - } - } - } -} - -void ewol::SceneElement::AddEarrerDestroy(uint32_t uId) -{ - //EWOL_DEBUG("ADD eraer : " << uId); - if (uId==0) { - return; - } - eventDestroy.PushBack(uId); -} - -void ewol::SceneElement::RmEarrerDestroy(uint32_t uId) -{ - //EWOL_DEBUG("RM eraer : " << uId); - if (uId==0) { - return; - } - for (int32_t iii=0; iiiMessage("Destroy", uId); - } - } - } -} diff --git a/sources/ewol/game/SceneElement.h b/sources/ewol/game/SceneElement.h deleted file mode 100644 index ef1a7f53..00000000 --- a/sources/ewol/game/SceneElement.h +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - -#ifndef __EWOL_SCENE_ELEMENT_H__ -#define __EWOL_SCENE_ELEMENT_H__ - -#include -#include -#include - -namespace ewol { - class GameElement; - class SceneElement; - - typedef ewol::GameElement* (creatorElement_tf)(SceneElement & sceneElement, etk::UString& tmpName, etk::UString& userString); - - class listRegisteElement { - public: - etk::UString name; //!< name of an element - etk::UString userString; //!< additionnal sting defined by the user - creatorElement_tf * loadElement; //!< callback function to create it - }; - #define MAX_GROUP_NUMBER (32) - - class SceneElement { - private: - int16_t m_id; //!< Unique element ID ==> to reference the element unicly - int32_t retreviveElement; - int32_t allocatedElements; - public: - SceneElement(void); - ~SceneElement(void); - etk::Vector eventDestroy; //!< element uid when element is destroy - int32_t numberOfGroup; //!< curent scene number of group - etk::UString groupDescription[MAX_GROUP_NUMBER]; //!< name of all the groups - int32_t groupEnemy[MAX_GROUP_NUMBER][MAX_GROUP_NUMBER]; //!< list of the ennemy - ewol::OObject2DTextured* background; //!< background element - etk::Vector animated; //!< element that must be display the second - etk::Vector listAnimatedElements[MAX_GROUP_NUMBER]; //!< generic element to display order in the diffferent group - etk::Vector listGarbage; //!< garbage of the old element allocated ==> prevent multiple alloc and free - etk::Vector listCreatorElement; //!< list of all creatable elements - int16_t GetUniqueId(void) { int16_t iddd = m_id; m_id++; return iddd; }; - void RegisterElementType(etk::UString name, creatorElement_tf * loadElement, etk::UString userString); - void RmElement(int16_t group, int16_t posInList); - void RmElement(int32_t elementID); - uint32_t AddElement(int32_t group, ewol::GameElement* newElement); - uint32_t AddElementNamed(int32_t group, etk::UString &elementName); - ewol::GameElement* GetElement(uint32_t idElement); - uint32_t GetNearestEnemy(vec2 position, int32_t groupId, float maxRange=9999999999999999.0); - void GetNearestEnemy(vec2 position, int32_t groupId, float maxRange, etk::Vector& list); - uint32_t GetNearestFriend(vec2 position, int32_t groupId, uint32_t us); - void GetNearestFriend(vec2 position, int32_t groupId, float maxRange, etk::Vector& list, uint32_t us); - bool HaveImpact(int32_t group, int32_t type, vec2 position, float size); - void Explosion(int32_t group, int32_t type, vec2 position, float pxAtenuation, float power); - uint32_t GetElementAtPos(vec2 position, int32_t maxDistanceDetection); - void SetEventInput(uint32_t id, vec2 position); - void SetEventExternButton(uint32_t id, int32_t btId, int32_t state); - void SetEventExternJoystick(uint32_t id, int32_t joyId, float angle, float distance, int32_t state); - /** - * @brief Load or get a previous loaded sprite, it will be done on the current Sprite list - * @param[in] fileName Sprite name - * @param[in] maxSize maximum size of the sprite - * @return the id of the sprite requested or -1 if it does not existed - */ - int32_t LoadSprite(etk::UString fileName, float maxSize); - /** - * @brief UnLoad or not(if needed) the sprite selected, it will be done on the current Sprite list - * @param[in,out] listOfElement Reference on the list of sprite that we need to find if it exist or added a new one - * @param[in] spriteId Sprite registered id - * @return --- - */ - void UnLoadSprite(int32_t spriteId); - void AddEarrerDestroy(uint32_t uId); - void RmEarrerDestroy(uint32_t uId); - void SendEventRemove(uint32_t uId); - ewol::OObject2DTextured* GetBackground(void) { return background; }; - }; -}; - -#endif - diff --git a/sources/ewol/game/Sky.cpp b/sources/ewol/game/Sky.cpp new file mode 100644 index 00000000..4b6d4347 --- /dev/null +++ b/sources/ewol/game/Sky.cpp @@ -0,0 +1,7 @@ +/** + * @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 new file mode 100644 index 00000000..334a607b --- /dev/null +++ b/sources/ewol/game/Sky.h @@ -0,0 +1,15 @@ +/** + * @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/Mesh.cpp b/sources/ewol/renderer/resources/Mesh.cpp index 1cf3afdd..8a9a52f1 100644 --- a/sources/ewol/renderer/resources/Mesh.cpp +++ b/sources/ewol/renderer/resources/Mesh.cpp @@ -61,7 +61,7 @@ void ewol::Mesh::Draw(mat4& positionMatrix) m_GLprogram->Use(); // set Matrix : translation/positionMatrix mat4 tmpMatrix = ewol::openGL::GetMatrix(); - tmpMatrix = positionMatrix * tmpMatrix; + tmpMatrix = tmpMatrix * positionMatrix; m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat); // TextureID m_GLprogram->SetTexture0(m_GLtexID, m_texture1->GetId()); diff --git a/sources/ewol/renderer/resources/Mesh.h b/sources/ewol/renderer/resources/Mesh.h index f47c6f0e..0e8ba275 100644 --- a/sources/ewol/renderer/resources/Mesh.h +++ b/sources/ewol/renderer/resources/Mesh.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include namespace ewol { @@ -27,7 +27,7 @@ namespace ewol int32_t m_GLColor; int32_t m_GLtexture; int32_t m_GLtexID; - ephysics::MeshObject m_object; + game::MeshObject m_object; ewol::TextureFile* m_texture1; etk::Vector m_coordColor; //!< internal color of the different point public: diff --git a/sources/ewol/renderer/resources/image/ImagePNG.cpp b/sources/ewol/renderer/resources/image/ImagePNG.cpp index bdcd7a4e..83fb99af 100644 --- a/sources/ewol/renderer/resources/image/ImagePNG.cpp +++ b/sources/ewol/renderer/resources/image/ImagePNG.cpp @@ -14,7 +14,7 @@ #undef __class__ -#define __class__ "texture::TextureBMP" +#define __class__ "texture::TexturePNG" // we must change the access of the IO of the png lib : static void local_ReadData(png_structp png_ptr, png_bytep data, png_size_t length) @@ -97,6 +97,7 @@ bool ewol::imagePNG::GenerateImage(etk::UString & inputFile, draw::Image & ouput int32_t width = png_get_image_width(png_ptr, info_ptr); int32_t height = png_get_image_height(png_ptr, info_ptr); // reallocate the image + EWOL_DEBUG("Load PNG image : (" << width << "," << height << ")" ); ouputImage.Resize(ivec2(width,height)); int32_t bit_depth = png_get_bit_depth(png_ptr, info_ptr); @@ -113,27 +114,47 @@ bool ewol::imagePNG::GenerateImage(etk::UString & inputFile, draw::Image & ouput png_read_image(png_ptr, row_pointers); png_set_expand(png_ptr); png_set_strip_16(png_ptr); - if (png_get_color_type(png_ptr, info_ptr) != PNG_COLOR_TYPE_RGBA) { - EWOL_ERROR("Must be RGBA"); - return false; - } draw::Color tmpColor(0,0,0,0); - // Conversion to OpenGL texture - //texture = (GLubyte*)malloc (width * height * 4 * sizeof(GLubyte)); - for (y = 0; y < height; y++) + switch (png_get_color_type(png_ptr, info_ptr) ) { - png_byte* row = row_pointers[y]; - for (x = 0; x < width; x++) - { - png_byte* ptr = &(row[x*4]); - tmpColor.r = ptr[0]; - tmpColor.g = ptr[1]; - tmpColor.b = ptr[2]; - tmpColor.a = ptr[3]; - ouputImage.Set(ivec2(x,y), tmpColor); - } - delete row_pointers[y]; + case PNG_COLOR_TYPE_RGBA: + // Conversion to OpenGL texture + for (y = 0; y < height; y++) + { + png_byte* row = row_pointers[y]; + for (x = 0; x < width; x++) + { + png_byte* ptr = &(row[x*4]); + tmpColor.r = ptr[0]; + tmpColor.g = ptr[1]; + tmpColor.b = ptr[2]; + tmpColor.a = ptr[3]; + ouputImage.Set(ivec2(x,y), tmpColor); + } + delete row_pointers[y]; + } + break; + case PNG_COLOR_TYPE_RGB: + // Conversion to OpenGL texture + for (y = 0; y < height; y++) + { + png_byte* row = row_pointers[y]; + for (x = 0; x < width; x++) + { + png_byte* ptr = &(row[x*3]); + tmpColor.r = ptr[0]; + tmpColor.g = ptr[1]; + tmpColor.b = ptr[2]; + tmpColor.a = 0xFF; + ouputImage.Set(ivec2(x,y), tmpColor); + } + delete row_pointers[y]; + } + break; + default: + EWOL_ERROR("Must be RGBA/RGB"); + return false; } fileName.FileClose(); diff --git a/sources/ewol/widget/Scene.cpp b/sources/ewol/widget/Scene.cpp index 673db8cb..01dd2a29 100644 --- a/sources/ewol/widget/Scene.cpp +++ b/sources/ewol/widget/Scene.cpp @@ -21,7 +21,7 @@ widget::Scene::Scene(game::Engine* gameEngine) : { SetCanHaveFocus(true); PeriodicCallSet(true); - m_zoom = 1.0; + m_zoom = 1.0/1000.0; } @@ -63,21 +63,6 @@ void widget::Scene::PauseToggle(void) void widget::Scene::OnDraw(ewol::DrawProperty& displayProp) { - /* - //EWOL_ERROR(" On draw : " << m_currentDrawId); - // draw background : - // TODO : ... - if (NULL != m_sceneElement.background) { - m_sceneElement.background->Draw(); - } - //background - // draw elements - for (int32_t iii=0; iiiDraw(); - } - } - */ if (NULL != m_gameEngine) { m_gameEngine->Draw(displayProp); } @@ -122,7 +107,6 @@ void widget::Scene::GenDraw(ewol::DrawProperty displayProp) // set internal matrix system : ewol::openGL::SetMatrix(tmpMat); } else { - m_zoom = 1.0/1000.0; //EWOL_INFO("ratio : " << ratio); mat4 tmpProjection; @@ -177,3 +161,47 @@ vec2 widget::Scene::RelativePosition(vec2 pos) return pos; }; + +bool widget::Scene::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te statusEvent, vec2 pos) +{ + vec2 relativePos = RelativePosition(pos); + //EWOL_DEBUG("type : " << type << " IdInput=" << IdInput << " " << "status=" << statusEvent << " RelPos=" << relativePos); + + if (type == ewol::keyEvent::typeMouse) { + if (4 == IdInput && ewol::keyEvent::statusUp == statusEvent) { + m_zoom *= 0.91; + } else if (5 == IdInput && ewol::keyEvent::statusUp == statusEvent) { + m_zoom *= 1.1; + } + } else if (type == ewol::keyEvent::typeFinger) { + + } + // note : we did not parse the oether media ... + + return false; +} + + +bool widget::Scene::OnEventKb(ewol::keyEvent::status_te statusEvent, uniChar_t unicodeData) +{ + /* + EWOL_DEBUG("KB EVENT : \"" << unicodeData << "\"" << "type=" << statusEvent); + if (statusEvent == ewol::ewol::keyEvent::statusDown) { + + } + */ + return false; +} + + +bool widget::Scene::OnEventKbMove(ewol::keyEvent::status_te statusEvent, ewol::keyEvent::keyboard_te specialKey) +{ + /* + if (statusEvent == ewol::ewol::keyEvent::statusDown) { + MarkToRedraw(); + } + return true; + */ + return false; +} + diff --git a/sources/ewol/widget/Scene.h b/sources/ewol/widget/Scene.h index 3eea8059..6cbcd608 100644 --- a/sources/ewol/widget/Scene.h +++ b/sources/ewol/widget/Scene.h @@ -48,18 +48,10 @@ namespace widget { * @brief Toggle between pause and running */ void PauseToggle(void); - /** - * @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...]) - * This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget - * @note This function is virtual for the scrolled widget, and the more complicated OpenGl widget - */ + // Derived function virtual void GenDraw(ewol::DrawProperty displayProp); protected: - /** - * @brief Periodic call in the sub element timed - * @param localTime curent system time - * @param deltaTime delta time while the previous call - */ + // Derived function virtual void ScenePeriodicCall(int64_t localTime, int32_t deltaTime) { }; // camera properties : private: @@ -91,6 +83,12 @@ namespace widget { // Derived function virtual void OnDraw(ewol::DrawProperty& displayProp); + // Derived function + virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te statusEvent, vec2 pos); + // Derived function + virtual bool OnEventKb(ewol::keyEvent::status_te statusEvent, uniChar_t unicodeData); + // Derived function + virtual bool OnEventKbMove(ewol::keyEvent::status_te statusEvent, ewol::keyEvent::keyboard_te specialKey); }; }; diff --git a/sources/file.mk b/sources/file.mk index 2a3ffb07..cd05397a 100644 --- a/sources/file.mk +++ b/sources/file.mk @@ -81,7 +81,16 @@ 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/Element.cpp \ + ewol/game/Bounding.cpp \ + ewol/game/BoundingAABB.cpp \ + ewol/game/BoundingOBB.cpp \ + ewol/game/BoundingPlane.cpp \ + ewol/game/BoundingSphere.cpp \ + ewol/game/Geometry.cpp \ + ewol/game/Map.cpp \ + ewol/game/Mass.cpp \ + ewol/game/Sky.cpp LOCAL_COPY_FILES := ../data/textured3D.prog:textured3D.prog \ diff --git a/test/human/appl/TestScene.cpp b/test/human/appl/TestScene.cpp index a545f2eb..12615cab 100644 --- a/test/human/appl/TestScene.cpp +++ b/test/human/appl/TestScene.cpp @@ -28,6 +28,9 @@ static const char * l_eventAddBox = "event-add-box"; static const char * l_eventAddSphere = "event-add-sphere"; +static const char * l_eventRotationX = "event-rotation-X"; +static const char * l_eventRotationY = "event-rotation-Y"; +static const char * l_eventRotationZ = "event-rotation-Z"; @@ -58,6 +61,21 @@ TestScene::TestScene(void) myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventAddSphere); mySizerHori->SubWidgetAdd(myButton); } + myButton = new widget::Button("Rotation X"); + if (NULL != myButton) { + myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventRotationX); + mySizerHori->SubWidgetAdd(myButton); + } + myButton = new widget::Button("Rotation Y"); + if (NULL != myButton) { + myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventRotationY); + mySizerHori->SubWidgetAdd(myButton); + } + myButton = new widget::Button("Rotation Z"); + if (NULL != myButton) { + myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventRotationZ); + mySizerHori->SubWidgetAdd(myButton); + } widget::Spacer* mySpacer = new widget::Spacer(); if (NULL != mySpacer) { @@ -129,10 +147,19 @@ TestScene::~TestScene(void) #include + +vec3 baseRotationVect; class stupidCube : public game::Element { public: stupidCube(void) : game::Element("DATA:cube.obj") {}; + + // herited methode + virtual bool ArtificialIntelligence(int32_t deltaMicroSecond) + { + m_property.Rotate(baseRotationVect, 0.01); + return false; + } }; @@ -158,6 +185,12 @@ void TestScene::OnReceiveMessage(ewol::EObject * CallerObject, const char * even if (NULL!=m_testWidget) { } + } else if (eventId == l_eventRotationX) { + baseRotationVect = vec3(1,0,0); + } else if (eventId == l_eventRotationY) { + baseRotationVect = vec3(0,1,0); + } else if (eventId == l_eventRotationZ) { + baseRotationVect = vec3(0,0,1); } return; diff --git a/test/human/data/cube.bmp b/test/human/data/cube.bmp deleted file mode 100644 index 63b4df8e..00000000 Binary files a/test/human/data/cube.bmp and /dev/null differ diff --git a/test/human/data/cube.obj b/test/human/data/cube.obj index 98e7aba6..47f3dbce 100644 --- a/test/human/data/cube.obj +++ b/test/human/data/cube.obj @@ -1,47 +1,46 @@ # Blender3D v249 OBJ File: untitled.blend # www.blender3d.org mtllib cube.mtl -v 1.000000 -1.000000 -1.000000 -v 1.000000 -1.000000 1.000000 -v -1.000000 -1.000000 1.000000 -v -1.000000 -1.000000 -1.000000 -v 1.000000 1.000000 -1.000000 -v 0.999999 1.000000 1.000001 -v -1.000000 1.000000 1.000000 -v -1.000000 1.000000 -1.000000 -vt 0.748573 0.750412 -vt 0.749279 0.501284 -vt 0.999110 0.501077 -vt 0.999455 0.750380 -vt 0.250471 0.500702 -vt 0.249682 0.749677 -vt 0.001085 0.750380 -vt 0.001517 0.499994 -vt 0.499422 0.500239 -vt 0.500149 0.750166 -vt 0.748355 0.998230 -vt 0.500193 0.998728 -vt 0.498993 0.250415 -vt 0.748953 0.250920 -vn 0.000000 0.000000 -1.000000 +v 1.0 -1.0 -1.0 +v 1.0 -1.0 1.0 +v -1.0 -1.0 1.0 +v -1.0 -1.0 -1.0 +v 1.0 1.0 -1.0 +v 1.0 1.0 1.0 +v -1.0 1.0 1.0 +v -1.0 1.0 -1.0 + +vt 0.0 0.0 +vt 1.0 0.0 +vt 1.0 1.0 +vt 0.0 1.0 + +vn 0.000000 0.000000 -1.000000 vn -1.000000 -0.000000 -0.000000 -vn -0.000000 -0.000000 1.000000 -vn -0.000001 0.000000 1.000000 -vn 1.000000 -0.000000 0.000000 -vn 1.000000 0.000000 0.000001 -vn 0.000000 1.000000 -0.000000 -vn -0.000000 -1.000000 0.000000 -usemtl cube.bmp +vn -0.000000 -0.000000 1.000000 +vn -0.000001 0.000000 1.000000 +vn 1.000000 -0.000000 0.000000 +vn 1.000000 0.000000 0.000001 +vn 0.000000 1.000000 -0.000000 +vn -0.000000 -1.000000 0.000000 +usemtl stone.png s off + f 5/1/1 1/2/1 4/3/1 f 5/1/1 4/3/1 8/4/1 -f 3/5/2 7/6/2 8/7/2 -f 3/5/2 8/7/2 4/8/2 -f 2/9/3 6/10/3 3/5/3 -f 6/10/4 7/6/4 3/5/4 -f 1/2/5 5/1/5 2/9/5 -f 5/1/6 6/10/6 2/9/6 -f 5/1/7 8/11/7 6/10/7 -f 8/11/7 7/12/7 6/10/7 -f 1/2/8 2/9/8 3/13/8 -f 1/2/8 3/13/8 4/14/8 \ No newline at end of file + +f 3/1/2 7/2/2 8/3/2 +f 3/1/2 8/3/2 4/4/2 + +f 2/1/3 6/2/3 3/3/3 +f 6/1/4 7/3/4 3/4/4 + +f 1/1/5 5/2/5 2/3/5 +f 5/1/6 6/3/6 2/4/6 + +f 5/1/7 8/2/7 6/3/7 +f 8/1/7 7/3/7 6/4/7 + +f 1/1/8 2/2/8 3/3/8 +f 1/1/8 3/3/8 4/4/8 + diff --git a/test/human/data/stone.png b/test/human/data/stone.png new file mode 100644 index 00000000..94ee2e42 Binary files /dev/null and b/test/human/data/stone.png differ diff --git a/test/human/data/stone2.png b/test/human/data/stone2.png new file mode 100644 index 00000000..f8803666 Binary files /dev/null and b/test/human/data/stone2.png differ diff --git a/test/human/file.mk b/test/human/file.mk index 92b91120..727a72e5 100644 --- a/test/human/file.mk +++ b/test/human/file.mk @@ -15,3 +15,4 @@ FILE_LIST:= appl/Debug.cpp \ LOCAL_COPY_FOLDERS := data/icon.*:theme/default \ data/cube.*: \ + data/stone*: \