Android OpenGLES 光照问题
嘿大家, 我正在为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从视频来看,您的法线似乎不正确。
对于轴对齐立方体,法线位于 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.你用
错了。
应该是:
You are using
wrong.
It should be: