simplify scene sprite management
This commit is contained in:
parent
d797d61c10
commit
1c583aafdd
@ -54,7 +54,7 @@ ewol::GameElement::GameElement(SceneElement & sceneElement, etk::UString& tmpNam
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Requuest the draw of the current element, it will be done on the current Sprite list
|
* @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,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] fileName Sprite name
|
||||||
* @param[in] maxSize maximum size of the sprite
|
* @param[in] maxSize maximum size of the sprite
|
||||||
@ -65,7 +65,8 @@ int32_t ewol::GameElement::LoadSprite(etk::VectorType<ewol::Sprite*> listOfEleme
|
|||||||
for (int32_t iii=0; iii<listOfElement[0].Size(); iii++) {
|
for (int32_t iii=0; iii<listOfElement[0].Size(); iii++) {
|
||||||
if (listOfElement[0][iii] != NULL) {
|
if (listOfElement[0][iii] != NULL) {
|
||||||
if (listOfElement[0][iii]->HasName(fileName) == true) {
|
if (listOfElement[0][iii]->HasName(fileName) == true) {
|
||||||
// TODO : control the size ...
|
// count the number of element registered ...
|
||||||
|
listOfElement[0][iii]->IncreaseLoadedTime();
|
||||||
return iii;
|
return iii;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,6 +84,28 @@ int32_t ewol::GameElement::LoadSprite(etk::VectorType<ewol::Sprite*> listOfEleme
|
|||||||
return listOfElement[0].Size() -1;
|
return listOfElement[0].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::GameElement::UnLoadSprite(etk::VectorType<ewol::Sprite*> listOfElement[NB_BOUBLE_BUFFER], int32_t spriteId)
|
||||||
|
{
|
||||||
|
if (spriteId >= 0 && spriteId < listOfElement[0].Size()) {
|
||||||
|
if (listOfElement[0][spriteId] != NULL) {
|
||||||
|
// count the number of element registered ...
|
||||||
|
if (true == listOfElement[0][spriteId]->DecreaseLoadedTime() ) {
|
||||||
|
// must remove the sprite ==> pb with the double buffer ...
|
||||||
|
// TODO : ==> for all double buffer ...
|
||||||
|
for(int32_t iii=0; iii<NB_BOUBLE_BUFFER; iii++) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
float quadDist(Vector2D<float> pos1, Vector2D<float> pos2)
|
float quadDist(Vector2D<float> pos1, Vector2D<float> pos2)
|
||||||
{
|
{
|
||||||
|
@ -70,32 +70,32 @@ namespace ewol {
|
|||||||
virtual void Init(void) { };
|
virtual void Init(void) { };
|
||||||
virtual void UnInit(void) { };
|
virtual void UnInit(void) { };
|
||||||
|
|
||||||
uint16_t GetUniqueId(void) { return m_uniqueId; };
|
uint16_t GetUniqueId(void) { return m_uniqueId; };
|
||||||
|
|
||||||
bool HasName(etk::UString tmpName) { return (tmpName == m_fileNameConfig); };
|
bool HasName(etk::UString tmpName) { return (tmpName == m_fileNameConfig); };
|
||||||
bool IsVisible(void) { return m_visible; };
|
bool IsVisible(void) { return m_visible; };
|
||||||
void SetVisible(bool state) { m_visible = state; };
|
void SetVisible(bool state) { m_visible = state; };
|
||||||
Vector2D<float> PositionGet(void) { return m_position; };
|
Vector2D<float> PositionGet(void) { return m_position; };
|
||||||
void PositionSet(Vector2D<float> state) { m_position = state; };
|
void PositionSet(Vector2D<float> state) { m_position = state; };
|
||||||
void PositionSet(float xxx, float yyy) { m_position.x = xxx; m_position.y = yyy; };
|
void PositionSet(float xxx, float yyy) { m_position.x = xxx; m_position.y = yyy; };
|
||||||
Vector2D<float> SpeedGet(void) { return m_speed; };
|
Vector2D<float> SpeedGet(void) { return m_speed; };
|
||||||
void SpeedSet(Vector2D<float> state) { m_speed = state; };
|
void SpeedSet(Vector2D<float> state) { m_speed = state; };
|
||||||
void SpeedSet(float xxx, float yyy) { m_speed.x = xxx; m_speed.y = yyy; };
|
void SpeedSet(float xxx, float yyy) { m_speed.x = xxx; m_speed.y = yyy; };
|
||||||
float SizeGet(void) { return m_size; };
|
float SizeGet(void) { return m_size; };
|
||||||
void SizeSet(float state) { m_size = state; };
|
void SizeSet(float state) { m_size = state; };
|
||||||
float AngleGet(void) { return m_angle; };
|
float AngleGet(void) { return m_angle; };
|
||||||
void AngleSet(float state) { m_angle = state; };
|
void AngleSet(float state) { m_angle = state; };
|
||||||
float GravityGet(void) { return m_gravity; };
|
float GravityGet(void) { return m_gravity; };
|
||||||
void GravitySet(float state) { m_gravity = state; };
|
void GravitySet(float state) { m_gravity = state; };
|
||||||
int32_t PowerGet(void) { return m_power; };
|
int32_t PowerGet(void) { return m_power; };
|
||||||
void PowerSet(int32_t state) { m_power = state; };
|
void PowerSet(int32_t state) { m_power = state; };
|
||||||
bool CanBeCibledGet(void) { return m_canBeCibled; };
|
bool CanBeCibledGet(void) { return m_canBeCibled; };
|
||||||
void CanBeCibledSet(bool state) { m_canBeCibled = state; };
|
void CanBeCibledSet(bool state) { m_canBeCibled = state; };
|
||||||
|
|
||||||
int32_t GetType(void) { return m_type; }; // DEPRECATED ...
|
int32_t GetType(void) { return m_type; }; // TODO : DEPRECATED ...
|
||||||
int32_t TypeGet(void) { return m_type; };
|
int32_t TypeGet(void) { return m_type; };
|
||||||
uint16_t GroupGet(void) { return m_group; };
|
uint16_t GroupGet(void) { return m_group; };
|
||||||
void GroupSet(uint16_t state) { m_group = state; };
|
void GroupSet(uint16_t state) { m_group = state; };
|
||||||
|
|
||||||
void GetElementProperty(gameElementGenericProperty_ts &element);
|
void GetElementProperty(gameElementGenericProperty_ts &element);
|
||||||
/**
|
/**
|
||||||
@ -115,7 +115,7 @@ namespace ewol {
|
|||||||
* @param[in,out] listOfEffects Reference on the list where the display must be done for every effects
|
* @param[in,out] listOfEffects Reference on the list where the display must be done for every effects
|
||||||
* @return ---
|
* @return ---
|
||||||
*/
|
*/
|
||||||
virtual void Draw(etk::VectorType<ewol::Sprite*> & listOfSprite, etk::VectorType<ewol::Sprite*> & listOfEffects) { };
|
virtual void Draw(int32_t currentCreateId) { };
|
||||||
/**
|
/**
|
||||||
* @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
|
* @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
|
* @param[in] idOfElement Id of the element that has been removed
|
||||||
@ -125,13 +125,20 @@ namespace ewol {
|
|||||||
virtual bool HaveImpact(int32_t group, int32_t type, Vector2D<float> position, float size);
|
virtual bool HaveImpact(int32_t group, int32_t type, Vector2D<float> position, float size);
|
||||||
virtual bool Explosion(int32_t group, int32_t type, Vector2D<float> position, float pxAtenuation, float power) { return false; } ;
|
virtual bool Explosion(int32_t group, int32_t type, Vector2D<float> position, float pxAtenuation, float power) { return false; } ;
|
||||||
/**
|
/**
|
||||||
* @brief Requuest the draw of the current element, it will be done on the current Sprite list
|
* @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,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] fileName Sprite name
|
||||||
* @param[in] maxSize maximum size of the sprite
|
* @param[in] maxSize maximum size of the sprite
|
||||||
* @return the id of the sprite requested or -1 if it does not existed
|
* @return the id of the sprite requested or -1 if it does not existed
|
||||||
*/
|
*/
|
||||||
int32_t LoadSprite(etk::VectorType<ewol::Sprite*> listOfElement[NB_BOUBLE_BUFFER], etk::UString fileName, Vector2D<float> maxSize);
|
int32_t LoadSprite(etk::VectorType<ewol::Sprite*> listOfElement[NB_BOUBLE_BUFFER], etk::UString fileName, Vector2D<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(etk::VectorType<ewol::Sprite*> listOfElement[NB_BOUBLE_BUFFER], int32_t spriteId);
|
||||||
|
|
||||||
virtual void Message(etk::UString control, etk::UString message) { } ;
|
virtual void Message(etk::UString control, etk::UString message) { } ;
|
||||||
};
|
};
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
static ewol::GameElementLua * tmpObj = NULL;
|
static ewol::GameElementLua * tmpObj = NULL;
|
||||||
static etk::VectorType<ewol::Sprite*> * tmpSprite = NULL;
|
static etk::VectorType<ewol::Sprite*> * tmpSprite = NULL;
|
||||||
static etk::VectorType<ewol::Sprite*> * tmpEffects = NULL;
|
|
||||||
static ewol::SceneElement * tmpScene = NULL;
|
static ewol::SceneElement * tmpScene = NULL;
|
||||||
|
|
||||||
template <typename T> int index(lua_State* L);
|
template <typename T> int index(lua_State* L);
|
||||||
@ -410,12 +409,10 @@ LUAMOD_API int lua_ElementAdd(lua_State *L)
|
|||||||
// TODO : Remove this when find an other way do do it ...
|
// TODO : Remove this when find an other way do do it ...
|
||||||
ewol::GameElementLua * ttmpObj = tmpObj;
|
ewol::GameElementLua * ttmpObj = tmpObj;
|
||||||
etk::VectorType<ewol::Sprite*> * ttmpSprite = tmpSprite;
|
etk::VectorType<ewol::Sprite*> * ttmpSprite = tmpSprite;
|
||||||
etk::VectorType<ewol::Sprite*> * ttmpEffects = tmpEffects;
|
|
||||||
ewol::SceneElement * ttmpScene = tmpScene;
|
ewol::SceneElement * ttmpScene = tmpScene;
|
||||||
uint32_t elementId = tmpScene->AddElementNamed(group, elementName);
|
uint32_t elementId = tmpScene->AddElementNamed(group, elementName);
|
||||||
tmpObj = ttmpObj;
|
tmpObj = ttmpObj;
|
||||||
tmpSprite = ttmpSprite;
|
tmpSprite = ttmpSprite;
|
||||||
tmpEffects = ttmpEffects;
|
|
||||||
tmpScene = ttmpScene;
|
tmpScene = ttmpScene;
|
||||||
|
|
||||||
if (0==elementId) {
|
if (0==elementId) {
|
||||||
@ -555,14 +552,12 @@ LUAMOD_API int lua_HaveImpact(lua_State *L)
|
|||||||
// TODO : Remove this when find an other way do do it ...
|
// TODO : Remove this when find an other way do do it ...
|
||||||
ewol::GameElementLua * ttmpObj = tmpObj;
|
ewol::GameElementLua * ttmpObj = tmpObj;
|
||||||
etk::VectorType<ewol::Sprite*> * ttmpSprite = tmpSprite;
|
etk::VectorType<ewol::Sprite*> * ttmpSprite = tmpSprite;
|
||||||
etk::VectorType<ewol::Sprite*> * ttmpEffects = tmpEffects;
|
|
||||||
ewol::SceneElement * ttmpScene = tmpScene;
|
ewol::SceneElement * ttmpScene = tmpScene;
|
||||||
|
|
||||||
bool result = tmpScene->HaveImpact(tmpObj->GroupGet(), tmpObj->TypeGet(), tmpObj->PositionGet(), tmpObj->SizeGet());
|
bool result = tmpScene->HaveImpact(tmpObj->GroupGet(), tmpObj->TypeGet(), tmpObj->PositionGet(), tmpObj->SizeGet());
|
||||||
|
|
||||||
tmpObj = ttmpObj;
|
tmpObj = ttmpObj;
|
||||||
tmpSprite = ttmpSprite;
|
tmpSprite = ttmpSprite;
|
||||||
tmpEffects = ttmpEffects;
|
|
||||||
tmpScene = ttmpScene;
|
tmpScene = ttmpScene;
|
||||||
|
|
||||||
lua_pushboolean(L, result );
|
lua_pushboolean(L, result );
|
||||||
@ -581,14 +576,12 @@ LUAMOD_API int lua_Explosion(lua_State *L)
|
|||||||
// TODO : Remove this when find an other way do do it ...
|
// TODO : Remove this when find an other way do do it ...
|
||||||
ewol::GameElementLua * ttmpObj = tmpObj;
|
ewol::GameElementLua * ttmpObj = tmpObj;
|
||||||
etk::VectorType<ewol::Sprite*> * ttmpSprite = tmpSprite;
|
etk::VectorType<ewol::Sprite*> * ttmpSprite = tmpSprite;
|
||||||
etk::VectorType<ewol::Sprite*> * ttmpEffects = tmpEffects;
|
|
||||||
ewol::SceneElement * ttmpScene = tmpScene;
|
ewol::SceneElement * ttmpScene = tmpScene;
|
||||||
|
|
||||||
tmpScene->Explosion(tmpObj->GroupGet(), tmpObj->TypeGet(), tmpObj->PositionGet(), 0.01, tmpObj->PowerGet());
|
tmpScene->Explosion(tmpObj->GroupGet(), tmpObj->TypeGet(), tmpObj->PositionGet(), 0.01, tmpObj->PowerGet());
|
||||||
|
|
||||||
tmpObj = ttmpObj;
|
tmpObj = ttmpObj;
|
||||||
tmpSprite = ttmpSprite;
|
tmpSprite = ttmpSprite;
|
||||||
tmpEffects = ttmpEffects;
|
|
||||||
tmpScene = ttmpScene;
|
tmpScene = ttmpScene;
|
||||||
|
|
||||||
// return number of parameters
|
// return number of parameters
|
||||||
@ -803,11 +796,10 @@ bool ewol::GameElementLua::Process(int64_t time, int32_t deltaTime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::GameElementLua::Draw(etk::VectorType<ewol::Sprite*> & listOfSprite, etk::VectorType<ewol::Sprite*> & listOfEffects)
|
void ewol::GameElementLua::Draw(int32_t currentCreateId)
|
||||||
{
|
{
|
||||||
tmpObj = this;
|
tmpObj = this;
|
||||||
tmpSprite = &listOfSprite;
|
tmpSprite = &m_sceneElement.animated[currentCreateId];
|
||||||
tmpEffects = &listOfEffects;
|
|
||||||
if (NULL != m_luaState) {
|
if (NULL != m_luaState) {
|
||||||
// call the Draw function
|
// call the Draw function
|
||||||
lua_getglobal(m_luaState, "Draw");
|
lua_getglobal(m_luaState, "Draw");
|
||||||
@ -823,7 +815,6 @@ void ewol::GameElementLua::Draw(etk::VectorType<ewol::Sprite*> & listOfSprite, e
|
|||||||
}
|
}
|
||||||
tmpObj = NULL;
|
tmpObj = NULL;
|
||||||
tmpSprite = NULL;
|
tmpSprite = NULL;
|
||||||
tmpEffects = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ namespace ewol {
|
|||||||
virtual void Init(void);
|
virtual void Init(void);
|
||||||
virtual void UnInit(void);
|
virtual void UnInit(void);
|
||||||
virtual bool Process(int64_t time, int32_t deltaTime);
|
virtual bool Process(int64_t time, int32_t deltaTime);
|
||||||
virtual void Draw(etk::VectorType<ewol::Sprite*> & listOfSprite, etk::VectorType<ewol::Sprite*> & listOfEffects);
|
virtual void Draw(int32_t currentCreateId);
|
||||||
virtual bool HaveImpact(int32_t group, int32_t type, Vector2D<float> position, float size);
|
virtual bool HaveImpact(int32_t group, int32_t type, Vector2D<float> position, float size);
|
||||||
virtual bool Explosion(int32_t group, int32_t type, Vector2D<float> position, float pxAtenuation, float power);
|
virtual bool Explosion(int32_t group, int32_t type, Vector2D<float> position, float pxAtenuation, float power);
|
||||||
virtual void Message(etk::UString control, etk::UString message);
|
virtual void Message(etk::UString control, etk::UString message);
|
||||||
|
@ -79,15 +79,6 @@ ewol::SceneElement::~SceneElement(void)
|
|||||||
}
|
}
|
||||||
listAnimatedElements[iii].Clear();
|
listAnimatedElements[iii].Clear();
|
||||||
}
|
}
|
||||||
for (int32_t iii=0; iii<NB_BOUBLE_BUFFER; iii++) {
|
|
||||||
for (int32_t jjj=0; jjj<backgroundElements[iii].Size(); jjj++) {
|
|
||||||
if (NULL != backgroundElements[iii][jjj]) {
|
|
||||||
delete(backgroundElements[iii][jjj]);
|
|
||||||
backgroundElements[iii][jjj] = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
backgroundElements[iii].Clear();
|
|
||||||
}
|
|
||||||
for (int32_t iii=0; iii<NB_BOUBLE_BUFFER; iii++) {
|
for (int32_t iii=0; iii<NB_BOUBLE_BUFFER; iii++) {
|
||||||
for (int32_t jjj=0; jjj<animated[iii].Size(); jjj++) {
|
for (int32_t jjj=0; jjj<animated[iii].Size(); jjj++) {
|
||||||
if (NULL != animated[iii][jjj]) {
|
if (NULL != animated[iii][jjj]) {
|
||||||
@ -97,15 +88,6 @@ ewol::SceneElement::~SceneElement(void)
|
|||||||
}
|
}
|
||||||
animated[iii].Clear();
|
animated[iii].Clear();
|
||||||
}
|
}
|
||||||
for (int32_t iii=0; iii<NB_BOUBLE_BUFFER; iii++) {
|
|
||||||
for (int32_t jjj=0; jjj<effects[iii].Size(); jjj++) {
|
|
||||||
if (NULL != effects[iii][jjj]) {
|
|
||||||
delete(effects[iii][jjj]);
|
|
||||||
effects[iii][jjj] = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
effects[iii].Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::SceneElement::RegisterElementType(etk::UString name, creatorElement_tf * loadElement, etk::UString userString)
|
void ewol::SceneElement::RegisterElementType(etk::UString name, creatorElement_tf * loadElement, etk::UString userString)
|
||||||
|
@ -37,10 +37,10 @@ namespace ewol {
|
|||||||
uint32_t id; //!< unique id of the element
|
uint32_t id; //!< unique id of the element
|
||||||
int32_t group; //!< element group
|
int32_t group; //!< element group
|
||||||
int32_t type; //!< element type
|
int32_t type; //!< element type
|
||||||
Vector2D<float> position; //!< current position
|
Vector2D<float> position; //!< current position
|
||||||
Vector2D<float> speed; //!< current speed
|
Vector2D<float> speed; //!< current speed
|
||||||
Vector2D<float> size; //!< curent size of the element
|
Vector2D<float> size; //!< curent size of the element
|
||||||
float angle; //!< element angle
|
float angle; //!< element angle
|
||||||
} gameElementGenericProperty_ts;
|
} gameElementGenericProperty_ts;
|
||||||
|
|
||||||
typedef ewol::GameElement* (creatorElement_tf)(SceneElement & sceneElement, etk::UString& tmpName, etk::UString& userString);
|
typedef ewol::GameElement* (creatorElement_tf)(SceneElement & sceneElement, etk::UString& tmpName, etk::UString& userString);
|
||||||
@ -64,9 +64,7 @@ namespace ewol {
|
|||||||
int32_t numberOfGroup; //!< curent scene number of group
|
int32_t numberOfGroup; //!< curent scene number of group
|
||||||
etk::UString groupDescription[MAX_GROUP_NUMBER]; //!< name of all the groups
|
etk::UString groupDescription[MAX_GROUP_NUMBER]; //!< name of all the groups
|
||||||
int32_t groupEnemy[MAX_GROUP_NUMBER][MAX_GROUP_NUMBER]; //!< list of the ennemy
|
int32_t groupEnemy[MAX_GROUP_NUMBER][MAX_GROUP_NUMBER]; //!< list of the ennemy
|
||||||
etk::VectorType<ewol::OObject*> backgroundElements[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
|
||||||
etk::VectorType<ewol::Sprite*> animated[NB_BOUBLE_BUFFER]; //!< element that must be display the second
|
etk::VectorType<ewol::Sprite*> animated[NB_BOUBLE_BUFFER]; //!< element that must be display the second
|
||||||
etk::VectorType<ewol::Sprite*> effects[NB_BOUBLE_BUFFER]; //!< element that must be display the third
|
|
||||||
etk::VectorType<ewol::GameElement*> listAnimatedElements[MAX_GROUP_NUMBER]; //!< generic element to display order in the diffferent group
|
etk::VectorType<ewol::GameElement*> listAnimatedElements[MAX_GROUP_NUMBER]; //!< generic element to display order in the diffferent group
|
||||||
etk::VectorType<ewol::GameElement*> listGarbage; //!< garbage of the old element allocated ==> prevent multiple alloc and free
|
etk::VectorType<ewol::GameElement*> listGarbage; //!< garbage of the old element allocated ==> prevent multiple alloc and free
|
||||||
etk::VectorType<listRegisteElement*> listCreatorElement; //!< list of all creatable elements
|
etk::VectorType<listRegisteElement*> listCreatorElement; //!< list of all creatable elements
|
||||||
|
@ -37,6 +37,7 @@ ewol::OObject::OObject(void)
|
|||||||
m_hasClipping = false;
|
m_hasClipping = false;
|
||||||
m_scaling.x = 1.0;
|
m_scaling.x = 1.0;
|
||||||
m_scaling.y = 1.0;
|
m_scaling.y = 1.0;
|
||||||
|
m_nbLoadedTime = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ namespace ewol {
|
|||||||
class OObject
|
class OObject
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
int32_t m_nbLoadedTime; //!< specific in case of non multiple allocation
|
||||||
bool m_hasClipping;
|
bool m_hasClipping;
|
||||||
clipping_ts m_clipping;
|
clipping_ts m_clipping;
|
||||||
Vector2D<float> m_scaling; //!< scaling ol the object
|
Vector2D<float> m_scaling; //!< scaling ol the object
|
||||||
@ -54,6 +55,15 @@ namespace ewol {
|
|||||||
void clippingEnable(void) {m_hasClipping = true;};
|
void clippingEnable(void) {m_hasClipping = true;};
|
||||||
void scalingSet(Vector2D<float> scale) {m_scaling = scale;};
|
void scalingSet(Vector2D<float> scale) {m_scaling = scale;};
|
||||||
virtual void Draw(void) = 0;
|
virtual void Draw(void) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Increase the number of element registered on this class ==> this is specific to decrese the memory usage in special case (scene)
|
||||||
|
*/
|
||||||
|
void IncreaseLoadedTime(void) { m_nbLoadedTime++;};
|
||||||
|
/**
|
||||||
|
* @brief Decrease the number of element registered on this class ==> this is specific to decrese the memory usage in special case (scene)
|
||||||
|
* @return true, if no more element registered on it ...
|
||||||
|
*/
|
||||||
|
bool DecreaseLoadedTime(void) { m_nbLoadedTime--; if (m_nbLoadedTime <= 0) { return true;} else { return false;} };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ void ewol::Sprite::Draw(void)
|
|||||||
glBindTexture(GL_TEXTURE_2D, ewol::texture::GetGLID(m_textureId));
|
glBindTexture(GL_TEXTURE_2D, ewol::texture::GetGLID(m_textureId));
|
||||||
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
|
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
|
||||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
||||||
glVertexPointer( 2, GL_FLOAT, 0, &m_coord[0] );
|
glVertexPointer( 3, GL_FLOAT, 0, &m_coord[0] );
|
||||||
glTexCoordPointer( 2, GL_FLOAT, 0, &m_coordTex[0] );
|
glTexCoordPointer( 2, GL_FLOAT, 0, &m_coordTex[0] );
|
||||||
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
|
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
|
||||||
//EWOL_DEBUG("request draw of " << m_coord.Size() << " elements");
|
//EWOL_DEBUG("request draw of " << m_coord.Size() << " elements");
|
||||||
@ -98,7 +98,56 @@ void ewol::Sprite::Element(Vector2D<float> pos, float size, float angle)
|
|||||||
texD.u = 1.0;
|
texD.u = 1.0;
|
||||||
texD.v = 0.0;
|
texD.v = 0.0;
|
||||||
|
|
||||||
Vector2D<float> point;
|
Vector3D<float> point;
|
||||||
|
point.y = 0;
|
||||||
|
float yyySin = sin(angle) * size;
|
||||||
|
float xxxCos = cos(angle) * size;
|
||||||
|
|
||||||
|
point.x = xxxCos + pos.x;
|
||||||
|
point.y = yyySin + pos.y;
|
||||||
|
m_coord.PushBack(point);
|
||||||
|
m_coordTex.PushBack(texB);
|
||||||
|
|
||||||
|
point.x = yyySin + pos.x;
|
||||||
|
point.y = -xxxCos + pos.y;
|
||||||
|
m_coord.PushBack(point);
|
||||||
|
m_coordTex.PushBack(texC);
|
||||||
|
|
||||||
|
point.x = -xxxCos + pos.x;
|
||||||
|
point.y = -yyySin + pos.y;
|
||||||
|
m_coord.PushBack(point);
|
||||||
|
m_coordTex.PushBack(texD);
|
||||||
|
|
||||||
|
m_coord.PushBack(point);
|
||||||
|
m_coordTex.PushBack(texD);
|
||||||
|
|
||||||
|
point.x = -yyySin + pos.x;
|
||||||
|
point.y = xxxCos + pos.y;
|
||||||
|
m_coord.PushBack(point);
|
||||||
|
m_coordTex.PushBack(texA);
|
||||||
|
|
||||||
|
point.x = xxxCos + pos.x;
|
||||||
|
point.y = yyySin + pos.y;
|
||||||
|
m_coord.PushBack(point);
|
||||||
|
m_coordTex.PushBack(texB);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::Sprite::Element(Vector3D<float> pos, float size, float angle)
|
||||||
|
{
|
||||||
|
angle -= M_PI/4;
|
||||||
|
size *= 0.7;
|
||||||
|
texCoord_ts texA, texB, texC, texD;
|
||||||
|
texA.u = 0.0;
|
||||||
|
texA.v = 0.0;
|
||||||
|
texB.u = 0.0;
|
||||||
|
texB.v = 1.0;
|
||||||
|
texC.u = 1.0;
|
||||||
|
texC.v = 1.0;
|
||||||
|
texD.u = 1.0;
|
||||||
|
texD.v = 0.0;
|
||||||
|
|
||||||
|
Vector3D<float> point = pos;
|
||||||
float yyySin = sin(angle) * size;
|
float yyySin = sin(angle) * size;
|
||||||
float xxxCos = cos(angle) * size;
|
float xxxCos = cos(angle) * size;
|
||||||
|
|
||||||
|
@ -38,12 +38,13 @@ namespace ewol {
|
|||||||
virtual ~Sprite(void);
|
virtual ~Sprite(void);
|
||||||
virtual void Draw(void);
|
virtual void Draw(void);
|
||||||
void Clear(void);
|
void Clear(void);
|
||||||
void Element(Vector2D<float> pos, float size, float angle);
|
void Element(Vector2D<float> pos, float size, float angle);
|
||||||
|
void Element(Vector3D<float> pos, float size, float angle);
|
||||||
bool HasName(etk::UString& name) { return name == m_name; };
|
bool HasName(etk::UString& name) { return name == m_name; };
|
||||||
protected:
|
protected:
|
||||||
int32_t m_textureId; //!< texture internal ID
|
int32_t m_textureId; //!< texture internal ID
|
||||||
etk::VectorType<Vector2D<float> > m_coord; //!< internal coord of the object
|
etk::VectorType<Vector3D<float> > m_coord; //!< internal coord of the object
|
||||||
etk::VectorType<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
etk::VectorType<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,17 +104,11 @@ void ewol::Scene::OnRegenerateDisplay(void)
|
|||||||
m_sceneElement.animated[m_currentCreateId][iii]->Clear();
|
m_sceneElement.animated[m_currentCreateId][iii]->Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// clean effects
|
|
||||||
for (int32_t iii=0; iii<m_sceneElement.effects[m_currentCreateId].Size(); iii++) {
|
|
||||||
if (NULL != m_sceneElement.effects[m_currentCreateId][iii]) {
|
|
||||||
m_sceneElement.effects[m_currentCreateId][iii]->Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int32_t jjj=0; jjj<MAX_GROUP_NUMBER; jjj++) {
|
for (int32_t jjj=0; jjj<MAX_GROUP_NUMBER; jjj++) {
|
||||||
for (int32_t iii=0; iii<m_sceneElement.listAnimatedElements[jjj].Size(); iii++) {
|
for (int32_t iii=0; iii<m_sceneElement.listAnimatedElements[jjj].Size(); iii++) {
|
||||||
if (NULL != m_sceneElement.listAnimatedElements[jjj][iii]) {
|
if (NULL != m_sceneElement.listAnimatedElements[jjj][iii]) {
|
||||||
// find an empty slot ...
|
// find an empty slot ...
|
||||||
m_sceneElement.listAnimatedElements[jjj][iii]->Draw(m_sceneElement.animated[m_currentCreateId], m_sceneElement.effects[m_currentCreateId]);
|
m_sceneElement.listAnimatedElements[jjj][iii]->Draw(m_currentCreateId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,20 +125,12 @@ void ewol::Scene::OnRegenerateDisplay(void)
|
|||||||
void ewol::Scene::OnDraw(void)
|
void ewol::Scene::OnDraw(void)
|
||||||
{
|
{
|
||||||
//EWOL_ERROR(" On draw : " << m_currentDrawId);
|
//EWOL_ERROR(" On draw : " << m_currentDrawId);
|
||||||
// draw background
|
|
||||||
// TODO : ...
|
|
||||||
// draw elements
|
// draw elements
|
||||||
for (int32_t iii=0; iii<m_sceneElement.animated[m_currentDrawId].Size(); iii++) {
|
for (int32_t iii=0; iii<m_sceneElement.animated[m_currentDrawId].Size(); iii++) {
|
||||||
if (NULL != m_sceneElement.animated[m_currentDrawId][iii]) {
|
if (NULL != m_sceneElement.animated[m_currentDrawId][iii]) {
|
||||||
m_sceneElement.animated[m_currentDrawId][iii]->Draw();
|
m_sceneElement.animated[m_currentDrawId][iii]->Draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// draw effects
|
|
||||||
for (int32_t iii=0; iii<m_sceneElement.effects[m_currentDrawId].Size(); iii++) {
|
|
||||||
if (NULL != m_sceneElement.effects[m_currentDrawId][iii]) {
|
|
||||||
m_sceneElement.effects[m_currentDrawId][iii]->Draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user