2013-10-11 37 views
2

我从http://heikobehrens.net/2009/08/27/obj2opengl/下载了banana.h文件。我在EAGLView.mm中包含了.h文件。我换成了EAGLView.mm文件。我遵循了用另一个3D模式取代茶壶的指示。但我没有得到任何替代产出。我不知道我做了错误不能用香蕉取代茶壶

namespace {  
    // Teapot texture filenames  
    const char* textureFilenames[] = {  
    "banana.jpg",  
    /* 

    "TextureTeapotBrass.png", 
    "TextureTeapotBlue.png", 
    "TextureTeapotRed.png" 
    */ 
    } 

    // Model scale factor 
    const float kObjectScale = 3.0f; 
} 

- (void) setup3dObjects  
{  
    // build the array of objects we want drawn and their texture  
    // in this example we have 3 targets and require 3 models 
    // but using the same underlying 3D model of a teapot, differentiated 
    // by using a different texture for each 

    for (int i=0; i < [textures count]; i++) 
    { 
     Object3D *obj3D = [[Object3D alloc] init]; 
    // obj3D.numVertices = NUM_TEAPOT_OBJECT_VERTEX; 

     obj3D.numVertices =bananaNumVerts; 
     obj3D.vertices = bananaVerts; 
     obj3D.normals = bananaNormals; 
     obj3D.texCoords = bananaTexCoords; 
     obj3D.numIndices = 0; 
     obj3D.indices = nil; 
     obj3D.texture = [textures objectAtIndex:i]; 

     [objects3D addObject:obj3D]; 
     [obj3D release]; 
    } 
} 

在renderFrame代替:

glVertexPointer(3, GL_FLOAT, 0, bananaVerts);  
glNormalPointer(GL_FLOAT, 0, bananaNormals); 
glTexCoordPointer(2, GL_FLOAT, 0, bananaTexCoords); 
glDrawArrays(GL_TRIANGLES, 0, bananaNumVerts); 

哪里我犯了一个错误?

+0

有一个关于此的讨论可能会帮助你:https://developer.vuforia.com/forum/ios/different-3d-model-not-shown(注意它从底部到顶部读取) – ashatte

回答

1

您的代码是正确的。尝试增加比例尺寸,因为你的模型可能非常小。更改

const float kObjectScale = 50.0f; // Scale up 

并且还使用.png格式进行纹理。