Commit ca42b69e authored by Sylvain Thery's avatar Sylvain Thery

minor modifs for viewerOBJ

parent 5d78847f
......@@ -104,18 +104,17 @@ void ObjView::cb_redraw()
{
m_shader2->setTexture(mats[i]->textureDiffuse);
m_shader2->setShininess(mats[i]->shininess);
m_shader2->setAmbient(0.3f);
m_shader2->setAmbient(0.8f);
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;
// v[0] = mats[i]->ambiantColor[0]; v[1] = mats[i]->ambiantColor[1]; v[2] = mats[i]->ambiantColor[2]; v[3] = 0.0f;
v[0] = 0.5f; v[1] = 0.5f; v[2] = 0.5f; 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) ;
......
......@@ -93,6 +93,8 @@ protected:
std::vector<unsigned int> m_beginIndices;
std::vector<unsigned int> m_nbIndices;
unsigned int m_maxTextureSize;
/// vector of group name
// std::vector<std::string> m_groupNames;
// std::vector<std::string> m_groupMaterialNames;
......@@ -149,6 +151,12 @@ public:
~OBJModel();
/**
* @brief resize texture (at import) to max size
* @param mts max texture size in x & y
*/
void setMaxTextureSize(unsigned int mts);
/**
* @brief set position attribute
* @param position attribute
......@@ -231,7 +239,7 @@ public:
* @brief read materials from files. Call after creating VBOs !!
* @param filename name of file
*/
void readMaterials(unsigned int maxTextureSize=2048, const std::string& filename="");
void readMaterials(const std::string& filename="");
/**
* @brief getMaterials
......
......@@ -41,7 +41,7 @@ namespace Import
template <typename PFP>
OBJModel<PFP>::OBJModel(typename PFP::MAP& map):
m_map(map),
m_map(map), m_maxTextureSize(2048),
m_tagV(0),m_tagVT(0),m_tagVN(0),m_tagG(0),m_tagF(0),
m_specialVertices(map),m_dirtyEdges(map)
{
......@@ -55,6 +55,16 @@ OBJModel<PFP>::~OBJModel()
delete *it;
}
template <typename PFP>
inline void OBJModel<PFP>::setMaxTextureSize(unsigned int mts)
{
m_maxTextureSize = mts;
}
template <typename PFP>
inline typename PFP::VEC3 OBJModel<PFP>::getPosition(Dart d)
{
......@@ -62,6 +72,7 @@ inline typename PFP::VEC3 OBJModel<PFP>::getPosition(Dart d)
}
template <typename PFP>
inline typename PFP::VEC3 OBJModel<PFP>::getNormal(Dart d)
{
......@@ -105,7 +116,7 @@ void OBJModel<PFP>::setTexCoordAttribute(VertexAttribute<Geom::Vec2f>texcoord)
template <typename PFP>
void OBJModel<PFP>::readMaterials(unsigned int /*maxTextureSize*/, const std::string& filename)
void OBJModel<PFP>::readMaterials(const std::string& filename)
{
m_materials.reserve(m_materialNames.size());
......@@ -211,7 +222,7 @@ void OBJModel<PFP>::readMaterials(unsigned int /*maxTextureSize*/, const std::st
currentMat->textureDiffuse->load(m_matPath+tname);
CGoGNout << "Loading texture "<< m_matPath+tname << " -> "<<std::hex << currentMat->textureDiffuse <<std::dec<<CGoGNendl;
// currentMat->textureDiffuse->scaleNearest( currentMat->textureDiffuse->newMaxSize(maxTextureSize));
currentMat->textureDiffuse->scaleNearest( currentMat->textureDiffuse->newMaxSize(m_maxTextureSize));
currentMat->textureDiffuse->setFiltering(GL_LINEAR);
currentMat->textureDiffuse->setWrapping(GL_REPEAT);
currentMat->textureDiffuse->update();
......@@ -231,6 +242,7 @@ void OBJModel<PFP>::readMaterials(unsigned int /*maxTextureSize*/, const std::st
tname = tname.substr(0,tname.length()-1);
currentMat->textureDiffuse->load(m_matPath+tname);
CGoGNout << "Loading texture "<< m_matPath+tname << " -> "<<std::hex << currentMat->textureDiffuse <<std::dec<<CGoGNendl;
currentMat->textureDiffuse->scaleNearest( currentMat->textureDiffuse->newMaxSize(m_maxTextureSize));
currentMat->textureDiffuse->setFiltering(GL_LINEAR);
currentMat->textureDiffuse->setWrapping(GL_REPEAT);
currentMat->textureDiffuse->update();
......
......@@ -1095,7 +1095,6 @@ void Texture<DIM,TYPE>::update()
glTexImage1D(m_target, 0, internalFormat(), this->m_size[0], 0, format(), m_type, this->m_data_ptr);
break;
case 2:
std::cout << "updateSize: " << this->m_size[0] << " / " << this->m_size[1] << std::endl;
glTexImage2D(m_target, 0, internalFormat(), this->m_size[0], this->m_size[1], 0, format(), m_type, this->m_data_ptr);
break;
case 3:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment