I am struggling with creating mesh objects programmatically. This is perfectly working:
CC3MeshNode *pMeshBox = [[CC3MeshNode alloc] init];
[pMeshBox populateAsCenteredRectangleWithSize:CGSizeMake(3, 3) andTessellation:ccg(5, 0)]; // AsSphereWithRadius:1 andTessellation:ccg(5, 0)]; // edges, rounded-corners
[self addChild:pMeshBox];
[pMeshBox release];
But this does not show anything (I expect a flat square of height 0 which and spawns in x/z direction).
float fPolygonVertices[] = {
-3, 0, 3,
3, 0, 3,
3, 0, -3,
-3, 0, -3
};
CC3VertexLocations* pvlPolygon = [CC3VertexLocations vertexArrayWithName: @"PolygonVL"];
pvlPolygon.vertexCount = 4;
pvlPolygon.vertices = fPolygonVertices;
CC3VertexArrayMesh* pvamPolygon = [CC3VertexArrayMesh meshWithName:@"PolygonM"];
pvamPolygon.vertexLocations = pvlPolygon;
CC3MeshNode *pMeshNode = [[CC3MeshNode alloc] init];
pMeshNode.mesh = pvamPolygon;
ccColor3B color = { 50, 0, 200 };
pMeshNode.color = color;
[self addChild:pMeshNode];
[pMeshNode release];
I assume camera setting and everything else is correct as the scene shows the populateAsCenteredRectangleWithSize created object...
I tried various color and material settings but without luck.