Rendering a SceneKit scene to video output

前端 未结 4 662
隐瞒了意图╮
隐瞒了意图╮ 2020-12-12 23:17

As a primarily high-level/iOS dev, I\'m interested in using SceneKit for animation projects.

I\'ve been having fun with SceneKit for some months now, despite it obvi

4条回答
  •  甜味超标
    2020-12-12 23:45

    It would actually be pretty easy! Here's a pseudo code of how I would do it (on the SCNView):

    int numberOfFrames = 300;
    int currentFrame = 0;
    int framesPerSecond = 30;
    
    -(void) renderAFrame{
        [self renderAtTime:1/framesPerSecond];
    
        NSImage *frame = [self snapshot];
    
        // save the image with the frame number in the name such as f_001.png
    
        currentFrame++;
    
        if(currentFrame < numberOfFrames){
            [self renderAFrame];
        }
    
    }
    

    It will output you a sequence of images, rendered at 30 frames per second, that you can import in any editing software and convert to video.

提交回复
热议问题