[DEV] continue cleaning code to update new API
This commit is contained in:
parent
4a80003857
commit
fc598bd164
@ -6,6 +6,8 @@ import bpy
|
||||
import mathutils
|
||||
import bpy_extras.io_utils
|
||||
|
||||
EXPORT_COLLISION_NAME = ""
|
||||
|
||||
#blender myscene.blend --background --python myscript.py
|
||||
|
||||
def getChildren(obj):
|
||||
@ -523,10 +525,10 @@ def write_mesh(scene, file, object, mtl_dict):
|
||||
if object.dupli_type != 'NONE':
|
||||
object.dupli_list_clear()
|
||||
#####################################################################
|
||||
## Save collision shapes (for one object:
|
||||
## Save collision shapes (for one object):
|
||||
#####################################################################
|
||||
for subObj in getChildren(object):
|
||||
print(" child:'%s'" % (subObj.name))
|
||||
print(" child:'%s' check if start with : '%s'" % (subObj.name, EXPORT_COLLISION_NAME))
|
||||
if subObj.name.lower().startswith(EXPORT_COLLISION_NAME):
|
||||
print(" find physics:'%s'" % (subObj.name))
|
||||
write_collision_shape(subObj, file, object.scale, 1)
|
||||
|
@ -230,31 +230,6 @@ void ege::Environement::addCreator(const etk::String& _type, ege::createEntity_t
|
||||
}
|
||||
|
||||
|
||||
ememory::SharedPtr<ege::Entity> ege::Environement::createEntity(const etk::String& _type, const etk::String& _description, bool _autoAddEntity) {
|
||||
if (getHachTableCreating().exist(_type) == false) {
|
||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ege::createEntity_tf creatorPointer = getHachTableCreating()[_type];
|
||||
if (creatorPointer == nullptr) {
|
||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ememory::SharedPtr<ege::Entity> tmpEntity = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
||||
if (tmpEntity == nullptr) {
|
||||
EGE_ERROR("allocation error '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (tmpEntity->initString(_description) == false) {
|
||||
EGE_ERROR("Init error ... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (_autoAddEntity == true) {
|
||||
addEntity(tmpEntity);
|
||||
}
|
||||
return tmpEntity;
|
||||
}
|
||||
|
||||
ememory::SharedPtr<ege::Entity> ege::Environement::createEntity(const etk::String& _type, const ejson::Value& _value, bool _autoAddEntity) {
|
||||
if (getHachTableCreating().exist(_type) == false) {
|
||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||
@ -265,65 +240,11 @@ ememory::SharedPtr<ege::Entity> ege::Environement::createEntity(const etk::Strin
|
||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ememory::SharedPtr<ege::Entity> tmpEntity = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
||||
ememory::SharedPtr<ege::Entity> tmpEntity = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()), _value);
|
||||
if (tmpEntity == nullptr) {
|
||||
EGE_ERROR("allocation error '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (tmpEntity->initJSON(_value) == false) {
|
||||
EGE_ERROR("Init error ... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (_autoAddEntity == true) {
|
||||
addEntity(tmpEntity);
|
||||
}
|
||||
return tmpEntity;
|
||||
}
|
||||
|
||||
ememory::SharedPtr<ege::Entity> ege::Environement::createEntity(const etk::String& _type, const exml::Node& _node, bool _autoAddEntity) {
|
||||
if (getHachTableCreating().exist(_type) == false) {
|
||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ege::createEntity_tf creatorPointer = getHachTableCreating()[_type];
|
||||
if (creatorPointer == nullptr) {
|
||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ememory::SharedPtr<ege::Entity> tmpEntity = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
||||
if (tmpEntity == nullptr) {
|
||||
EGE_ERROR("allocation error '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (tmpEntity->initXML(_node) == false) {
|
||||
EGE_ERROR("Init error ... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (_autoAddEntity == true) {
|
||||
addEntity(tmpEntity);
|
||||
}
|
||||
return tmpEntity;
|
||||
}
|
||||
|
||||
ememory::SharedPtr<ege::Entity> ege::Environement::createEntity(const etk::String& _type, void* _data, bool _autoAddEntity) {
|
||||
if (getHachTableCreating().exist(_type) == false) {
|
||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ege::createEntity_tf creatorPointer = getHachTableCreating()[_type];
|
||||
if (creatorPointer == nullptr) {
|
||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ememory::SharedPtr<ege::Entity> tmpEntity = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
||||
if (tmpEntity == nullptr) {
|
||||
EGE_ERROR("allocation error '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (tmpEntity->initVoid(_data) == false) {
|
||||
EGE_ERROR("Init error ... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (_autoAddEntity == true) {
|
||||
addEntity(tmpEntity);
|
||||
}
|
||||
@ -331,28 +252,8 @@ ememory::SharedPtr<ege::Entity> ege::Environement::createEntity(const etk::Strin
|
||||
}
|
||||
|
||||
ememory::SharedPtr<ege::Entity> ege::Environement::createEntity(const etk::String& _type, bool _autoAddEntity) {
|
||||
if (getHachTableCreating().exist(_type) == false) {
|
||||
EGE_ERROR("Request creating of an type that is not known '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ege::createEntity_tf creatorPointer = getHachTableCreating()[_type];
|
||||
if (creatorPointer == nullptr) {
|
||||
EGE_ERROR("nullptr pointer creator == > internal error... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ememory::SharedPtr<ege::Entity> tmpEntity = creatorPointer(ememory::dynamicPointerCast<ege::Environement>(sharedFromThis()));
|
||||
if (tmpEntity == nullptr) {
|
||||
EGE_ERROR("allocation error '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (tmpEntity->init() == false) {
|
||||
EGE_ERROR("Init error ... '" << _type << "'");
|
||||
return nullptr;
|
||||
}
|
||||
if (_autoAddEntity == true) {
|
||||
addEntity(tmpEntity);
|
||||
}
|
||||
return tmpEntity;
|
||||
ejson::Value empty;
|
||||
return createEntity(_type, empty, _autoAddEntity);
|
||||
}
|
||||
|
||||
void ege::Environement::addEntity(ememory::SharedPtr<ege::Entity> _newEntity) {
|
||||
|
@ -18,7 +18,6 @@ namespace ege {
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/math/Vector3D.hpp>
|
||||
#include <ejson/ejson.hpp>
|
||||
#include <exml/exml.hpp>
|
||||
#include <ewol/object/Object.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
#include <ewol/event/Time.hpp>
|
||||
@ -28,7 +27,7 @@ namespace ege {
|
||||
namespace ege {
|
||||
class Entity;
|
||||
class Environement;
|
||||
typedef ememory::SharedPtr<ege::Entity> (*createEntity_tf)(const ememory::SharedPtr<ege::Environement>& _env);
|
||||
typedef ememory::SharedPtr<ege::Entity> (*createEntity_tf)(const ememory::SharedPtr<ege::Environement>& _env, const ejson::Value& _property);
|
||||
|
||||
enum gameStatus {
|
||||
gameStart,
|
||||
@ -142,10 +141,7 @@ namespace ege {
|
||||
* @return nullptr if an error occured OR the pointer on the entity and it is already added on the system.
|
||||
* @note Pointer is return in case of setting properties on it...
|
||||
*/
|
||||
ememory::SharedPtr<ege::Entity> createEntity(const etk::String& _type, const etk::String& _description, bool _autoAddEntity=true);
|
||||
ememory::SharedPtr<ege::Entity> createEntity(const etk::String& _type, const ejson::Value& _value, bool _autoAddEntity=true);
|
||||
ememory::SharedPtr<ege::Entity> createEntity(const etk::String& _type, const exml::Node& _node, bool _autoAddEntity=true);
|
||||
ememory::SharedPtr<ege::Entity> createEntity(const etk::String& _type, void* _data, bool _autoAddEntity=true);
|
||||
ememory::SharedPtr<ege::Entity> createEntity(const etk::String& _type, bool _autoAddEntity=true);
|
||||
public:
|
||||
class ResultNearestEntity {
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
ememory::SharedPtr<ege::physics::Shape> ege::physics::Shape::create(const etk::String& _name) {
|
||||
ememory::SharedPtr<ege::physics::Shape> tmpp = nullptr;
|
||||
etk::String name = etk::tolower(_name);
|
||||
etk::String name = etk::toLower(_name);
|
||||
if (name == "box") {
|
||||
tmpp = ememory::makeShared<ege::physics::shape::Box>();
|
||||
} else if (name == "sphere") {
|
||||
|
@ -65,7 +65,7 @@ void ege::resource::Mesh::init(const etk::String& _fileName, const etk::String&
|
||||
// TO facilitate some debugs we add a name of the VBO:
|
||||
m_verticesVBO->setName("[VBO] of " + _fileName);
|
||||
// load the curent file :
|
||||
etk::String tmpName = etk::tolower(_fileName);
|
||||
etk::String tmpName = etk::toLower(_fileName);
|
||||
// select the corect loader :
|
||||
if (etk::end_with(tmpName, ".obj") == true) {
|
||||
if (loadOBJ(_fileName) == false) {
|
||||
@ -717,6 +717,10 @@ void ege::resource::Mesh::addTriangle(const etk::String& _layerName, const vec3&
|
||||
#include <ege/physics/shape/Concave.hpp>
|
||||
const etk::Vector<ememory::SharedPtr<ege::physics::Shape>>& ege::resource::Mesh::getPhysicalProperties() {
|
||||
for (auto &it: m_physics) {
|
||||
if (it == nullptr) {
|
||||
EGE_WARNING("Get nullptr ... ");
|
||||
continue;
|
||||
}
|
||||
if (it->getType() == ege::physics::Shape::type::concave) {
|
||||
// need to generate the internal list of point and triangle needed:
|
||||
ege::physics::shape::Concave* tmpElement = it->toConcave();
|
||||
|
@ -165,6 +165,9 @@ namespace ege {
|
||||
};
|
||||
const etk::Vector<ememory::SharedPtr<ege::physics::Shape>>& getPhysicalProperties();
|
||||
void addPhysicElement(const ememory::SharedPtr<ege::physics::Shape>& _shape) {
|
||||
if (_shape == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_physics.pushBack(_shape);
|
||||
}
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user