如何不每次我想创建一个CC3MeshNode时导入新的POD文件



在cocos3d中,我想复制一个来自.POD 文件 (earth.pod)。这就是我制作 1 的方式:

[self addContentFromPODFile: @"earth.pod"];
CC3MeshNode* earth = (CC3MeshNode*)[self getNodeNamed: @"Sphere"];
[earth setRotation:cc3v(0.0, 0.0, 0.0)];
CCActionInterval* rotate = [CC3RotateBy actionWithDuration: 1.0
                                                       rotateBy: cc3v(0.0, 30.0, 5.0)];
[earth runAction: [CCRepeatForever actionWithAction: rotate]];
earth.location = cc3v(0, 0, 0);

现在我想创造第二个地球:

CC3MeshNode* earth2 = (CC3MeshNode*)[self getNodeNamed: @"Sphere"];
[earth2 setRotation:cc3v(0.0, 0.0, 0.0)];
CCActionInterval* rotate2 = [CC3RotateBy actionWithDuration: 1.0
                                                       rotateBy: cc3v(0.0, 30.0, 5.0)];
[earth runAction: [CCRepeatForever actionWithAction: rotate2]];
earth2.location = cc3v(5, 0, 0);

但这摆脱了原版。如何从可以复制的 POD 文件创建 CC3MeshNode?

谢谢:)

CC3MeshNode* earth2 = [(CC3MeshNode*)[self getNodeNamed: @"Sphere"] copyAutorelease];

你应该能够执行以下操作:

CC3PODResourceNode *resourceNode = [CC3PODResourceNode nodeFromFile: @"earth.pod"];
CC3MeshNode *meshNode1 = [resourceNode getMeshNodeNamed: @"Sphere"];
CC3MeshNode *meshNode2 = [meshNode1 copyWithName: @"Sphere2"];

相关内容

  • 没有找到相关文章

最新更新