Hello everyone,
I am trying to load 20 planes like this:
-(void) createObjects{
for (int i=0; i<20; i++) {
CC3Texture *textureBack = [CC3Texture textureFromFile:[NSString stringWithFormat:@"%i_b.png",i]];
CC3MeshNode *backMesh = [CC3MeshNode node];
[backMesh populateAsCenteredTexturedRectangleWithSize: CGSizeMake(500.0,500.0) andTessellation: ccg(20, 20)];
backMesh.texture = textureBack;
[backMesh setName:[NSString stringWithFormat:@"Back Side %i",i]];
[backMesh alignInvertedTextures];
backMesh.location = cc3v(0.0, 0.0, i+10);
backMesh.isTouchEnabled = YES;
backMesh.shouldCullBackFaces = NO;
backMesh.uniformScale = 0.35;
CC3Texture *textureFront = [CC3Texture textureFromFile:[NSString stringWithFormat:@"%i_f.png",i]];
CC3MeshNode *frontMesh = [CC3MeshNode node];
[frontMesh populateAsCenteredTexturedRectangleWithSize: CGSizeMake(500.0,500.0) andTessellation: ccg(20, 20)];
frontMesh.texture = textureFront;
[frontMesh setName:[NSString stringWithFormat:@"Front Side %i",i]];
[frontMesh alignInvertedTextures];
frontMesh.location = cc3v(0.0, 0.0, i+10);
frontMesh.isTouchEnabled = YES;
frontMesh.shouldCullBackFaces = YES;
frontMesh.uniformScale = 0.35;
[self addChild:backMesh];
[self addChild:frontMesh];
}
}
I am using two meshes (Back and Front) because each object has two different textures and I want to change the vertices directly.
I initialize my world here:
-(void) initializeWorld {
// Create the camera, place it back a bit, and add it to the world
CC3Camera* cam = [CC3Camera nodeWithName: @"Camera"];
cam.location = cc3v( -100.0, 0.0, 500.0 );
cam.shouldTrackTarget = YES;
[self addChild: cam];
// Create a light, place it back and to the left at a specific
// position (not just directional lighting), and add it to the world
self.ambientLight = kCCC4FBlackTransparent;
// Improve performance by avoiding clearing the depth buffer when transitioning
// between 2D content and 3D content.
self.shouldClearDepthBufferBefore2D = NO;
self.shouldClearDepthBufferBefore3D = NO;
// There are no translucent nodes that need to be reordered.
self.drawingSequencer = [CC3NodeArraySequencer sequencerWithEvaluator: [CC3LocalContentNodeAcceptor evaluator]];
self.drawingSequencer.allowSequenceUpdates = NO;
[self createObjects];
}
The problem is that although I explicitly declare that each object should be at a certain distance (stack) , all objects appear on the same plane. What am I doing wrong? Do you think I mess up with the transformation matrix? Any ideas would be really appreciated.
Thanks,
Alex