Android:如何向屏幕添加多个对象(OpenGL)?
我正在使用一个模型查看器模板,该模板在屏幕中央显示 3D 立方体。我想要实现的目标是在屏幕上放置另一个较小的 3D 立方体,并且与主立方体处于不同的 XY 位置。因此,在视觉上,如果原始立方体位于中心,我想将第二个较小的立方体放置在右侧。
那么如何向屏幕添加另一个立方体、使其变小并更改其位置呢? 注意:我正在使用基本模板进行工作。
I'm working with a model viewer template that displays a 3D cube in the center of the screen. What I'm trying to achieve is put another, but smaller 3D cube on the screen and in a different XY position from the main. So visually, if the original cube is in the center, I would like to place the second smaller cube to the right.
So how do I add a another cube to the screen, make it smaller, and change its position?
Note: I'm working from a basic template.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为第二个对象分配不同的模型转换矩阵。
如果您使用固定管道进行渲染,那么就像调用 glMulMatrix 一样简单。
如果您使用着色器进行渲染,请将适当的矩阵作为统一的矩阵传递给顶点着色器。
以下是有关此主题的一些基本阅读内容:
Assign different model transformation matrix to second object.
If you are rendering with fixed pipeline, then it's as simple as calling glMulMatrix.
If you are rendering with shaders, then pass appropriate matrix as uniform to your vertex shader.
Here's some basic reading about this subject:
你有很多方法可以做到这一点。
我还猜测您涉及旋转(以便您的立方体显示其 3D 优点),因此转换的顺序非常重要。
如果您想进一步学习,您可以阅读 OpenGL 红皮书,该书可以在互联网上免费合法获取。第一章回答了您的所有问题。
You have a lot of ways to do this.
I'm also guessing that you have rotations involved (so that your cube is showing its 3D goodness), so the order of the transformations is really important.
If you want to study a little bit more, you might read the OpenGL red book, available legally for free on the internet. The first chapters answer all your questions.