跪求一个OpenGL的编程~~编一个3D的球体,有光照阴影,200+行,发我邮箱里,谢~
跪求一个OpenGL的编程~~编一个3D的球体,有光照阴影,200+行~~!!其实可以有其他的东西像旋转啦,缩放啦之类的,在保证光照阴影的前提下随便加~~不过不要太多。。...
跪求一个OpenGL的编程~~编一个3D的球体,有光照阴影,200+行~~!!
其实可以有其他的东西像旋转啦,缩放啦之类的,在保证光照阴影的前提下随便加~~不过不要太多。。。
亲们,一定要200+行啊~~!!
最好每步都有解释,声明:我是小白。。。不过有书可以查,但我还是小白。。。
所有财富值奉上~~~!!!谢过各位大神啦~~!!!
邮箱:lmeat@sina.com~~~~
再次感谢大神~~
^_^ 展开
其实可以有其他的东西像旋转啦,缩放啦之类的,在保证光照阴影的前提下随便加~~不过不要太多。。。
亲们,一定要200+行啊~~!!
最好每步都有解释,声明:我是小白。。。不过有书可以查,但我还是小白。。。
所有财富值奉上~~~!!!谢过各位大神啦~~!!!
邮箱:lmeat@sina.com~~~~
再次感谢大神~~
^_^ 展开
2个回答
展开全部
《NEHE的教程》上有那么多例子可以供你参考。。
追问
我勒个去。。。我是小白。。。我要是有时间就自己学了。。。我也想学啊,可是没时间啊。。。现在为了这玩意通宵了三个晚上了,伤不起了。。。。跪求啊。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
static public void drawShere(GL10 gl) {
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glRotatef(NoRenderer.xrot, 1, 0, 0);
gl.glRotatef(NoRenderer.yrot, 0, 1, 0);
gl.glEnable(GL10.GL_CULL_FACE);
gl.glShadeModel(GL10.GL_FLAT);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);
gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
gl.glPointSize(2);
if (shareOrgVertice == null) {
shareOrgVertice = ByteBuffer
.allocateDirect(shareVerBufSize * 8 * 2)
.order(ByteOrder.nativeOrder()).asDoubleBuffer();
for (int angle = 0; angle <= shareAngleDesity; angle++) {
double xAngle = shareAngleRange * angle / shareAngleDesity;
double x = Math.cos(xAngle);
double z = Math.sin(xAngle);
shareOrgVertice.put(new double[] { +x, +z });
}
}
if (shareVertice == null)
shareVertice = ByteBuffer.allocateDirect(shareVerBufSize * 4 * 3)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
shareVertice.position(0);
for (int heightStep = -shareHeightDesity; heightStep <= shareHeightDesity; heightStep++) {
double y = R
* Math.sin(heightStep * Math.PI / shareHeightDesity / 2);
double y1 = R
* Math.sin((heightStep + 1) * Math.PI / shareHeightDesity
/ 2);
double r = Math.sqrt(R * R - y * y);
double r1 = Math.sqrt(R * R - y1 * y1);
for (int angleStep = 0; angleStep <= shareAngleDesity; angleStep++) {
float x = (float) (r * shareOrgVertice.get(2 * angleStep));
float z = (float) (r * shareOrgVertice.get(2 * angleStep + 1));
float x1 = (float) (r1 * shareOrgVertice.get(2 * angleStep));
float z1 = (float) (r1 * shareOrgVertice.get(2 * angleStep + 1));
shareVertice.put(new float[] { x, (float) y, z });
shareVertice.put(new float[] { x1, (float) y1, z1 });
}
if (shareVertice.position() == shareVertice.capacity()) {
shareVertice.position(0);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, shareVertice);
gl.glColorPointer(3, GL10.GL_FLOAT, 0, shareVertice);
gl.glNormalPointer(GL10.GL_FLOAT, 0, shareVertice);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0,
shareVertice.capacity() / 3);
} else {
Log.e("hjx", "ERROR->position:" + shareVertice.position()
+ "capacity:" + shareVertice.capacity());
}
}
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDisableClientState(GL10.GL_NORMAL_ARRAY);
gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
}
按经纬度,一圈圈来.20分,只能给你这么多.
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glRotatef(NoRenderer.xrot, 1, 0, 0);
gl.glRotatef(NoRenderer.yrot, 0, 1, 0);
gl.glEnable(GL10.GL_CULL_FACE);
gl.glShadeModel(GL10.GL_FLAT);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);
gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
gl.glPointSize(2);
if (shareOrgVertice == null) {
shareOrgVertice = ByteBuffer
.allocateDirect(shareVerBufSize * 8 * 2)
.order(ByteOrder.nativeOrder()).asDoubleBuffer();
for (int angle = 0; angle <= shareAngleDesity; angle++) {
double xAngle = shareAngleRange * angle / shareAngleDesity;
double x = Math.cos(xAngle);
double z = Math.sin(xAngle);
shareOrgVertice.put(new double[] { +x, +z });
}
}
if (shareVertice == null)
shareVertice = ByteBuffer.allocateDirect(shareVerBufSize * 4 * 3)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
shareVertice.position(0);
for (int heightStep = -shareHeightDesity; heightStep <= shareHeightDesity; heightStep++) {
double y = R
* Math.sin(heightStep * Math.PI / shareHeightDesity / 2);
double y1 = R
* Math.sin((heightStep + 1) * Math.PI / shareHeightDesity
/ 2);
double r = Math.sqrt(R * R - y * y);
double r1 = Math.sqrt(R * R - y1 * y1);
for (int angleStep = 0; angleStep <= shareAngleDesity; angleStep++) {
float x = (float) (r * shareOrgVertice.get(2 * angleStep));
float z = (float) (r * shareOrgVertice.get(2 * angleStep + 1));
float x1 = (float) (r1 * shareOrgVertice.get(2 * angleStep));
float z1 = (float) (r1 * shareOrgVertice.get(2 * angleStep + 1));
shareVertice.put(new float[] { x, (float) y, z });
shareVertice.put(new float[] { x1, (float) y1, z1 });
}
if (shareVertice.position() == shareVertice.capacity()) {
shareVertice.position(0);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, shareVertice);
gl.glColorPointer(3, GL10.GL_FLOAT, 0, shareVertice);
gl.glNormalPointer(GL10.GL_FLOAT, 0, shareVertice);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0,
shareVertice.capacity() / 3);
} else {
Log.e("hjx", "ERROR->position:" + shareVertice.position()
+ "capacity:" + shareVertice.capacity());
}
}
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDisableClientState(GL10.GL_NORMAL_ARRAY);
gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
}
按经纬度,一圈圈来.20分,只能给你这么多.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询