星空屏保方程
对于那些不太记得旧版 Windows Starfield 屏幕保护程序是什么样子的人,这里有一个 YouTube 视频:http://www.youtube.com/watch?v=r5AoFiVs2ME
现在,我可以在一定半径内生成随机粒子(“星星”)。我遇到的困难是找出实现上述链接视频中所见受影响的最佳方法。
问题:假设我有随机生成的粒子的坐标(向量)。 为它们提供方向(矢量)的最佳方法和/或方程式是什么,以便它们以与旧屏幕保护程序中看到的方式非常相似的方式在屏幕上移动?< /strong>
谢谢!
For those of you who don't remember exactly what the old windows Starfield screensaver looked like, here's a YouTube video: http://www.youtube.com/watch?v=r5AoFiVs2ME
Right now, I can generate random particles ("stars") inside in a certain radius. What I've having trouble doing is figuring out the best way the achieve the affected seen in the afore-linked video.
Question: Given that I have the coordinates (vectors) for my randomly generated particles. What is the best way and/or equation to give them a direction (vector) so that they move across the screen in a way which closely resembles that which is seen in the old screensaver?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
他们似乎正在远离中心。您可以尝试计算从屏幕中心点到生成的粒子位置的矢量吗?然后用相同的方向移动粒子,并加速粒子,直到粒子出现在屏幕之外。
They seem to move away from the center. You could try to calculate the vector from the center point of the screen to the generated particle position? Then use the same direction to move the particle and accelerate the particle until it is outside the screen.
供您使用的基本算法:
在随机位置生成具有 3-D 高斯分布的星星(最有可能在屏幕中间,距离屏幕越远则不太可能)。请注意,星星的运动矢量是由该起始点决定的...运动将有效地沿着由原点和起始位置形成的线向外传播。
为每个新生成的星星分配一个距离。请注意,距离与起始位置无关。
以指数级增加的速度沿直线移动恒星,同时减小其距离。您必须自己调整这些参数。
无论速度如何,当星星穿过屏幕边界时,星星都应该消失。
A basic algorithm for you to work with:
Generate stars at random location, with a 3-D gaussian distribution (middle of screen most likely, less likely as you go farther from the screen). Note that the motion vector of the star is determined by this starting point... the motion will effectively travel along the line formed by the origin point and the starting location, outward.
Assign each newly generated star a distance. Note that distance is irrespective of starting location.
Move the star in a straight line at an exponentially increasing speed while simultaneously decreasing it's distance. You'll have to tweak these parameters yourself.
The star should disappear when it passes the boundary of the screen, regardless of speed.