[DEV] detect bounding and display bounding simplify
This commit is contained in:
parent
d1e48b5d0d
commit
549ac760d7
10
data/simple3D.frag
Normal file
10
data/simple3D.frag
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
precision mediump int;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
varying vec4 f_color;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
gl_FragColor = f_color;
|
||||||
|
}
|
2
data/simple3D.prog
Normal file
2
data/simple3D.prog
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
simple3D.vert
|
||||||
|
simple3D.frag
|
18
data/simple3D.vert
Normal file
18
data/simple3D.vert
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
precision mediump int;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Input :
|
||||||
|
attribute vec3 EW_coord3d;
|
||||||
|
uniform vec4 EW_color;
|
||||||
|
uniform mat4 EW_MatrixTransformation;
|
||||||
|
|
||||||
|
// output :
|
||||||
|
varying vec4 f_color;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
gl_Position = EW_MatrixTransformation * vec4(EW_coord3d, 1.0);
|
||||||
|
//gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(EW_coord2d, 0.0, 1.0);
|
||||||
|
f_color = EW_color;
|
||||||
|
}
|
2
external/agg
vendored
2
external/agg
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 4a997e47d5b724d994403f499f2258fc86e764b3
|
Subproject commit 404b68ec9fcd970c3daf5aa6a43331bd852551df
|
@ -11,7 +11,8 @@
|
|||||||
|
|
||||||
|
|
||||||
game::Bounding::Bounding(boundingMode mode) :
|
game::Bounding::Bounding(boundingMode mode) :
|
||||||
m_mode(mode)
|
m_mode(mode),
|
||||||
|
m_hasContact(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,25 +9,26 @@
|
|||||||
#ifndef __GAME_BOUNDING_H__
|
#ifndef __GAME_BOUNDING_H__
|
||||||
#define __GAME_BOUNDING_H__
|
#define __GAME_BOUNDING_H__
|
||||||
|
|
||||||
#include "ewol/debug.h"
|
#include <ewol/debug.h>
|
||||||
#include "ewol/game/MeshObject.h"
|
#include <ewol/game/MeshObject.h>
|
||||||
#include <etk/math/Matrix4.h>
|
#include <etk/math/Matrix4.h>
|
||||||
|
//#include <ewol/game/Contact.h>
|
||||||
|
|
||||||
namespace game
|
namespace game
|
||||||
{
|
{
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BoundingModeNone, //!< No Bounding.
|
|
||||||
BoundingModePlane, //!< plane Bounding.
|
BoundingModePlane, //!< plane Bounding.
|
||||||
BoundingModeAABB, //!< Anti-aligned Bounding Boxes.
|
|
||||||
BoundingModeSphere, //!< Sphere.
|
BoundingModeSphere, //!< Sphere.
|
||||||
|
BoundingModeAABB, //!< Anti-aligned Bounding Boxes.
|
||||||
BoundingModeOBB, //!< Oriented Bounding Box.
|
BoundingModeOBB, //!< Oriented Bounding Box.
|
||||||
// TODO : Add more if needed to implement
|
// TODO : Add more if needed to implement
|
||||||
} boundingMode;
|
} boundingMode;
|
||||||
|
|
||||||
class Bounding
|
class Bounding
|
||||||
{
|
{
|
||||||
protected :
|
protected:
|
||||||
boundingMode m_mode; //!< bounding mode of this system.
|
boundingMode m_mode; //!< bounding mode of this system.
|
||||||
|
bool m_hasContact; //!< this bounding is on contact with something else ...
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @biref Main constructor.
|
* @biref Main constructor.
|
||||||
@ -48,9 +49,20 @@ namespace game
|
|||||||
*/
|
*/
|
||||||
virtual void Update(game::MeshObject& object, mat4& transformMatrix) {};
|
virtual void Update(game::MeshObject& object, mat4& transformMatrix) {};
|
||||||
/**
|
/**
|
||||||
* Draw the bounding ==> for test ...
|
* @brief Draw the bounding ==> for test ...
|
||||||
*/
|
*/
|
||||||
virtual void Draw(void) {};
|
virtual void Draw(void) {};
|
||||||
|
/**
|
||||||
|
* @brief Detect the colision positions.
|
||||||
|
*/
|
||||||
|
//virtual void GenerateContact(game::Element* ourElement, game::Bounding* otherbounding, game::Element* otherElements, etk::Vector<game::Contact>& contactList);
|
||||||
|
virtual bool HasContact(game::Bounding& otherbounding) { return false; };
|
||||||
|
/**
|
||||||
|
* @brief Set the contact property at a specific value ...
|
||||||
|
*/
|
||||||
|
void SetContactMode(bool newStatus) { m_hasContact=newStatus; };
|
||||||
|
|
||||||
|
bool GetContactStatus(void) { return m_hasContact; };
|
||||||
};
|
};
|
||||||
|
|
||||||
Bounding* CreateBounding(boundingMode mode);
|
Bounding* CreateBounding(boundingMode mode);
|
||||||
|
@ -21,12 +21,8 @@ game::BoundingAABB::BoundingAABB(void) :
|
|||||||
if (false == ewol::resource::Keep(m_displayBounding) ) {
|
if (false == ewol::resource::Keep(m_displayBounding) ) {
|
||||||
EWOL_DEBUG("Can not keep ewol::Colored3DObject ...");
|
EWOL_DEBUG("Can not keep ewol::Colored3DObject ...");
|
||||||
}
|
}
|
||||||
// color never change ...
|
|
||||||
draw::Color tmpColorNormal(0xFF000055);
|
|
||||||
draw::Colorf tmpColor(tmpColorNormal);
|
|
||||||
vec3 tmpPos(0,0,0);
|
vec3 tmpPos(0,0,0);
|
||||||
for(int32_t iii=0; iii<36; iii++) {
|
for(int32_t iii=0; iii<36; iii++) {
|
||||||
m_color.PushBack(tmpColor);
|
|
||||||
m_vertices.PushBack(tmpPos);
|
m_vertices.PushBack(tmpPos);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -156,9 +152,13 @@ void game::BoundingAABB::Update(game::MeshObject& object, mat4& transformMatrix)
|
|||||||
void game::BoundingAABB::Draw(void)
|
void game::BoundingAABB::Draw(void)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
draw::Colorf color(0.0, 1.0, 0.0, 0.2);
|
||||||
|
if (true == m_hasContact) {
|
||||||
|
color = draw::Colorf(1.0, 0.0, 0.0, 0.2);
|
||||||
|
}
|
||||||
if (0 != m_vertices.Size()) {
|
if (0 != m_vertices.Size()) {
|
||||||
if (NULL != m_displayBounding) {
|
if (NULL != m_displayBounding) {
|
||||||
m_displayBounding->Draw(m_vertices, m_color, false);
|
m_displayBounding->Draw(m_vertices, color, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EWOL_DEBUG("Bounding size is not correct...");
|
EWOL_DEBUG("Bounding size is not correct...");
|
||||||
@ -167,4 +167,26 @@ void game::BoundingAABB::Draw(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool game::BoundingAABB::HasContact(game::Bounding& otherbounding)
|
||||||
|
{
|
||||||
|
switch(otherbounding.GetType()) {
|
||||||
|
case game::BoundingModeAABB:
|
||||||
|
{
|
||||||
|
game::BoundingAABB& other = static_cast<game::BoundingAABB&>(otherbounding);
|
||||||
|
if( m_PointStart.x > other.m_PointStop.x
|
||||||
|
|| m_PointStop.x < other.m_PointStart.x
|
||||||
|
|| m_PointStart.y > other.m_PointStop.y
|
||||||
|
|| m_PointStop.y < other.m_PointStart.y
|
||||||
|
|| m_PointStart.z > other.m_PointStop.z
|
||||||
|
|| m_PointStop.z < other.m_PointStart.z) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
EWOL_DEBUG("TODO ... ");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ namespace game
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
ewol::Colored3DObject* m_displayBounding;
|
ewol::Colored3DObject* m_displayBounding;
|
||||||
etk::Vector<vec3> m_vertices;
|
etk::Vector<vec3> m_vertices;
|
||||||
etk::Vector<draw::Colorf> m_color;
|
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -40,6 +39,8 @@ namespace game
|
|||||||
virtual void Update(game::MeshObject& object, mat4& transformMatrix);
|
virtual void Update(game::MeshObject& object, mat4& transformMatrix);
|
||||||
// herited methodes
|
// herited methodes
|
||||||
virtual void Draw(void);
|
virtual void Draw(void);
|
||||||
|
// herited methodes
|
||||||
|
virtual bool HasContact(game::Bounding& otherbounding);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ game::Element::Element(etk::UString meshResource) :
|
|||||||
m_bounding(NULL),
|
m_bounding(NULL),
|
||||||
m_matrixNeedUpdate(true),
|
m_matrixNeedUpdate(true),
|
||||||
m_scale(1,1,1),
|
m_scale(1,1,1),
|
||||||
|
m_speedMax(2000000, 2000000, 2000000),
|
||||||
m_mass(0.0f),
|
m_mass(0.0f),
|
||||||
m_uniqueId(uniqueId),
|
m_uniqueId(uniqueId),
|
||||||
m_groupId(0),
|
m_groupId(0),
|
||||||
@ -65,7 +66,7 @@ void game::Element::DrawDebug(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool game::Element::ArtificialIntelligence(int32_t deltaMicroSecond)
|
bool game::Element::ArtificialIntelligence(float deltaMicroSecond)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -99,10 +100,15 @@ void game::Element::ProcessGravity(float delta, game::Gravity& gravity)
|
|||||||
|
|
||||||
void game::Element::ProcessPosition(float delta)
|
void game::Element::ProcessPosition(float delta)
|
||||||
{
|
{
|
||||||
|
if( NULL!=m_bounding
|
||||||
|
&& true == m_bounding->GetContactStatus()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
vec3 m_speed0(m_speed);
|
vec3 m_speed0(m_speed);
|
||||||
vec3 curentAcceleration(m_gravityForce + m_userAcceleration);
|
vec3 curentAcceleration(m_gravityForce + m_userAcceleration);
|
||||||
m_speed += curentAcceleration*delta;
|
m_speed += curentAcceleration*delta;
|
||||||
vec3 tmpPos = m_position +m_speed0*delta + curentAcceleration*delta*delta/2.0f ;
|
vec3 tmpPos = m_position +m_speed0*delta + curentAcceleration*delta*delta/2.0f ;
|
||||||
|
|
||||||
if (m_position != tmpPos) {
|
if (m_position != tmpPos) {
|
||||||
m_position = tmpPos;
|
m_position = tmpPos;
|
||||||
m_matrixNeedUpdate = true;
|
m_matrixNeedUpdate = true;
|
||||||
|
@ -36,6 +36,7 @@ namespace game
|
|||||||
// specific for the physical engine :
|
// specific for the physical engine :
|
||||||
vec3 m_position; //!< position of the element. (in m)
|
vec3 m_position; //!< position of the element. (in m)
|
||||||
vec3 m_speed; //!< Speed of the element. (in m/s)
|
vec3 m_speed; //!< Speed of the element. (in m/s)
|
||||||
|
vec3 m_speedMax; //!< Speed maximum limitation. (in m/s)
|
||||||
float m_mass; //!< object mass (in kg)
|
float m_mass; //!< object mass (in kg)
|
||||||
vec3 m_gravityForce; //!< curent gravity force in newton of the object (m/s^2)
|
vec3 m_gravityForce; //!< curent gravity force in newton of the object (m/s^2)
|
||||||
vec3 m_userAcceleration; //!< the only one parameter that the user can change (m/s^2), if the coder want that the equation do not take stipid things ...
|
vec3 m_userAcceleration; //!< the only one parameter that the user can change (m/s^2), if the coder want that the equation do not take stipid things ...
|
||||||
@ -68,7 +69,7 @@ namespace game
|
|||||||
* @param[in] deltaMicroSecond delta from the last call.
|
* @param[in] deltaMicroSecond delta from the last call.
|
||||||
* @return true if this element must be destroyed
|
* @return true if this element must be destroyed
|
||||||
*/
|
*/
|
||||||
virtual bool ArtificialIntelligence(int32_t deltaMicroSecond);
|
virtual bool ArtificialIntelligence(float delta);
|
||||||
/**
|
/**
|
||||||
* @brief Clear the current gravity reference
|
* @brief Clear the current gravity reference
|
||||||
*/
|
*/
|
||||||
@ -144,6 +145,11 @@ namespace game
|
|||||||
{
|
{
|
||||||
m_speed = newSpeed;
|
m_speed = newSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
game::Bounding* GetBounding(void)
|
||||||
|
{
|
||||||
|
return m_bounding;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,20 +20,13 @@ game::Engine::Engine(void)
|
|||||||
|
|
||||||
game::Engine::~Engine(void)
|
game::Engine::~Engine(void)
|
||||||
{
|
{
|
||||||
for (int32_t iii=0; iii<m_elementsStatic.Size() ; iii++) {
|
for (int32_t iii=0; iii<m_elements.Size() ; iii++) {
|
||||||
if (NULL != m_elementsStatic[iii]) {
|
if (NULL != m_elements[iii]) {
|
||||||
delete(m_elementsStatic[iii]);
|
delete(m_elements[iii]);
|
||||||
m_elementsStatic[iii] = NULL;
|
m_elements[iii] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_elementsStatic.Clear();
|
m_elements.Clear();
|
||||||
for (int32_t iii=0; iii<m_elementsDynamic.Size() ; iii++) {
|
|
||||||
if (NULL != m_elementsDynamic[iii]) {
|
|
||||||
delete(m_elementsDynamic[iii]);
|
|
||||||
m_elementsDynamic[iii] = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_elementsDynamic.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void game::Engine::Process(double lastTime, float deltaTime)
|
void game::Engine::Process(double lastTime, float deltaTime)
|
||||||
@ -47,17 +40,11 @@ void game::Engine::ProcessGravity(float deltaTime)
|
|||||||
{
|
{
|
||||||
//EWOL_DEBUG("Gravity management");
|
//EWOL_DEBUG("Gravity management");
|
||||||
for(int32_t jjj=0 ; jjj<m_gravity.Size() ; jjj++) {
|
for(int32_t jjj=0 ; jjj<m_gravity.Size() ; jjj++) {
|
||||||
for (int32_t iii=0; iii<m_elementsStatic.Size() ; iii++) {
|
for (int32_t iii=0; iii<m_elements.Size() ; iii++) {
|
||||||
if (NULL != m_elementsStatic[iii]) {
|
if (NULL != m_elements[iii]) {
|
||||||
m_elementsStatic[iii]->ProcessGravity(deltaTime, m_gravity[jjj]);
|
m_elements[iii]->ProcessGravity(deltaTime, m_gravity[jjj]);
|
||||||
}
|
}
|
||||||
m_elementsStatic[iii]->ProcessPosition(deltaTime);
|
m_elements[iii]->ProcessPosition(deltaTime);
|
||||||
}
|
|
||||||
for (int32_t iii=0; iii<m_elementsDynamic.Size() ; iii++) {
|
|
||||||
if (NULL != m_elementsDynamic[iii]) {
|
|
||||||
m_elementsDynamic[iii]->ProcessGravity(deltaTime, m_gravity[jjj]);
|
|
||||||
}
|
|
||||||
m_elementsDynamic[iii]->ProcessPosition(deltaTime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,14 +52,9 @@ void game::Engine::ProcessGravity(float deltaTime)
|
|||||||
void game::Engine::ProcessIA(float deltaTime)
|
void game::Engine::ProcessIA(float deltaTime)
|
||||||
{
|
{
|
||||||
//EWOL_DEBUG("Artificial Intelligence management");
|
//EWOL_DEBUG("Artificial Intelligence management");
|
||||||
for (int32_t iii=0; iii<m_elementsStatic.Size() ; iii++) {
|
for (int32_t iii=0; iii<m_elements.Size() ; iii++) {
|
||||||
if (NULL != m_elementsStatic[iii]) {
|
if (NULL != m_elements[iii]) {
|
||||||
m_elementsStatic[iii]->ArtificialIntelligence(deltaTime);
|
m_elements[iii]->ArtificialIntelligence(deltaTime);
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int32_t iii=0; iii<m_elementsDynamic.Size() ; iii++) {
|
|
||||||
if (NULL != m_elementsDynamic[iii]) {
|
|
||||||
m_elementsDynamic[iii]->ArtificialIntelligence(deltaTime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,63 +62,75 @@ void game::Engine::ProcessIA(float deltaTime)
|
|||||||
void game::Engine::ProcessCollision(float deltaTime)
|
void game::Engine::ProcessCollision(float deltaTime)
|
||||||
{
|
{
|
||||||
//EWOL_DEBUG("Collision management");
|
//EWOL_DEBUG("Collision management");
|
||||||
|
m_contacts.Clear();
|
||||||
|
for (int32_t iii=0; iii<m_elements.Size() ; iii++) {
|
||||||
|
if (NULL != m_elements[iii]) {
|
||||||
|
game::Bounding* bounding1 = m_elements[iii]->GetBounding();
|
||||||
|
if (NULL != bounding1) {
|
||||||
|
bounding1->SetContactMode(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t iii=0; iii<m_elements.Size() ; iii++) {
|
||||||
|
if (NULL != m_elements[iii]) {
|
||||||
|
game::Bounding* bounding1 = m_elements[iii]->GetBounding();
|
||||||
|
if (NULL != bounding1) {
|
||||||
|
for (int32_t jjj=iii+1; jjj<m_elements.Size() ; jjj++) {
|
||||||
|
if (NULL!=m_elements[jjj]) {
|
||||||
|
game::Bounding* bounding2 = m_elements[jjj]->GetBounding();
|
||||||
|
if (NULL != bounding2) {
|
||||||
|
bool hasContactConfirmed = false;
|
||||||
|
if (bounding1->GetType() < bounding2->GetType()) {
|
||||||
|
//bounding2->GenerateContact(m_elements[jjj], bounding1, m_elements[iii], m_contacts);
|
||||||
|
hasContactConfirmed = bounding2->HasContact(*bounding1);
|
||||||
|
} else {
|
||||||
|
//bounding1->GenerateContact(m_elements[iii], bounding2, m_elements[jjj], m_contacts);
|
||||||
|
hasContactConfirmed = bounding1->HasContact(*bounding2);
|
||||||
|
}
|
||||||
|
if (true == hasContactConfirmed) {
|
||||||
|
bounding2->SetContactMode(true);
|
||||||
|
bounding1->SetContactMode(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void game::Engine::Draw(ewol::DrawProperty& displayProp)
|
void game::Engine::Draw(ewol::DrawProperty& displayProp)
|
||||||
{
|
{
|
||||||
//EWOL_DEBUG("Drawing the system");
|
//EWOL_DEBUG("Drawing the system");
|
||||||
for (int32_t iii=0; iii<m_elementsStatic.Size() ; iii++) {
|
for (int32_t iii=0; iii<m_elements.Size() ; iii++) {
|
||||||
if (NULL != m_elementsStatic[iii]) {
|
if (NULL != m_elements[iii]) {
|
||||||
m_elementsStatic[iii]->Draw();
|
m_elements[iii]->Draw();
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int32_t iii=0; iii<m_elementsDynamic.Size() ; iii++) {
|
|
||||||
if (NULL != m_elementsDynamic[iii]) {
|
|
||||||
m_elementsDynamic[iii]->Draw();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
for (int32_t iii=0; iii<m_elementsStatic.Size() ; iii++) {
|
for (int32_t iii=0; iii<m_elements.Size() ; iii++) {
|
||||||
if (NULL != m_elementsStatic[iii]) {
|
if (NULL != m_elements[iii]) {
|
||||||
m_elementsStatic[iii]->DrawDebug();
|
m_elements[iii]->DrawDebug();
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int32_t iii=0; iii<m_elementsDynamic.Size() ; iii++) {
|
|
||||||
if (NULL != m_elementsDynamic[iii]) {
|
|
||||||
m_elementsDynamic[iii]->DrawDebug();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void game::Engine::AddElement(game::Element* newElement, bool dynamic)
|
void game::Engine::AddElement(game::Element* newElement)
|
||||||
{
|
{
|
||||||
bool find=false;
|
bool find=false;
|
||||||
if (true == dynamic) {
|
for (int32_t iii=0 ; iii<m_elements.Size() ; iii++) {
|
||||||
for (int32_t iii=0 ; iii<m_elementsDynamic.Size() ; iii++) {
|
if (NULL == m_elements[iii]) {
|
||||||
if (NULL == m_elementsDynamic[iii]) {
|
m_elements[iii] = newElement;
|
||||||
m_elementsDynamic[iii] = newElement;
|
find = true;
|
||||||
find = true;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (false==find) {
|
|
||||||
m_elementsDynamic.PushBack(newElement);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int32_t iii=0 ; iii<m_elementsStatic.Size() ; iii++) {
|
|
||||||
if (NULL == m_elementsStatic[iii]) {
|
|
||||||
m_elementsStatic[iii] = newElement;
|
|
||||||
find = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (false==find) {
|
|
||||||
m_elementsStatic.PushBack(newElement);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (false==find) {
|
||||||
|
m_elements.PushBack(newElement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,10 +24,9 @@ namespace game
|
|||||||
class Engine
|
class Engine
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
etk::Vector<game::Gravity> m_gravity; //!< list of gravity element
|
etk::Vector<game::Gravity> m_gravity; //!< list of gravity element
|
||||||
etk::Vector<game::Element*> m_elementsStatic; //!< List of the game element (bounding does not move)
|
etk::Vector<game::Element*> m_elements; //!< List of the game element
|
||||||
etk::Vector<game::Element*> m_elementsDynamic; //!< List of the game element (change position all the time)
|
etk::Vector<game::Contact> m_contacts; //!< list of all contact that existe in the system
|
||||||
etk::Vector<game::Contact> m_contacts; //!< list of all contact that existe in the system
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Basic constructor.
|
* @brief Basic constructor.
|
||||||
@ -65,9 +64,8 @@ namespace game
|
|||||||
/**
|
/**
|
||||||
* @brief Add an element on the system.
|
* @brief Add an element on the system.
|
||||||
* @param[in] newElement element to display.
|
* @param[in] newElement element to display.
|
||||||
* @param[in] dynamic this element change of place.
|
|
||||||
*/
|
*/
|
||||||
void AddElement(game::Element* newElement, bool dynamic);
|
void AddElement(game::Element* newElement);
|
||||||
/**
|
/**
|
||||||
* @brief Add a gravity on the system.
|
* @brief Add a gravity on the system.
|
||||||
* @param[in] gravity The gravity to add.
|
* @param[in] gravity The gravity to add.
|
||||||
|
@ -15,12 +15,12 @@ ewol::Colored3DObject::Colored3DObject(etk::UString genName) :
|
|||||||
ewol::Resource(genName),
|
ewol::Resource(genName),
|
||||||
m_GLprogram(NULL)
|
m_GLprogram(NULL)
|
||||||
{
|
{
|
||||||
etk::UString tmpString("DATA:color3.prog");
|
etk::UString tmpString("DATA:simple3D.prog");
|
||||||
// get the shader resource :
|
// get the shader resource :
|
||||||
m_GLPosition = 0;
|
m_GLPosition = 0;
|
||||||
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {
|
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {
|
||||||
m_GLPosition = m_GLprogram->GetAttribute("EW_coord3d");
|
m_GLPosition = m_GLprogram->GetAttribute("EW_coord3d");
|
||||||
m_GLColor = m_GLprogram->GetAttribute("EW_color");
|
m_GLColor = m_GLprogram->GetUniform("EW_color");
|
||||||
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ ewol::Colored3DObject::~Colored3DObject(void)
|
|||||||
|
|
||||||
|
|
||||||
void ewol::Colored3DObject::Draw(etk::Vector<vec3>& vertices,
|
void ewol::Colored3DObject::Draw(etk::Vector<vec3>& vertices,
|
||||||
etk::Vector<draw::Colorf>& color,
|
draw::Colorf& color,
|
||||||
bool updateDepthBuffer)
|
bool updateDepthBuffer)
|
||||||
{
|
{
|
||||||
if (vertices.Size()<=0) {
|
if (vertices.Size()<=0) {
|
||||||
@ -57,7 +57,7 @@ void ewol::Colored3DObject::Draw(etk::Vector<vec3>& vertices,
|
|||||||
// position :
|
// position :
|
||||||
m_GLprogram->SendAttribute(m_GLPosition, 3/*x,y,z*/, &vertices[0]);
|
m_GLprogram->SendAttribute(m_GLPosition, 3/*x,y,z*/, &vertices[0]);
|
||||||
// color :
|
// color :
|
||||||
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &color[0]);
|
m_GLprogram->Uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&color);
|
||||||
// Request the draw od the elements :
|
// Request the draw od the elements :
|
||||||
glDrawArrays(GL_TRIANGLES, 0, vertices.Size());
|
glDrawArrays(GL_TRIANGLES, 0, vertices.Size());
|
||||||
m_GLprogram->UnUse();
|
m_GLprogram->UnUse();
|
||||||
|
@ -30,7 +30,7 @@ namespace ewol
|
|||||||
virtual ~Colored3DObject(void);
|
virtual ~Colored3DObject(void);
|
||||||
virtual const char* GetType(void) { return "ewol::Colored3DObject"; };
|
virtual const char* GetType(void) { return "ewol::Colored3DObject"; };
|
||||||
virtual void Draw(etk::Vector<vec3>& vertices,
|
virtual void Draw(etk::Vector<vec3>& vertices,
|
||||||
etk::Vector<draw::Colorf>& color,
|
draw::Colorf& color,
|
||||||
bool updateDepthBuffer=true);
|
bool updateDepthBuffer=true);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -110,6 +110,10 @@ LOCAL_COPY_FILES := ../data/textured3D.prog:textured3D.prog \
|
|||||||
../data/color3.frag:color3.frag \
|
../data/color3.frag:color3.frag \
|
||||||
../data/color3.vert:color3.vert \
|
../data/color3.vert:color3.vert \
|
||||||
\
|
\
|
||||||
|
../data/simple3D.prog:simple3D.prog \
|
||||||
|
../data/simple3D.frag:simple3D.frag \
|
||||||
|
../data/simple3D.vert:simple3D.vert \
|
||||||
|
\
|
||||||
../data/textured.prog:textured.prog \
|
../data/textured.prog:textured.prog \
|
||||||
../data/textured.frag:textured.frag \
|
../data/textured.frag:textured.frag \
|
||||||
../data/textured.vert:textured.vert \
|
../data/textured.vert:textured.vert \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user