SceneKit: custom scene a half of sphere, but have black point on the bottom, how to refine this point?

685 Views Asked by At

half of sphere by using "geometrySourceWithData" CODE like:

NSData *indicesData = [NSData dataWithBytes:indices
                                     length:sizeof(indices)*indexCount];
SCNGeometryElement *indicesElement = [SCNGeometryElement
                                      geometryElementWithData:indicesData
                                      primitiveType:SCNGeometryPrimitiveTypeTriangleStrip
                                      primitiveCount:indexCount
                                      bytesPerIndex:sizeof(int)];

NSMutableData *vertexData = [NSMutableData 
                             dataWithBytes:vertices 
                             length:pointCount * sizeof(SCNVector3)];

SCNGeometrySource *verticesSource = 
[SCNGeometrySource geometrySourceWithData:vertexData
                                 semantic:SCNGeometrySourceSemanticVertex
                              vectorCount:pointCount
                          floatComponents:YES
                      componentsPerVector:3
                        bytesPerComponent:sizeof(float)
                               dataOffset:0
                               dataStride:sizeof(SCNVector3)];

NSMutableData *normalData = [NSMutableData dataWithBytes:normals
                                                  length:pointCount * sizeof(SCNVector3)];

SCNGeometrySource *normalsSource = [SCNGeometrySource 
                                    geometrySourceWithData:normalData
                                    semantic:SCNGeometrySourceSemanticNormal
                                    vectorCount:pointCount
                                    floatComponents:YES
                                    componentsPerVector:3
                                    bytesPerComponent:sizeof(float)
                                    dataOffset:0
                                    dataStride:sizeof(SCNVector3)];

NSMutableData *textureData = [NSMutableData dataWithBytes:UVs 
                                                   length:pointCount * sizeof(float)*2.0];

SCNGeometrySource *textureSource = [SCNGeometrySource 
                                    geometrySourceWithData:textureData
                                    semantic:SCNGeometrySourceSemanticTexcoord
                                    vectorCount:pointCount
                                    floatComponents:YES
                                    componentsPerVector:2
                                    bytesPerComponent:sizeof(float)
                                    dataOffset:0
                                    dataStride:sizeof(float)*2.0];
SCNGeometry *geometry = [SCNGeometry 
                         geometryWithSources:@[verticesSource, normalsSource, textureSource]

                         elements:@[indicesElement]];


SCNMaterial *blueMaterial = [SCNMaterial material];
//  material.diffuse.contents = [UIColor redColor];
blueMaterial.diffuse.contents = image;
blueMaterial.diffuse.wrapS = SCNWrapModeRepeat;
blueMaterial.diffuse.wrapT = SCNWrapModeRepeat;
blueMaterial.diffuse.contentsTransform = SCNMatrix4MakeScale( 1.0f, 1.0f, 1.0f);
blueMaterial.doubleSided = YES;

NSMutableArray *array_ = [NSMutableArray array];

[array_ addObject:blueMaterial];

geometry.materials = array_;

SCNNode *geometryNode = [SCNNode nodeWithGeometry:geometry];

enter image description here

But have a big black point in the middle.

enter image description here

all sphere point like this pic:

enter image description here

or i have try to using SYSTEM sphere: and like: it is better then i create(custom sphere)

enter image description here

---------------------UPDATE 001

sphere_.segmentCount=100;
sphere_.firstMaterial.doubleSided = NO;
sphere_.firstMaterial.cullMode =SCNCullModeFront;

[sphere_ setGeodesic:NO];

set as NO LIKE:

enter image description here

set as YES LIKE: oh GOD!!!

[sphere_ setGeodesic:YES];

enter image description here

-------------------------------------------------UPDATE 20170116

The original pic: it is a half of sphere;

enter image description here

0

There are 0 best solutions below