工作 ARKit 的 MoCap 解决方案
- 在 Autodesk Maya 2020 中创建角色
- 下载 Apple 的模型 Biped 骨架并将其导入 Maya
- 适当地装配 Apple 的骨骼以进行动作捕捉
Skin
使用-<code>Bind Skin将骨架绑定到网格
- 在 Outliner 中选择骨架和网格并使用
File
-<code>Game Exporter
- 选择文件类型:
Binary
和版本:FBX 2020
然后按Save
然后下载USDZ Tools for Xcode 12和FBX Python SDK。
这是我的POST,您可以在其中找到如何.zshrc
在 macOS 中创建文件的说明。
测试 MoCap 模型:
import RealityKit
import ARKit
class ViewController: UIViewController, ARSessionDelegate {
@IBOutlet var arView: ARView!
var character: Entity?
let characterAnchor = AnchorEntity()
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
arView.session.delegate = self
guard ARBodyTrackingConfiguration.isSupported
else { fatalError("MoCap is available on A12 & later") }
let config = ARBodyTrackingConfiguration()
arView.session.run(config)
arView.scene.addAnchor(characterAnchor)
character = try? Entity.load(named: "character")
}
func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {
for anchor in anchors {
guard let bodyAnchor = anchor as? ARBodyAnchor
else { continue }
let bodyPosition = simd_make_float3(bodyAnchor.transform.columns.3)
characterAnchor.position = bodyPosition
characterAnchor.orientation = Transform(matrix: bodyAnchor.transform).rotation
if let character = character, character.parent == nil {
characterAnchor.addChild(character)
characterAnchor.scale = [0.02, 0.02, 0.02]
}
}
}
}