[DEV] import engine instead of creating an extern

This commit is contained in:
Edouard DUPIN 2012-12-17 22:21:54 +01:00
parent 03876b5a71
commit 4b4758bc7f
43 changed files with 894 additions and 909 deletions

View File

@ -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

2
external/etk vendored

@ -1 +1 @@
Subproject commit e6af555b152d01a561526bc8c5515338cec464fe
Subproject commit 0b2050cf687a0f698b838df781a8095a9e92939d

View File

@ -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 :=

View File

@ -0,0 +1,24 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/game/Bounding.h>
game::Bounding::Bounding(boundingMode mode) :
m_markedToUpdate(true),
m_mode(mode)
{
}
game::Bounding::~Bounding(void)
{
}

View File

@ -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

View File

@ -0,0 +1,38 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/debug.h>
#include <ewol/game/BoundingAABB.h>
#include <etk/math/Matrix4.h>
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<object.m_vertices.Size(); iii++) {
vec3 point = transMat * object.m_vertices[iii];
}
}
}

View File

@ -0,0 +1,40 @@
/**
* @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 "ewol/game/Bounding.h"
#include "etk/math/Vector3D.h"
namespace game
{
class BoundingAABB : public Bounding
{
private :
vec3 m_PointStart;
vec3 m_PointStop;
public:
/**
* @biref Main constructor.
* @param[in] mode Bounding mode.
*/
BoundingAABB(void);
/**
* @biref Main constructor.
*/
virtual ~BoundingAABB(void);
/**
* @brief Update Bounding properties.
*/
virtual void Update(game::MeshObject& object, game::MeshProperty& property);
};
}
#endif

View File

@ -0,0 +1,30 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/debug.h>
#include <ewol/game/BoundingOBB.h>
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)
{
}

View File

@ -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

View File

@ -0,0 +1,30 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/debug.h>
#include <ewol/game/BoundingPlane.h>
game::BoundingPlane::BoundingPlane(void) :
Bounding(game::BoundingModePlane)
{
}
game::BoundingPlane::~BoundingPlane(void)
{
}
void game::BoundingPlane::Update(game::MeshObject& object, game::MeshProperty& property)
{
}

View File

@ -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

View File

@ -0,0 +1,31 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/debug.h>
#include <ewol/game/BoundingSphere.h>
game::BoundingSphere::BoundingSphere(void) :
Bounding(game::BoundingModeSphere)
{
}
game::BoundingSphere::~BoundingSphere(void)
{
}
void game::BoundingSphere::Update(game::MeshObject& object, game::MeshProperty& property)
{
}

View File

@ -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

View File

@ -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());
}
}

View File

@ -14,16 +14,16 @@
#include <etk/math/Vector3D.h>
#include <etk/Vector.h>
#include <ewol/debug.h>
#include <ePhysics/MeshProperty.h>
#include <ewol/game/MeshProperty.h>
#include <ewol/renderer/resources/Mesh.h>
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);
};
};

View File

@ -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; iii<m_elementsStatic.Size() ; iii++) {
if (NULL != m_elementsStatic[iii]) {
m_elementsStatic[iii]->Draw();

View File

@ -14,17 +14,14 @@
#include <ewol/debug.h>
#include <ewol/game/Element.h>
#include <ewol/widget/Widget.h>
#include <ePhysics/World.h>
namespace game
{
class Engine
{
private:
//game::Map* m_map; //!< basic system map (BSD or other ...)
etk::Vector<game::Element*> m_elementsStatic;
etk::Vector<game::Element*> m_elementsDynamic;
ephysics::World m_world; //!< physical world engine
public:
/**
* @brief Basic constructor.

View File

@ -1,64 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/game/GameElement.h>
#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;
}

View File

@ -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 <etk/Types.h>
#include <ewol/Debug.h>
#include <ewol/oObject/Sprite.h>
#include <ewol/widget/Widget.h>
#include <ewol/game/SceneElement.h>
#include <math.h>
#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 <ewol/widget/Scene.h>
float quadDist(vec2 pos1, vec2 pos2);
#endif

View File

@ -0,0 +1,79 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/game/Geometry.h>
#include <ewol/game/BoundingAABB.h>
#include <ewol/game/BoundingOBB.h>
#include <ewol/game/BoundingPlane.h>
#include <ewol/game/BoundingSphere.h>
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);
}
}

View File

@ -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 <ewol/debug.h>
#include <ewol/game/Bounding.h>
#include <ewol/game/Mass.h>
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

View File

@ -0,0 +1,7 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/

15
sources/ewol/game/Map.h Normal file
View File

@ -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

View File

@ -0,0 +1,7 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/

25
sources/ewol/game/Mass.h Normal file
View File

@ -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

View File

@ -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 <etk/types.h>
#include <etk/Vector.h>
#include <etk/math/Vector3D.h>
#include <etk/math/Vector2D.h>
namespace game
{
class MeshObject
{
public:
etk::Vector<uint32_t> m_indices;
etk::Vector<vec3> m_vertices;
etk::Vector<vec2> m_uvTextures;
etk::Vector<vec3> m_normals;
public:
MeshObject(void) {};
virtual ~MeshObject(void) {};
};
};
#endif

View File

@ -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 <etk/types.h>
#include <etk/Vector.h>
#include <etk/math/Vector3D.h>
#include <etk/math/Matrix4.h>
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<float> vect)
{
m_position += vect;
needUpdate = true;
}
void Scale(etk::Vector3D<float> vect)
{
m_scale = vect;
needUpdate = true;
}
void Rotate(etk::Vector3D<float> 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

View File

@ -1,506 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/ewol.h>
#include <ewol/Debug.h>
#include <ewol/game/GameElement.h>
#include <ewol/game/GameElementLua.h>
#include <ewol/game/SceneElement.h>
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; iii<MAX_GROUP_NUMBER; iii++) {
int32_t kkk = 0;
for (int32_t jjj=0; jjj<MAX_GROUP_NUMBER-1; jjj++) {
if (iii == kkk) {
kkk++;
}
groupEnemy[iii][jjj] = kkk;
kkk++;
}
groupEnemy[iii][MAX_GROUP_NUMBER-1] = -1;
}
retreviveElement = 0;
allocatedElements = 0;
background = new ewol::OObject2DTextured(1024,1024);
if (NULL == background ) {
EWOL_ERROR("error to keep the scene background");
}
}
ewol::SceneElement::~SceneElement(void)
{
EWOL_DEBUG("Remove sceane, allocated element : " << allocatedElements << " and retreive : " << retreviveElement);
// clean all element allocated :
for (int32_t jjj=0; jjj<listGarbage.Size(); jjj++) {
if (NULL != listGarbage[jjj]) {
delete(listGarbage[jjj]);
listGarbage[jjj] = NULL;
}
}
listGarbage.Clear();
for (int32_t jjj=0; jjj<listCreatorElement.Size(); jjj++) {
if (NULL != listCreatorElement[jjj]) {
delete(listCreatorElement[jjj]);
listCreatorElement[jjj] = NULL;
}
}
listCreatorElement.Clear();
for (int32_t iii=0; iii<MAX_GROUP_NUMBER; iii++) {
for (int32_t jjj=0; jjj<listAnimatedElements[iii].Size(); jjj++) {
if (NULL != listAnimatedElements[iii][jjj]) {
delete(listAnimatedElements[iii][jjj]);
listAnimatedElements[iii][jjj] = NULL;
}
}
listAnimatedElements[iii].Clear();
}
for (int32_t jjj=0; jjj<animated.Size(); jjj++) {
if (NULL != animated[jjj]) {
delete(animated[jjj]);
animated[jjj] = NULL;
}
}
animated.Clear();
if (NULL != background) {
delete background;
background = NULL;
}
}
void ewol::SceneElement::RegisterElementType(etk::UString name, creatorElement_tf * loadElement, etk::UString userString)
{
// TODO : Check if the element already existed
ewol::listRegisteElement * tmpElement = new listRegisteElement();
if (NULL == tmpElement) {
EWOL_ERROR("Memory error in allocation registered element");
return;
}
tmpElement->name = 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; iii<listGarbage.Size(); iii++) {
if (NULL == listGarbage[iii]) {
// find an empty slot ...
listGarbage[iii] = listAnimatedElements[group][idElement];
listAnimatedElements[group][idElement] = NULL;
return;
}
}
listAnimatedElements[group][idElement]->UnInit();
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; iii<numberOfGroup; iii++) {
if( posInList < listAnimatedElements[iii].Size()
&& NULL != listAnimatedElements[iii][posInList]
&& realUniqueId == listAnimatedElements[iii][posInList]->GetUniqueId()) {
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; iii<listAnimatedElements[group].Size(); iii++) {
if (NULL == listAnimatedElements[group][iii]) {
// find an empty slot ...
listAnimatedElements[group][iii] = newElement;
return createUniqueId(newElement->GetUniqueId(), 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; iii<listGarbage.Size(); iii++) {
if (NULL != listGarbage[iii]) {
// check his name :
if (true == listGarbage[iii]->HasName(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; iii<listCreatorElement.Size(); iii++) {
if (NULL != listCreatorElement[iii]) {
// check his name :
if (listCreatorElement[iii]->name == 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; iii<numberOfGroup; iii++) {
if( posInList < listAnimatedElements[iii].Size()
&& NULL != listAnimatedElements[iii][posInList]
&& realUniqueId == listAnimatedElements[iii][posInList]->GetUniqueId()) {
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; iii<listAnimatedElements[gId].Size(); iii++) {
if (NULL != listAnimatedElements[gId][iii]) {
if( true == listAnimatedElements[gId][iii]->IsEnable()
&& 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<uint32_t>& 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; iii<listAnimatedElements[gId].Size(); iii++) {
if (NULL != listAnimatedElements[gId][iii]) {
if( true == listAnimatedElements[gId][iii]->IsEnable()
&& 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; iii<listAnimatedElements[gId].Size(); iii++) {
if (NULL != listAnimatedElements[gId][iii]) {
if( true == listAnimatedElements[gId][iii]->IsEnable()
&& 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<uint32_t>& 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; iii<listAnimatedElements[groupId].Size(); iii++) {
if (NULL != listAnimatedElements[groupId][iii]) {
if( true == listAnimatedElements[groupId][iii]->IsEnable()
&& 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; jjj<MAX_GROUP_NUMBER; jjj++) {
if (group != jjj) {
for (int32_t iii=0; iii<listAnimatedElements[jjj].Size(); iii++) {
if (NULL != listAnimatedElements[jjj][iii]) {
if( true == listAnimatedElements[jjj][iii]->IsEnable()
&& 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; jjj<MAX_GROUP_NUMBER; jjj++) {
for (int32_t iii=0; iii<listAnimatedElements[jjj].Size(); iii++) {
if (NULL != listAnimatedElements[jjj][iii]) {
if( true == listAnimatedElements[jjj][iii]->IsEnable()
&& 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; jjj<MAX_GROUP_NUMBER; jjj++) {
for (int32_t iii=0; iii<listAnimatedElements[jjj].Size(); iii++) {
if (NULL != listAnimatedElements[jjj][iii]) {
if( true == listAnimatedElements[jjj][iii]->IsEnable()) {
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; iii<animated.Size(); iii++) {
if (animated[iii] != NULL) {
if (animated[iii]->HasName(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; iii<eventDestroy.Size(); iii++) {
if (eventDestroy[iii] == uId) {
eventDestroy.Erase(iii);
return;
}
}
}
void ewol::SceneElement::SendEventRemove(uint32_t uId)
{
//EWOL_DEBUG("EVENT eraer : " << uId << " nb earer " << eventDestroy.Size());
for (int32_t iii=0; iii<eventDestroy.Size(); iii++) {
if (eventDestroy[iii] == uId) {
eventDestroy.Erase(iii);
return;
} else {
ewol::GameElement* tmpElem = GetElement(eventDestroy[iii]);
if (tmpElem!=NULL) {
tmpElem->Message("Destroy", uId);
}
}
}
}

View File

@ -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 <etk/Types.h>
#include <ewol/Debug.h>
#include <ewol/oObject/Sprite.h>
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<uint32_t> 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<ewol::Sprite*> animated; //!< element that must be display the second
etk::Vector<ewol::GameElement*> listAnimatedElements[MAX_GROUP_NUMBER]; //!< generic element to display order in the diffferent group
etk::Vector<ewol::GameElement*> listGarbage; //!< garbage of the old element allocated ==> prevent multiple alloc and free
etk::Vector<listRegisteElement*> 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<uint32_t>& list);
uint32_t GetNearestFriend(vec2 position, int32_t groupId, uint32_t us);
void GetNearestFriend(vec2 position, int32_t groupId, float maxRange, etk::Vector<uint32_t>& 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

View File

@ -0,0 +1,7 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/

15
sources/ewol/game/Sky.h Normal file
View File

@ -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

View File

@ -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());

View File

@ -14,7 +14,7 @@
#include <ewol/renderer/resources/Image.h>
#include <ewol/renderer/resources/Shader.h>
#include <ewol/renderer/resources/Program.h>
#include <ePhysics/MeshObject.h>
#include <ewol/game/MeshObject.h>
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<draw::Colorf> m_coordColor; //!< internal color of the different point
public:

View File

@ -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();

View File

@ -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; iii<m_sceneElement.animated.Size(); iii++) {
if (NULL != m_sceneElement.animated[iii]) {
m_sceneElement.animated[iii]->Draw();
}
}
*/
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;
}

View File

@ -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);
};
};

View File

@ -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 \

View File

@ -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 <ewol/game/Element.h>
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;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 KiB

View File

@ -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
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

BIN
test/human/data/stone.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
test/human/data/stone2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

@ -15,3 +15,4 @@ FILE_LIST:= appl/Debug.cpp \
LOCAL_COPY_FOLDERS := data/icon.*:theme/default \
data/cube.*: \
data/stone*: \