I am trying to append texture to my model imported from Maya. I am able to create soft body out of the model and able o drop it down due to gravity. Now I am trying to attach texture to it. Any help would be appreciated.
void ViewManager::renderSoftbodyMeshes(btSoftBody* sBody)
{
btTransform meshTransform = sBody->getWorldTransform();
int j = 0;
static btScalar tempForm[16];
meshTransform.getOpenGLMatrix(tempForm);
glBindTexture(GL_TEXTURE_2D, GLuint(imageData));
glTexImage2D(GL_TEXTURE_2D, 0, 3, imageCols, imageRows, 0, GL_RGB, GL_UNSIGNED_BYTE, imageData);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glPushMatrix();
glMultMatrixf(tempForm);
glBegin(GL_TRIANGLES);
int numFaces = sBody->m_faces.size();
for (int i=0; i< numFaces; i++)
{
glNormal3fv(sBody->m_faces.m_n[0]->m_n);
glTexCoord2fv(&objmodel->texcoords[objmodel->triangles.tindices[0]]);
glVertex3fv(sBody->m_faces.m_n[0]->m_q);
glNormal3fv(sBody->m_faces.m_n[1]->m_n);
glTexCoord2fv(&objmodel->texcoords[objmodel->triangles.tindices[1]]);
glVertex3fv(sBody->m_faces.m_n[1]->m_q);
glNormal3fv(sBody->m_faces.m_n[2]->m_n);
glTexCoord2fv(&objmodel->texcoords[objmodel->triangles.tindices[2]]);
glVertex3fv(sBody->m_faces.m_n[2]->m_q);
}
glEnd();
glPopMatrix();
glDisable(GL_TEXTURE_2D);
}
Soft body texture
-
- Posts: 12
- Joined: Mon Dec 05, 2011 8:36 pm
Re: Soft body texture
Please help me...I have to complete this part by wednesday and I am stuck here. Plzzzzzzzzzzzzzzzzzzzz.