Compare commits

...

6 Commits

32 changed files with 273 additions and 184 deletions

View File

@ -0,0 +1,55 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
struct DirectionalLight {
vec3 direction;
vec3 halfplane;
vec4 ambientColor;
vec4 diffuseColor;
vec4 specularColor;
};
struct Material {
vec4 ambientFactor;
vec4 diffuseFactor;
vec4 specularFactor;
float shininess;
};
// Light
uniform DirectionalLight EW_directionalLight;
// Material
uniform Material EW_material;
// Input :
uniform sampler2D EW_texID;
varying vec2 f_texcoord;
varying vec3 v_ecNormal;
void main(void) {
vec4 tmpElementColor = texture2D(EW_texID, f_texcoord);
// Normalize v_ecNormal
vec3 ecNormal = v_ecNormal / length(v_ecNormal);
float ecNormalDotLightDirection = max(0.0, dot(ecNormal, EW_directionalLight.direction));
float ecNormalDotLightHalfplane = max(0.0, dot(ecNormal, EW_directionalLight.halfplane));
// Calculate ambient light
vec4 ambientLight = EW_directionalLight.ambientColor * EW_material.ambientFactor;
// Calculate diffuse light
vec4 diffuseLight = ecNormalDotLightDirection * EW_directionalLight.diffuseColor * EW_material.diffuseFactor;
// Calculate specular light
vec4 specularLight = vec4(0.0);
if (ecNormalDotLightHalfplane > 0.0) {
specularLight = pow(ecNormalDotLightHalfplane, EW_material.shininess) * EW_directionalLight.specularColor * EW_material.specularFactor;
specularLight = EW_directionalLight.specularColor * EW_material.specularFactor;
}
vec4 light = ambientLight + diffuseLight + specularLight;
gl_FragColor = tmpElementColor;// * light;
}

View File

@ -0,0 +1,25 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
// Input :
attribute vec3 EW_coord3d;
attribute vec2 EW_texture2d;
attribute vec3 EW_normal;
uniform mat4 EW_MatrixTransformation;
uniform mat4 EW_MatrixPosition;
// output :
varying vec2 f_texcoord;
varying vec3 v_ecNormal;
void main(void) {
gl_Position = EW_MatrixTransformation * EW_MatrixPosition * vec4(EW_coord3d, 1.0);
// set texture output coord
f_texcoord = EW_texture2d;
mat4 MatrixPosition = EW_MatrixPosition;
MatrixPosition[3][0] = 0.0;
MatrixPosition[3][1] = 0.0;
MatrixPosition[3][2] = 0.0;
v_ecNormal = vec3(MatrixPosition * vec4(EW_normal, 1.0) );
}

View File

@ -66,6 +66,10 @@ void ege::Material::draw(ememory::SharedPtr<gale::resource::Program> _prog, cons
EGE_VERBOSE("draw Material: ( end )"); EGE_VERBOSE("draw Material: ( end )");
} }
bool ege::Material::haveTexture() const {
return m_texture0 != null;
}
void ege::Material::setAmbientFactor(const vec4& _val) { void ege::Material::setAmbientFactor(const vec4& _val) {
m_ambientFactor = _val; m_ambientFactor = _val;
} }
@ -83,14 +87,14 @@ void ege::Material::setShininess(float _val) {
m_shininess = _val; m_shininess = _val;
} }
void ege::Material::setTexture0(const etk::String& _filename) { void ege::Material::setTexture0(const etk::Uri& _uri) {
ivec2 tmpSize(256, 256); ivec2 tmpSize(256, 256);
if (_filename != "") { if (_uri.isEmpty() == false) {
// prevent overloard error : // prevent overloard error :
ememory::SharedPtr<ewol::resource::Texture> tmpCopy = m_texture0; ememory::SharedPtr<ewol::resource::Texture> tmpCopy = m_texture0;
m_texture0 = ewol::resource::TextureFile::create(_filename, tmpSize); m_texture0 = ewol::resource::TextureFile::create(_uri, tmpSize);
if (m_texture0 == null) { if (m_texture0 == null) {
EGE_ERROR("Can not load specific texture : " << _filename); EGE_ERROR("Can not load specific texture : " << _uri);
// retreave previous texture: // retreave previous texture:
m_texture0 = tmpCopy; m_texture0 = tmpCopy;
if (m_texture0 != null) { if (m_texture0 != null) {

View File

@ -49,13 +49,14 @@ namespace ege {
void setRenderMode(enum gale::openGL::renderMode _val); void setRenderMode(enum gale::openGL::renderMode _val);
enum gale::openGL::renderMode getRenderModeOpenGl(); enum gale::openGL::renderMode getRenderModeOpenGl();
enum gale::openGL::renderMode getRenderMode(); enum gale::openGL::renderMode getRenderMode();
void setTexture0(const etk::String& _filename); void setTexture0(const etk::Uri& _uri);
void setTexture0Magic(const ivec2& _size); void setTexture0Magic(const ivec2& _size);
void setImageSize(const ivec2& _newSize); void setImageSize(const ivec2& _newSize);
// get the reference on this image to draw nomething on it ... // get the reference on this image to draw nomething on it ...
egami::Image* get(); egami::Image* get();
// flush the data to send it at the openGl system // flush the data to send it at the openGl system
void flush(); void flush();
bool haveTexture() const;
}; };
} }

View File

@ -8,7 +8,7 @@
#include <ege/resource/Mesh.hpp> #include <ege/resource/Mesh.hpp>
#include <gale/resource/Manager.hpp> #include <gale/resource/Manager.hpp>
#include <gale/renderer/openGL/openGL-include.hpp> #include <gale/renderer/openGL/openGL-include.hpp>
#include <etk/os/FSNode.hpp> #include <etk/uri/uri.hpp>
#include <ege/resource/tools/viewBox.hpp> #include <ege/resource/tools/viewBox.hpp>
#include <ege/resource/tools/isoSphere.hpp> #include <ege/resource/tools/isoSphere.hpp>
#include <ege/resource/tools/icoSphere.hpp> #include <ege/resource/tools/icoSphere.hpp>
@ -31,9 +31,10 @@ ege::resource::Mesh::Mesh() :
addResourceType("ege::resource::Mesh"); addResourceType("ege::resource::Mesh");
} }
void ege::resource::Mesh::init(const etk::String& _fileName, const etk::String& _shaderName) { void ege::resource::Mesh::init(const etk::Uri& _fileName, const etk::Uri& _shaderName) {
gale::Resource::init(_fileName); gale::Resource::init(_fileName.getString());
EGE_VERBOSE("Load a new mesh : '" << _fileName << "'"); EGE_VERBOSE("Load a new mesh : '" << _fileName << "'");
// ------------------------------------------------------------------------------------------------
// get the shader resource : // get the shader resource :
m_GLPosition = 0; m_GLPosition = 0;
@ -42,9 +43,47 @@ void ege::resource::Mesh::init(const etk::String& _fileName, const etk::String&
m_light.setAmbientColor(vec4(1.0f,1.0f,1.0f,1.0f)); // Global anbiant color of the scene m_light.setAmbientColor(vec4(1.0f,1.0f,1.0f,1.0f)); // Global anbiant color of the scene
m_light.setDiffuseColor(vec4(1.0f,1.0f,1.0f,1.0f)); // Color of the object m_light.setDiffuseColor(vec4(1.0f,1.0f,1.0f,1.0f)); // Color of the object
m_light.setSpecularColor(vec4(0.0f,0.0f,0.0f,1.0f)); // Light color reflection m_light.setSpecularColor(vec4(0.0f,0.0f,0.0f,1.0f)); // Light color reflection
// ------------------------------------------------------------------------------------------------
EGE_VERBOSE(m_name << " " << m_light << " shader=" << _shaderName); // this is the properties of the buffer requested : "r"/"w" + "-" + buffer type "f"=flaot "i"=integer
m_GLprogram = gale::resource::Program::create(_shaderName); m_verticesVBO = gale::resource::VirtualBufferObject::create(5);
if (m_verticesVBO == null) {
EGE_ERROR("can not instanciate VBO ...");
return;
}
// TO facilitate some debugs we add a name of the VBO:
m_verticesVBO->setName("[VBO] of " + _fileName.getString());
// ------------------------------------------------------------------------------------------------
// load the curent file :
etk::String extention = etk::toLower(_fileName.getPath().getExtention());
// select the corect loader :
if (extention == "obj") {
if (loadOBJ(_fileName) == false) {
EGE_ERROR("Error To load OBJ file " << _fileName );
return;
}
} else if (extention == "emf") {
if (loadEMF(_fileName) == false) {
EGE_ERROR("Error To load EMF file " << _fileName );
return;
}
//EGE_CRITICAL("Load a new mesh : '" << _fileName << "' (end)");
} else {
// nothing to do == > reqiest an enmpty mesh ==> user manage it ...
}
// ------------------------------------------------------------------------------------------------
etk::Uri shaderName = _shaderName;
if (shaderName.isEmpty() == true) {
shaderName = "DATA:///material3D.prog";
for (auto &it: m_materials) {
if (it.second->haveTexture() == true) {
shaderName = "DATA:///material3DTextured.prog";
break;
}
}
}
// ------------------------------------------------------------------------------------------------
EGE_VERBOSE(m_name << " " << m_light << " shader=" << shaderName);
m_GLprogram = gale::resource::Program::create(shaderName);
if (m_GLprogram != null) { if (m_GLprogram != null) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
m_GLtexture = m_GLprogram->getAttribute("EW_texture2d"); m_GLtexture = m_GLprogram->getAttribute("EW_texture2d");
@ -56,31 +95,7 @@ void ege::resource::Mesh::init(const etk::String& _fileName, const etk::String&
m_GLMaterial.link(m_GLprogram, "EW_material"); m_GLMaterial.link(m_GLprogram, "EW_material");
m_light.link(m_GLprogram, "EW_directionalLight"); m_light.link(m_GLprogram, "EW_directionalLight");
} }
// this is the properties of the buffer requested : "r"/"w" + "-" + buffer type "f"=flaot "i"=integer // ------------------------------------------------------------------------------------------------
m_verticesVBO = gale::resource::VirtualBufferObject::create(5);
if (m_verticesVBO == null) {
EGE_ERROR("can not instanciate VBO ...");
return;
}
// 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);
// select the corect loader :
if (etk::end_with(tmpName, ".obj") == true) {
if (loadOBJ(_fileName) == false) {
EGE_ERROR("Error To load OBJ file " << tmpName );
return;
}
} else if (etk::end_with(tmpName, ".emf") ) {
if (loadEMF(_fileName) == false) {
EGE_ERROR("Error To load EMF file " << tmpName );
return;
}
//EGE_CRITICAL("Load a new mesh : '" << _fileName << "' (end)");
} else {
// nothing to do == > reqiest an enmpty mesh ==> user manage it ...
}
} }
@ -407,6 +422,10 @@ void ege::resource::Mesh::generateVBO() {
// clean faces indexes : // clean faces indexes :
m_listFaces.getValue(kkk).m_index.clear(); m_listFaces.getValue(kkk).m_index.clear();
int32_t nbIndicInFace = 3; int32_t nbIndicInFace = 3;
if (m_materials.exist(m_listFaces.getKey(kkk)) == false) {
EGE_WARNING("missing materials : '" << m_listFaces.getKey(kkk) << "' not in " << m_materials.getKeys() );
continue;
}
if (m_materials[m_listFaces.getKey(kkk)] == null) { if (m_materials[m_listFaces.getKey(kkk)] == null) {
EGE_ERROR("Can not get material : " << m_listFaces.getKey(kkk) << " pointer value: " << size_t(m_materials[m_listFaces.getKey(kkk)].get())); EGE_ERROR("Can not get material : " << m_listFaces.getKey(kkk) << " pointer value: " << size_t(m_materials[m_listFaces.getKey(kkk)].get()));
continue; continue;
@ -532,7 +551,8 @@ void ege::resource::Mesh::addMaterial(const etk::String& _name, ememory::SharedP
EGE_ERROR(" can not add material with no name"); EGE_ERROR(" can not add material with no name");
return; return;
} }
// really add the material : // really add the material:
EGE_WARNING("Add material: " << _name);
m_materials.add(_name, _data); m_materials.add(_name, _data);
} }

View File

@ -118,13 +118,12 @@ namespace ege {
ememory::SharedPtr<gale::resource::VirtualBufferObject> m_verticesVBO; ememory::SharedPtr<gale::resource::VirtualBufferObject> m_verticesVBO;
protected: protected:
Mesh(); Mesh();
void init(const etk::String& _fileName="---", void init(const etk::Uri& _fileName="---",
//const etk::String& _shaderName="DATA:textured3D2.prog" const etk::Uri& _shaderName=etk::Uri() //==> Shader is automatically selected (depending on the presence or ot of texture...
const etk::String& _shaderName="DATA:material3D.prog"
); );
public: public:
virtual ~Mesh(); virtual ~Mesh();
DECLARE_RESOURCE_NAMED_FACTORY(Mesh); DECLARE_RESOURCE_URI_FACTORY(Mesh);
public: public:
virtual void draw(mat4& _positionMatrix, bool _enableDepthTest=true, bool _enableDepthUpdate=true); virtual void draw(mat4& _positionMatrix, bool _enableDepthTest=true, bool _enableDepthUpdate=true);
virtual void draw(mat4& _positionMatrix, virtual void draw(mat4& _positionMatrix,
@ -144,8 +143,8 @@ namespace ege {
void createViewBox(const etk::String& _materialName,float _size=1.0); void createViewBox(const etk::String& _materialName,float _size=1.0);
void createIcoSphere(const etk::String& _materialName,float _size=1.0, int32_t _subdivision=3); void createIcoSphere(const etk::String& _materialName,float _size=1.0, int32_t _subdivision=3);
private: private:
bool loadOBJ(const etk::String& _fileName); bool loadOBJ(const etk::Uri& _fileName);
bool loadEMF(const etk::String& _fileName); bool loadEMF(const etk::Uri& _fileName);
public: public:
void addMaterial(const etk::String& _name, ememory::SharedPtr<ege::Material> _data); void addMaterial(const etk::String& _name, ememory::SharedPtr<ege::Material> _data);
public: public:

View File

@ -9,7 +9,7 @@
ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCapsule(float _radius, float _size, const etk::String& _materialName, const etk::Color<float>& _color, int32_t _lats, int32_t _longs) { ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCapsule(float _radius, float _size, const etk::String& _materialName, const etk::Color<float>& _color, int32_t _lats, int32_t _longs) {
EGE_VERBOSE(" create a capsule _size=" << _size << " _materialName=" << _materialName << " _color=" << _color); EGE_VERBOSE(" create a capsule _size=" << _size << " _materialName=" << _materialName << " _color=" << _color);
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:color3.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:///color3.prog");
if (out != null) { if (out != null) {
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>(); ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
// set the element material properties : // set the element material properties :

View File

@ -9,7 +9,7 @@
ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCone(float _radius, float _size, const etk::String& _materialName, const etk::Color<float>& _color, int32_t _lats, int32_t _longs) { ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCone(float _radius, float _size, const etk::String& _materialName, const etk::Color<float>& _color, int32_t _lats, int32_t _longs) {
EGE_VERBOSE(" create a cylinder _size=" << _size << " _materialName=" << _materialName << " _color=" << _color); EGE_VERBOSE(" create a cylinder _size=" << _size << " _materialName=" << _materialName << " _color=" << _color);
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:color3.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:///color3.prog");
if (out != null) { if (out != null) {
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>(); ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
// set the element material properties : // set the element material properties :

View File

@ -13,7 +13,7 @@ ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCube(float _s
ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCube(const vec3& _size, const etk::String& _materialName, const etk::Color<float>& _color) { ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCube(const vec3& _size, const etk::String& _materialName, const etk::Color<float>& _color) {
EGE_VERBOSE(" create a cube _size=" << _size << " _materialName=" << _materialName << " _color=" << _color); EGE_VERBOSE(" create a cube _size=" << _size << " _materialName=" << _materialName << " _color=" << _color);
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:color3.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:///color3.prog");
if (out != null) { if (out != null) {
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>(); ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
// set the element material properties : // set the element material properties :

View File

@ -9,7 +9,7 @@
ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCylinder(float _radius, float _size, const etk::String& _materialName, const etk::Color<float>& _color, int32_t _lats, int32_t _longs) { ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createCylinder(float _radius, float _size, const etk::String& _materialName, const etk::Color<float>& _color, int32_t _lats, int32_t _longs) {
EGE_VERBOSE(" create a cylinder _size=" << _size << " _materialName=" << _materialName << " _color=" << _color); EGE_VERBOSE(" create a cylinder _size=" << _size << " _materialName=" << _materialName << " _color=" << _color);
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:color3.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:///color3.prog");
if (out != null) { if (out != null) {
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>(); ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
// set the element material properties : // set the element material properties :

View File

@ -6,25 +6,25 @@
#include <ege/debug.hpp> #include <ege/debug.hpp>
#include <ege/resource/Mesh.hpp> #include <ege/resource/Mesh.hpp>
#include <etk/os/FSNode.hpp> #include <etk/uri/uri.hpp>
static void jumpEndLine(etk::FSNode& _file) { static void jumpEndLine(ememory::SharedPtr<etk::io::Interface>& _file) {
char current=_file.fileGet(); char current=_file->get();
while( current != '\0' while( current != '\0'
&& current != '\n') { && current != '\n') {
//printf("%c", current); //printf("%c", current);
current=_file.fileGet(); current=_file->get();
} }
} }
static int32_t countIndent(etk::FSNode& _file) { static int32_t countIndent(ememory::SharedPtr<etk::io::Interface>& _file) {
int32_t nbIndent=0; int32_t nbIndent=0;
int32_t nbSpacesTab=0; int32_t nbSpacesTab=0;
int32_t nbChar=0; int32_t nbChar=0;
//EGE_DEBUG(" start count Indent"); //EGE_DEBUG(" start count Indent");
for(char current=_file.fileGet(); current != '\0'; current=_file.fileGet()) { for(char current=_file->get(); current != '\0'; current=_file->get()) {
nbChar++; nbChar++;
//EGE_DEBUG("parse : " << current); //EGE_DEBUG("parse : " << current);
if (current == '\t') { if (current == '\t') {
@ -46,18 +46,17 @@ static int32_t countIndent(etk::FSNode& _file) {
} }
} }
//EGE_DEBUG("indent : " << nbIndent); //EGE_DEBUG("indent : " << nbIndent);
_file.fileSeek(-nbChar, etk::seekNode_current); _file->seek(-nbChar, etk::io::SeekMode::Current);
return nbIndent; return nbIndent;
} }
static char* loadNextData(char* _elementLine, static bool loadNextData(etk::String& _elementLine,
int64_t _maxData, int64_t _maxData,
etk::FSNode& _file, ememory::SharedPtr<etk::io::Interface>& _file,
bool _removeTabs=false, bool _removeTabs=false,
bool _stopColomn=false, bool _stopColomn=false,
bool _stopPipe=true) { bool _stopPipe=true) {
memset(_elementLine, 0, _maxData); _elementLine.clear();
char * element = _elementLine;
int64_t outSize = 0; int64_t outSize = 0;
/* /*
if (m_zipReadingOffset >= m_zipContent->size()) { if (m_zipReadingOffset >= m_zipContent->size()) {
@ -65,12 +64,11 @@ static char* loadNextData(char* _elementLine,
return null; return null;
} }
*/ */
char current = _file.fileGet(); char current = _file->get();
while (current != '\0') { while (current != '\0') {
if( _removeTabs == false if( _removeTabs == false
|| element != _elementLine) { || _elementLine.isEmpty() == false) {
*element = current; _elementLine.pushBack(current);
element++;
} }
if( current == '\n' if( current == '\n'
|| current == '\r' || current == '\r'
@ -79,42 +77,32 @@ static char* loadNextData(char* _elementLine,
|| ( current == ':' || ( current == ':'
&& _stopColomn == true) ) && _stopColomn == true) )
{ {
*element = '\0';
//EGE_DEBUG(" plop : '" << _elementLine << "'" ); //EGE_DEBUG(" plop : '" << _elementLine << "'" );
return _elementLine; return true;
} else if( element == _elementLine } else if( _elementLine.isEmpty() == true
&& current != '\t') { && current != '\t') {
*element = current; _elementLine.pushBack(current);
element++;
} }
// check maxData size ... // check maxData size ...
if (outSize >= _maxData-1) { if (outSize >= _maxData-1) {
*element = '\0'; return true;
return _elementLine;
} }
current = _file.fileGet(); current = _file->get();
} }
if (outSize == 0) { if (outSize == 0) {
return null; return false;
} else { } else {
// send last line // send last line
return _elementLine; return true;
} }
return null; return false;
} }
static void removeEndLine(char* _val) { static void removeEndLine(etk::String& _value) {
int32_t len = strlen(_val); while ( _value.size() > 0
if( len>0 && ( _value.back() == '\n'
&& ( _val[len-1] == '\n' || _value.back() == '\r') ) {
|| _val[len-1] == '\r' ) ) { _value.popBack();
_val[len-1] = '\0';
}
len--;
if( len>0
&& ( _val[len-1] == '\n'
|| _val[len-1] == '\r') ) {
_val[len-1] = '\0';
} }
} }
@ -139,26 +127,26 @@ enum emfModuleMode {
}; };
// TODO : rework with string line extractor // TODO : rework with string line extractor
bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) { bool ege::resource::Mesh::loadEMF(const etk::Uri& _fileName) {
m_checkNormal = true; m_checkNormal = true;
m_normalMode = ege::resource::Mesh::normalMode::none; m_normalMode = ege::resource::Mesh::normalMode::none;
etk::FSNode fileName(_fileName); ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(_fileName);
// get the fileSize ... // get the fileSize ...
int32_t size = fileName.fileSize(); int32_t size = fileIO->size();
if (size == 0 ) { if (fileIO == null ) {
EGE_ERROR("No data in the file named='" << fileName << "'"); EGE_ERROR("CAn not get the file named='" << _fileName << "'");
return false; return false;
} }
if (fileName.fileOpenRead() == false) { if (fileIO->open(etk::io::OpenMode::Read) == false) {
EGE_ERROR("Can not find the file name='" << fileName << "'"); EGE_ERROR("Can not find the file name='" << _fileName << "'");
return false; return false;
} }
char inputDataLine[2048]; etk::String inputDataLine;
// load the first line : // load the first line :
fileName.fileGets(inputDataLine, 2048); fileIO->gets(inputDataLine);
if(strncmp(inputDataLine, "EMF(STRING)", 11) == 0) { if (inputDataLine.startWith("EMF(STRING)") == true) {
// parse in string mode ... // parse in string mode ...
} else if (strncmp(inputDataLine, "EMF(BINARY)", 11) == 0) { } else if (inputDataLine.startWith("EMF(BINARY)") == true) {
EGE_ERROR(" file binary mode is not supported now : 'EMF(BINARY)'"); EGE_ERROR(" file binary mode is not supported now : 'EMF(BINARY)'");
return false; return false;
} else { } else {
@ -166,7 +154,7 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
return false; return false;
} }
enum emfModuleMode currentMode = EMFModuleNone; enum emfModuleMode currentMode = EMFModuleNone;
EGE_VERBOSE("Start parsing Mesh file : " << fileName); EGE_VERBOSE("Start parsing Mesh file : " << _fileName);
// mesh global param : // mesh global param :
etk::String currentMeshName = ""; etk::String currentMeshName = "";
int32_t meshFaceMaterialID = -1; int32_t meshFaceMaterialID = -1;
@ -181,14 +169,14 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
size_t offsetFaceNormal = 0; size_t offsetFaceNormal = 0;
size_t offsetVertexNormal = 0; size_t offsetVertexNormal = 0;
while (1) { while (1) {
int32_t level = countIndent(fileName); int32_t level = countIndent(fileIO);
if (level == 0) { if (level == 0) {
// new section ... // new section ...
if (loadNextData(inputDataLine, 2048, fileName) == null) { if (loadNextData(inputDataLine, 2048, fileIO) == false) {
// reach end of file ... // reach end of file ...
break; break;
} }
if(strncmp(inputDataLine, "Mesh:", 5) == 0) { if(inputDataLine.startWith("Mesh:") == true) {
currentMode = EMFModuleMesh; currentMode = EMFModuleMesh;
removeEndLine(inputDataLine); removeEndLine(inputDataLine);
currentMeshName = inputDataLine + 6; currentMeshName = inputDataLine + 6;
@ -198,7 +186,7 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
offsetFaceNormal = m_listFacesNormal.size(); offsetFaceNormal = m_listFacesNormal.size();
offsetVertexNormal = m_listVertexNormal.size(); offsetVertexNormal = m_listVertexNormal.size();
//EGE_ERROR("new offset: " << offsetVertexId << " " << offsetUV << " " << offsetFaceNormal << " " << offsetVertexNormal); //EGE_ERROR("new offset: " << offsetVertexId << " " << offsetUV << " " << offsetFaceNormal << " " << offsetVertexNormal);
} else if(strncmp(inputDataLine, "Materials:", 9) == 0) { } else if(inputDataLine.startWith("Materials:") == true) {
currentMode = EMFModuleMaterial; currentMode = EMFModuleMaterial;
// add previous material: // add previous material:
if( materialName != "" if( materialName != ""
@ -209,9 +197,9 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
} }
material = ememory::makeShared<ege::Material>(); material = ememory::makeShared<ege::Material>();
removeEndLine(inputDataLine); removeEndLine(inputDataLine);
materialName = inputDataLine + 10; materialName = inputDataLine.extract(10, etk::String::npos);
EGE_VERBOSE("Parse Material: " << materialName); EGE_VERBOSE("Parse Material: " << materialName);
} else if(strncmp(inputDataLine, "Physics:", 8) == 0) { } else if(inputDataLine.startWith("Physics:") == true) {
currentMode = EMFModulePhysics; currentMode = EMFModulePhysics;
removeEndLine(inputDataLine); removeEndLine(inputDataLine);
EGE_VERBOSE("Parse global Physics: "); EGE_VERBOSE("Parse global Physics: ");
@ -223,32 +211,32 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
&& currentMode <= EMFModuleMesh_END) { && currentMode <= EMFModuleMesh_END) {
if (level == 1) { if (level == 1) {
// In the mesh level 2 the line size must not exced 2048 // In the mesh level 2 the line size must not exced 2048
if (loadNextData(inputDataLine, 2048, fileName, true) == null) { if (loadNextData(inputDataLine, 2048, fileIO, true) == false) {
// reach end of file ... // reach end of file ...
break; break;
} }
removeEndLine(inputDataLine); removeEndLine(inputDataLine);
if(strncmp(inputDataLine, "Vertex", 6) == 0) { if(inputDataLine.startWith("Vertex") == true) {
currentMode = EMFModuleMeshVertex; currentMode = EMFModuleMeshVertex;
EGE_VERBOSE(" Vertex ..."); EGE_VERBOSE(" Vertex ...");
} else if(strncmp(inputDataLine, "UV-mapping", 10) == 0) { } else if(inputDataLine.startWith("UV-mapping") == true) {
currentMode = EMFModuleMeshUVMapping; currentMode = EMFModuleMeshUVMapping;
haveUVMapping = true; haveUVMapping = true;
EGE_VERBOSE(" UV-mapping ..."); EGE_VERBOSE(" UV-mapping ...");
} else if(strncmp(inputDataLine, "Normal(vertex)", 14) == 0) { } else if(inputDataLine.startWith("Normal(vertex)") == true) {
currentMode = EMFModuleMeshNormalVertex; currentMode = EMFModuleMeshNormalVertex;
EGE_VERBOSE(" Normal(vertex) ..."); EGE_VERBOSE(" Normal(vertex) ...");
} else if(strncmp(inputDataLine, "Normal(face)", 12) == 0) { } else if(inputDataLine.startWith("Normal(face)") == true) {
currentMode = EMFModuleMeshNormalFace; currentMode = EMFModuleMeshNormalFace;
EGE_VERBOSE(" Normal(face) ..."); EGE_VERBOSE(" Normal(face) ...");
} else if(strncmp(inputDataLine, "Face", 4) == 0) { } else if(inputDataLine.startWith("Face") == true) {
currentMode = EMFModuleMeshFace; currentMode = EMFModuleMeshFace;
EGE_VERBOSE(" Face ..."); EGE_VERBOSE(" Face ...");
} else if(strncmp(inputDataLine, "Physics", 7) == 0) { } else if(inputDataLine.startWith("Physics") == true) {
currentMode = EMFModuleMeshPhysics; currentMode = EMFModuleMeshPhysics;
EGE_VERBOSE(" Physics ..."); EGE_VERBOSE(" Physics ...");
} else { } else {
EGE_ERROR(" Unknow mesh property '"<<inputDataLine<<"'"); EGE_ERROR(" Unknow mesh property '" << inputDataLine << "'");
currentMode = EMFModuleMesh; currentMode = EMFModuleMesh;
} }
continue; continue;
@ -257,19 +245,18 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
switch (currentMode) { switch (currentMode) {
default: default:
EGE_ERROR("Unknow ... "<< level); EGE_ERROR("Unknow ... "<< level);
jumpEndLine(fileName); jumpEndLine(fileIO);
break; break;
case EMFModuleMeshVertex: { case EMFModuleMeshVertex: {
vec3 vertex(0,0,0); vec3 vertex(0,0,0);
while (loadNextData(inputDataLine, 2048, fileName, true, true) != null) { while (loadNextData(inputDataLine, 2048, fileIO, true, true) == true) {
if (inputDataLine[0] == '\0') { if (inputDataLine[0] == '\0') {
break; break;
} }
sscanf(inputDataLine, "%f %f %f", &vertex.m_floats[0], &vertex.m_floats[1], &vertex.m_floats[2] ); sscanf(&inputDataLine[0], "%f %f %f", &vertex.m_floats[0], &vertex.m_floats[1], &vertex.m_floats[2] );
m_listVertex.pushBack(vertex); m_listVertex.pushBack(vertex);
int32_t len = strlen(inputDataLine)-1; if( inputDataLine.back() == '\n'
if( inputDataLine[len] == '\n' || inputDataLine.back() == '\r') {
|| inputDataLine[len] == '\r') {
break; break;
} }
} }
@ -278,15 +265,14 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
} }
case EMFModuleMeshUVMapping: { case EMFModuleMeshUVMapping: {
vec2 uvMap(0,0); vec2 uvMap(0,0);
while (loadNextData(inputDataLine, 2048, fileName, true, true) != null) { while (loadNextData(inputDataLine, 2048, fileIO, true, true) == true) {
if (inputDataLine[0] == '\0') { if (inputDataLine[0] == '\0') {
break; break;
} }
sscanf(inputDataLine, "%f %f", &uvMap.m_floats[0], &uvMap.m_floats[1]); sscanf(&inputDataLine[0], "%f %f", &uvMap.m_floats[0], &uvMap.m_floats[1]);
m_listUV.pushBack(uvMap); m_listUV.pushBack(uvMap);
int32_t len = strlen(inputDataLine)-1; if( inputDataLine.back() == '\n'
if( inputDataLine[len] == '\n' || inputDataLine.back() == '\r') {
|| inputDataLine[len] == '\r') {
break; break;
} }
} }
@ -297,15 +283,14 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
m_normalMode = ege::resource::Mesh::normalMode::vertex; m_normalMode = ege::resource::Mesh::normalMode::vertex;
vec3 normal(0,0,0); vec3 normal(0,0,0);
// find the vertex Normal list. // find the vertex Normal list.
while (loadNextData(inputDataLine, 2048, fileName, true, true) != null) { while (loadNextData(inputDataLine, 2048, fileIO, true, true) == true) {
if (inputDataLine[0] == '\0') { if (inputDataLine[0] == '\0') {
break; break;
} }
sscanf(inputDataLine, "%f %f %f", &normal.m_floats[0], &normal.m_floats[1], &normal.m_floats[2] ); sscanf(&inputDataLine[0], "%f %f %f", &normal.m_floats[0], &normal.m_floats[1], &normal.m_floats[2] );
m_listVertexNormal.pushBack(normal); m_listVertexNormal.pushBack(normal);
int32_t len = strlen(inputDataLine)-1; if( inputDataLine.back() == '\n'
if( inputDataLine[len] == '\n' || inputDataLine.back() == '\r') {
|| inputDataLine[len] == '\r') {
break; break;
} }
} }
@ -317,15 +302,14 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
m_normalMode = ege::resource::Mesh::normalMode::face; // TODO : check if it is the same mode of display the normal from the start of the file m_normalMode = ege::resource::Mesh::normalMode::face; // TODO : check if it is the same mode of display the normal from the start of the file
vec3 normal(0,0,0); vec3 normal(0,0,0);
// find the face Normal list. // find the face Normal list.
while (loadNextData(inputDataLine, 2048, fileName, true, true) != null) { while (loadNextData(inputDataLine, 2048, fileIO, true, true) == true) {
if (inputDataLine[0] == '\0') { if (inputDataLine[0] == '\0') {
break; break;
} }
sscanf(inputDataLine, "%f %f %f", &normal.m_floats[0], &normal.m_floats[1], &normal.m_floats[2] ); sscanf(&inputDataLine[0], "%f %f %f", &normal.m_floats[0], &normal.m_floats[1], &normal.m_floats[2] );
m_listFacesNormal.pushBack(normal); m_listFacesNormal.pushBack(normal);
int32_t len = strlen(inputDataLine)-1; if( inputDataLine.back() == '\n'
if( inputDataLine[len] == '\n' || inputDataLine.back() == '\r') {
|| inputDataLine[len] == '\r') {
break; break;
} }
} }
@ -336,7 +320,7 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
case EMFModuleMeshFaceMaterial: case EMFModuleMeshFaceMaterial:
if (level == 2) { if (level == 2) {
//Find mesh name ... //Find mesh name ...
if (loadNextData(inputDataLine, 2048, fileName, true) == null) { if (loadNextData(inputDataLine, 2048, fileIO, true) == false) {
// reach end of file ... // reach end of file ...
break; break;
} }
@ -350,7 +334,7 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
meshFaceMaterialID = m_listFaces.getId(inputDataLine); meshFaceMaterialID = m_listFaces.getId(inputDataLine);
EGE_VERBOSE(" " << inputDataLine); EGE_VERBOSE(" " << inputDataLine);
} else if (currentMode == EMFModuleMeshFaceMaterial) { } else if (currentMode == EMFModuleMeshFaceMaterial) {
while (loadNextData(inputDataLine, 2048, fileName, true, true) != null) { while (loadNextData(inputDataLine, 2048, fileIO, true, true) == true) {
if (inputDataLine[0] == '\0') { if (inputDataLine[0] == '\0') {
// end of line // end of line
break; break;
@ -369,7 +353,7 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
normalIndex[1] = 0; normalIndex[1] = 0;
normalIndex[2] = 0; normalIndex[2] = 0;
if (haveUVMapping == true) { if (haveUVMapping == true) {
sscanf(inputDataLine, "%d/%d/%d %d/%d/%d %d/%d/%d", sscanf(&inputDataLine[0], "%d/%d/%d %d/%d/%d %d/%d/%d",
&vertexIndex[0], &uvIndex[0], &normalIndex[0], &vertexIndex[0], &uvIndex[0], &normalIndex[0],
&vertexIndex[1], &uvIndex[1], &normalIndex[1], &vertexIndex[1], &uvIndex[1], &normalIndex[1],
&vertexIndex[2], &uvIndex[2], &normalIndex[2] ); &vertexIndex[2], &uvIndex[2], &normalIndex[2] );
@ -389,7 +373,7 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
normalIndex[2] += offsetVertexNormal; normalIndex[2] += offsetVertexNormal;
} }
} else { } else {
sscanf(inputDataLine, "%d/%d %d/%d %d/%d", sscanf(&inputDataLine[0], "%d/%d %d/%d %d/%d",
&vertexIndex[0], &normalIndex[0], &vertexIndex[0], &normalIndex[0],
&vertexIndex[1], &normalIndex[1], &vertexIndex[1], &normalIndex[1],
&vertexIndex[2], &normalIndex[2] ); &vertexIndex[2], &normalIndex[2] );
@ -414,9 +398,8 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
" " << vertexIndex[1] << "/" << uvIndex[1] << "/" << normalIndex[1] << " " << vertexIndex[1] << "/" << uvIndex[1] << "/" << normalIndex[1] <<
" " << vertexIndex[2] << "/" << uvIndex[2] << "/" << normalIndex[2]); " " << vertexIndex[2] << "/" << uvIndex[2] << "/" << normalIndex[2]);
*/ */
int32_t len = strlen(inputDataLine)-1; if( inputDataLine.back() == '\n'
if( inputDataLine[len] == '\n' || inputDataLine.back() == '\r') {
|| inputDataLine[len] == '\r') {
break; break;
} }
} }
@ -424,12 +407,12 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
} else { } else {
// insert element without material ... // insert element without material ...
EGE_ERROR(" try to add face without material selection ..."); EGE_ERROR(" try to add face without material selection ...");
jumpEndLine(fileName); jumpEndLine(fileIO);
} }
break; break;
case EMFModuleMeshPhysics: case EMFModuleMeshPhysics:
case EMFModuleMeshPhysicsNamed: case EMFModuleMeshPhysicsNamed:
if (loadNextData(inputDataLine, 2048, fileName, true, false, false) == null) { if (loadNextData(inputDataLine, 2048, fileIO, true, false, false) == false) {
// reach end of file ... // reach end of file ...
break; break;
} }
@ -448,7 +431,7 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
EGE_ERROR("Can not parse :'" << inputDataLine << "' in physical shape ..."); EGE_ERROR("Can not parse :'" << inputDataLine << "' in physical shape ...");
continue; continue;
} }
if (physics->parse(inputDataLine) == false) { if (physics->parse(&inputDataLine[0]) == false) {
EGE_ERROR("ERROR when parsing :'" << inputDataLine << "' in physical shape ..."); EGE_ERROR("ERROR when parsing :'" << inputDataLine << "' in physical shape ...");
} }
} }
@ -458,22 +441,22 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
} else if ( currentMode >= EMFModuleMaterial } else if ( currentMode >= EMFModuleMaterial
&& currentMode <= EMFModuleMaterial_END) { && currentMode <= EMFModuleMaterial_END) {
// all material element is stored on 1 line (size < 2048) // all material element is stored on 1 line (size < 2048)
if (loadNextData(inputDataLine, 2048, fileName, true) == null) { if (loadNextData(inputDataLine, 2048, fileIO, true) == false) {
// reach end of file ... // reach end of file ...
break; break;
} }
removeEndLine(inputDataLine); removeEndLine(inputDataLine);
if (material == null) { if (material == null) {
EGE_ERROR("material allocation error"); EGE_ERROR("material allocation error");
jumpEndLine(fileName); jumpEndLine(fileIO);
continue; continue;
} }
if(strncmp(inputDataLine,"Ns ",3) == 0) { if(inputDataLine.startWith("Ns ") == true) {
float tmpVal=0; float tmpVal=0;
sscanf(&inputDataLine[3], "%f", &tmpVal); sscanf(&inputDataLine[3], "%f", &tmpVal);
material->setShininess(tmpVal); material->setShininess(tmpVal);
EGE_VERBOSE(" Shininess " << tmpVal); EGE_VERBOSE(" Shininess " << tmpVal);
} else if(strncmp(inputDataLine,"Ka ",3) == 0) { } else if(inputDataLine.startWith("Ka ") == true) {
float tmpVal1=0; float tmpVal1=0;
float tmpVal2=0; float tmpVal2=0;
float tmpVal3=0; float tmpVal3=0;
@ -481,7 +464,7 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1); vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1);
material->setAmbientFactor(tmp); material->setAmbientFactor(tmp);
EGE_VERBOSE(" AmbientFactor " << tmp); EGE_VERBOSE(" AmbientFactor " << tmp);
} else if(strncmp(inputDataLine,"Kd ",3) == 0) { } else if(inputDataLine.startWith("Kd ") == true) {
float tmpVal1=0; float tmpVal1=0;
float tmpVal2=0; float tmpVal2=0;
float tmpVal3=0; float tmpVal3=0;
@ -492,7 +475,7 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1); vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1);
material->setDiffuseFactor(tmp); material->setDiffuseFactor(tmp);
EGE_ERROR(" DiffuseFactor " << tmp); EGE_ERROR(" DiffuseFactor " << tmp);
} else if(strncmp(inputDataLine,"Ks ",3) == 0) { } else if(inputDataLine.startWith("Ks ") == true) {
float tmpVal1=0; float tmpVal1=0;
float tmpVal2=0; float tmpVal2=0;
float tmpVal3=0; float tmpVal3=0;
@ -500,25 +483,27 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1); vec4 tmp(tmpVal1, tmpVal2, tmpVal3, 1);
material->setSpecularFactor(tmp); material->setSpecularFactor(tmp);
EGE_VERBOSE(" SpecularFactor " << tmp); EGE_VERBOSE(" SpecularFactor " << tmp);
} else if(strncmp(inputDataLine,"Ni ",3) == 0) { } else if(inputDataLine.startWith("Ni ") == true) {
float tmpVal=0; float tmpVal=0;
sscanf(&inputDataLine[3], "%f", &tmpVal); sscanf(&inputDataLine[3], "%f", &tmpVal);
// TODO : ... // TODO : ...
EGE_VERBOSE(" Ni " << tmpVal); EGE_VERBOSE(" Ni " << tmpVal);
} else if(strncmp(inputDataLine,"d ",2) == 0) { } else if(inputDataLine.startWith("d ") == true) {
float tmpVal=0; float tmpVal=0;
sscanf(&inputDataLine[2], "%f", &tmpVal); sscanf(&inputDataLine[2], "%f", &tmpVal);
// TODO : ... // TODO : ...
EGE_VERBOSE(" d " << tmpVal); EGE_VERBOSE(" d " << tmpVal);
} else if(strncmp(inputDataLine,"illum ",6) == 0) { } else if(inputDataLine.startWith("illum ") == true) {
int tmpVal=0; int tmpVal=0;
sscanf(&inputDataLine[6], "%d", &tmpVal); sscanf(&inputDataLine[6], "%d", &tmpVal);
// TODO : ... // TODO : ...
EGE_VERBOSE(" illum " << tmpVal); EGE_VERBOSE(" illum " << tmpVal);
} else if(strncmp(inputDataLine,"map_Kd ",7) == 0) { } else if(inputDataLine.startWith("map_Kd ") == true) {
material->setTexture0(fileName.getRelativeFolder() + &inputDataLine[7]); etk::Uri tmpTexture = _fileName;
tmpTexture.setPath(_fileName.getPath().getParent() / &inputDataLine[7]);
material->setTexture0(tmpTexture);
EGE_VERBOSE(" Texture " << &inputDataLine[7]); EGE_VERBOSE(" Texture " << &inputDataLine[7]);
} else if(strncmp(inputDataLine,"renderMode ",11) == 0) { } else if(inputDataLine.startWith("renderMode ") == true) {
gale::openGL::renderMode mode; gale::openGL::renderMode mode;
etk::from_string(mode, &inputDataLine[11]); etk::from_string(mode, &inputDataLine[11]);
material->setRenderMode(mode); material->setRenderMode(mode);
@ -528,7 +513,7 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
} }
} else if ( currentMode >= EMFModulePhysics } else if ( currentMode >= EMFModulePhysics
&& currentMode <= EMFModulePhysics_END) { && currentMode <= EMFModulePhysics_END) {
if (loadNextData(inputDataLine, 2048, fileName, true, false, false) == null) { if (loadNextData(inputDataLine, 2048, fileIO, true, false, false) == false) {
// reach end of file ... // reach end of file ...
break; break;
} }
@ -548,14 +533,14 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
EGE_ERROR("Can not parse :'" << inputDataLine << "' in physical shape ..."); EGE_ERROR("Can not parse :'" << inputDataLine << "' in physical shape ...");
continue; continue;
} }
if (physics->parse(inputDataLine) == false) { if (physics->parse(&inputDataLine[0]) == false) {
EGE_ERROR("ERROR when parsing :'" << inputDataLine << "' in physical shape ..."); EGE_ERROR("ERROR when parsing :'" << inputDataLine << "' in physical shape ...");
} }
} }
} else { } else {
// unknow ... // unknow ...
EGE_WARNING("Unknow type of line == > jump end of line ... " << inputDataLine); EGE_WARNING("Unknow type of line == > jump end of line ... " << inputDataLine);
jumpEndLine(fileName); jumpEndLine(fileIO);
} }
} }
} }
@ -568,7 +553,7 @@ bool ege::resource::Mesh::loadEMF(const etk::String& _fileName) {
} }
EGE_VERBOSE("Stop parsing Mesh file"); EGE_VERBOSE("Stop parsing Mesh file");
fileName.fileClose(); fileIO->close();
EGE_VERBOSE("New mesh : "); EGE_VERBOSE("New mesh : ");
EGE_VERBOSE(" nb vertex: " << m_listVertex.size()); EGE_VERBOSE(" nb vertex: " << m_listVertex.size());

View File

@ -8,7 +8,7 @@
#include <ege/resource/Mesh.hpp> #include <ege/resource/Mesh.hpp>
ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createGrid(int32_t _lineCount, const vec3& _position, float _size, const etk::String& _materialName) { ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createGrid(int32_t _lineCount, const vec3& _position, float _size, const etk::String& _materialName) {
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:color3.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:///color3.prog");
if (out != null) { if (out != null) {
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>(); ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
// set the element material properties : // set the element material properties :

View File

@ -8,7 +8,7 @@
#include <ege/resource/Mesh.hpp> #include <ege/resource/Mesh.hpp>
bool ege::resource::Mesh::loadOBJ(const etk::String& _fileName) { bool ege::resource::Mesh::loadOBJ(const etk::Uri& _fileName) {
m_normalMode = ege::resource::Mesh::normalMode::none; m_normalMode = ege::resource::Mesh::normalMode::none;
#if 0 #if 0
etk::FSNode fileName(_fileName); etk::FSNode fileName(_fileName);

View File

@ -9,7 +9,7 @@
ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createSphere(float _radius, const etk::String& _materialName, const etk::Color<float>& _color, int32_t _lats, int32_t _longs) { ememory::SharedPtr<ege::resource::Mesh> ege::resource::Mesh::createSphere(float _radius, const etk::String& _materialName, const etk::Color<float>& _color, int32_t _lats, int32_t _longs) {
EGE_VERBOSE(" create a sphere _size=" << _radius << " _materialName=" << _materialName << " _color=" << _color); EGE_VERBOSE(" create a sphere _size=" << _radius << " _materialName=" << _materialName << " _color=" << _color);
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:color3.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:///color3.prog");
if (out != null) { if (out != null) {
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>(); ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
// set the element material properties : // set the element material properties :

View File

@ -14,7 +14,7 @@ namespace ege {
int32_t m_GLMainColor; int32_t m_GLMainColor;
protected: protected:
ParticuleMesh(); ParticuleMesh();
void init(const etk::String& _fileName, const etk::String& _shaderName="DATA:ParticuleMesh.prog"); void init(const etk::String& _fileName, const etk::String& _shaderName="DATA:///ParticuleMesh.prog");
public: public:
DECLARE_RESOURCE_NAMED_FACTORY(ParticuleMesh); DECLARE_RESOURCE_NAMED_FACTORY(ParticuleMesh);
virtual ~ParticuleMesh(); virtual ~ParticuleMesh();

View File

@ -1,5 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
import lutin.debug as debug import realog.debug as debug
import lutin.tools as tools import lutin.tools as tools
@ -77,7 +77,7 @@ def configure(target, my_module):
'ege/Ray.cpp', 'ege/Ray.cpp',
]) ])
my_module.copy_path('data/ParticuleMesh.*') my_module.copy_path('data/ParticuleMesh.*')
my_module.copy_path('data/material3D.*') my_module.copy_path('data/material*')
my_module.add_depend([ my_module.add_depend([
'ewol', 'ewol',
'ephysics', 'ephysics',

View File

@ -31,7 +31,7 @@ appl::Windows::Windows() {
static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() { static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() {
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:texturedNoMaterial.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:///texturedNoMaterial.prog");
if (out != null) { if (out != null) {
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>(); ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
// set the entity material properties : // set the entity material properties :

View File

@ -1,5 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
import lutin.debug as debug import realog.debug as debug
import lutin.tools as tools import lutin.tools as tools

View File

@ -33,7 +33,7 @@ appl::Windows::Windows() {
static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() { static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() {
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:texturedNoMaterial.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:///texturedNoMaterial.prog");
if (out == null) { if (out == null) {
return out; return out;
} }

View File

@ -1,5 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
import lutin.debug as debug import realog.debug as debug
import lutin.tools as tools import lutin.tools as tools

View File

@ -32,7 +32,7 @@ appl::Windows::Windows() {
static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() { static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() {
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:texturedNoMaterial.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:///texturedNoMaterial.prog");
if (out != null) { if (out != null) {
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>(); ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
// set the entity material properties : // set the entity material properties :

View File

@ -1,5 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
import lutin.debug as debug import realog.debug as debug
import lutin.tools as tools import lutin.tools as tools

View File

@ -32,7 +32,7 @@ appl::Windows::Windows() {
static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() { static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() {
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:texturedNoMaterial.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:///texturedNoMaterial.prog");
if (out != null) { if (out != null) {
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>(); ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
// set the entity material properties : // set the entity material properties :
@ -119,7 +119,7 @@ void appl::Windows::init() {
// add it .. // add it ..
m_env->addEntity(entity); m_env->addEntity(entity);
} }
myMesh = ege::resource::Mesh::create("DATA:tower.emf"); myMesh = ege::resource::Mesh::create("DATA:///tower.emf");
if (myMesh != null) { if (myMesh != null) {
ememory::SharedPtr<ege::Entity> entity = ememory::makeShared<ege::Entity>(m_env); ememory::SharedPtr<ege::Entity> entity = ememory::makeShared<ege::Entity>(m_env);
// add all component: // add all component:
@ -134,7 +134,7 @@ void appl::Windows::init() {
componentPhysics->generate(); componentPhysics->generate();
entity->addComponent(componentPhysics); entity->addComponent(componentPhysics);
// 3rd this object have some intelligence: // 3rd this object have some intelligence:
ememory::SharedPtr<ege::ia::Component> componentIA = ememory::makeShared<ege::ia::ComponentLua>("DATA:tower.lua"); ememory::SharedPtr<ege::ia::Component> componentIA = ememory::makeShared<ege::ia::ComponentLua>("DATA:///tower.lua");
entity->addComponent(componentIA); entity->addComponent(componentIA);
// add it .. // add it ..
m_env->addEntity(entity); m_env->addEntity(entity);

View File

@ -1,5 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
import lutin.debug as debug import realog.debug as debug
import lutin.tools as tools import lutin.tools as tools

View File

@ -31,7 +31,7 @@ appl::Windows::Windows() {
static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() { static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() {
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:texturedNoMaterial.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:///texturedNoMaterial.prog");
if (out != null) { if (out != null) {
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>(); ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
// set the entity material properties : // set the entity material properties :
@ -118,7 +118,7 @@ void appl::Windows::init() {
// add it .. // add it ..
m_env->addEntity(entity); m_env->addEntity(entity);
} }
myMesh = ege::resource::Mesh::create("DATA:tree_1.emf"); myMesh = ege::resource::Mesh::create("DATA:///tree_1.emf");
if (myMesh != null) { if (myMesh != null) {
ememory::SharedPtr<ege::Entity> entity = ememory::makeShared<ege::Entity>(m_env); ememory::SharedPtr<ege::Entity> entity = ememory::makeShared<ege::Entity>(m_env);
// add all component: // add all component:

View File

@ -1,5 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
import lutin.debug as debug import realog.debug as debug
import lutin.tools as tools import lutin.tools as tools

View File

@ -31,7 +31,7 @@ appl::Windows::Windows() {
} }
static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() { static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() {
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:texturedNoMaterial.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("---", "DATA:///texturedNoMaterial.prog");
if (out != null) { if (out != null) {
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>(); ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
// set the entity material properties : // set the entity material properties :
@ -73,7 +73,7 @@ static ememory::SharedPtr<ege::resource::Mesh> createMars() {
material->setDiffuseFactor(vec4(0.512f,0.512f,0.512f,1.0f)); material->setDiffuseFactor(vec4(0.512f,0.512f,0.512f,1.0f));
material->setSpecularFactor(vec4(0.5f,0.5f,0.5f,1.0f)); material->setSpecularFactor(vec4(0.5f,0.5f,0.5f,1.0f));
material->setShininess(96.078431f); material->setShininess(96.078431f);
material->setTexture0("DATA:texture_mars.png"); material->setTexture0("DATA:///texture_mars.png");
out->addMaterial("basics", material); out->addMaterial("basics", material);
out->createIcoSphere("basics", 16, 3); out->createIcoSphere("basics", 16, 3);
out->generateVBO(); out->generateVBO();

View File

@ -1,5 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
import lutin.debug as debug import realog.debug as debug
import lutin.tools as tools import lutin.tools as tools

View File

@ -30,7 +30,7 @@ appl::Windows::Windows() {
} }
static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() { static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() {
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:texturedNoMaterial.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:///texturedNoMaterial.prog");
if (out != null) { if (out != null) {
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>(); ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
// set the entity material properties : // set the entity material properties :

View File

@ -1,5 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
import lutin.debug as debug import realog.debug as debug
import lutin.tools as tools import lutin.tools as tools

View File

@ -33,7 +33,7 @@ appl::Windows::Windows() {
static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() { static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() {
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:texturedNoMaterial.prog"); ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:///texturedNoMaterial.prog");
if (out == null) { if (out == null) {
return out; return out;
} }

View File

@ -1,5 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
import lutin.debug as debug import realog.debug as debug
import lutin.tools as tools import lutin.tools as tools