我正在開發一個只繪製3D立方體的iPad應用程序。用戶可以用手指移動它,並可以通過捏住它來放大/縮小。確定3D立方體的表面
現在我在同一時間着色整個立方體(每個表面)。現在,如果我想要用戶分別對立方體的每個表面着色,意味着用戶將點擊一個表面,並且它只會着色該表面,但我不知道如何識別該表面用戶已經挖掘了哪些表面。
我正在繪製整個立方體簡單的openGL基礎如下。
static const GLfloat cubeVertices[] = {
-1.0, -1.0, 1.0,
1.0, -1.0, 1.0,
1.0, 1.0, 1.0,
-1.0, 1.0, 1.0,
-1.0, -1.0, -1.0,
1.0, -1.0, -1.0,
1.0, 1.0, -1.0,
-1.0, 1.0, -1.0,
};
static const GLushort cubeIndicesFaceFront[] = {
0, 1, 2, 3, 0
};
static const GLushort cubeIndicesFaceBack[] = {
4, 5, 6, 7, 4
};
static const GLushort cubeIndicesFaceLeft[] = {
0, 4, 7, 3, 0
};
static const GLushort cubeIndicesFaceRight[] = {
1, 5, 6, 2, 1
};
static const GLushort cubeIndicesFaceTop[] = {
3, 2, 6, 7, 3
};
static const GLushort cubeIndicesFaceBottom[] = {
0, 1, 5, 4, 0
};
static const GLubyte cubeColors[] = {
0, 255, 255, 255,
0, 255, 255, 255,
0, 255, 255, 255,
0, 255, 255, 255,
0, 255, 255, 255,
};
glVertexPointer(3, GL_FLOAT, 0, cubeVertices);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, cubeColors);
glEnableClientState(GL_COLOR_ARRAY);
glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceFront);
glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceBack);
glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceLeft);
glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceRight);
glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceTop);
glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceBottom);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
在此先感謝....讚賞您的支持。
謝謝....就這一工作。我認爲這將是一個漫長的過程 – rohanparekh 2010-07-22 05:00:57