当前位置: 首页 > news >正文

【Unity】模型渐变技术 BlendShapes变形

模型fbx拖拽到场景并赋予脚本上SkinnedMeshRenderer参数 按下空格即可演示渐变

可去到3DsMax 或 Blender等软件制作 这种带有BlendShapes的模型 (Sphere002)是另一个模型,3DsMax叫变形器。

可参考:【技术美术百人计划】美术 3.5 BlendShape基础_哔哩哔哩_bilibili

变形器大概用法:

1. 先复制一份这个原本的模型,拉到旁边,并编辑这个复制体,改改顶点(编辑顶点)

2. 原本的模型 添加变形器,  如上图 点击空的位置 右键 选中 场景中的复制体。

3. 选中要导出的模型  文件 - 导出 - 导出选定对象 ,后面要注意勾选变形 默认勾选的

假如不勾选变形会发生如下事情:

导出的fbx 放入Unity会发现没有BlendShapes 取而代之的是一个普通的MeshRenderer模型 

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class BlendShapesTest : MonoBehaviour
{public SkinnedMeshRenderer skinMesh;public float speed = 4f;public float timer;public bool isPlaying;public int dir = 1;private int index;private void Awake(){index = skinMesh.sharedMesh.GetBlendShapeIndex("Sphere002");Debug.Log("index:"  + index);}void Update(){//按下空格 进行A->B 或 B->A渐变模型if (!isPlaying && Input.GetKeyDown(KeyCode.Space)){isPlaying = true;float weight = skinMesh.GetBlendShapeWeight(index);if (weight <= 0){dir = 1;skinMesh.SetBlendShapeWeight(index, 0f);timer = 0;Debug.Log("开始动画 0 -> 100");}else{dir = -1;skinMesh.SetBlendShapeWeight(index, 100f);timer = 100f;Debug.Log("开始动画 100 -> 0");}}if (isPlaying){timer += Time.deltaTime * dir * speed;skinMesh.SetBlendShapeWeight(index, timer);if (dir == 1 && timer >= 100){skinMesh.SetBlendShapeWeight(index, 100);isPlaying = false;Debug.Log("0 -> 100 完成动画!");}else if (dir == -1 && timer <= 0){skinMesh.SetBlendShapeWeight(index, 0);isPlaying = false;Debug.Log("100 -> 0 完成动画!");}}}
}
http://www.dtcms.com/a/222147.html

相关文章:

  • UE5蓝图暴露变量,类似Unity中public一个变量,在游戏运行时修改变量实时变化和看向目标跟随目标Find Look at Rotation
  • 当 Redis 作为缓存使用时,如何保证缓存数据与数据库(或其他服务的数据源)之间的一致性?
  • BKP(备份寄存器)和 RTC(实时时钟)
  • Datatable和实体集合互转
  • go的select多路复用
  • 如何在 Vue.js 中集成 Three.js —— 创建一个旋转的 3D 立方体
  • 《算力觉醒!ONNX Runtime + DirectML如何点燃Windows ARM设备的AI引擎》
  • 优化版本,增加3D 视觉 查看前面的记录
  • 基于 HT for Web 轻量化 3D 数字孪生数据中心解决方案
  • 山海鲸轻 3D 渲染技术深度解析:预渲染如何突破多终端性能瓶颈
  • Docker 替换宿主与容器的映射端口和文件路径
  • @Pushgateway自定义脚本推送数据
  • 数据基座觉醒!大数据+AI如何重构企业智能决策金字塔(上)
  • @Pushgateway 数据自动清理
  • 40. 自动化异步测试开发之编写异步业务函数、测试函数和测试类(类写法)
  • 类 Excel 数据填报
  • 91.评论日记
  • 投稿 IEEE Transactions on Knowledge and Data Engineering 注意事项
  • Lifecycle原理
  • Python 训练营打卡 Day 30-模块和库的导入
  • Spring MVC 框架
  • C++之string的模拟实现
  • java-文件IO
  • MySQL 的 super_read_only 和 read_only 参数
  • 深度刨析树结构(从入门到入土讲解AVL树及红黑树的奥秘)
  • AU6825集成音频DSP的2x32W数字型ClaSSD音频功率放大器(替代TAS5825)
  • 机器人变量类型与配置
  • 【maker-pdf 文档文字识别(包含ocr),安装使用完整教程】
  • 论文速读《UAV-Flow Colosseo: 自然语言控制无人机系统》
  • 使用 Akamai 分布式云与 CDN 保障视频供稿传输安全