Extracting vertices from scenekit

后端 未结 7 450
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 01:42

I\'m having a problem with understanding scenekit geometery.

I have the default cube from Blender, and I export as collada (DAE), and can bring it into scenekit....

7条回答
  •  猫巷女王i
    2020-12-03 02:17

    For someone like me want to extract data of face from SCNGeometryElement.

    Notice I only consider primtive type is triangle and index size is 2 or 4.

    void extractInfoFromGeoElement(NSString* scenePath){
        NSURL *url = [NSURL fileURLWithPath:scenePath];
        SCNScene *scene = [SCNScene sceneWithURL:url options:nil error:nil];
        SCNGeometry *geo = scene.rootNode.childNodes.firstObject.geometry;
        SCNGeometryElement *elem = geo.geometryElements.firstObject;
        NSInteger componentOfPrimitive = (elem.primitiveType == SCNGeometryPrimitiveTypeTriangles) ? 3 : 0;
        if (!componentOfPrimitive) {//TODO: Code deals with triangle primitive only
            return;
        }
        for (int i=0; i

提交回复
热议问题