2
如何檢測iphone GLKit 3d對象上的觸摸位置?GLKit檢測觸摸位置
if it on the object? 和哪裏?
我有從三角形建立立方體,我需要知道觸摸即使是在對象上,如果是在那裏
我立方:
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}}
};
常量GLubyte指數[] = {// 前 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 20 };