NSDT工具推荐Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器 - REVIT导出3D模型插件 - 3D模型语义搜索引擎 - Three.js虚拟轴心开发包 - 3D模型在线减面 - STL模型在线切割

我敢说这个世界上有两种人:喜欢《玩具总动员》的人和没看过《玩具总动员》的人。

好吧,这只是动画电影忠实粉丝的意见。 当我还是个孩子的时候,我总是梦想有一个可以移动和和我一起玩的玩具,就像我自己的巴斯光年一样。 多亏了一种叫做索具的奇特技术,我现在可以让我的玩具栩栩如生,尽管我现在可能已经太老了。

1、什么是 3D 动画中的 Rigging?

简而言之,绑定(rigging)是为 3D 模型创建骨架以使其移动的过程。 换句话说,绑定创建一组连接的虚拟骨骼,用于控制 3D 模型。

它为动画铺平了道路,因为它使模型能够变形,使其可移动,这就是 3D 动画需要绑定的原因。

2、什么是自动绑定?

3D 动画已被多个领域(游戏、电子商务、视频等)的移动应用程序采用,以实现比 2D 更逼真的动画。

然而,这种图形技术让许多开发人员(像我一样)感到畏惧,因为其主要先决条件之一的绑定对于不熟悉建模的人来说既困难又耗时。 具体来说,大多数高性能索具解决方案都有很多要求。

例如,输入模型应处于标准位置,应添加七个或八个关键骨骼点,以及必须添加到骨骼的逆运动学等等。

幸运的是,有一些解决方案可以自动完成绑定,例如HMS Core 3D Modeling Kit的自动绑定解决方案。

此功能提供了完全自动化的绑定过程,只需要使用手机摄像头拍摄的图像生成的双足人形模型。 输入模型后,自动绑定使用 AI 算法进行肢体绑定并生成模型骨架和蒙皮权重(决定骨骼对网格体一部分的影响程度)。

然后,该功能会改变骨架的方向和位置,以便模型可以执行一系列预设动作,例如行走、跑步和跳跃。 此外,绑定的模型还可以根据使用动作捕捉技术生成的动作进行移动,或者导入到主要的3D动画引擎中。

较低的要求不会影响绑定精度。 自动绑定建立在数十万条 3D 模型绑定数据记录的基础上。 由于一些微调的数据记录,该功能提供了理想的算法准确性和泛化性。

我知道仅靠文字并不能证明这一点,因此请查看我使用该功能创建的动画模型。

动作流畅,让可爱的熊猫动作几乎像真的熊猫一样。 现在我想向你展示如何创建此模型以及如何将自动装配集成到我的演示应用程序中。

3、整合程序

在进行真正的集成工作之前,需要做好必要的准备工作,包括:在AppGallery Connect中配置应用信息、将HMS Core SDK集成到应用项目中,其中包括Maven仓库地址配置、配置混淆脚本以及声明必要的权限。

在应用程序初始化期间设置访问令牌或 API 密钥(可在 agconnect-services.json 中找到)以进行应用程序身份验证。

使用访问令牌:调用setAccessToken设置访问令牌。 在应用程序初始化期间仅需要执行一次此任务。

ReconstructApplication.getInstance().setAccessToken("your AccessToken");

使用API Key:调用setApiKey设置API Key。 该key`不需要再次设置。

ReconstructApplication.getInstance().setApiKey("your api_key");

建议使用访问令牌。 如果你更喜欢 API 密钥,它会在 AppGallery Connect 中创建应用程序时分配给该应用程序。

创建 3D 对象重建引擎并初始化它。 然后,创建一个自动装配配置器。

// Create a 3D object reconstruction engine.
Modeling3dReconstructEngine modeling3dReconstructEngine = Modeling3dReconstructEngine.getInstance(context); 
// Create an auto rigging configurator.
Modeling3dReconstructSetting setting = new Modeling3dReconstructSetting.Factory() 
    // Set the working mode of the engine to PICTURE.
    .setReconstructMode(Modeling3dReconstructConstants.ReconstructMode.PICTURE) 
    // Set the task type to auto rigging.
    .setTaskType(Modeling3dReconstructConstants.TaskType.AUTO_RIGGING) 
    .create();

创建一个监听对象上传图片结果的监听器。

private Modeling3dReconstructUploadListener uploadListener = new Modeling3dReconstructUploadListener() { 
    @Override 
    public void onUploadProgress(String taskId, double progress, Object ext) { 
         // Callback when the upload progress is received.
    } 
    @Override 
    public void onResult(String taskId, Modeling3dReconstructUploadResult result, Object ext) { 
         // Callback when the upload is successful. 
    } 
    @Override 
    public void onError(String taskId, int errorCode, String message) { 
        // Callback when the upload failed.
    } 
};

使用 3D 对象重建配置器初始化任务,为步骤 1 中创建的引擎设置上传侦听器,然后上传图像。

// Use the configurator to initialize the task, which should be done in a sub-thread.
Modeling3dReconstructInitResult modeling3dReconstructInitResult = modeling3dReconstructEngine.initTask(setting); 
String taskId = modeling3dReconstructInitResult.getTaskId(); 
// Set an upload listener.
modeling3dReconstructEngine.setReconstructUploadListener(uploadListener); 
// Call the uploadFile API of the 3D object reconstruction engine to upload images.
modeling3dReconstructEngine.uploadFile(taskId, filePath);

查询自动绑定任务的状态。

// Initialize the task processing class.
Modeling3dReconstructTaskUtils modeling3dReconstructTaskUtils = Modeling3dReconstructTaskUtils.getInstance(context); 
// Call queryTask in a sub-thread to query the task status.
Modeling3dReconstructQueryResult queryResult = modeling3dReconstructTaskUtils.queryTask(taskId); 
// Obtain the task status.
int status = queryResult.getStatus();

为模型文件下载结果创建监听器。

private Modeling3dReconstructDownloadListener modeling3dReconstructDownloadListener = new Modeling3dReconstructDownloadListener() { 
    @Override 
    public void onDownloadProgress(String taskId, double progress, Object ext) { 
        // Callback when download progress is received.
    }     
    @Override 
    public void onResult(String taskId, Modeling3dReconstructDownloadResult result, Object ext) { 
        // Callback when download is successful.
    } 
    @Override 
    public void onError(String taskId, int errorCode, String message) { 
        // Callback when download failed.
    } 
};

将下载侦听器传递给 3D 对象重建引擎,以下载装配模型。

// Set download configurations.
Modeling3dReconstructDownloadConfig downloadConfig = new Modeling3dReconstructDownloadConfig.Factory() 
    // Set the model file format to OBJ or glTF.
    .setModelFormat(Modeling3dReconstructConstants.ModelFormat.OBJ) 
    // Set the texture map mode to normal mode or PBR mode.
    .setTextureMode(Modeling3dReconstructConstants.TextureMode.PBR) 
    .create(); 
// Set the download listener.
modeling3dReconstructEngine.setReconstructDownloadListener(modeling3dReconstructDownloadListener); 
// Call downloadModelWithConfig, passing the task ID, path to which the downloaded file will be saved, and download configurations, to download the rigged model.
modeling3dReconstructEngine.downloadModelWithConfig(taskId, fileSavePath, downloadConfig);

4、在哪里使用

自动装配用于许多场景,例如:

  • 游戏:使用自动装备的最直接方法是在 3D 游戏中创建可移动的角色。 或者,我认为我们可以将其与 AR 结合起来,创建可以出现在移动设备的相机显示屏上的动画模型,从而与用户进行交互。
  • 在线教育:我们可以使用自动绑定来制作流行玩具的 3D 模型动画,并通过舞蹈动作、画外音和童谣让它们生动起来,从而制作教育视频。 这些模型可以用在教育视频中,以更吸引孩子们。
  • 电商:动漫人物与动漫中的行为相比,看起来相当朴素。 为了给雕像增添趣味,我们可以使用自动绑定来制作 3D 模型的动画,使其看起来更具吸引力和活力。

5、结束语

3D 动画广泛应用于移动应用程序中,因为它以更有趣和更具交互性的方式呈现对象。

创建出色的 3D 动画的一项关键技术是绑定。 传统的绑定需要建模技巧和专业知识,这让许多业余建模者望而却步。

自动装配是应对这一挑战的完美解决方案,因为其全自动装配流程可以生成高度精确的装配模型,并且可以使用市场上的主要引擎轻松制作动画。 自动绑定不仅降低了 3D 模型生成和动画的成本和要求,还有助于 3D 模型看起来更具吸引力。


原文链接:Streamlining 3D Animation Creation via Rigging

BimAnt翻译整理,转载请标明出处