Commit b656baed authored by cclepper's avatar cclepper
Browse files

added support for rectangle textures to glm


git-svn-id: https://pd-gem.svn.sourceforge.net/svnroot/pd-gem/trunk/Gem@817 49b2a0ca-c541-4d49-a7ef-d785e4371512
parent 92a7c288
......@@ -37,6 +37,8 @@ model :: model(t_symbol *filename)
// make sure that there are some characters
m_model = 0;
m_group = 0;
currentH = 1.f;
currentW = 1.f;
if (filename->s_name[0]) openMess(filename);
}
......@@ -90,7 +92,7 @@ void model :: textureMess(int state)
if (!m_model) return;
if (state)glmSpheremapTexture(m_model);
else glmLinearTexture(m_model);
else glmLinearTexture(m_model,currentH,currentW);
buildList();
}
......@@ -170,7 +172,7 @@ void model :: openMess(t_symbol *filename)
glmFacetNormals (m_model);
glmVertexNormals(m_model, m_smooth);
glmLinearTexture(m_model);
glmLinearTexture(m_model,currentH,currentW);
buildList();
this->setModified();
......@@ -201,8 +203,17 @@ void model :: buildList()
// render
//
/////////////////////////////////////////////////////////
void model :: render(GemState *)
void model :: render(GemState *state)
{
if (currentH != state->texCoordX(1) || currentW != state->texCoordY(1)){
currentH = state->texCoordX(1);
currentW = state->texCoordY(1);
glmLinearTexture(m_model,currentH,currentW);
post("model: resizing texcoords");
buildList();
}
if (!m_dispList)return;
glCallList(m_dispList);
}
......
......@@ -100,6 +100,8 @@ class GEM_EXTERN model : public GemBase
int m_group;
float currentH, currentW;
private:
//////////
......
......@@ -1153,7 +1153,8 @@ glmVertexNormals(GLMmodel* model, GLfloat angle)
* model - pointer to initialized GLMmodel structure
*/
GLvoid
glmLinearTexture(GLMmodel* model)
//glmLinearTexture(GLMmodel* model)
glmLinearTexture(GLMmodel* model, float h, float w)
{
GLMgroup *group;
GLfloat dimensions[3];
......@@ -1175,8 +1176,8 @@ glmLinearTexture(GLMmodel* model)
for(i = 1; i <= model->numvertices; i++) {
x = model->vertices[3 * i + 0] * scalefactor;
y = model->vertices[3 * i + 2] * scalefactor;
model->texcoords[2 * i + 0] = (x + 1.0) / 2.0;
model->texcoords[2 * i + 1] = (y + 1.0) / 2.0;
model->texcoords[2 * i + 0] = ((x + 1.0) / 2.0) * w;
model->texcoords[2 * i + 1] = ((y + 1.0) / 2.0) * h;
}
/* go through and put texture coordinate indices in all the triangles */
......
......@@ -173,7 +173,8 @@ glmVertexNormals(GLMmodel* model, GLfloat angle);
* model - pointer to initialized GLMmodel structure
*/
GLvoid
glmLinearTexture(GLMmodel* model);
//glmLinearTexture(GLMmodel* model);
glmLinearTexture(GLMmodel* model, float h, float w);
/* glmSpheremapTexture: Generates texture coordinates according to a
* spherical projection of the texture map. Sometimes referred to as
......
......@@ -192,7 +192,7 @@ void multimodel :: openMess(t_symbol *filename, int baseModel, int topModel, int
glmFacetNormals (m_model);
glmVertexNormals(m_model, 90); /* SMOOTH */
glmLinearTexture(m_model);
glmLinearTexture(m_model,1,1);
newCache->realmodels[i]=m_model;
}
m_curModel = 0;
......
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