Commit 99facfe2 authored by Sylvain Thery's avatar Sylvain Thery

SandBox and viewerOBJ

parent 7a4f43d9
......@@ -28,6 +28,9 @@ ENDIF(WIN32)
IF (WITH_QT)
add_subdirectory(Tuto)
add_subdirectory(Examples/Release)
IF (NOT DONOT_COMPILE_SANDBOX)
add_subdirectory(SandBox)
ENDIF (NOT DONOT_COMPILE_SANDBOX)
ENDIF (WITH_QT)
add_subdirectory(Examples/Tests)
......@@ -73,3 +73,9 @@ target_link_libraries( mcmeshD ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS})
QT4_WRAP_CPP( concave_rendering_moc ../concave_rendering.h )
add_executable( concave_renderingD ../concave_rendering.cpp ${concave_rendering_moc} ${concave_rendering_ui} )
target_link_libraries( concave_renderingD ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS})
QT4_WRAP_CPP( viewerOBJ_moc ../viewerOBJ.h )
add_executable( viewerOBJD ../viewerOBJ.cpp ${viewerOBJ_moc} )
target_link_libraries( viewerOBJD ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} )
......@@ -66,3 +66,8 @@ target_link_libraries( mcmesh ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} )
QT4_WRAP_CPP( concave_rendering_moc ../concave_rendering.h )
add_executable( concave_rendering ../concave_rendering.cpp ${concave_rendering_moc} ${concave_rendering_ui} )
target_link_libraries( concave_rendering ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} )
QT4_WRAP_CPP( viewerOBJ_moc ../viewerOBJ.h )
add_executable( viewerOBJ ../viewerOBJ.cpp ${viewerOBJ_moc} )
target_link_libraries( viewerOBJ ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} )
......@@ -107,18 +107,18 @@ int main(int argc, char **argv)
// define the face extruded (here a cross)
std::vector<PFP::VEC3> objV;
objV.push_back(PFP::VEC3(-1, 0,-1));
objV.push_back(PFP::VEC3(-1, 0,-2));
objV.push_back(PFP::VEC3(+1, 0,-2));
objV.push_back(PFP::VEC3(+1, 0,-1));
objV.push_back(PFP::VEC3(+2, 0,-1));
objV.push_back(PFP::VEC3(+2, 0,+1));
objV.push_back(PFP::VEC3(+1, 0,+1));
objV.push_back(PFP::VEC3(+1, 0,+2));
objV.push_back(PFP::VEC3(-1, 0,+2));
objV.push_back(PFP::VEC3(-1, 0,+1));
objV.push_back(PFP::VEC3(-2, 0,+1));
objV.push_back(PFP::VEC3(-2, 0,-1));
objV.push_back(PFP::VEC3(-2, 0,+1));
objV.push_back(PFP::VEC3(-1, 0,+1));
objV.push_back(PFP::VEC3(-1, 0,+2));
objV.push_back(PFP::VEC3(+1, 0,+2));
objV.push_back(PFP::VEC3(+1, 0,+1));
objV.push_back(PFP::VEC3(+2, 0,+1));
objV.push_back(PFP::VEC3(+2, 0,-1));
objV.push_back(PFP::VEC3(+1, 0,-1));
objV.push_back(PFP::VEC3(+1, 0,-2));
objV.push_back(PFP::VEC3(-1, 0,-2));
objV.push_back(PFP::VEC3(-1, 0,-1));
// define a path (here an helicoid)
std::vector<PFP::VEC3> pathV;
......@@ -129,7 +129,7 @@ int main(int argc, char **argv)
PFP::REAL alpha = 3.141592/20.0 * i;
PFP::REAL rad = 20.0 - 0.2*i;
pathV.push_back(PFP::VEC3(rad*cos(alpha),rad*sin(alpha), 0.5*i));
pathRadius.push_back(1.5f+0.7*cos(alpha));
pathRadius.push_back(2.0f+0.3*cos(alpha));
}
// extrusion
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "viewerOBJ.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/polyhedron.h"
#include "Utils/vbo.h"
ObjView::ObjView():
m_obj(myMap),
m_positionVBO(NULL),
m_normalVBO(NULL),
m_texcoordVBO(NULL),
m_shader(NULL),
m_shader2(NULL)
{}
ObjView::~ObjView()
{
if (m_shader!=NULL)
delete m_shader;
if (m_shader2!=NULL)
delete m_shader2;
if (m_phongShader!=NULL)
delete m_phongShader;
if (m_positionVBO!=NULL)
delete m_positionVBO;
if (m_normalVBO!=NULL)
delete m_normalVBO;
if (m_texcoordVBO!=NULL)
delete m_texcoordVBO;
}
void ObjView::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create VBO for position
m_positionVBO = new Utils::VBO;
m_texcoordVBO = new Utils::VBO;
m_normalVBO = new Utils::VBO;
// m_shader = new Utils::ShaderSimpleTexture();
// m_shader->setAttributePosition(m_positionVBO);
// m_shader->setAttributeTexCoord(m_texcoordVBO);
// m_shader->setTextureUnit(GL_TEXTURE0);
// registerShader(m_shader);
m_shader2 = new Utils::ShaderPhongTexture();
m_shader2->setAttributePosition(m_positionVBO);
m_shader2->setAttributeTexCoord(m_texcoordVBO);
m_shader2->setAttributeNormal(m_normalVBO);
m_shader2->setTextureUnit(GL_TEXTURE1);
m_shader2->setShininess(10.0f);
m_shader2->setAmbient(0.1f);
m_shader2->setSpecular(Geom::Vec4f(0.5));
registerShader(m_shader2);
m_phongShader = new Utils::ShaderPhong() ;
m_phongShader->setAttributePosition(m_positionVBO) ;
m_phongShader->setAttributeNormal(m_normalVBO) ;
registerShader(m_phongShader);
glEnable(GL_TEXTURE_2D);
m_obj.createGroupMatVBO_PTN(m_positionVBO,m_texcoordVBO,m_normalVBO);
}
void ObjView::cb_redraw()
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
unsigned int nb = m_obj.nbMatGroups();
const std::vector<Algo::Surface::Import::MaterialOBJ*>& mats = m_obj.getMaterials();
for (unsigned int i=0; i<nb; ++i)
{
if (mats[i]->textureDiffuse != NULL)
{
m_shader2->setTexture(mats[i]->textureDiffuse);
m_shader2->setShininess(mats[i]->shininess);
m_shader2->setAmbient(0.3f);
m_shader2->activeTexture();
m_shader2->enableVertexAttribs();
glDrawArrays(GL_TRIANGLES, m_obj.beginIndex(i), m_obj.nbIndices(i));
m_shader2->disableVertexAttribs();
}
else
{
Geom::Vec4f v;
v[0] = mats[i]->ambiantColor[0]; v[1] = mats[i]->ambiantColor[1]; v[2] = mats[i]->ambiantColor[2]; v[3] = 0.0f;
m_phongShader->setAmbiant(v) ;
v[0] = mats[i]->diffuseColor[0]; v[1] = mats[i]->diffuseColor[1]; v[2] = mats[i]->diffuseColor[2]; v[3] = 0.0f;
m_phongShader->setDiffuse(v) ;
v[0] = mats[i]->specularColor[0]; v[1] = mats[i]->specularColor[1]; v[2] = mats[i]->specularColor[2]; v[3] = 0.0f;
m_phongShader->setSpecular(v) ;
m_phongShader->setShininess(mats[i]->shininess) ;
m_phongShader->enableVertexAttribs();
glDrawArrays(GL_TRIANGLES, m_obj.beginIndex(i), m_obj.nbIndices(i));
m_phongShader->disableVertexAttribs();
}
}
}
void ObjView::init(const std::string& fnm)
{
std::vector<std::string> attrNames;
m_obj.import(fnm,attrNames);
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, m_obj.m_positions);
float lWidthObj = std::max<PFP::REAL>(std::max<PFP::REAL>(bb.size(0), bb.size(1)), bb.size(2));
Geom::Vec3f lPosObj = (bb.min() + bb.max()) / PFP::REAL(2);
// send BB info to interface for centering on GL screen
setParamObject(lWidthObj, lPosObj.data());
}
int main(int argc, char**argv)
{
// interface:
QApplication app(argc, argv);
ObjView tv;
if (argc == 2)
{
tv.init(argv[1]);
}
else
{
CGoGNerr << argv[0] << " objFile"<< CGoGNendl;
}
tv.show();
// et on attend la fin.
return app.exec();
}
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef _TEXTURE_EXAMPLE_
#define _TEXTURE_EXAMPLE_
#include <iostream>
//#include "Utils/Qt/qtSimple.h"
#include "Utils/Qt/qtQGLV.h"
#include "Utils/textures.h"
#include "Utils/Shaders/shaderSimpleTexture.h"
#include "Utils/Shaders/shaderPhongTexture.h"
#include "Utils/Shaders/shaderPhong.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Algo/Import/importObjTex.h"
// forward definitions (minimize includes)
namespace CGoGN { namespace Algo { namespace Render { namespace GL2 { class MapRender; }}}}
namespace CGoGN { namespace Utils { class VBO; } }
using namespace CGoGN ;
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedMap2 MAP ;
};
typedef PFP::MAP MAP ;
typedef PFP::VEC3 VEC3 ;
/**
* A class for a little interface and rendering
*/
//class ObjView: public Utils::QT::SimpleQT
class ObjView: public Utils::QT::SimpleQGLV
{
Q_OBJECT
public:
MAP myMap ;
Algo::Surface::Import::OBJModel<PFP> m_obj;
// VBO
Utils::VBO* m_positionVBO;
Utils::VBO* m_normalVBO;
Utils::VBO* m_texcoordVBO;
// shader simple texture
Utils::ShaderSimpleTexture* m_shader;
Utils::ShaderPhongTexture* m_shader2;
Utils::ShaderPhong* m_phongShader;
ObjView();
~ObjView();
void init(const std::string& fnm);
// callbacks of simpleQT to overdefine:
void cb_redraw();
void cb_initGL();
};
#endif
cmake_minimum_required(VERSION 2.8)
project(SandBox)
SET (CMAKE_BUILD_TYPE Debug)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING")
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CGoGN_ROOT_DIR}/include
${CGoGN_EXT_INCLUDES}
)
# define libs path
IF(WIN32)
link_directories(${CGoGN_ROOT_DIR}/lib/$(ConfigurationName)
${Boost_LIBRARY_DIRS})
ELSE(WIN32)
link_directories(${CGoGN_ROOT_DIR}/lib/Release ${CGoGN_ROOT_DIR}/lib/Debug)
ENDIF(WIN32)
#define exec to compile
add_executable( multi_att multi_att.cpp)
target_link_libraries( multi_att ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
# Example with Qt
#
#QT4_WRAP_CPP(tuto1_moc tuto1.h)
#add_executable( tuto1 tuto1.cpp ${tuto1_moc})
#target_link_libraries( tuto1 ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
#QT4_WRAP_CPP(tuto_mt_moc tuto_mt.h)
#add_executable( tuto_mt tuto_mt.cpp ${tuto_mt_moc})
#target_link_libraries( tuto_mt
# ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ${Boost_THREAD_LIBRARY})
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include <iostream>
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Geometry/vector_gen.h"
#include "Algo/Import/import.h"
#include "Topology/generic/multiAttribs.h"
#include "Algo/Geometry/centroid.h"
#include "Algo/Geometry/normal.h"
#include "Algo/Modelisation/subdivision.h"
using namespace CGoGN ;
/**
* Struct that contains some informations about the types of the manipulated objects
* Mainly here to be used by the algorithms that are parameterized by it
*/
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedMap2 MAP;
};
/**
* Simple example of function that work with generic type of attribute
*/
template <typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE smooth(typename PFP::MAP& map, Dart d, const V_ATT& attributs)
{
typename V_ATT::DATA_TYPE res(0);
int count=0;
if (attributs.getOrbit() == VERTEX)
{
Traversor2VVaE<typename PFP::MAP> tra(map,d);
for (Dart e = tra.begin(); e != tra.end(); e = tra.next())
{
res += attributs[d];
count ++;
}
res /= typename PFP::REAL(count);
return res;
}
else if (attributs.getOrbit() == FACE)
{
Traversor2FFaV<typename PFP::MAP> tra(map,d);
for (Dart e = tra.begin(); e != tra.end(); e = tra.next())
{
res += attributs[d];
count ++;
}
res /= typename PFP::REAL(count);
return res;
}
return res;
}
template <typename PFP, typename V_ATT>
void applySmooth(typename PFP::MAP& map, const V_ATT& att_in, V_ATT& att_out)
{
if (att_in.getOrbit() == VERTEX)
{
TraversorV<typename PFP::MAP> tra(map);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
att_out[d] = smooth<PFP>(map,d,att_in);
}
}
else if (att_in.getOrbit() == FACE)
{
TraversorF<typename PFP::MAP> tra(map);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
att_out[d] = smooth<PFP>(map,d,att_in);
}
}
else
CGoGNerr << "unsupported orbit"<< CGoGNendl;
}
int main(int argc, char **argv)
{
if(argc != 3)
{
CGoGNout << "Usage : " << argv[0] << " filename nbSteps" << CGoGNendl;
return 0;
}
std::string filename(argv[1]);
unsigned int nbSteps;
std::istringstream iss(argv[2]);
iss >> nbSteps;
// declaration of the map
PFP::MAP myMap;
std::vector<std::string> attrNames ;
Algo::Surface::Import::importMesh<PFP>(myMap, argv[1], attrNames);
// get a handler to the 3D vector attribute created by the import
VertexAttribute<PFP::VEC3> position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]);
VertexAttribute<PFP::VEC3> pos2 = myMap.addAttribute<PFP::VEC3, VERTEX>("pos2");
VertexAttribute<PFP::VEC4> vc = myMap.addAttribute<PFP::VEC4, VERTEX>("vertexColor");
VertexAttribute<PFP::VEC4> vc2 = myMap.addAttribute<PFP::VEC4, VERTEX>("vertexColor2");
// classic usage with simple vertex attributes
applySmooth<PFP>(myMap,position,pos2);
// multi attributes usage
Vertex2Attributes<PFP::VEC3, PFP::VEC4> pv_in(position,vc);
Vertex2Attributes<PFP::VEC3, PFP::VEC4> pv_out(pos2,vc2);
applySmooth<PFP>(myMap,pv_in,pv_out);
// usage with with a face attribute
FaceAttribute<PFP::VEC4> fc = myMap.addAttribute<PFP::VEC4, FACE>("faceColor");
FaceAttribute<PFP::VEC4> fc2 = myMap.addAttribute<PFP::VEC4, FACE>("faceColor2");
applySmooth<PFP>(myMap,fc,fc2);
//// for(unsigned int i = 0; i < nbSteps; ++i)
//// Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position);
//// PFP::VEC3 c = Algo::Surface::Geometry::faceCentroidGen<PFP, VertexAttribute<PFP::VEC3> > (myMap, myMap.begin(),position);
// T2 cc = Algo::Surface::Geometry::faceCentroid<PFP,T1> (myMap, myMap.begin(), xx);
// typedef Face2Attributes<PFP::VEC3,PFP::VEC3> TF;
// TF yy(fc,fco);
// Algo::Surface::Geometry::computeCentroidFaces< PFP >(myMap,xx,yy);
//// Algo::Surface::Geometry::computeCentroidFacesGen< PFP,VertexAttribute<PFP::VEC3> , FaceAttribute<PFP::VEC3> >(myMap,position,fc);
// Algo::Surface::Geometry::computeCentroidFaces<PFP>(myMap,position,fc);
// FaceAttribute<PFP::VEC3> fc2 = myMap.addAttribute<PFP::VEC3, FACE>("faceCenter2");
// Algo::Surface::Geometry::computeCentroidFaces<PFP>(myMap,position,fc2);
// PFP::VEC3 cx = Algo::Surface::Geometry::faceCentroid<PFP>(myMap,myMap.begin(),position);
// for (unsigned int i=fc.begin(); i!= fc.end(); fc.next(i))
// {
// if (fc[i] != fc2[i])
// std::cout << "PROBLEM" << std::endl;
// }
// for(unsigned int i = 0; i < nbSteps; ++i)
// Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, xx) ;
//// Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position);
return 0;
}
......@@ -15,6 +15,9 @@ SET ( WITH_ASSIMP ON CACHE BOOL "build CGoGN with Assimp" )
SET ( WITH_ZINRI ON CACHE BOOL "build CGoGN with Zinri lib" )
SET ( WITH_QT ON CACHE BOOL "build CGoGN with Qt lib" )
SET ( DESIRED_QT_VERSION "4" CACHE STRING "4: QT4/ 5 not yet implemented" )
SET ( DONOT_COMPILE_SANDBOX OFF CACHE BOOL "do not compile the SandBox directory" )
# for CGoGN MR
SET ( FORCE_MR "0" CACHE STRING "0: normal mode / 1 multires mode" )
......
......@@ -27,6 +27,7 @@
//#include "Topology/generic/mapBrowser.h"
#include "Container/containerBrowser.h"
#include "Topology/generic/cellmarker.h"
#include "Utils/textures.h"
namespace CGoGN
{
......@@ -41,7 +42,17 @@ namespace Import
class MaterialOBJ
{
public:
MaterialOBJ():textureDiffuse(NULL){}
MaterialOBJ():
illuminationModel(0),
ambiantColor(0.0f,0.0f,0.0f),
diffuseColor(0.0f,0.0f,0.0f),
specularColor(0.0f,0.0f,0.0f),
shininess(100.0f),
transparentFilter(0.0f,0.0f,0.0f),
transparency(0.0f),
textureDiffuse(NULL)
{}
~MaterialOBJ()
{
if (textureDiffuse!=NULL)
......@@ -49,6 +60,7 @@ public:
}
std::string name;
int illuminationModel; // 0 Diffu / 1 D+Ambiant / 3 A+D+Specular
Geom::Vec3f ambiantColor;
Geom::Vec3f diffuseColor;
Geom::Vec3f specularColor;
......@@ -56,9 +68,19 @@ public:
Geom::Vec3f transparentFilter;
float transparency;
Utils::Texture<2,Geom::Vec3uc>* textureDiffuse;
// static bool compare(MaterialOBJ* m1, MaterialOBJ* m2)
// {
// if (m1->textureDiffuse > m2->textureDiffuse)
// return true;
// if (m1->textureDiffuse == m2->textureDiffuse)
// return m1->illuminationModel > m2->illuminationModel;
// return false;
// }
};
template <typename PFP>
class OBJModel
{
......@@ -68,19 +90,25 @@ class OBJModel
protected:
typename PFP::MAP& m_map;
std::vector<unsigned int> m_beginIndices;
std::vector<unsigned int> m_nbIndices;
/// vector of group name
std::vector<std::string> m_groupNames;
std::vector<std::string> m_groupMaterialNames;
std::vector<int> m_groupMaterialID;
// std::vector<std::string> m_groupNames;
// std::vector<std::string> m_groupMaterialNames;
// std::vector<int> m_groupMaterialID;
/// vector of material names
/// map of material names -> group id
std::map<std::string,int> m_materialNames;
/// filename of mtllib
std::string m_matFileName;
/// path of mtllib
std::string m_matPath;
/// vector of material struct
// std::vector<MaterialOBJ> m_materials;
std::vector<MaterialOBJ*> m_materials;
/// read face line with different indices v v/t v//n v/t/n
short readObjLine(std::stringstream& oss, std::vector<unsigned int>& indices);
......@@ -101,6 +129,7 @@ public:
/// Face Attribute for group ID storage
FaceAttribute<unsigned int> m_groups;
FaceAttribute<unsigned int> m_attMat;
/// Vertex Attribute Handlers
VertexAttribute<VEC3> m_positions;
......@@ -118,6 +147,8 @@ public:
*/
OBJModel(typename PFP::MAP& map);
~OBJModel();
/**
* @brief set position attribute
* @param position attribute
......@@ -190,19 +221,52 @@ public:
std::vector<std::string>& getMaterialNames();
/**
* @brief read materials from files
* @brief getMaterialIndex
* @param name name of material
* @return index in generated vector of material by readMaterials
*/
unsigned int getMaterialIndex(const std::string& name) const;
/**
* @brief read materials from files. Call after creating VBOs !!
* @param filename name of file
*/
void readMaterials(const std::string& filename, std::vector<MaterialOBJ>& materials);
void readMaterials(unsigned int maxTextureSize=2048, const std::string& filename="");
/**
* @brief getMaterials
* @return the vector of MaterialObj*
*/
const std::vector<MaterialOBJ*>& getMaterials() const { return m_materials;}
/**
* @brief nb group of indices created by createGroupMatVBO_XXX
* @return
*/
unsigned int nbMatGroups() { return m_beginIndices.size(); }
/**
* @brief get the begin index of each group in VBOs (for glDrawArrays)
* @param i id of group
* @return begin index
*/
unsigned int beginIndex(unsigned int i) const { return m_beginIndices[i]; }
/**
* @brief get the number of indices of each group in VBOs (for glDrawArrays)
* @param i id of group
* @return number of indices
*/
unsigned int nbIndices(unsigned int i) const { return m_nbIndices[i]; }
/**
* @brief create simple VBO for separated triangles
* @param positionVBO
* @param texcoordVBO
* @param normalVBO