[DEV] update new version of ewol API 0.9
This commit is contained in:
parent
ba20ab59f7
commit
73455cc61b
@ -27,8 +27,8 @@
|
||||
#undef __class__
|
||||
#define __class__ "CollisionShapeCreator"
|
||||
|
||||
btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh) {
|
||||
if (NULL == _mesh) {
|
||||
btCollisionShape* ege::collision::createShape(const ewol::object::Shared<ege::resource::Mesh>& _mesh) {
|
||||
if (nullptr == _mesh) {
|
||||
return new btEmptyShape();;
|
||||
}
|
||||
const std::vector<ege::PhysicsShape*>& physiqueProperty = _mesh->getPhysicalProperties();
|
||||
@ -37,29 +37,29 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh)
|
||||
}
|
||||
int32_t count = 0;
|
||||
for (size_t iii=0; iii<physiqueProperty.size(); iii++) {
|
||||
if (NULL == physiqueProperty[iii]) {
|
||||
if (nullptr == physiqueProperty[iii]) {
|
||||
continue;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
btCompoundShape* outputShape = NULL;
|
||||
btCompoundShape* outputShape = nullptr;
|
||||
if (count>1) {
|
||||
outputShape = new btCompoundShape();
|
||||
}
|
||||
for (size_t iii=0; iii<physiqueProperty.size(); iii++) {
|
||||
if (NULL == physiqueProperty[iii]) {
|
||||
if (nullptr == physiqueProperty[iii]) {
|
||||
continue;
|
||||
}
|
||||
switch (physiqueProperty[iii]->getType()) {
|
||||
case ege::PhysicsShape::box : {
|
||||
const ege::PhysicsBox* tmpElement = physiqueProperty[iii]->toBox();
|
||||
if (NULL == tmpElement) {
|
||||
if (nullptr == tmpElement) {
|
||||
// ERROR ...
|
||||
continue;
|
||||
}
|
||||
btCollisionShape* tmpShape = new btBoxShape(tmpElement->getSize());
|
||||
if (NULL != tmpShape) {
|
||||
if (outputShape == NULL) {
|
||||
if (nullptr != tmpShape) {
|
||||
if (outputShape == nullptr) {
|
||||
return tmpShape;
|
||||
} else {
|
||||
vec4 qqq = tmpElement->getQuaternion();
|
||||
@ -71,13 +71,13 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh)
|
||||
}
|
||||
case ege::PhysicsShape::cylinder : {
|
||||
const ege::PhysicsCylinder* tmpElement = physiqueProperty[iii]->toCylinder();
|
||||
if (NULL == tmpElement) {
|
||||
if (nullptr == tmpElement) {
|
||||
// ERROR ...
|
||||
continue;
|
||||
}
|
||||
btCollisionShape* tmpShape = new btCylinderShape(tmpElement->getSize());
|
||||
if (NULL != tmpShape) {
|
||||
if (outputShape == NULL) {
|
||||
if (nullptr != tmpShape) {
|
||||
if (outputShape == nullptr) {
|
||||
return tmpShape;
|
||||
} else {
|
||||
vec4 qqq = tmpElement->getQuaternion();
|
||||
@ -89,13 +89,13 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh)
|
||||
}
|
||||
case ege::PhysicsShape::capsule : {
|
||||
const ege::PhysicsCapsule* tmpElement = physiqueProperty[iii]->toCapsule();
|
||||
if (NULL == tmpElement) {
|
||||
if (nullptr == tmpElement) {
|
||||
// ERROR ...
|
||||
continue;
|
||||
}
|
||||
btCollisionShape* tmpShape = new btCapsuleShape(tmpElement->getRadius(), tmpElement->getHeight());
|
||||
if (NULL != tmpShape) {
|
||||
if (outputShape == NULL) {
|
||||
if (nullptr != tmpShape) {
|
||||
if (outputShape == nullptr) {
|
||||
return tmpShape;
|
||||
} else {
|
||||
vec4 qqq = tmpElement->getQuaternion();
|
||||
@ -107,13 +107,13 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh)
|
||||
}
|
||||
case ege::PhysicsShape::cone : {
|
||||
const ege::PhysicsCone* tmpElement = physiqueProperty[iii]->toCone();
|
||||
if (NULL == tmpElement) {
|
||||
if (nullptr == tmpElement) {
|
||||
// ERROR ...
|
||||
continue;
|
||||
}
|
||||
btCollisionShape* tmpShape = new btConeShape(tmpElement->getRadius(), tmpElement->getHeight());
|
||||
if (NULL != tmpShape) {
|
||||
if (outputShape == NULL) {
|
||||
if (nullptr != tmpShape) {
|
||||
if (outputShape == nullptr) {
|
||||
return tmpShape;
|
||||
} else {
|
||||
vec4 qqq = tmpElement->getQuaternion();
|
||||
@ -125,13 +125,13 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh)
|
||||
}
|
||||
case ege::PhysicsShape::sphere : {
|
||||
const ege::PhysicsSphere* tmpElement = physiqueProperty[iii]->toSphere();
|
||||
if (NULL == tmpElement) {
|
||||
if (nullptr == tmpElement) {
|
||||
// ERROR ...
|
||||
continue;
|
||||
}
|
||||
btCollisionShape* tmpShape = new btSphereShape(tmpElement->getRadius());
|
||||
if (NULL != tmpShape) {
|
||||
if (outputShape == NULL) {
|
||||
if (nullptr != tmpShape) {
|
||||
if (outputShape == nullptr) {
|
||||
return tmpShape;
|
||||
} else {
|
||||
vec4 qqq = tmpElement->getQuaternion();
|
||||
@ -143,13 +143,13 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh)
|
||||
}
|
||||
case ege::PhysicsShape::convexHull : {
|
||||
const ege::PhysicsConvexHull* tmpElement = physiqueProperty[iii]->toConvexHull();
|
||||
if (NULL == tmpElement) {
|
||||
if (nullptr == tmpElement) {
|
||||
// ERROR ...
|
||||
continue;
|
||||
}
|
||||
btConvexHullShape* tmpShape = new btConvexHullShape(&(tmpElement->getPointList()[0].x()), tmpElement->getPointList().size());
|
||||
if (NULL != tmpShape) {
|
||||
if (outputShape == NULL) {
|
||||
if (nullptr != tmpShape) {
|
||||
if (outputShape == nullptr) {
|
||||
return tmpShape;
|
||||
} else {
|
||||
vec4 qqq = tmpElement->getQuaternion();
|
||||
@ -164,7 +164,7 @@ btCollisionShape* ege::collision::createShape(const ege::resource::Mesh* _mesh)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (NULL == outputShape) {
|
||||
if (nullptr == outputShape) {
|
||||
return new btEmptyShape();
|
||||
}
|
||||
return outputShape;
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
namespace ege {
|
||||
namespace collision {
|
||||
btCollisionShape* createShape(const ege::resource::Mesh* _mesh);
|
||||
btCollisionShape* createShape(const ewol::object::Shared<ege::resource::Mesh>& _mesh);
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
@ -36,17 +36,17 @@ const std::string& ege::ElementGame::getType() const {
|
||||
|
||||
ege::ElementGame::ElementGame(ege::Environement& _env) :
|
||||
m_env(_env),
|
||||
m_body(NULL),
|
||||
m_body(nullptr),
|
||||
m_uID(0),
|
||||
m_mesh(NULL),
|
||||
m_shape(NULL),
|
||||
m_mesh(nullptr),
|
||||
m_shape(nullptr),
|
||||
m_life(100),
|
||||
m_lifeMax(100),
|
||||
m_group(0),
|
||||
m_fixe(true),
|
||||
m_radius(0),
|
||||
m_elementInPhysicsSystem(false),
|
||||
m_IA(NULL) {
|
||||
m_IA(nullptr) {
|
||||
static uint32_t unique=0;
|
||||
m_uID = unique;
|
||||
EGE_DEBUG("Create element : uId=" << m_uID);
|
||||
@ -60,61 +60,60 @@ ege::ElementGame::~ElementGame() {
|
||||
// same ...
|
||||
dynamicDisable();
|
||||
removeShape();
|
||||
ege::resource::Mesh::release(m_mesh);
|
||||
if (NULL != m_body) {
|
||||
if (nullptr != m_body) {
|
||||
delete(m_body);
|
||||
m_body = NULL;
|
||||
m_body = nullptr;
|
||||
}
|
||||
EGE_DEBUG("Destroy element : uId=" << m_uID);
|
||||
}
|
||||
|
||||
void ege::ElementGame::removeShape() {
|
||||
// no shape
|
||||
if (NULL == m_shape) {
|
||||
if (nullptr == m_shape) {
|
||||
return;
|
||||
}
|
||||
// need to chek if the shape is the same as the mesh shape ...
|
||||
if (m_mesh == NULL) {
|
||||
if (m_mesh == nullptr) {
|
||||
// no mesh == > standalone shape
|
||||
delete(m_shape);
|
||||
m_shape=NULL;
|
||||
m_shape=nullptr;
|
||||
return;
|
||||
}
|
||||
if (m_shape != m_mesh->getShape()) {
|
||||
delete(m_shape);
|
||||
m_shape=NULL;
|
||||
m_shape=nullptr;
|
||||
return;
|
||||
}
|
||||
// otherwise : the shape is auto remove by the resources when no more needed ...
|
||||
}
|
||||
|
||||
void ege::ElementGame::FunctionFreeShape(void* _pointer) {
|
||||
if (NULL == _pointer) {
|
||||
if (nullptr == _pointer) {
|
||||
return;
|
||||
}
|
||||
delete(static_cast<btCollisionShape*>(_pointer));
|
||||
}
|
||||
|
||||
bool ege::ElementGame::loadMesh(const std::string& _meshFileName) {
|
||||
ege::resource::Mesh* tmpMesh = ege::resource::Mesh::keep(_meshFileName);
|
||||
if(NULL == tmpMesh) {
|
||||
ewol::object::Shared<ege::resource::Mesh> tmpMesh = ege::resource::Mesh::keep(_meshFileName);
|
||||
if(nullptr == tmpMesh) {
|
||||
EGE_ERROR("can not load the resources : " << _meshFileName);
|
||||
return false;
|
||||
}
|
||||
return setMesh(tmpMesh);
|
||||
}
|
||||
|
||||
bool ege::ElementGame::setMesh(ege::resource::Mesh* _mesh) {
|
||||
if (NULL!=m_mesh) {
|
||||
bool ege::ElementGame::setMesh(const ewol::object::Shared<ege::resource::Mesh>& _mesh) {
|
||||
if (nullptr!=m_mesh) {
|
||||
removeShape();
|
||||
ege::resource::Mesh::release(m_mesh);
|
||||
m_mesh.reset();
|
||||
}
|
||||
m_mesh = _mesh;
|
||||
// auto load the shape :
|
||||
if (NULL == m_mesh) {
|
||||
if (m_mesh == nullptr) {
|
||||
return true;
|
||||
}
|
||||
if (NULL != m_mesh->getShape()) {
|
||||
if (m_mesh->getShape() != nullptr) {
|
||||
m_shape = static_cast<btCollisionShape*>(m_mesh->getShape());
|
||||
return true;
|
||||
}
|
||||
@ -150,7 +149,7 @@ void ege::ElementGame::setFireOn(int32_t _groupIdSource, int32_t _type, float _p
|
||||
}
|
||||
|
||||
void ege::ElementGame::setPosition(const vec3& _pos) {
|
||||
if (NULL!=m_body) {
|
||||
if (nullptr!=m_body) {
|
||||
btTransform transformation = m_body->getCenterOfMassTransform();
|
||||
transformation.setOrigin(_pos);
|
||||
m_body->setCenterOfMassTransform(transformation);
|
||||
@ -160,7 +159,7 @@ void ege::ElementGame::setPosition(const vec3& _pos) {
|
||||
const vec3& ege::ElementGame::getPosition() {
|
||||
// this is to prevent error like segmentation fault ...
|
||||
static vec3 emptyPosition(-1000000,-1000000,-1000000);
|
||||
if (NULL!=m_body) {
|
||||
if (nullptr!=m_body) {
|
||||
return m_body->getCenterOfMassPosition();
|
||||
}
|
||||
return emptyPosition;
|
||||
@ -169,20 +168,20 @@ const vec3& ege::ElementGame::getPosition() {
|
||||
const vec3& ege::ElementGame::getSpeed() {
|
||||
// this is to prevent error like segmentation fault ...
|
||||
static vec3 emptySpeed(0,0,0);
|
||||
if (NULL!=m_body) {
|
||||
if (nullptr!=m_body) {
|
||||
return m_body->getLinearVelocity();
|
||||
}
|
||||
return emptySpeed;
|
||||
};
|
||||
|
||||
const float ege::ElementGame::getInvMass() {
|
||||
if (NULL!=m_body) {
|
||||
if (nullptr!=m_body) {
|
||||
return m_body->getInvMass();
|
||||
}
|
||||
return 0.0000000001f;
|
||||
};
|
||||
|
||||
static void drawSphere(ewol::resource::Colored3DObject* _draw,
|
||||
static void drawSphere(const ewol::object::Shared<ewol::resource::Colored3DObject>& _draw,
|
||||
btScalar _radius,
|
||||
int _lats,
|
||||
int _longs,
|
||||
@ -230,8 +229,8 @@ const float lifeHeight = 0.3f;
|
||||
const float lifeWidth = 2.0f;
|
||||
const float lifeYPos = 1.7f;
|
||||
|
||||
void ege::ElementGame::drawLife(ewol::resource::Colored3DObject* _draw, const ege::Camera& _camera) {
|
||||
if (NULL == _draw) {
|
||||
void ege::ElementGame::drawLife(const ewol::object::Shared<ewol::resource::Colored3DObject>& _draw, const ege::Camera& _camera) {
|
||||
if (nullptr == _draw) {
|
||||
return;
|
||||
}
|
||||
float ratio = getLifeRatio();
|
||||
@ -268,11 +267,11 @@ void ege::ElementGame::drawLife(ewol::resource::Colored3DObject* _draw, const eg
|
||||
}
|
||||
|
||||
static void drawShape(const btCollisionShape* _shape,
|
||||
ewol::resource::Colored3DObject* _draw,
|
||||
const ewol::object::Shared<ewol::resource::Colored3DObject>& _draw,
|
||||
mat4 _transformationMatrix,
|
||||
std::vector<vec3> _tmpVertices) {
|
||||
if( NULL == _draw
|
||||
|| NULL == _shape) {
|
||||
if( nullptr == _draw
|
||||
|| nullptr == _shape) {
|
||||
return;
|
||||
}
|
||||
etk::Color<float> tmpColor(1.0, 0.0, 0.0, 0.3);
|
||||
@ -338,7 +337,7 @@ static void drawShape(const btCollisionShape* _shape,
|
||||
if (_shape->isConvex()) {
|
||||
EGE_DEBUG(" shape->isConvex()");
|
||||
const btConvexPolyhedron* poly = _shape->isPolyhedral() ? ((btPolyhedralConvexShape*) _shape)->getConvexPolyhedron() : 0;
|
||||
if (NULL!=poly) {
|
||||
if (nullptr!=poly) {
|
||||
EGE_DEBUG(" have poly");
|
||||
/*
|
||||
glBegin(GL_TRIANGLES);
|
||||
@ -435,7 +434,7 @@ static void drawShape(const btCollisionShape* _shape,
|
||||
}
|
||||
}
|
||||
|
||||
void ege::ElementGame::drawDebug(ewol::resource::Colored3DObject* _draw, const ege::Camera& _camera) {
|
||||
void ege::ElementGame::drawDebug(const ewol::object::Shared<ewol::resource::Colored3DObject>& _draw, const ege::Camera& _camera) {
|
||||
m_debugText.clear();
|
||||
m_debugText.setColor(0x00FF00FF);
|
||||
m_debugText.setPos(vec3(-20,32,0));
|
||||
@ -465,8 +464,8 @@ void ege::ElementGame::draw(int32_t _pass) {
|
||||
return;
|
||||
}
|
||||
if (_pass == 0) {
|
||||
if( NULL != m_body
|
||||
&& NULL != m_mesh
|
||||
if( nullptr != m_body
|
||||
&& nullptr != m_mesh
|
||||
&& m_body->getMotionState() ) {
|
||||
btScalar mmm[16];
|
||||
btDefaultMotionState* myMotionState = (btDefaultMotionState*)m_body->getMotionState();
|
||||
@ -483,10 +482,10 @@ void ege::ElementGame::dynamicEnable() {
|
||||
if (true == m_elementInPhysicsSystem) {
|
||||
return;
|
||||
}
|
||||
if(NULL!=m_body) {
|
||||
if(nullptr!=m_body) {
|
||||
m_env.getDynamicWorld()->addRigidBody(m_body);
|
||||
}
|
||||
if(NULL!=m_IA) {
|
||||
if(nullptr!=m_IA) {
|
||||
m_env.getDynamicWorld()->addAction(m_IA);
|
||||
}
|
||||
m_elementInPhysicsSystem = true;
|
||||
@ -496,10 +495,10 @@ void ege::ElementGame::dynamicDisable() {
|
||||
if (false == m_elementInPhysicsSystem) {
|
||||
return;
|
||||
}
|
||||
if(NULL!=m_IA) {
|
||||
if(nullptr!=m_IA) {
|
||||
m_env.getDynamicWorld()->removeAction(m_IA);
|
||||
}
|
||||
if(NULL!=m_body) {
|
||||
if(nullptr!=m_body) {
|
||||
// Unlink element from the engine
|
||||
m_env.getDynamicWorld()->removeRigidBody(m_body);
|
||||
m_env.getDynamicWorld()->removeCollisionObject(m_body);
|
||||
@ -508,12 +507,12 @@ void ege::ElementGame::dynamicDisable() {
|
||||
}
|
||||
|
||||
void ege::ElementGame::iaEnable() {
|
||||
if (NULL != m_IA) {
|
||||
if (nullptr != m_IA) {
|
||||
// IA already started ...
|
||||
return;
|
||||
}
|
||||
m_IA = new localIA(*this);
|
||||
if (NULL == m_IA) {
|
||||
if (nullptr == m_IA) {
|
||||
EGE_ERROR("Can not start the IA == > allocation error");
|
||||
return;
|
||||
}
|
||||
@ -523,7 +522,7 @@ void ege::ElementGame::iaEnable() {
|
||||
}
|
||||
|
||||
void ege::ElementGame::iaDisable() {
|
||||
if (NULL == m_IA) {
|
||||
if (nullptr == m_IA) {
|
||||
// IA already stopped ...
|
||||
return;
|
||||
}
|
||||
@ -532,7 +531,7 @@ void ege::ElementGame::iaDisable() {
|
||||
}
|
||||
// remove IA :
|
||||
delete(m_IA);
|
||||
m_IA = NULL;
|
||||
m_IA = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,7 +75,7 @@ namespace ege {
|
||||
return m_uID;
|
||||
};
|
||||
private:
|
||||
ege::resource::Mesh* m_mesh; //!< Mesh of the Element (can be NULL)
|
||||
ewol::object::Shared<ege::resource::Mesh> m_mesh; //!< Mesh of the Element (can be nullptr)
|
||||
btCollisionShape* m_shape; //!< shape of the element (set a copy here to have the debug display of it)
|
||||
public:
|
||||
/**
|
||||
@ -87,11 +87,11 @@ namespace ege {
|
||||
bool loadMesh(const std::string& _meshFileName);
|
||||
/**
|
||||
* @brief set the the Mesh properties.
|
||||
* @param[in] _mesh The mesh pointer. (NULL to force the mesh remove ...)
|
||||
* @param[in] _mesh The mesh pointer. (nullptr to force the mesh remove ...)
|
||||
* @note : this remove the shape and the mesh properties.
|
||||
* @return true if no error occured
|
||||
*/
|
||||
bool setMesh(ege::resource::Mesh* _mesh);
|
||||
bool setMesh(const ewol::object::Shared<ege::resource::Mesh>& _mesh);
|
||||
/**
|
||||
* @brief set the shape properties.
|
||||
* @param[in] _shape The shape pointer.
|
||||
@ -103,7 +103,7 @@ namespace ege {
|
||||
* @brief get a pointer on the Mesh file.
|
||||
* @return the mesh pointer.
|
||||
*/
|
||||
inline ege::resource::Mesh* getMesh() {
|
||||
inline const ewol::object::Shared<ege::resource::Mesh>& getMesh() {
|
||||
return m_mesh;
|
||||
};
|
||||
/**
|
||||
@ -186,7 +186,7 @@ namespace ege {
|
||||
/**
|
||||
* @brief draw the current life of the element
|
||||
*/
|
||||
virtual void drawLife(ewol::resource::Colored3DObject* _draw, const ege::Camera& _camera);
|
||||
virtual void drawLife(const ewol::object::Shared<ewol::resource::Colored3DObject>& _draw, const ege::Camera& _camera);
|
||||
|
||||
protected:
|
||||
// For debug only ...
|
||||
@ -196,7 +196,7 @@ namespace ege {
|
||||
* @brief Debug display of the current element
|
||||
* @param[in,out] draw Basic system to draw the debug shape and informations
|
||||
*/
|
||||
virtual void drawDebug(ewol::resource::Colored3DObject* _draw, const ege::Camera& _camera);
|
||||
virtual void drawDebug(const ewol::object::Shared<ewol::resource::Colored3DObject>& _draw, const ege::Camera& _camera);
|
||||
|
||||
/**
|
||||
* @brief get the theoric position. Sometimes, the element has move due to an explosion or something else, then its real position in not the one that woult it be at the end ...
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
|
||||
ege::ElementGame* ege::Environement::getElementNearest(ege::ElementGame* _sourceRequest, float& _distance) {
|
||||
if (NULL == _sourceRequest) {
|
||||
return NULL;
|
||||
if (nullptr == _sourceRequest) {
|
||||
return nullptr;
|
||||
}
|
||||
vec3 sourcePosition = _sourceRequest->getPosition();
|
||||
ege::ElementGame* result = NULL;
|
||||
ege::ElementGame* result = nullptr;
|
||||
for (size_t iii=0; iii<m_listElementGame.size() ; iii++) {
|
||||
// chack NULL pointer
|
||||
if (NULL == m_listElementGame[iii]) {
|
||||
// chack nullptr pointer
|
||||
if (nullptr == m_listElementGame[iii]) {
|
||||
continue;
|
||||
}
|
||||
if (m_listElementGame[iii]->getGroup() <= 0) {
|
||||
@ -52,11 +52,11 @@ void ege::Environement::getElementNearest(const vec3& _sourcePosition,
|
||||
_resultList.clear();
|
||||
ege::Environement::ResultNearestElement result;
|
||||
result.dist = 99999999999.0f;
|
||||
result.element = NULL;
|
||||
result.element = nullptr;
|
||||
for (size_t iii=0; iii<m_listElementGame.size() ; iii++) {
|
||||
// chack NULL pointer
|
||||
// chack nullptr pointer
|
||||
result.element = m_listElementGame[iii];
|
||||
if (NULL == result.element) {
|
||||
if (nullptr == result.element) {
|
||||
continue;
|
||||
}
|
||||
// check distance ...
|
||||
@ -78,11 +78,11 @@ void ege::Environement::getElementNearestFixed(const vec3& _sourcePosition,
|
||||
_resultList.clear();
|
||||
ege::Environement::ResultNearestElement result;
|
||||
result.dist = 99999999999.0f;
|
||||
result.element = NULL;
|
||||
result.element = nullptr;
|
||||
for (size_t iii=0; iii<m_listElementGame.size() ; iii++) {
|
||||
// chack NULL pointer
|
||||
// chack nullptr pointer
|
||||
result.element = m_listElementGame[iii];
|
||||
if (NULL == result.element) {
|
||||
if (nullptr == result.element) {
|
||||
continue;
|
||||
}
|
||||
if (false == result.element->isFixed()) {
|
||||
@ -116,7 +116,7 @@ static etk::Hash<ege::createElement_tf>& getHachTableCreating() {
|
||||
}
|
||||
|
||||
void ege::Environement::addCreator(const std::string& _type, ege::createElement_tf _creator) {
|
||||
if (NULL == _creator) {
|
||||
if (nullptr == _creator) {
|
||||
EGE_ERROR("Try to add an empty CREATOR ...");
|
||||
return;
|
||||
}
|
||||
@ -128,23 +128,23 @@ void ege::Environement::addCreator(const std::string& _type, ege::createElement_
|
||||
ege::ElementGame* ege::Environement::createElement(const std::string& _type, bool _autoAddElement, enum ege::property _property, void* _value) {
|
||||
if (false == getHachTableCreating().exist(_type)) {
|
||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
ege::createElement_tf creatorPointer = getHachTableCreating()[_type];
|
||||
if (NULL == creatorPointer) {
|
||||
EGE_ERROR("NULL pointer creator == > internal error... '" << _type << "'");
|
||||
return NULL;
|
||||
if (nullptr == creatorPointer) {
|
||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ege::ElementGame* tmpElement = creatorPointer(*this);
|
||||
if (NULL == tmpElement) {
|
||||
if (nullptr == tmpElement) {
|
||||
EGE_ERROR("allocation error '" << _type << "'");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (false == tmpElement->init(_property, _value)) {
|
||||
EGE_ERROR("Init error ... '" << _type << "'");
|
||||
// remove created element ...
|
||||
delete(tmpElement);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (_autoAddElement == true) {
|
||||
addElementGame(tmpElement);
|
||||
@ -167,11 +167,11 @@ ege::ElementGame* ege::Environement::createElement(const std::string& _type, exm
|
||||
|
||||
void ege::Environement::addElementGame(ege::ElementGame* _newElement) {
|
||||
// prevent memory allocation and un allocation ...
|
||||
if (NULL == _newElement) {
|
||||
if (nullptr == _newElement) {
|
||||
return;
|
||||
}
|
||||
for (size_t iii=0; iii<m_listElementGame.size() ; iii++) {
|
||||
if (NULL == m_listElementGame[iii]) {
|
||||
if (nullptr == m_listElementGame[iii]) {
|
||||
m_listElementGame[iii] = _newElement;
|
||||
m_listElementGame[iii]->dynamicEnable();
|
||||
return;
|
||||
@ -182,12 +182,12 @@ void ege::Environement::addElementGame(ege::ElementGame* _newElement) {
|
||||
}
|
||||
|
||||
void ege::Environement::rmElementGame(ege::ElementGame* _removeElement) {
|
||||
if (NULL == _removeElement) {
|
||||
if (nullptr == _removeElement) {
|
||||
return;
|
||||
}
|
||||
// inform the element that an element has been removed == > this permit to keep pointer on elements ...
|
||||
for (size_t iii=0; iii<m_listElementGame.size() ; iii++) {
|
||||
if (NULL != m_listElementGame[iii]) {
|
||||
if (nullptr != m_listElementGame[iii]) {
|
||||
m_listElementGame[iii]->elementIsRemoved(_removeElement);
|
||||
}
|
||||
}
|
||||
@ -198,7 +198,7 @@ void ege::Environement::rmElementGame(ege::ElementGame* _removeElement) {
|
||||
m_listElementGame[iii]->dynamicDisable();
|
||||
m_listElementGame[iii]->unInit();
|
||||
delete(m_listElementGame[iii]);
|
||||
m_listElementGame[iii] = NULL;
|
||||
m_listElementGame[iii] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -212,11 +212,11 @@ void ege::Environement::getOrderedElementForDisplay(std::vector<ege::Environemen
|
||||
// basic element result
|
||||
ege::Environement::ResultNearestElement result;
|
||||
result.dist = 99999999999.0f;
|
||||
result.element = NULL;
|
||||
result.element = nullptr;
|
||||
// for all element in the game we chek if it is needed to display it ...
|
||||
for (size_t iii=0; iii<m_listElementGame.size() ; iii++) {
|
||||
// chack NULL pointer
|
||||
if (NULL == m_listElementGame[iii]) {
|
||||
// chack nullptr pointer
|
||||
if (nullptr == m_listElementGame[iii]) {
|
||||
// no pointer null are set in the output list ...
|
||||
continue;
|
||||
}
|
||||
@ -254,7 +254,7 @@ void ege::Environement::getOrderedElementForDisplay(std::vector<ege::Environemen
|
||||
void ege::Environement::generateInteraction(ege::ElementInteraction& _event) {
|
||||
// inform the element that an element has been removed == > this permit to keep pointer on elements ...
|
||||
for (size_t iii=0; iii<m_listElementGame.size() ; iii++) {
|
||||
if (NULL == m_listElementGame[iii]) {
|
||||
if (nullptr == m_listElementGame[iii]) {
|
||||
continue;
|
||||
}
|
||||
_event.applyEvent(*m_listElementGame[iii]);
|
||||
@ -271,7 +271,7 @@ void ege::Environement::generateInteraction(ege::ElementInteraction& _event) {
|
||||
}
|
||||
|
||||
ege::Environement::Environement() :
|
||||
m_dynamicsWorld(NULL),
|
||||
m_dynamicsWorld(nullptr),
|
||||
m_particuleEngine(*this) {
|
||||
// nothing to do ...
|
||||
}
|
||||
|
@ -91,10 +91,10 @@ namespace ege {
|
||||
* @param[in] _type Type of the element that might be created.
|
||||
* @param[in] _description String that describe the content of the element properties.
|
||||
* @param[in] _autoAddElement this permit to add the element if it is created == > no more action ...
|
||||
* @return NULL if an error occured OR the pointer on the element and it is already added on the system.
|
||||
* @return nullptr if an error occured OR the pointer on the element and it is already added on the system.
|
||||
* @note Pointer is return in case of setting properties on it...
|
||||
*/
|
||||
ege::ElementGame* createElement(const std::string& _type, bool _autoAddElement=true, enum ege::property _property=ege::typeNone, void* _value=NULL);
|
||||
ege::ElementGame* createElement(const std::string& _type, bool _autoAddElement=true, enum ege::property _property=ege::typeNone, void* _value=nullptr);
|
||||
ege::ElementGame* createElement(const std::string& _type, std::string& _description, bool _autoAddElement=true);
|
||||
ege::ElementGame* createElement(const std::string& _type, ejson::Value* _value, bool _autoAddElement=true);
|
||||
ege::ElementGame* createElement(const std::string& _type, exml::Node* _node, bool _autoAddElement=true);
|
||||
@ -129,7 +129,7 @@ namespace ege {
|
||||
* @brief get the nearest Element
|
||||
* @param[in] _sourceRequest Pointer on the element that request this.
|
||||
* @param[in] _distance Maximum distance search == > return the element distance
|
||||
* @return Pointer on the neares element OR NULL
|
||||
* @return Pointer on the neares element OR nullptr
|
||||
*/
|
||||
ege::ElementGame* getElementNearest(ege::ElementGame* _sourceRequest, float& _distance);
|
||||
|
||||
|
@ -27,8 +27,8 @@ ege::Light::~Light() {
|
||||
|
||||
}
|
||||
|
||||
void ege::Light::link(ewol::resource::Program* _prog, const std::string& _baseName) {
|
||||
if (NULL == _prog) {
|
||||
void ege::Light::link(const ewol::object::Shared<ewol::resource::Program>& _prog, const std::string& _baseName) {
|
||||
if (nullptr == _prog) {
|
||||
return;
|
||||
}
|
||||
m_GL_direction = _prog->getUniform(_baseName+".direction");
|
||||
@ -38,7 +38,7 @@ void ege::Light::link(ewol::resource::Program* _prog, const std::string& _baseNa
|
||||
m_GL_specularColor = _prog->getUniform(_baseName+".specularColor");
|
||||
}
|
||||
|
||||
void ege::Light::draw(ewol::resource::Program* _prog) {
|
||||
void ege::Light::draw(const ewol::object::Shared<ewol::resource::Program>& _prog) {
|
||||
_prog->uniform3(m_GL_direction, m_direction);
|
||||
_prog->uniform3(m_GL_halfplane, m_halfplane);
|
||||
_prog->uniform4(m_GL_ambientColor, m_ambientColor);
|
||||
|
@ -33,8 +33,8 @@ namespace ege {
|
||||
public:
|
||||
Light();
|
||||
~Light();
|
||||
void link(ewol::resource::Program* _prog, const std::string& _baseName);
|
||||
void draw(ewol::resource::Program* _prog);
|
||||
void link(const ewol::object::Shared<ewol::resource::Program>& _prog, const std::string& _baseName);
|
||||
void draw(const ewol::object::Shared<ewol::resource::Program>& _prog);
|
||||
void setDirection(const vec3& val) {
|
||||
m_direction = val;
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ ege::MaterialGlId::MaterialGlId() :
|
||||
}
|
||||
|
||||
|
||||
void ege::MaterialGlId::link(ewol::resource::Program* _prog, const std::string& _baseName) {
|
||||
if (NULL == _prog) {
|
||||
void ege::MaterialGlId::link(const ewol::object::Shared<ewol::resource::Program>& _prog, const std::string& _baseName) {
|
||||
if (nullptr == _prog) {
|
||||
return;
|
||||
}
|
||||
m_GL_ambientFactor = _prog->getUniform(_baseName+".ambientFactor");
|
||||
@ -36,21 +36,19 @@ ege::Material::Material() :
|
||||
m_diffuseFactor(0,0,0,1),
|
||||
m_specularFactor(0,0,0,1),
|
||||
m_shininess(1),
|
||||
m_texture0(NULL) {
|
||||
m_texture0(nullptr) {
|
||||
// nothing to do else ...
|
||||
}
|
||||
ege::Material::~Material() {
|
||||
if(NULL!=m_texture0) {
|
||||
ewol::resource::TextureFile::release(m_texture0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ege::Material::draw(ewol::resource::Program* _prog, const MaterialGlId& _glID) {
|
||||
void ege::Material::draw(const ewol::object::Shared<ewol::resource::Program>& _prog, const MaterialGlId& _glID) {
|
||||
_prog->uniform4(_glID.m_GL_ambientFactor, m_ambientFactor);
|
||||
_prog->uniform4(_glID.m_GL_diffuseFactor, m_diffuseFactor);
|
||||
_prog->uniform4(_glID.m_GL_specularFactor, m_specularFactor);
|
||||
_prog->uniform1f(_glID.m_GL_shininess, m_shininess);
|
||||
if (NULL != m_texture0) {
|
||||
if (nullptr != m_texture0) {
|
||||
_prog->setTexture0(_glID.m_GL_texture0, m_texture0->getId());
|
||||
}
|
||||
}
|
||||
@ -58,18 +56,14 @@ void ege::Material::draw(ewol::resource::Program* _prog, const MaterialGlId& _gl
|
||||
void ege::Material::setTexture0(const std::string& _filename) {
|
||||
ivec2 tmpSize(256, 256);
|
||||
// prevent overloard error :
|
||||
ewol::resource::TextureFile* tmpCopy = m_texture0;
|
||||
ewol::object::Shared<ewol::resource::TextureFile> tmpCopy = m_texture0;
|
||||
m_texture0 = ewol::resource::TextureFile::keep(_filename, tmpSize);
|
||||
if (NULL == m_texture0 ) {
|
||||
if (m_texture0 == nullptr) {
|
||||
EGE_ERROR("Can not load specific texture : " << _filename);
|
||||
// retreave previous texture:
|
||||
m_texture0 = tmpCopy;
|
||||
return;
|
||||
}
|
||||
if (NULL != tmpCopy) {
|
||||
// really release previous texture. In case of same texture loading, then we did not have reload it .. just increase and decrease index...
|
||||
ewol::resource::TextureFile::release(tmpCopy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace ege {
|
||||
int32_t m_GL_shininess;
|
||||
int32_t m_GL_texture0;
|
||||
MaterialGlId();
|
||||
void link(ewol::resource::Program* _prog, const std::string& _baseName);
|
||||
void link(const ewol::object::Shared<ewol::resource::Program>& _prog, const std::string& _baseName);
|
||||
};
|
||||
class Material {
|
||||
private:
|
||||
@ -37,13 +37,13 @@ namespace ege {
|
||||
vec4 m_diffuseFactor;
|
||||
vec4 m_specularFactor;
|
||||
float m_shininess;
|
||||
ewol::resource::TextureFile* m_texture0;
|
||||
ewol::object::Shared<ewol::resource::TextureFile> m_texture0;
|
||||
public:
|
||||
std::vector<uint32_t> m_listIndexFaces;
|
||||
public:
|
||||
Material();
|
||||
~Material();
|
||||
void draw(ewol::resource::Program* _prog, const ege::MaterialGlId& _glID);
|
||||
void draw(const ewol::object::Shared<ewol::resource::Program>& _prog, const ege::MaterialGlId& _glID);
|
||||
void setAmbientFactor(const vec4& _val) {
|
||||
m_ambientFactor = _val;
|
||||
}
|
||||
@ -59,21 +59,21 @@ namespace ege {
|
||||
void setTexture0(const std::string& _filename);
|
||||
|
||||
void setImageSize(const ivec2& _newSize) {
|
||||
if (m_texture0 == NULL){
|
||||
if (m_texture0 == nullptr){
|
||||
return;
|
||||
}
|
||||
m_texture0->setImageSize(_newSize);
|
||||
};
|
||||
// get the reference on this image to draw nomething on it ...
|
||||
egami::Image* get() {
|
||||
if (m_texture0 == NULL){
|
||||
return NULL;
|
||||
if (m_texture0 == nullptr){
|
||||
return nullptr;
|
||||
}
|
||||
return &m_texture0->get();
|
||||
};
|
||||
// flush the data to send it at the openGl system
|
||||
void flush() {
|
||||
if (m_texture0 == NULL){
|
||||
if (m_texture0 == nullptr){
|
||||
return;
|
||||
}
|
||||
m_texture0->flush();
|
||||
|
@ -32,9 +32,9 @@ namespace ege {
|
||||
/**
|
||||
* @brief Constructor.
|
||||
* @param[in] _particuleEngine reference on the particule engine ...
|
||||
* @param[in] _particuleType Type of the particule (set NULL if you did not want to use the respowner ...)
|
||||
* @param[in] _particuleType Type of the particule (set nullptr if you did not want to use the respowner ...)
|
||||
*/
|
||||
Particule(ege::ParticuleEngine& _particuleEngine, const char* _particuleType = NULL);
|
||||
Particule(ege::ParticuleEngine& _particuleEngine, const char* _particuleType = nullptr);
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
|
@ -22,12 +22,12 @@ ege::ParticuleEngine::~ParticuleEngine() {
|
||||
}
|
||||
|
||||
void ege::ParticuleEngine::add(Particule* _particule) {
|
||||
if (_particule == NULL) {
|
||||
EGE_ERROR("Try to add particule NULL");
|
||||
if (_particule == nullptr) {
|
||||
EGE_ERROR("Try to add particule nullptr");
|
||||
return;
|
||||
}
|
||||
for (size_t iii=0; iii<m_particuleList.size(); ++iii) {
|
||||
if (m_particuleList[iii] != NULL) {
|
||||
if (m_particuleList[iii] != nullptr) {
|
||||
continue;
|
||||
}
|
||||
m_particuleList[iii] = _particule;
|
||||
@ -38,11 +38,11 @@ void ege::ParticuleEngine::add(Particule* _particule) {
|
||||
}
|
||||
|
||||
void ege::ParticuleEngine::addRemoved(Particule* _particule) {
|
||||
if (_particule == NULL) {
|
||||
if (_particule == nullptr) {
|
||||
return;
|
||||
}
|
||||
for (size_t iii=0; iii<m_particuleRemoved.size(); ++iii) {
|
||||
if (m_particuleRemoved[iii] != NULL) {
|
||||
if (m_particuleRemoved[iii] != nullptr) {
|
||||
continue;
|
||||
}
|
||||
m_particuleRemoved[iii] = _particule;
|
||||
@ -53,22 +53,22 @@ void ege::ParticuleEngine::addRemoved(Particule* _particule) {
|
||||
}
|
||||
|
||||
ege::Particule* ege::ParticuleEngine::respown(const char* _particuleType) {
|
||||
if (_particuleType == NULL) {
|
||||
return NULL;
|
||||
if (_particuleType == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
for (size_t iii=0; iii<m_particuleRemoved.size(); ++iii) {
|
||||
if (m_particuleRemoved[iii] == NULL) {
|
||||
if (m_particuleRemoved[iii] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (m_particuleRemoved[iii]->getParticuleType() == _particuleType) {
|
||||
add(m_particuleRemoved[iii]);
|
||||
ege::Particule* tmpParticule = m_particuleRemoved[iii];
|
||||
m_particuleRemoved[iii]=NULL;
|
||||
m_particuleRemoved[iii]=nullptr;
|
||||
tmpParticule->init();
|
||||
return tmpParticule;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ege::ParticuleEngine::update(float _deltaTime) {
|
||||
@ -76,31 +76,31 @@ void ege::ParticuleEngine::update(float _deltaTime) {
|
||||
_deltaTime = (1.0f/60.0f);
|
||||
}
|
||||
for (size_t iii=0; iii<m_particuleList.size(); ++iii) {
|
||||
if (m_particuleList[iii] == NULL) {
|
||||
if (m_particuleList[iii] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
m_particuleList[iii]->update(_deltaTime);
|
||||
}
|
||||
// check removing elements
|
||||
for (size_t iii=0; iii<m_particuleList.size(); ++iii) {
|
||||
if (m_particuleList[iii] == NULL) {
|
||||
if (m_particuleList[iii] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (m_particuleList[iii]->needRemove()) {
|
||||
m_particuleList[iii]->onEnd();
|
||||
if (m_particuleList[iii]->getParticuleType() == NULL) {
|
||||
if (m_particuleList[iii]->getParticuleType() == nullptr) {
|
||||
// Real remove particule ...
|
||||
delete (m_particuleList[iii]);
|
||||
} else {
|
||||
addRemoved(m_particuleList[iii]);
|
||||
}
|
||||
m_particuleList[iii] = NULL;
|
||||
m_particuleList[iii] = nullptr;
|
||||
}
|
||||
}
|
||||
/*
|
||||
int32_t nbParticule = 0;
|
||||
for (int32_t iii=0; iii<m_particuleList.size(); ++iii) {
|
||||
if (m_particuleList[iii] == NULL) {
|
||||
if (m_particuleList[iii] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
nbParticule++;
|
||||
@ -111,7 +111,7 @@ void ege::ParticuleEngine::update(float _deltaTime) {
|
||||
|
||||
void ege::ParticuleEngine::draw(const ege::Camera& _camera) {
|
||||
for (size_t iii=0; iii<m_particuleList.size(); ++iii) {
|
||||
if (m_particuleList[iii] == NULL) {
|
||||
if (m_particuleList[iii] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
m_particuleList[iii]->draw(_camera);
|
||||
@ -121,20 +121,20 @@ void ege::ParticuleEngine::draw(const ege::Camera& _camera) {
|
||||
void ege::ParticuleEngine::clear() {
|
||||
// clear element not removed
|
||||
for (size_t iii=0; iii<m_particuleList.size(); ++iii) {
|
||||
if (m_particuleList[iii] == NULL) {
|
||||
if (m_particuleList[iii] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
delete m_particuleList[iii];
|
||||
m_particuleList[iii] = NULL;
|
||||
m_particuleList[iii] = nullptr;
|
||||
}
|
||||
m_particuleList.clear();
|
||||
// clear element that are auto-removed
|
||||
for (size_t iii=0; iii<m_particuleRemoved.size(); ++iii) {
|
||||
if (m_particuleRemoved[iii] == NULL) {
|
||||
if (m_particuleRemoved[iii] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
delete m_particuleRemoved[iii];
|
||||
m_particuleRemoved[iii] = NULL;
|
||||
m_particuleRemoved[iii] = nullptr;
|
||||
}
|
||||
m_particuleRemoved.clear();
|
||||
}
|
||||
|
@ -59,9 +59,9 @@ namespace ege {
|
||||
/**
|
||||
* @brief get a particue with his type, we get particule that has been already removed, otherwise, you will create new
|
||||
* @param[in] _particuleType Particule type, this chek only the pointer not the data.
|
||||
* @return NULL, the particule has not been removed from the created pool
|
||||
* @return nullptr, the particule has not been removed from the created pool
|
||||
* @return The pointer on the requested element (an init has been done).
|
||||
* @note If you did not want to use respawn set type at NULL.
|
||||
* @note If you did not want to use respawn set type at nullptr.
|
||||
*/
|
||||
Particule* respown(const char* _particuleType);
|
||||
|
||||
|
@ -19,7 +19,7 @@ bool ege::PhysicsConvexHull::parse(const char* _line) {
|
||||
char* base = (char*)(&_line[8]);
|
||||
char* tmp= strchr(base, '|');
|
||||
vec3 pos(0,0,0);
|
||||
while (tmp != NULL) {
|
||||
while (tmp != nullptr) {
|
||||
*tmp = '\0';
|
||||
sscanf(base, "%f %f %f", &pos.m_floats[0], &pos.m_floats[1], &pos.m_floats[2] );
|
||||
m_points.push_back(pos);
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
|
||||
ege::PhysicsShape* ege::PhysicsShape::create(const std::string& _name) {
|
||||
ege::PhysicsShape* tmpp = NULL;
|
||||
ege::PhysicsShape* tmpp = nullptr;
|
||||
std::string name = std::tolower(_name);
|
||||
if (name == "box") {
|
||||
tmpp = new ege::PhysicsBox();
|
||||
@ -32,9 +32,9 @@ ege::PhysicsShape* ege::PhysicsShape::create(const std::string& _name) {
|
||||
tmpp = new ege::PhysicsConvexHull();
|
||||
} else {
|
||||
EGE_ERROR("Create an unknow element : '" << _name << "' availlable : [BOX,SPHERE,CONE,CYLINDER,CAPSULE,CONVEXHULL]");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (tmpp == NULL) {
|
||||
if (tmpp == nullptr) {
|
||||
EGE_ERROR("Allocation error for physical element : '" << _name << "'");
|
||||
}
|
||||
return tmpp;
|
||||
|
@ -89,45 +89,45 @@ namespace ege {
|
||||
};
|
||||
|
||||
virtual const ege::PhysicsBox* toBox() const {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
};
|
||||
virtual ege::PhysicsBox* toBox() {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
virtual const ege::PhysicsCylinder* toCylinder() const {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
};
|
||||
virtual ege::PhysicsCylinder* toCylinder() {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
virtual const ege::PhysicsCapsule* toCapsule() const {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
};
|
||||
virtual ege::PhysicsCapsule* toCapsule() {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
virtual const ege::PhysicsCone* toCone() const {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
};
|
||||
virtual ege::PhysicsCone* toCone() {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
virtual const ege::PhysicsConvexHull* toConvexHull() const {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
};
|
||||
virtual ege::PhysicsConvexHull* toConvexHull() {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
virtual const ege::PhysicsSphere* toSphere() const {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
};
|
||||
virtual ege::PhysicsSphere* toSphere() {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -18,8 +18,8 @@ ege::resource::Mesh::Mesh(const std::string& _fileName, const std::string& _shad
|
||||
ewol::Resource(_fileName),
|
||||
m_normalMode(normalModeNone),
|
||||
m_checkNormal(false),
|
||||
m_pointerShape(NULL),
|
||||
m_functionFreeShape(NULL) {
|
||||
m_pointerShape(nullptr),
|
||||
m_functionFreeShape(nullptr) {
|
||||
addObjectType("ewol::resource::Mesh");
|
||||
EGE_VERBOSE("Load a new mesh : '" << _fileName << "'");
|
||||
// get the shader resource :
|
||||
@ -33,7 +33,7 @@ ege::resource::Mesh::Mesh(const std::string& _fileName, const std::string& _shad
|
||||
|
||||
//EGE_DEBUG(m_name << " " << m_light);
|
||||
m_GLprogram = ewol::resource::Program::keep(_shaderName);
|
||||
if (NULL != m_GLprogram ) {
|
||||
if (m_GLprogram != nullptr) {
|
||||
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
|
||||
m_GLtexture = m_GLprogram->getAttribute("EW_texture2d");
|
||||
m_GLNormal = m_GLprogram->getAttribute("EW_normal");
|
||||
@ -67,11 +67,9 @@ ege::resource::Mesh::Mesh(const std::string& _fileName, const std::string& _shad
|
||||
|
||||
ege::resource::Mesh::~Mesh() {
|
||||
// remove dynamics dependencies :
|
||||
ewol::resource::Program::release(m_GLprogram);
|
||||
ewol::resource::VirtualBufferObject::release(m_verticesVBO);
|
||||
if (m_functionFreeShape!=NULL) {
|
||||
if (m_functionFreeShape!=nullptr) {
|
||||
m_functionFreeShape(m_pointerShape);
|
||||
m_pointerShape = NULL;
|
||||
m_pointerShape = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +78,7 @@ ege::resource::Mesh::~Mesh() {
|
||||
void ege::resource::Mesh::draw(mat4& _positionMatrix,
|
||||
bool _enableDepthTest,
|
||||
bool _enableDepthUpdate) {
|
||||
if (m_GLprogram == NULL) {
|
||||
if (m_GLprogram == nullptr) {
|
||||
EGE_ERROR("No shader ...");
|
||||
return;
|
||||
}
|
||||
@ -394,7 +392,7 @@ bool ege::resource::Mesh::loadOBJ(const std::string& _fileName) {
|
||||
char inputDataLine[2048];
|
||||
|
||||
int32_t lineID = 0;
|
||||
while (NULL != fileName.fileGets(inputDataLine, 2048) )
|
||||
while (nullptr != fileName.fileGets(inputDataLine, 2048) )
|
||||
{
|
||||
lineID++;
|
||||
if (inputDataLine[0] == 'v') {
|
||||
@ -552,7 +550,7 @@ char* loadNextData(char* _elementLine,
|
||||
/*
|
||||
if (m_zipReadingOffset >= m_zipContent->size()) {
|
||||
element[0] = '\0';
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
*/
|
||||
char current = _file.fileGet();
|
||||
@ -585,12 +583,12 @@ char* loadNextData(char* _elementLine,
|
||||
current = _file.fileGet();
|
||||
}
|
||||
if (outSize == 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
// send last line
|
||||
return _elementLine;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void removeEndLine(char* _val) {
|
||||
@ -659,14 +657,14 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
int32_t meshFaceMaterialID = -1;
|
||||
// material global param :
|
||||
std::string materialName = "";
|
||||
ege::Material* material = NULL;
|
||||
ege::Material* material = nullptr;
|
||||
// physical shape:
|
||||
ege::PhysicsShape* physics = NULL;
|
||||
ege::PhysicsShape* physics = nullptr;
|
||||
while(1) {
|
||||
int32_t level = countIndent(fileName);
|
||||
if (level == 0) {
|
||||
// new section ...
|
||||
if (NULL == loadNextData(inputDataLine, 2048, fileName)) {
|
||||
if (nullptr == loadNextData(inputDataLine, 2048, fileName)) {
|
||||
// reach end of file ...
|
||||
break;
|
||||
}
|
||||
@ -683,7 +681,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
if (currentMode >= EMFModuleMesh && currentMode <= EMFModuleMesh_END) {
|
||||
if (level == 1) {
|
||||
//Find mesh name ...
|
||||
if (NULL == loadNextData(inputDataLine, 2048, fileName, true)) {
|
||||
if (nullptr == loadNextData(inputDataLine, 2048, fileName, true)) {
|
||||
// reach end of file ...
|
||||
break;
|
||||
}
|
||||
@ -695,7 +693,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
}
|
||||
if (level == 2) {
|
||||
// In the mesh level 2 the line size must not exced 2048
|
||||
if (NULL == loadNextData(inputDataLine, 2048, fileName, true)) {
|
||||
if (nullptr == loadNextData(inputDataLine, 2048, fileName, true)) {
|
||||
// reach end of file ...
|
||||
break;
|
||||
}
|
||||
@ -732,7 +730,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
break;
|
||||
case EMFModuleMeshVertex: {
|
||||
vec3 vertex(0,0,0);
|
||||
while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
|
||||
while (nullptr != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
|
||||
if (inputDataLine[0] == '\0') {
|
||||
break;
|
||||
}
|
||||
@ -749,7 +747,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
}
|
||||
case EMFModuleMeshUVMapping: {
|
||||
vec2 uvMap(0,0);
|
||||
while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
|
||||
while (nullptr != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
|
||||
if (inputDataLine[0] == '\0') {
|
||||
break;
|
||||
}
|
||||
@ -768,7 +766,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
m_normalMode = normalModeVertex;
|
||||
vec3 normal(0,0,0);
|
||||
// find the vertex Normal list.
|
||||
while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
|
||||
while (nullptr != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
|
||||
if (inputDataLine[0] == '\0') {
|
||||
break;
|
||||
}
|
||||
@ -787,7 +785,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
m_normalMode = normalModeFace;
|
||||
vec3 normal(0,0,0);
|
||||
// find the face Normal list.
|
||||
while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
|
||||
while (nullptr != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
|
||||
if (inputDataLine[0] == '\0') {
|
||||
break;
|
||||
}
|
||||
@ -806,7 +804,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
case EMFModuleMeshFaceMaterial:
|
||||
if (level == 3) {
|
||||
//Find mesh name ...
|
||||
if (NULL == loadNextData(inputDataLine, 2048, fileName, true)) {
|
||||
if (nullptr == loadNextData(inputDataLine, 2048, fileName, true)) {
|
||||
// reach end of file ...
|
||||
break;
|
||||
}
|
||||
@ -818,7 +816,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
meshFaceMaterialID = m_listFaces.getId(inputDataLine);
|
||||
EGE_VERBOSE(" " << inputDataLine);
|
||||
} else if (currentMode == EMFModuleMeshFaceMaterial) {
|
||||
while (NULL != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
|
||||
while (nullptr != loadNextData(inputDataLine, 2048, fileName, true, true) ) {
|
||||
if (inputDataLine[0] == '\0') {
|
||||
// end of line
|
||||
break;
|
||||
@ -863,14 +861,14 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
break;
|
||||
case EMFModuleMeshPhysics:
|
||||
case EMFModuleMeshPhysicsNamed:
|
||||
if (NULL == loadNextData(inputDataLine, 2048, fileName, true, false, false)) {
|
||||
if (nullptr == loadNextData(inputDataLine, 2048, fileName, true, false, false)) {
|
||||
// reach end of file ...
|
||||
break;
|
||||
}
|
||||
removeEndLine(inputDataLine);
|
||||
if (level == 3) {
|
||||
physics = ege::PhysicsShape::create(inputDataLine);
|
||||
if (physics == NULL) {
|
||||
if (physics == nullptr) {
|
||||
EGE_ERROR("Allocation error when creating physical shape ...");
|
||||
continue;
|
||||
}
|
||||
@ -878,7 +876,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
EGE_VERBOSE(" " << m_physics.size() << " " << inputDataLine);
|
||||
currentMode = EMFModuleMeshPhysicsNamed;
|
||||
} else if (currentMode == EMFModuleMeshPhysicsNamed) {
|
||||
if (physics == NULL) {
|
||||
if (physics == nullptr) {
|
||||
EGE_ERROR("Can not parse :'" << inputDataLine << "' in physical shape ...");
|
||||
continue;
|
||||
}
|
||||
@ -891,7 +889,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
continue;
|
||||
} else if (currentMode >= EMFModuleMaterial && currentMode <= EMFModuleMaterial_END) {
|
||||
// all material element is stored on 1 line (size < 2048)
|
||||
if (NULL == loadNextData(inputDataLine, 2048, fileName, true)) {
|
||||
if (nullptr == loadNextData(inputDataLine, 2048, fileName, true)) {
|
||||
// reach end of file ...
|
||||
break;
|
||||
}
|
||||
@ -899,10 +897,10 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
if (level == 1) {
|
||||
// add previous material :
|
||||
if( materialName != ""
|
||||
&& material!=NULL) {
|
||||
&& material!=nullptr) {
|
||||
m_materials.add(materialName, material);
|
||||
materialName = "";
|
||||
material = NULL;
|
||||
material = nullptr;
|
||||
}
|
||||
material = new ege::Material();
|
||||
materialName = inputDataLine;
|
||||
@ -916,7 +914,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
jumpEndLine(fileName);
|
||||
continue;
|
||||
}
|
||||
if (NULL == material) {
|
||||
if (nullptr == material) {
|
||||
EGE_ERROR("material allocation error");
|
||||
jumpEndLine(fileName);
|
||||
continue;
|
||||
@ -980,10 +978,10 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
}
|
||||
// add last material ...
|
||||
if( materialName != ""
|
||||
&& material!=NULL) {
|
||||
&& material!=nullptr) {
|
||||
m_materials.add(materialName, material);
|
||||
materialName = "";
|
||||
material = NULL;
|
||||
material = nullptr;
|
||||
}
|
||||
EGE_VERBOSE("Stop parsing Mesh file");
|
||||
|
||||
@ -993,7 +991,7 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
|
||||
}
|
||||
|
||||
void ege::resource::Mesh::addMaterial(const std::string& _name, ege::Material* _data) {
|
||||
if (NULL == _data) {
|
||||
if (nullptr == _data) {
|
||||
EGE_ERROR(" can not add material with null pointer");
|
||||
return;
|
||||
}
|
||||
@ -1006,33 +1004,24 @@ void ege::resource::Mesh::addMaterial(const std::string& _name, ege::Material* _
|
||||
}
|
||||
|
||||
void ege::resource::Mesh::setShape(void* _shape) {
|
||||
if (m_functionFreeShape!=NULL) {
|
||||
if (m_functionFreeShape!=nullptr) {
|
||||
m_functionFreeShape(m_pointerShape);
|
||||
m_pointerShape = NULL;
|
||||
m_pointerShape = nullptr;
|
||||
}
|
||||
m_pointerShape=_shape;
|
||||
}
|
||||
|
||||
ege::resource::Mesh* ege::resource::Mesh::keep(const std::string& _meshName) {
|
||||
ege::resource::Mesh* object = static_cast<ege::resource::Mesh*>(getManager().localKeep(_meshName));
|
||||
if (NULL != object) {
|
||||
ewol::object::Shared<ege::resource::Mesh> ege::resource::Mesh::keep(const std::string& _meshName) {
|
||||
ewol::object::Shared<ege::resource::Mesh> object = ewol::dynamic_pointer_cast<ege::resource::Mesh>(getManager().localKeep(_meshName));
|
||||
if (object != nullptr) {
|
||||
return object;
|
||||
}
|
||||
EGE_DEBUG("CREATE: Mesh: '" << _meshName << "'");
|
||||
object = new ege::resource::Mesh(_meshName);
|
||||
if (NULL == object) {
|
||||
object = ewol::object::makeShared(new ege::resource::Mesh(_meshName));
|
||||
if (object == nullptr) {
|
||||
EGE_ERROR("allocation error of a resource : ??Mesh??" << _meshName);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
getManager().localAdd(object);
|
||||
return object;
|
||||
}
|
||||
|
||||
void ege::resource::Mesh::release(ege::resource::Mesh*& _object) {
|
||||
if (NULL == _object) {
|
||||
return;
|
||||
}
|
||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
|
||||
getManager().release(object2);
|
||||
_object = NULL;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ namespace ege {
|
||||
enum normalMode m_normalMode; // select the normal mode of display
|
||||
bool m_checkNormal; //!< when enable, this check the normal of the mesh before sending it at the 3d card
|
||||
protected:
|
||||
ewol::resource::Program* m_GLprogram;
|
||||
ewol::object::Shared<ewol::resource::Program> m_GLprogram;
|
||||
int32_t m_GLPosition;
|
||||
int32_t m_GLMatrix;
|
||||
int32_t m_GLMatrixPosition;
|
||||
@ -110,8 +110,8 @@ namespace ege {
|
||||
etk::Hash<ege::Material*> m_materials;
|
||||
std::vector<ege::PhysicsShape*> m_physics; //!< collision shape module ... (independent of bullet lib)
|
||||
protected:
|
||||
ewol::resource::VirtualBufferObject* m_verticesVBO;
|
||||
protected:
|
||||
ewol::object::Shared<ewol::resource::VirtualBufferObject> m_verticesVBO;
|
||||
public:
|
||||
Mesh(const std::string& _fileName, const std::string& _shaderName="DATA:textured3D2.prog");
|
||||
virtual ~Mesh();
|
||||
public:
|
||||
@ -177,14 +177,9 @@ namespace ege {
|
||||
* @brief keep the resource pointer.
|
||||
* @note Never free this pointer by your own...
|
||||
* @param[in] _filename Name of the ewol mesh file.
|
||||
* @return pointer on the resource or NULL if an error occured.
|
||||
* @return pointer on the resource or nullptr if an error occured.
|
||||
*/
|
||||
static ege::resource::Mesh* keep(const std::string& _meshname);
|
||||
/**
|
||||
* @brief release the keeped resources
|
||||
* @param[in,out] reference on the object pointer
|
||||
*/
|
||||
static void release(ege::resource::Mesh*& _object);
|
||||
static ewol::object::Shared<ege::resource::Mesh> keep(const std::string& _meshname);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -13,7 +13,7 @@
|
||||
ege::resource::ParticuleMesh::ParticuleMesh(const std::string& _fileName, const std::string& _shaderName) :
|
||||
ege::resource::Mesh(_fileName, _shaderName)
|
||||
{
|
||||
if (m_GLprogram != NULL) {
|
||||
if (m_GLprogram != nullptr) {
|
||||
m_GLMainColor = m_GLprogram->getUniform("EW_mainColor");
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix,
|
||||
bool _enableDepthTest,
|
||||
bool _enableDepthUpdate)
|
||||
{
|
||||
if (m_GLprogram == NULL) {
|
||||
if (m_GLprogram == nullptr) {
|
||||
EGE_ERROR("No shader ...");
|
||||
return;
|
||||
}
|
||||
@ -126,27 +126,18 @@ void ege::resource::ParticuleMesh::draw(mat4& _positionMatrix,
|
||||
glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||
}
|
||||
|
||||
ege::resource::ParticuleMesh* ege::resource::ParticuleMesh::keep(const std::string& _meshName, const std::string& _shaderName)
|
||||
ewol::object::Shared<ege::resource::ParticuleMesh> ege::resource::ParticuleMesh::keep(const std::string& _meshName, const std::string& _shaderName)
|
||||
{
|
||||
ege::resource::ParticuleMesh* object = static_cast<ege::resource::ParticuleMesh*>(getManager().localKeep(_meshName));
|
||||
if (NULL != object) {
|
||||
ewol::object::Shared<ege::resource::ParticuleMesh> object = ewol::dynamic_pointer_cast<ege::resource::ParticuleMesh>(getManager().localKeep(_meshName));
|
||||
if (object != nullptr) {
|
||||
return object;
|
||||
}
|
||||
object = new ege::resource::ParticuleMesh(_meshName, _shaderName);
|
||||
if (object == NULL) {
|
||||
object = ewol::object::makeShared(new ege::resource::ParticuleMesh(_meshName, _shaderName));
|
||||
if (object == nullptr) {
|
||||
EGE_ERROR("allocation error of a resource : ??Mesh??" << _meshName);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
getManager().localAdd(object);
|
||||
return object;
|
||||
}
|
||||
|
||||
void ege::resource::ParticuleMesh::release(ege::resource::ParticuleMesh*& _object)
|
||||
{
|
||||
if (_object == NULL) {
|
||||
return;
|
||||
}
|
||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
|
||||
getManager().release(object2);
|
||||
_object = NULL;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace ege {
|
||||
class ParticuleMesh : public ege::resource::Mesh {
|
||||
protected:
|
||||
int32_t m_GLMainColor;
|
||||
protected:
|
||||
public:
|
||||
ParticuleMesh(const std::string& _fileName, const std::string& _shaderName);
|
||||
virtual ~ParticuleMesh();
|
||||
public:
|
||||
@ -29,14 +29,9 @@ namespace ege {
|
||||
* @brief keep the resource pointer.
|
||||
* @note Never free this pointer by your own...
|
||||
* @param[in] _filename Name of the ewol mesh file.
|
||||
* @return pointer on the resource or NULL if an error occured.
|
||||
* @return pointer on the resource or nullptr if an error occured.
|
||||
*/
|
||||
static ege::resource::ParticuleMesh* keep(const std::string& _meshName, const std::string& _shaderName="DATA:ParticuleMesh.prog");
|
||||
/**
|
||||
* @brief release the keeped resources
|
||||
* @param[in,out] reference on the object pointer
|
||||
*/
|
||||
static void release(ege::resource::ParticuleMesh*& _object);
|
||||
static ewol::object::Shared<ege::resource::ParticuleMesh> keep(const std::string& _meshName, const std::string& _shaderName="DATA:ParticuleMesh.prog");
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -21,7 +21,6 @@ extern const char * const ewolEventMeshPressed = "ewol-mesh-Pressed";
|
||||
|
||||
ege::widget::Mesh::Mesh(const std::string& _filename) :
|
||||
m_meshName(_filename),
|
||||
m_object(NULL),
|
||||
m_position(0,0,0),
|
||||
m_angle(0,0,0),
|
||||
m_angleSpeed(0,0,0),
|
||||
@ -32,14 +31,14 @@ ege::widget::Mesh::Mesh(const std::string& _filename) :
|
||||
setMouseLimit(1);
|
||||
if (_filename!="") {
|
||||
m_object = ege::resource::Mesh::keep(m_meshName);
|
||||
if (NULL == m_object) {
|
||||
if (nullptr == m_object) {
|
||||
EGE_ERROR("Can not load the resource : \"" << m_meshName << "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ege::widget::Mesh::~Mesh() {
|
||||
ege::resource::Mesh::release(m_object);
|
||||
|
||||
}
|
||||
|
||||
void ege::widget::Mesh::onDraw() {
|
||||
@ -48,7 +47,7 @@ void ege::widget::Mesh::onDraw() {
|
||||
* etk::matRotate(vec3(1,0,0),m_angle.x())
|
||||
* etk::matRotate(vec3(0,1,0),m_angle.y())
|
||||
* etk::matRotate(vec3(0,0,1),m_angle.z());
|
||||
if (NULL != m_object) {
|
||||
if (nullptr != m_object) {
|
||||
m_object->draw(transformationMatrix);
|
||||
}
|
||||
}
|
||||
@ -97,10 +96,9 @@ bool ege::widget::Mesh::onEventInput(const ewol::event::Input& _event) {
|
||||
void ege::widget::Mesh::setFile(const std::string& _filename) {
|
||||
if( _filename!=""
|
||||
&& m_meshName != _filename ) {
|
||||
ege::resource::Mesh::release(m_object);
|
||||
m_meshName = _filename;
|
||||
m_object = ege::resource::Mesh::keep(m_meshName);
|
||||
if (NULL == m_object) {
|
||||
if (nullptr == m_object) {
|
||||
EGE_ERROR("Can not load the resource : \"" << m_meshName << "\"");
|
||||
}
|
||||
}
|
||||
@ -127,8 +125,7 @@ void ege::widget::Mesh::setAngleSpeed(const vec3& _speed) {
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void ege::widget::Mesh::setDistance(float _distance)
|
||||
{
|
||||
void ege::widget::Mesh::setDistance(float _distance) {
|
||||
m_cameraDistance = _distance;
|
||||
markToRedraw();
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace ege {
|
||||
private:
|
||||
// mesh name :
|
||||
std::string m_meshName;
|
||||
ege::resource::Mesh* m_object;
|
||||
ewol::object::Shared<ege::resource::Mesh> m_object;
|
||||
// mesh display properties:
|
||||
vec3 m_position;
|
||||
vec3 m_angle;
|
||||
|
@ -39,11 +39,12 @@ const char * const ege::widget::Scene::eventKillEnemy = "event-scene-kill-ennemy
|
||||
ege::widget::Scene::Scene(bool _setAutoBullet, bool _setAutoCamera) :
|
||||
m_gameTime(0),
|
||||
m_angleView(M_PI/3.0),
|
||||
m_dynamicsWorld(NULL),
|
||||
m_camera(NULL),
|
||||
m_dynamicsWorld(nullptr),
|
||||
m_camera(nullptr),
|
||||
m_isRunning(true),
|
||||
m_debugMode(false),
|
||||
m_debugDrawing(NULL) {
|
||||
m_debugDrawing(nullptr) {
|
||||
addObjectType("ege::widget::Scene");
|
||||
setKeyboardRepeate(false);
|
||||
setCanHaveFocus(true);
|
||||
periodicCallEnable();
|
||||
@ -66,31 +67,31 @@ void ege::widget::Scene::setBulletConfig(btDefaultCollisionConfiguration* _colli
|
||||
btBroadphaseInterface* _broadphase,
|
||||
btConstraintSolver* _solver,
|
||||
btDynamicsWorld* _dynamicsWorld) {
|
||||
if (NULL != _collisionConfiguration) {
|
||||
if (nullptr != _collisionConfiguration) {
|
||||
m_collisionConfiguration = _collisionConfiguration;
|
||||
} else {
|
||||
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||
}
|
||||
///use the default collision dispatcher.
|
||||
if (NULL != _dispatcher) {
|
||||
if (nullptr != _dispatcher) {
|
||||
m_dispatcher = _dispatcher;
|
||||
} else {
|
||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||
}
|
||||
if (NULL != _broadphase) {
|
||||
if (nullptr != _broadphase) {
|
||||
m_broadphase = _broadphase;
|
||||
} else {
|
||||
m_broadphase = new btDbvtBroadphase();
|
||||
}
|
||||
|
||||
///the default constraint solver.
|
||||
if (NULL != _solver) {
|
||||
if (nullptr != _solver) {
|
||||
m_solver = _solver;
|
||||
} else {
|
||||
m_solver = new btSequentialImpulseConstraintSolver();
|
||||
}
|
||||
|
||||
if (NULL != _dynamicsWorld) {
|
||||
if (nullptr != _dynamicsWorld) {
|
||||
m_dynamicsWorld = _dynamicsWorld;
|
||||
} else {
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
||||
@ -103,7 +104,7 @@ void ege::widget::Scene::setBulletConfig(btDefaultCollisionConfiguration* _colli
|
||||
}
|
||||
|
||||
void ege::widget::Scene::setCamera(ege::Camera* _camera) {
|
||||
if (NULL != _camera) {
|
||||
if (nullptr != _camera) {
|
||||
m_camera = _camera;
|
||||
} else {
|
||||
m_camera = new ege::Camera(vec3(0,0,0), 0, DEG_TO_RAD(45) ,50);
|
||||
@ -113,7 +114,7 @@ void ege::widget::Scene::setCamera(ege::Camera* _camera) {
|
||||
}
|
||||
|
||||
ege::widget::Scene::~Scene() {
|
||||
ewol::resource::Colored3DObject::release(m_debugDrawing);
|
||||
|
||||
/*
|
||||
ewol::resource::release(m_directDrawObject);
|
||||
//cleanup in the reverse order of creation/initialization
|
||||
@ -215,7 +216,7 @@ void ege::widget::Scene::onDraw() {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (NULL!=m_camera) {
|
||||
if (nullptr!=m_camera) {
|
||||
m_env.getParticuleEngine().draw(*m_camera);
|
||||
}
|
||||
#ifdef SCENE_DISPLAY_SPEED
|
||||
@ -257,7 +258,7 @@ void ege::widget::Scene::periodicCall(const ewol::event::Time& _event) {
|
||||
//EWOL_DEBUG("Time: m_lastCallTime=" << m_lastCallTime << " deltaTime=" << deltaTime);
|
||||
|
||||
// update camera positions:
|
||||
if (NULL != m_camera) {
|
||||
if (nullptr != m_camera) {
|
||||
m_camera->periodicCall(curentDelta);
|
||||
}
|
||||
//EGE_DEBUG("stepSimulation (start)");
|
||||
@ -274,7 +275,7 @@ void ege::widget::Scene::periodicCall(const ewol::event::Time& _event) {
|
||||
int32_t victoryPoint=0;
|
||||
std::vector<ege::ElementGame*>& elementList = m_env.getElementGame();
|
||||
for (int32_t iii=elementList.size()-1; iii >= 0; --iii) {
|
||||
if(NULL != elementList[iii]) {
|
||||
if(nullptr != elementList[iii]) {
|
||||
if (true == elementList[iii]->needToRemove()) {
|
||||
if (elementList[iii]->getGroup() > 1) {
|
||||
numberEnnemyKilled++;
|
||||
|
@ -51,12 +51,12 @@ namespace ege {
|
||||
* @brief Destructor of the widget classes
|
||||
*/
|
||||
virtual ~Scene();
|
||||
void setBulletConfig(btDefaultCollisionConfiguration* _collisionConfiguration=NULL,
|
||||
btCollisionDispatcher* _dispatcher=NULL,
|
||||
btBroadphaseInterface* _broadphase=NULL,
|
||||
btConstraintSolver* _solver=NULL,
|
||||
btDynamicsWorld* _dynamicsWorld=NULL);
|
||||
void setCamera(ege::Camera* _camera=NULL);
|
||||
void setBulletConfig(btDefaultCollisionConfiguration* _collisionConfiguration=nullptr,
|
||||
btCollisionDispatcher* _dispatcher=nullptr,
|
||||
btBroadphaseInterface* _broadphase=nullptr,
|
||||
btConstraintSolver* _solver=nullptr,
|
||||
btDynamicsWorld* _dynamicsWorld=nullptr);
|
||||
void setCamera(ege::Camera* _camera=nullptr);
|
||||
private:
|
||||
float m_gameTime; //!< time of the game running
|
||||
protected:
|
||||
@ -89,7 +89,7 @@ namespace ege {
|
||||
void pauseToggle();
|
||||
protected:
|
||||
bool m_debugMode;
|
||||
ewol::resource::Colored3DObject* m_debugDrawing; //!< for the debug draw elements
|
||||
ewol::object::Shared<ewol::resource::Colored3DObject> m_debugDrawing; //!< for the debug draw elements
|
||||
public:
|
||||
/**
|
||||
* @brief Toggle the debug mode == > usefull for DEBUG only ...
|
||||
|
Loading…
x
Reference in New Issue
Block a user