나는 큐브과 같이 정의 있습니다OpenGL에서 큐브의 텍스처 좌표는 무엇입니까?
float vertices[] = { -width, -height, -depth, // 0
width, -height, -depth, // 1
width, height, -depth, // 2
-width, height, -depth, // 3
-width, -height, depth, // 4
width, -height, depth, // 5
width, height, depth, // 6
-width, height, depth // 7
};
와 나는 간단하게 원하는 이미지가 128x128 큐브와 아무것도의 6 개 각면에 그려진해야합니다. 그렇다면 텍스처는 무엇입니까? 나는 실제 가치가 필요하다.
short indices[] = { 0, 2, 1,
0, 3, 2,
1,2,6,
6,5,1,
4,5,6,
6,7,4,
2,3,6,
6,3,7,
0,7,3,
0,4,7,
0,1,5,
0,5,4
};
내가 인덱스 배열 텍스 좌표를 찾기 위해 필요한 경우 확실하지 않다 :
// Counter-clockwise winding.
gl.glFrontFace(GL10.GL_CCW);
// Enable face culling.
gl.glEnable(GL10.GL_CULL_FACE);
// What faces to remove with the face culling.
gl.glCullFace(GL10.GL_BACK);
// Enabled the vertices buffer for writing and to be used during
// rendering.
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
// Specifies the location and data format of an array of vertex
// coordinates to use when rendering.
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVerticesBuffer);
// Bind the texture according to the set texture filter
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[filter]);
gl.glEnable(GL10.GL_TEXTURE_2D);
// Enable the texture state
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
// Point to our buffers
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTextureBuffer);
// Set flat color
gl.glColor4f(red, green, blue, alpha);
gl.glDrawElements(GL10.GL_TRIANGLES, mNumOfIndices,
GL10.GL_UNSIGNED_SHORT, mIndicesBuffer);
// ALL the DRAWING IS DONE NOW
// Disable the vertices buffer.
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
// Disable face culling.
gl.glDisable(GL10.GL_CULL_FACE);
이 인덱스 배열 :
이
그리기 코드입니다. 내가 준 큐브 버텍스 배열은 인덱스 배열을 사용하는 큐브를 가장 효율적으로 표현한 것입니다. 큐브는 완벽하게 그려 지지만 텍스처는 그려지지 않습니다. 한 쪽만 올바른 그림을 보여 주지만 다른면은 엉망입니다. 텍스처에 대한 다양한 온라인 자습서에 설명 된 방법을 사용했지만 작동하지 않습니다.
당신은 아마 ... 너무 – ltjax
을 그리기 코드를 게시해야 위의 정보에서 기술적으로 올바른 tex 좌표는 몇 개입니까? tex 좌표로 말하면, tex 좌표 배열에서 1,0과 같은 2 차원 점을 의미합니다. – ace