OC SCNPlane播放视频

创建Game项目

引用#import<SpriteKit/SpriteKit.h>

以下全部代码:

    SCNScene *scene = [SCNScene sceneNamed:@"art.scnassets/ship.scn"];

    // create and add a camera to the scene

    SCNNode*cameraNode = [SCNNodenode];

    cameraNode.camera= [SCNCameracamera];

    [scene.rootNodeaddChildNode:cameraNode];

    // place the camera

    cameraNode.position=SCNVector3Make(0,0,15);


    // create and add a light to the scene

    SCNNode*lightNode = [SCNNodenode];

    lightNode.light= [SCNLightlight];

    lightNode.light.type = SCNLightTypeOmni;

    lightNode.position=SCNVector3Make(0,10,10);

    [scene.rootNodeaddChildNode:lightNode];


    // create and add an ambient light to the scene

    SCNNode*ambientLightNode = [SCNNodenode];

    ambientLightNode.light= [SCNLightlight];

    ambientLightNode.light.type = SCNLightTypeAmbient;

    ambientLightNode.light.color= [UIColordarkGrayColor];

    [scene.rootNodeaddChildNode:ambientLightNode];


    // retrieve the ship node

    SCNNode *ship = [scene.rootNode childNodeWithName:@"ship" recursively:YES];


    // animate the 3d object

    [shiprunAction:[SCNAction repeatActionForever:[SCNAction rotateByX:0 y:2 z:0 duration:1]]];


    // retrieve the SCNView

    SCNView*scnView = (SCNView*)self.view;


    // set the scene to the view

    scnView.scene= scene;


    // allows the user to manipulate the camera

    scnView.allowsCameraControl = YES;


    // show statistics such as fps and timing information

    scnView.showsStatistics=YES;

    // configure the view

    scnView.backgroundColor= [UIColorblackColor];


    // add a tap gesture recognizer

    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];

    NSMutableArray*gestureRecognizers = [NSMutableArrayarray];

    [gestureRecognizersaddObject:tapGesture];

    [gestureRecognizersaddObjectsFromArray:scnView.gestureRecognizers];

    scnView.gestureRecognizers= gestureRecognizers;



    SCNNode*boxNode = [SCNNodenode];

    SCNPlane*plane = [SCNPlaneplaneWithWidth:16height:9];

    boxNode.geometry= plane;

    [boxNode.geometry.firstMaterial setDoubleSided:YES];

    boxNode.position=SCNVector3Make(0,0, -15);

    boxNode.eulerAngles=SCNVector3Make(0,M_PI,0);

    [scnView.scene.rootNodeaddChildNode:boxNode];


    NSURL*url = [[NSBundlemainBundle]URLForResource:@"带你到中国宣传视频短版本的副本.mov"withExtension:nil];

    SKVideoNode * videoNode = [SKVideoNode videoNodeWithURL:url];

    videoNode.size=CGSizeMake(1600,900);

    videoNode.position=CGPointMake(videoNode.size.width/2.0, videoNode.size.height/2.0);

    videoNode.zRotation=M_PI;


    SKScene*skScene = [SKScenesceneWithSize:videoNode.size];

    [skSceneaddChild:videoNode];


    plane.firstMaterial.diffuse.contents = skScene;

    [videoNodeplay];


    scnView.allowsCameraControl = YES;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 使用SceneKit如何播放视频 scenekit 播放视频的方式有很多种,今天我就给大家介绍一种最简单的播放视频...
    笑啥风云阅读 918评论 0 0
  • hello ,大家好。最近接触到AR项目,对于我来说,是一窍不通,现在开始学习,并开始记录学习过程,以防止忘记(本...
    升哥_d84b阅读 2,138评论 0 5
  • 基于SceneKit,先导入SceneKit.framework 首先说一下本人对全景图的理解,所谓全景图,就是一...
    修罗大人阅读 2,796评论 2 2
  • 简介 增强现实技术(Augmented Reality,简称 AR),是一种实时地计算摄影机影像的位置及角度并加上...
    牛奈奈阅读 1,318评论 1 3
  • 第一次写简书,鉴于ARKit网上相关资料比较少,写一套实战教程,希望能帮到需要的人吧。表达能力捉急,写的不好的请留...
    脸狐阅读 573评论 0 0