0

我正在尝试使用 ISGL3D 框架将 POD 文件 3d 对象(从 Blender 导出)导入我的 ipad。我没有收到任何错误,但我的 ipad 只显示黑屏。我尝试逐行调试,似乎是相机问题。

这是我在 HelloWorldView 中的代码:

- (id) init {

if ((self = [super init])) {

    container = [[self.scene createNode] retain];

    // Import pod data
    _podImporter = [Isgl3dPODImporter podImporterWithFile:@"ee.pod"];
    Isgl3dLight * light  = [Isgl3dLight lightWithHexColor:@"000000" diffuseColor:@"FFFFFF" specularColor:@"FFFFFF" attenuation:0.001];
    light.position = iv3(0, 0, 2);
    light.renderLight = YES;
    [container addChild:light];
///Problem seems to start from below
    [self.camera removeFromParent];
    self.camera = [_podImporter cameraAtIndex:0];
    [self.scene addChild:self.camera];


    role01 = [_podImporter meshNodeWithName:@"Sphere"];
    [vound addChild:role01];

    [self schedule:@selector(tick:)];
}
return self;}

我试图在没有 _podImporter 相机的情况下仅添加 3d 对象,但我得到异常,它无法找到我的 3d 对象。请帮忙,谢谢!

4

1 回答 1

0

我花了一段时间才发现问题:

我错过了这段代码:

[_podImporter buildSceneObjects];

所以让 podImporter 工作的正确代码是

- (id) init {

if ((self = [super init])) {

container = [[self.scene createNode] retain];

// Import pod data
_podImporter = [Isgl3dPODImporter podImporterWithFile:@"ee.pod"];

[_podImporter buildSceneObjects];///<--- Put it here or anywhere before the camera code

Isgl3dLight * light  = [Isgl3dLight lightWithHexColor:@"000000" diffuseColor:@"FFFFFF" specularColor:@"FFFFFF" attenuation:0.001];
light.position = iv3(0, 0, 2);
light.renderLight = YES;
[container addChild:light];
[self.camera removeFromParent];
self.camera = [_podImporter cameraAtIndex:0];
[self.scene addChild:self.camera];


role01 = [_podImporter meshNodeWithName:@"Sphere"];
[vound addChild:role01];

[self schedule:@selector(tick:)];

} 返回自我;}

于 2013-04-25T16:59:10.363 回答