简体   繁体   English

在时间T,位置x,y处的多边形

[英]Polygon at position x,y at time T

I am trying to make polygon A be at position (x,y) at time= 1 sec for example. 例如,我试图使多边形A在时间= 1秒处位于(x,y)位置。 Then it should be at position (x,y+2) when time = 2 sec. 然后,当时间= 2秒时,它应该在位置(x,y + 2)。 Then I plan to make more polygons like this. 然后,我计划制作更多这样的多边形。 I also want this to be animated and the polygon to smoothly move from the first position to the second, not a polygon jumping a round. 我也希望它能被动画化,并且多边形可以从第一个位置平稳地移动到第二个位置,而不是一个多边形跳出一个圆。

Now thus far, I have learned about the glutTimerFunction, however, from my understanding, I cannot individually tell polygons to be at position (x,y) and time T. But rather it seems like I have to make every polygon that i desire(around 500) and then have timer cycle through all the polygons at once. 到目前为止,我已经了解了glutTimerFunction,但是,根据我的理解,我无法单独告诉多边形处于位置(x,y)和时间T。但是似乎我必须制作我想要的每个多边形(大约500),然后让计时器一次遍历所有多边形。

Is there a way to explicitly tell the polygon to be at position (x,y) at time T using the glutTimerFunc? 有没有办法使用glutTimerFunc明确告诉多边形在时间T处在(x,y)位置?

OpenGL is a low level API, not an engine or a framework. OpenGL是一种低级API,不是引擎或框架。 It has no built-in method for automatically doing interpolation between positions over time, that's up to you as the engine writer to implement as you see fit. 它没有内置的方法可以随时间自动在位置之间进行插值,这取决于引擎编写者根据自己的意愿实施。 Linear interpolation between two points over time is fairly easy (ie, in pseudocode position = startPos + ((endPos - startPos) * timeElapsed ). Interpolation along a more complex curve is essentially the same, just the math is a little more involved to represent the desired curve. 随着时间的推移,两点之间的线性插值相当容易(即,在伪代码position = startPos + ((endPos - startPos) * timeElapsed )。沿着更复杂的曲线进行插值本质上是相同的,只是position = startPos + ((endPos - startPos) * timeElapsed更多的数学来表示所需的曲线。

You are correct that you must iterate through all of your polygons by hand and position them. 正确的是,您必须手动遍历所有多边形并将其放置。 This is another feature of using the low level graphics API instead of a pre-written engine. 这是使用低级图形API而不是预先编写的引擎的另一个功能。

There are a number of engines of varying complexity (and price) available that abstract away these details for you, however, if your goal is to learn graphics programming I would suggest shying away from them and plowing through. 有许多具有不同复杂性(和价格)的引擎可以为您抽象这些细节,但是,如果您的目标是学习图形编程,我建议您不要使用它们并进行研究。

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

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