I am trying to bake texture in 3DS Max and use it in OpenGL, but texture looks weird.
I was looking on google for few hours, but cant find any solution.
Here is my code:
public void RenderObject(CObject obj)
{
CMesh m; MFace f; MVertex v; MNormal n; MTexCords t; CTexture tx;
tx = obj.GetTexture(); m = obj.GetMesh();
if(tx.hasTexture())
{
tx.apply2Object(gl.getGL());
}
gl.glTranslatef(obj.location.x, obj.location.y, obj.location.z);
gl.glRotatef(obj.rotation.x, 1, 0, 0);
gl.glRotatef(obj.rotation.y, 0, 1, 0);
gl.glRotatef(obj.rotation.z, 0, 0, 1);
for(int i = 0; i < m.getFaceList().size();i++)
{
f = m.getFaceList().get(i);
gl.glColor3f(0.5f, 0.5f, 0.5f);
gl.glBegin(GL2.GL_POLYGON);
for(int j = 0;j < f.GetPolygonCount();j++)
{
v = m.getVertexList().get(f.GetPolygonByIndex(j).vertexIndex - 1);
t = m.getTexCordsList().get(f.GetPolygonByIndex(j).texcordIndex - 1);
n = m.getNormalList().get(f.GetPolygonByIndex(j).normalIndex - 1);
gl.glNormal3f(n.x, n.y, n.z);
gl.glTexCoord3f(t.u,t.v, t.w);
gl.glVertex3f(v.x, v.y, v.z);
}
gl.glEnd();
}
Code is based on open source OBJ loader in c++.
What i want:
http://img521.imageshack.us/img521/5181/wantp.jpg
What i get:
http://img171.imageshack.us/img171/645/getor.jpg
Baked texture:
http://img205.imageshack.us/img205/8562/bakedi.jpg
help!?