简体   繁体   English

如何在2D OpenGL场景中获得绝对平移

[英]how to get the absolute translation in a 2D opengl es scene

I have a pannable/zoomable image rendered in a 2d opengl es 1.1. 我在2d opengl es 1.1中渲染了一个可缩放/缩放的图像。 After zooming, how can i get the absolute position from the left side of the image to the left side of my viewable area? 缩放后,如何获得从图像左侧到可见区域左侧的绝对位置? Heres an image to clarify what i mean: 继承人的形象,以澄清我的意思是:

在此处输入图片说明

Well I don't know much about IOS, but logically speaking, depending on where the origin is and how your image is being drawn onto the screen, you could just calculate the distance from the x position of the image. 我对IOS不太了解,但是从逻辑上讲,根据原点在哪里以及图像在屏幕上的绘制方式,您只需计算与图像x位置的距离即可。 For instance, if your origin is on the top left of the screen (0,0), and your image is being drawn from the top left (eg. (-10, 0)), then your distance would simply be the absolute value of the x position of your image (eg. 10 units). 例如,如果您的原点位于屏幕的左上角(0,0),并且图像是从左上角绘制的(例如(-10,0)),则您的距离将仅仅是绝对值图片x位置的位置(例如10个单位)。 However, if your origin was lets say, at the center, then you would have to take the screen size into account and subtract half of the width to achieve the distance. 但是,如果说您的原点在中心,那么您就必须考虑屏幕尺寸并减去一半的宽度才能获得距离。 It may sound confusing but it should just be basic math. 这听起来可能令人困惑,但它应该只是基础数学。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM