解释Processing中的TexturedSphere示例
Processing 项目网站有一个实施 具有旋转功能的 3D 纹理球体。我试图理解代码,但由于我没有图形背景,所以我无法理解许多代码块。
对每个块试图完成的任务的任何更高级别的解释(也许引用相关算法)都将使我能够阅读这些概念并更好地理解实现。
The Processing project website has an example of implementing a 3D textured sphere with rotational capabilities. I'm trying to understand the code, but I'm having trouble comprehending many of the code blocks since I don't have a background in graphics.
Any higher-level explanation of what each block is trying to accomplish, perhaps referencing the relevant algorithm, would allow me to read up on the concepts and better understand the implementation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看了几分钟代码后,我想说每次重新绘制图像时,处理运行时系统都会调用draw()函数。这只是绘制黑色背景,然后使用 renderGlobe() 函数渲染地球。
renderGlobe()函数设置了绘制地球仪的环境、计算位置、打开灯光、设置纹理为IMAGE等,然后调用texturedSphere来绘制地球仪。之后,它会清理并调整下一次的位置变量。
initializeSphere() 函数计算球体的顶点位置。这是简单的三角学。
texturedSphere() 函数绘制球体。首先它画了南冠,它实际上是一个圆锥体,一个非常扁平的圆锥体。接下来,它为球体的每个部分绘制环,然后在其顶部绘制另一个圆锥体作为北盖。
虽然我还没有浏览处理学习材料,但标题表明,如果您从头开始,并按顺序尝试所有内容,您将很容易理解这段代码。
After just a few minutes looking at the code, I'd say the draw() function is called by the Processing runtime system each time the image should be redrawn. This just paints a black background, then renders the globe with the renderGlobe() function.
The renderGlobe() function sets up the environment for drawing the globe, calculating position, turing on lights, setting the texture to IMAGE, etc. Then it calls texturedSphere to draw the globe. After that, it cleans up and adjusts the position variables for the next time through.
The initializeSphere() function calculates the vertex locations for the sphere. This is simple trigonometry.
The texturedSphere() function draws the sphere. First it draws the southern cap, which is really a cone, a very flat cone. Next it draws rings for each section of the sphere, and then tops it off with another cone for the northern cap.
Although I haven't gone through the Processing learning materials, the headings indicate that if you start from the beginning, and try everything in order, you'll easily understand this code.