如何检测 iphone GLKit 3d 对象上的触摸位置?
如果它在物体上?在哪里?
我有由三角形构建的立方体,即使它在对象上,我也需要知道触摸,如果是,在哪里
我的立方体:
const Vertex Vertices[] = {
// Front - red
{{1, -1, 1}, {0.89, 0, 0, 1}, {1, 0}},
{{1, 1, 1}, {0.89, 0, 0, 1}, {1, 1}},
{{-1, 1, 1}, {0.89, 0, 0, 1}, {0, 1}},
{{-1, -1, 1}, {0.89, 0, 0, 1}, {0, 0}},
// Back - green
{{1, 1, -1}, {0, 0.92, 0, 1}, {0, 1}},
{{-1, -1, -1}, {0, 0.92, 0, 1}, {1, 0}},
{{1, -1, -1}, {0, 0.92, 0, 1}, {0, 0}},
{{-1, 1, -1}, {0, 0.92, 0, 1}, {1, 1}},
// Left - yellow
{{-1, -1, 1}, {1, 0.92, 0, 1}, {1, 0}},
{{-1, 1, 1}, {1, 0.92, 0, 1}, {1, 1}},
{{-1, 1, -1}, {1, 0.92, 0, 1}, {0, 1}},
{{-1, -1, -1}, {1, 0.92, 0, 1}, {0, 0}},
// Right - blue
{{1, -1, -1}, {0, 0, 0.89, 1}, {1, 0}},
{{1, 1, -1}, {0, 0, 0.89, 1}, {1, 1}},
{{1, 1, 1}, {0, 0, 0.89, 1}, {0, 1}},
{{1, -1, 1}, {0, 0, 0.89, 1}, {0, 0}},
// Top
{{1, 1, 1}, {0.35, 0.35, 0.35, 1}, {1, 0}},
{{1, 1, -1}, {0.35, 0.35, 0.35, 1}, {1, 1}},
{{-1, 1, -1},{0.35, 0.35, 0.35, 1}, {0, 1}},
{{-1, 1, 1}, {0.35, 0.35, 0.35, 1}, {0, 0}},
// Bottom
{{1, -1, -1}, {0.35, 0.35, 0.35, 1}, {1, 0}},
{{1, -1, 1}, {0.35, 0.35, 0.35, 1}, {1, 1}},
{{-1, -1, 1}, {0.35, 0.35, 0.35, 1}, {0, 1}},
{{-1, -1, -1}, {0.35, 0.35, 0.35, 1}, {0, 0}}
};
const GLubyte Indices[] = { // 前 0, 1, 2, 2, 3, 0, // 后 4, 6, 5, 4, 5, 7, // 左 8, 9, 10, 10, 11, 8, // 右 12, 13, 14, 14, 15, 12, // 上 16, 17, 18, 18, 19, 16, // 下 20, 21, 22, 22, 23, 20 };