OpenGL iOS屏幕坐标到场景坐标

时间:2015-05-19 16:09:40

标签: ios objective-c opengl-es coordinates glkit

我使用OpenGl制作一个小应用程序而我不知道如何获得触摸的string BloodReq = "insert into Blood_Request(R_Name,R_Phone,R_Blood_Group,R_City,R_Address,Date,Time) OUTPUT INSERTED.ID values (@Name,@cell,@BGroup,@City,@Address,@date,@time)" x , y坐标

例如:

z

这样我只能获得-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint touchPoint = [touch locationInView:[self view]]; float X = touchPoint.x; float Y = touchPoint.y; } x坐标,但我还需要y

1 个答案:

答案 0 :(得分:0)

您无法在OpenGL ES上读取z缓冲区。当我需要进行这种3D打击测试时,我已经在场景中投射了一条3D线并自己进行了击中测试。

对于Retina设备上的OpenGL,您需要将x和y乘以比例。要支持iPhone 6+,您需要在可用时使用nativeScale。

// Do this when setting up view controller and remember theScale.
if ([[UIScreen mainScreen] respondsToSelector:@selector(nativeScale)])
  theScale = [[UIScreen mainScreen] nativeScale];
else if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
  theScale = [[UIScreen mainScreen] scale];
else 
  theScale = 1.0;