c-Render.h Blender导出到带有openGL ES 1.1的iPhone



我有一个使用Jeff LaMarche.h导出脚本导出的搅拌机图像。我正在尝试让它在OpenGL ES 1.1中渲染。我认为我没有正确传递顶点、法线和纹理坐标。有人能帮我吗。这是我的东西。

这是包含顶点等的.h文件。

struct vertexDataTextured
{
    GLKVector3      vertex;
    GLKVector3      normal;
    GLKVector2      texCoord;
};
typedef struct vertexDataTextured vertexDataTextured;
typedef vertexDataTextured* vertexDataTexturedPtr;

static const vertexDataTextured MeshVertexData[] = {
    {/*v:*/{0.351562, 0.828125, -0.242188}, /*n:*/{0.183599, 0.982971, 0.005310}, /*t:*/{0.199397, 0.671493}},
    {/*v:*/{0.445312, 0.781250, -0.156250}, /*n:*/{0.715171, 0.222724, 0.662465}, /*t:*/{0.216226, 0.665719}},
    {/*v:*/{0.476562, 0.773438, -0.242188}, /*n:*/{0.964446, 0.263863, 0.012665}, /*t:*/{0.216737, 0.679097}},
    {/*v:*/{-0.476562, 0.773438, -0.242188}, /*n:*/{-0.964446, 0.263863, 0.012665}, /*t:*/{0.052251, 0.677297}},
    {/*v:*/{-0.445312, 0.781250, -0.156250}, /*n:*/{-0.715171, 0.222724, 0.662465}, /*t:*/{0.053356, 0.663955}},

这是我的绘图代码

glClearColor(1.0f, 1.0f, 0.0f, 1.0f); 
glClear(GL_COLOR_BUFFER_BIT); 

glMatrixMode(GL_MODELVIEW); 
glLoadIdentity(); 
glTranslatef(0.0f,-0.3f,-0.5f);

glVertexPointer(3, GL_FLOAT, 0, MeshVertexData); 
glEnableClientState(GL_VERTEX_ARRAY); 

glNormalPointer(GL_FLOAT, 0 , MeshVertexData);
glEnableClientState(GL_NORMAL_ARRAY);

glEnable(GL_TEXTURE_2D);                                             
glEnable(GL_BLEND);                                                  
glTexCoordPointer(2, GL_FLOAT,0,MeshVertexData);                      
glEnableClientState(GL_TEXTURE_COORD_ARRAY);                        
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); 
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); 
//glTranslatef(0.0f,-1.0f,-1.5f); 
glDrawArrays(GL_TRIANGLES, 0, sizeof(MeshVertexData)/ sizeof(vertexDataTextured));                               

glDisableClientState(GL_VERTEX_ARRAY); 
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); 

基本上,我的屏幕上到处都是三角形。非常感谢对N00B的任何帮助。感谢

您将步幅设置为0。它应该是sizeof (vertexDataTextured)。它告诉OpenGL一个顶点(或法线或纹理坐标)和下一个顶点之间有多少字节。

相关内容

  • 没有找到相关文章

最新更新