3D 图形中没有填充的球体
我想画一个立方体和像这样的圆形(没有填充的球体)。我正在使用 OpenTK
http://farm7.static.flickr.com/6074/6097051938_cb0b798ce0_z。 jpg
我一直遇到如下问题: 我尝试在立方体的顶部画一个圆圈。但是当我们旋转立方体和圆时,圆就变成了椭圆。
我尝试画球体而不是圆。但无法做到如上图所示。 有人有解决办法吗?提前致谢!
这是我的 http://farm7.static.flickr.com/6061/6096573967_22d56b2c2a_z.jpg
I want to draw a cube and circles like this (sphere without fill). I'm using OpenTK
http://farm7.static.flickr.com/6074/6097051938_cb0b798ce0_z.jpg
I've been having issue as below:
I've try to draw a circle at the top of Cube. But when we rotate Oy the cube and the circle, the circle become Ellipse.
I've try to draw sphere instead circle. But can not make it like the image above.
Anybody have the solution? Thanks in advance!
And this is mine
http://farm7.static.flickr.com/6061/6096573967_22d56b2c2a_z.jpg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
画一个始终面向相机的圆,画圆很容易。只需创建一个顶点环并使用 GL_LINE_STRIP 来绘制它。
创建一个始终看着相机的变换矩阵有点复杂。这是执行此操作的代码。只需将其设置为您的世界矩阵即可。
如果您知道矩阵是如何工作的,您应该能够弄清楚它是如何工作的;)。否则不用担心,实施它应该不会有问题。
Draw a circle that always faces the camera, drawing a circle is easy. Just create a ring of vertices and use GL_LINE_STRIP to draw it.
Creating a transformation matrix that always looks at the camera is a bit involved. Here is the code that does this. Simply set this one as your world matrix.
If you know how matricies work, you should be able to figure it how it works ;). Otherwise don't worry about it, you shouldn't have a problem implementing it.
在 2D 平面上画一个圆。
使用特殊的 2D 变换,由于这些只是看起来像金属丝网的渲染图并且颜色全部相同,因此您可以最后绘制 2D 部分。
所以:
我假设你希望圆的形状和大小保持不变,无论立方体如何旋转。
这可能会帮助您开始:
http://www.opentk.com/node/2478
这将是到目前为止比尝试让它帮助您绘制球体(甚至是无阴影的球体)更快。
Draw a circle on a 2D plane.
Use a special 2D transform, and since these are just wire mesh looking renderings and all the same color, you can draw the 2D part last.
So:
Im assuming you want the circles to be constant shape and size, no matter the rotation of the cube.
This may help get you started:
http://www.opentk.com/node/2478
This will be by far faster than attempting to let it help you draw a sphere, even an unshaded one.