Android OpenGLES 光照问题

发布于 2024-09-26 11:45:23 字数 1208 浏览 1 评论 0原文

嘿大家, 我正在为 android 编写一个小 3D 引擎,以更好地学习平台和 opengl。我希望最终能用它作为小型 3D 游戏的基础。

我现在正在尝试实现照明,并且通常遵循 NeHe opengl android 端口教程。我有一个简单的旋转立方体和 1 个不应改变位置的灯。在设备上渲染场景时,光线似乎会“变暗”,并随着立方体旋转而重新变亮。

这是该行为的 swf 视频: http://drop.io/obzfq4g

我的“引擎”的代码位于此处:http://github.com/mlasky/Smashout-Android-3D-Engine/

相关位是:

http:// /github.com/mlasky/Smashout-Android-3D-Engine/blob/master/src/com/supernovamobile/smashout/SmashoutGLRenderer.java
这是我初始化 opengl 并设置场景的地方。

http:// github.com/mlasky/Smashout-Android-3D-Engine/blob/master/src/com/supernovamobile/smashout/SMMesh.java 这是实际旋转/绘制立方体网格的代码。

我希望我能提出一个更好的问题;但我非常困惑/困惑,除了“有人知道什么可能导致我所看到的行为吗?”之外,我什至想不出一个明智的问题要问。

感谢您提供的任何帮助。

编辑:视频中动画的缓慢/断断续续也是屏幕截图软件的结果。在鸸鹋上的整个旋转过程中都很平稳。

Hey all,
I'm writing a little 3D engine for android to better learn the platform and opengl. I hope to eventually use it as a base for little 3D games.

I'm trying to implement lighting right now, and generally following the NeHe opengl android port tutorials. I have a simple spinning cube and 1 light that should not change position. Upon rendering my scene on a device the light appears to "dim" and re-lighten as cube rotates.

This is a swf video of the behavior:
http://drop.io/obzfq4g

The code for my "engine" is located here: http://github.com/mlasky/Smashout-Android-3D-Engine/

The relevant bits are:

http://github.com/mlasky/Smashout-Android-3D-Engine/blob/master/src/com/supernovamobile/smashout/SmashoutGLRenderer.java
this is where I'm initializing opengl and setting up my scene.

and

http://github.com/mlasky/Smashout-Android-3D-Engine/blob/master/src/com/supernovamobile/smashout/SMMesh.java
this is the code for actually rotating / drawing the cube mesh.

I wish I could formulate a better question; but I'm very stuck/confused and can't even think of an intelligent question to ask besides "does anyone know what might cause the kind of behavior I'm seeing?"

Thanks for any help you can provide.

Edit: Also the slowness / choppyness of the animation in the video is a result of the screencap software. It's smooth throughout the whole rotation on the emu.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

街道布景 2024-10-03 11:45:23

从视频来看,您的法线似乎不正确。

对于轴对齐立方体,法线位于 cube.xml 似乎关闭了。它们应该是轴对齐的,而不是无论它们是什么。你从哪里得到模型?

如果 mVNormalsBuffer 为空的。

From the video it looks like your normals are incorrect.

For an axis-aligned cube the normals in cube.xml seem off. They should be axis-aligned, not whatever they are. Where did you get the model?

This answer may also be related if mVNormalsBuffer is empty.

女中豪杰 2024-10-03 11:45:23

你用

gl.glNormalPointer(3, GL10.GL_FLOAT, mVNormalsBuffer);

错了。

应该是:

gl.glNormalPointer(GL10.GL_FLOAT,0, mVNormalsBuffer);

You are using

gl.glNormalPointer(3, GL10.GL_FLOAT, mVNormalsBuffer);

wrong.

It should be:

gl.glNormalPointer(GL10.GL_FLOAT,0, mVNormalsBuffer);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文