- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试使用 Scenekit 将视频作为纹理映射到 VR 项目的原始圆柱体:嵌入 SKScene 中的 SKVideoNode 作为 SceneKit SCNTube 对象的纹理,但我无法显示视频就像静止图像一样。下面的 PLayground 代码应该生成映射到圆柱体的移动视频,但映射不起作用:
编辑:在列表末尾添加单行以修复。下面的代码应该可以工作
import UIKit
import SceneKit // for 3D mapping
import SpriteKit // for SKVideoNode
import QuartzCore // for basic animation
import XCPlayground // for live preview
import AVFoundation // for video playback engine
// create a scene view with an empty scene
var sceneView = SCNView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))
var scene = SCNScene()
sceneView.scene = scene
// start a live preview of that view
XCPShowView("The Scene View", view: sceneView)
// default lighting
sceneView.autoenablesDefaultLighting = true
// a geometry object
var tube = SCNTube(innerRadius: 1.99, outerRadius: 2, height: 3)
var tubeNode = SCNNode(geometry: tube)
scene.rootNode.addChildNode(tubeNode)
// video scene
let urlStr = NSBundle.mainBundle().pathForResource("sample", ofType: "mp4")
let url = NSURL(fileURLWithPath: urlStr!)
let asset = AVURLAsset(URL: url, options: nil)
let playerItem = AVPlayerItem(asset: asset)
let player = AVPlayer(playerItem: playerItem)
let videoNode = SKVideoNode(AVPlayer: player)
let spritescene = SKScene(size: CGSize(width: 1211, height: 431))
videoNode.size.width=spritescene.size.width
videoNode.size.height=spritescene.size.height
spritescene.addChild(videoNode)
// configure the geometry object
var myImage = UIImage.init(named: "BandImage.jpeg")
tube.firstMaterial?.diffuse.contents = spritescene
// set a rotation axis (no angle) to be able to
// use a nicer keypath below and avoid needing
// to wrap it in an NSValue
tubeNode.rotation = SCNVector4(x: 0.0, y: 1.0, z: 0.0, w: 0.0)
// animate the rotation of the torus
var spin = CABasicAnimation(keyPath: "rotation.w") // only animate the angle
spin.toValue = 2.0*M_PI
spin.duration = 3
spin.repeatCount = HUGE // for infinity
tubeNode.addAnimation(spin, forKey: "spin around")
// starts the video, solving the issue
sceneView.playing = true
最佳答案
我已经在 github 上发布了我的代码(和一些示例全景内容),供任何想要工作示例代码或有兴趣在开源全景视频播放器上进行协作的人使用:
https://github.com/jglasse/OSVR
事实证明,模拟器(和 Playground )似乎不支持此功能。将上面的代码移动到一个项目并在设备上运行,我终于让它工作了。
所以故事的寓意是 - 如果您使用 SKVideoNodes 作为 Scenekit 的纹理,请使用实际设备进行测试。
关于ios - SKVideoNode(嵌入在 SKScene 中)作为 Scene Kit 节点的纹理不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32794733/
我正在尝试在 iOS 7.1 上使用 Sprite Kit 和 SKVideoNode 显示视频。 Apple 的文档使这看起来非常简单。来自 Sprite Kit 编程指南的示例: SKVideoN
我使用SpriteKit图像识别。 SpriteKit 工作正常,可以进行图像识别。识别后,我在该图片上添加视频。当相机改变方向并且视频节点不在 View 中时,如何删除视频? 简单代码: overr
SKVideoNode 在使用 videoNodeWithVideoFileNamed 加载时似乎工作正常,但是在使用 videoNodeWithAVPlayer 加载时它似乎只播放第一个(或一个)视
我已经在我的 GameScene 中添加了一个 SKVideoNode。当我尝试删除视频时,视频图像消失了,但音频继续播放。我试图在删除之前停止并暂停视频,但无论如何音频都会继续播放。 var int
您好,我正在尝试在 SKVideoNode 上快速播放视频这是我的代码,但它只播放一次,如果我点击 VideoSprite 它不播放但打印“我们点击了视频”我已经搜索但似乎找不到答案谢谢你看 impo
我有一个 SKVideoNode,就像这样 - let path = "videoURL"; let url = NSURL(string: path); let asset = AVURLAsset
我正在尝试使用 SpriteKit 让视频出现在屏幕上,但看不到它。屏幕底部的 FPS 计数器更新为 60 FPS 左右,这是有道理的。视频的音频也可以听到。删除更改 videoNode 位置的代码行
我正在尝试将背景视频和背景音乐添加到我正在创建的游戏中。为此,我创建了一个 SKVideoNode 和一个 SKAudioNode。当我运行游戏时,视频播放正常,但大多数时候音乐不播放。如果未创建 S
我正在使用一种非常简单的方法来设置 SKVideoNode 并通过几何体的漫反射内容将其放置在 SCNNode 中。当我这样做时,唯一纹理更新和正确显示视频的时间是相机或节点移动时。当两者都静止时,纹
我使用 SKVideoNode 作为我的 360 度视频球体的 Material ,但它只在球体的 xy 正向部分渲染视频,我从一个 URL 流式传输视频,它是 .m3u8 引用 - SKVideoN
我正在开发一个适用于 Swift 和 Sprite Kit 的应用程序(xCode 6.4,目前正在为 iOS 8.4 构建)。我将 SKVideoNode 与 AVPlayer 结合使用来播放全屏视
我正在使用 ARKit 并创建了一个应用程序,它将视频内容叠加到识别的图像上。代码如下: import UIKit import SceneKit import ARKit import Sprite
在进入我的游戏构建之前尝试运行“Cut Scense Video”。游戏效果很好。我创建了一个单独的场景,我将其命名为“StartScene”来播放我的剪辑场景。构建成功,但是当它到达模拟器上的剪切场
以下代码显示我的视频文件在正确的 zPosition 中与我正在使用的其他元素一起创建背景视频。 我遇到的问题是垂直视频(1080x1920 像素)逆时针旋转 90 度,并被拉伸(stretch)以适
我将视频加载到我的 Sprite Kit SKVideoNode 中,但如何停止并重新开始播放或转到视频中的特定时间?我看到的只是播放和暂停方法。 // AVPlayer NSURL *fileURL
下面是我编写的用于播放视频的代码。如果我单击一个按钮,它会调用一个方法,该方法具有用于播放视频的代码片段: if let urlStr = NSBundle.mainBundle().pathForR
如何从 AVPlayer 获取视频的视频大小以设置我的节点的几何大小? 例如,我有一个具有宽度和高度的 SCNPlane let planeGeo = SCNPlane(width: 5, heigh
我正在使用 SceneKit 和 ARKit 实现一个演示项目,我将相机放在一些图片上并从 url 播放视频。一切正常,但我无法停止之前的视频并开始播放另一个视频。以前的视频在后台播放。当我切换图像时
我正在尝试使用 Scenekit 将视频作为纹理映射到 VR 项目的原始圆柱体:嵌入 SKScene 中的 SKVideoNode 作为 SceneKit SCNTube 对象的纹理,但我无法显示视频
我的目标是使用 ARKit 在真实环境中呈现 2D 动画角色。动画角色是视频的一部分,在视频的以下快照中显示: 使用代码可以毫无问题地显示视频本身: func view(_ view: ARSKVie
我是一名优秀的程序员,十分优秀!