lua导入.BVH运动数据/ LUA表,然后使用表对.OBJ进行动画处理

如何解决lua导入.BVH运动数据/ LUA表,然后使用表对.OBJ进行动画处理

|| ×1126 这是可能的吗,因为.BVH文件是文本驱动的,而.OBJ文件也是tet驱动的,所以我一直在研究这段代码,但是我似乎缺少一些东西。
 import script to lua table


--[[ Parses a .bvh (motion capture) file into Lua table format.

--]]

-- A list of valid BVH transform tokens and their -- quaternion sequence equivalents. local xform_tokens = {

}

Xrotation = \"rx\",Yrotation = \"ry\",Zrotation = \"rz\",Xposition = \"tx\",Yposition = \"ty\",Zposition = \"tz\"

-- Main Function

BVH2Table = function(bhvfilename) local bhvfile,linenumber,bvhtable,levels_temp_info,line,rest,_ =

0)

assert(io.open(bhvfilename)),{},{}

local function readline() repeat

linenumber = linenumber + 1 line = bhvfile:read(\"*line\") -- trim line = line and string.gsub(string.gsub(line,\"^[ \\t]*\",\"\"),\"[ \\t\\n]*$\",\"\") or nil -- enable comments and while lines

until not line or (line ~= \"\" and string.sub(line,1,1) ~= \"#\") _,_,token = string.find(line or \"\",\"^([%u%l{}:]+)\") -- rest of line,stripped _,rest = string.find(line or \"\",\"^[%u%l{}:]+[ \\t]([%a%d%s%c%p]*)\")

end local function parse_error(err,...)

error(string.format(\"%s:%d: %s\",bhvfilename,string.format(err,unpack(arg))),end

local function checktoken(ctoken) if ctoken ~= token then

parse_error(\"token %s expected,got %s\",ctoken,token) bvhtable.root_segment = {}

end

end

local function read_joint_level(level) local level_temp_info = { rotation_seq = {},level = level } -- stored info for use at animation frame decoding time table.insert(levels_temp_info,level_temp_info) level.rotation = {} -- one for each animation frame



checktoken(\"{\") readline() while token ~= \"}\" do

if token == \"OFFSET\" then local ox,oy,oz

_,ox,oz = string.find(rest,\"[ \\t]*([%-%+%d%.]+)[ \\t]+([%-%+%d%.]+)[ \\t]+([%-%+%d%.]+)\")

angle

end

table.insert(level_temp_info.rotation_seq,token) table.insert(level_temp_info.rotation_seq,0)

-- \"rx\",\"ry\",or \"rz\" -- spot to put the

end

level.offset = vec4(ox,oz) elseif token == \"CHANNELS\" then

local _,e,channelcount = string.find(rest,\"([%d]+)[ \\t]*\") for i=1,channelcount do

local chname -- extract channel name (such as \"Xrotation\") _,chname = string.find(rest,\"([%w]+)[ \\t]*\",e)local token = xform_tokens[chname] or

parse_error(\"unknown channel type %s\",chname or \"(nil)\") if string.sub(token,1) ~= \"t\" then -- ignore translation tokens.

end

end elseif token == \"JOINT\" or token == \"End\" then

local newlevel = {} level.segments = level.segments or {} -- make sure we have a table therelevel.segments[(token == \"End\") and \"EndSite\" or rest] = newlevel -- new level readline() read_joint_level(newlevel)

elseif token ~= \"}\" then

parse_error(\"illegal/unknown token \'%s\'\",token) readline()

end

-- Read hierarchy

readline() checktoken(\"HIERARCHY\") readline() checktoken(\"ROOT\") readline() read_joint_level(bvhtable.root_segment) readline()

-- Read frames (insert them into the right places of the hierarchy)

checktoken(\"MOTION\") readline()

checktoken(\"Frames:\") _,bvhtable.framecount = string.find(rest,\"([%d]+)\") readline()

checktoken(\"Frame\") _,bvhtable.frametime = string.find(rest,\"([%d%.]+)\") readline()

for fr = 1,bvhtable.framecount do if token or not line then parse_error(\"frame data expected\") end local e = 1

-- Skip global translation - we don\'t need it

for l = 1,3 do local n

end

_,n = string.find(line,\"([%-%+%d%.]+)[\\t ]*\",e)

-- fill in the rotation sequence in rotation_seq with -- the right angles,turn it into a quaternion for l = 1,table.getn(levels_temp_info) do

local rs = levels_temp_info[l].rotation_seq for c = 2,table.getn(rs),2 do

end return bvhtable

end

end

local n _,e) -- capture number rs[c] = math.rad(tonumber(n)) -- insert right number into rotation sequence

-- constructs quad from rotation sequence

levels_temp_info[l].level.rotation[fr] = quat(unpack(rs)) readline()



end
BVH示例------------------------
HIERARCHY

ROOT hip

{

OFFSET 0.000000 0.000000 0.000000 

CHANNELS 6 Xposition Yposition Zposition Xrotation Zrotation Yrotation

JOINT abdomen

{

OFFSET 0.000000 3.402643 0.000000 

CHANNELS 3 Xrotation Zrotation Yrotation

JOINT chest

{

OFFSET 0.000000 8.438565 -0.680529 

CHANNELS 3 Xrotation Zrotation Yrotation

JOINT neck

{

OFFSET 0.000000 10.207942 -0.272212 

CHANNELS 3 Xrotation Zrotation Yrotation

JOINT head

{

OFFSET 0.000000 3.130431 0.000000 

CHANNELS 3 Xrotation Zrotation Yrotation

End Site

{

OFFSET 0.000000 3.130435 0.000000 

}

}

}

JOINT lCollar

{

OFFSET 3.470700 6.669187 -0.816635 

CHANNELS 3 Yrotation Zrotation Xrotation

JOINT lShldr

{

OFFSET 3.198488 0.000000 0.000000 

CHANNELS 3 Zrotation Yrotation Xrotation

JOINT lForeArm

{

OFFSET 10.139888 0.000000 0.000000 

CHANNELS 3 Yrotation Zrotation Xrotation

JOINT lHand

{

OFFSET 8.370511 0.000000 0.000000 

CHANNELS 3 Zrotation Yrotation Xrotation

End Site

{

OFFSET 4.083176 0.000000 0.000000 

}

}

}

}

}

JOINT rCollar

{

OFFSET -3.470700 6.669187 -0.816635 

CHANNELS 3 Yrotation Zrotation Xrotation

JOINT rShldr

{

OFFSET -3.198488 0.000000 0.000000 

CHANNELS 3 Zrotation Yrotation Xrotation

JOINT rForeArm

{

OFFSET -10.139888 0.000000 0.000000 

CHANNELS 3 Yrotation Zrotation Xrotation

JOINT rHand

{

OFFSET -8.370511 0.000000 0.000000 

CHANNELS 3 Zrotation Yrotation Xrotation

End Site

{

OFFSET -4.083176 0.000000 0.000000 

}

}

}

}

}

}

}

JOINT lThigh

{

OFFSET 5.308129 -1.633274 1.361059 

CHANNELS 3 Xrotation Zrotation Yrotation

JOINT lShin

{

OFFSET -2.041588 -20.007561 0.000000 

CHANNELS 3 Xrotation Zrotation Yrotation

JOINT lFoot

{

OFFSET 0.000000 -19.190928 -1.224953 

CHANNELS 3 Xrotation Yrotation Zrotation

End Site

{

OFFSET 0.000000 -2.449906 4.627600 

}

}

}

}

JOINT rThigh

{

OFFSET -5.308129 -1.633274 1.361059 

CHANNELS 3 Xrotation Zrotation Yrotation

JOINT rShin

{

OFFSET 2.041588 -20.007561 0.000000 

CHANNELS 3 Xrotation Zrotation Yrotation

JOINT rFoot

{

OFFSET 0.000000 -19.190928 -1.224953 

CHANNELS 3 Xrotation Yrotation Zrotation

End Site

{

OFFSET 0.000000 -2.449906 4.627600 

}

}

}

}

}

MOTION

Frames: 3

Frame Time: 0.033333

0.334508 49.638664 0.334508 0.000000 0.000000 0.000000 38.066406 -0.007741 -0.006054 -23.085936 -0.009696 0.000434 30.252640 10.959431 -20.480103 10.524219 0.508720 -0.030344 -26.006567 -12.095985 -14.674844 -69.630486 -2.351615 4.234642 -48.221165 -2.682419 1.985076 -59.212875 -62.296707 83.528305 -26.749914 11.561311 -14.691852 55.618294 -19.902231 31.929420 90.271812 3.187478 0.956403 39.090054 47.092247 65.247185 2.376307 2.553305 0.602678 2.310530 -1.853541 -1.517510 -4.662024 0.846682 -0.614829 2.206921 -3.085746 -0.644749 2.650610 1.831281 1.545582 -4.841407 -0.873909 1.111763 

0.334508 49.638664 0.334508 0.000000 0.000000 0.000000 38.066406 -0.007741 -0.006054 -22.246092 -0.009701 0.000292 34.186817 10.756927 -18.382940 10.524219 0.508720 -0.030344 -23.362236 -12.731888 -10.985835 -69.819717 -18.002703 5.484021 -48.221165 -2.682419 1.985076 -59.212875 -62.296707 83.528305 -25.608553 10.831628 -11.038041 64.898254 -5.748130 27.512720 84.760063 3.170111 1.120247 39.090054 47.092247 65.247185 2.376307 2.553305 0.602678 2.310530 -1.853541 -1.517510 -4.662024 0.846682 -0.614829 2.206921 -3.085746 -0.644749 2.650610 1.831281 1.545582 -4.841407 -0.873909 1.111763 

0.334508 49.638664 0.334508 0.000000 0.000000 0.000000 38.066406 -0.007741 -0.006054 -22.246092 -0.009701 0.000292 37.417660 9.695412 -15.840567 10.524219 0.508720 -0.030344 -20.065645 -13.200043 -8.106980 -66.682304 -8.166236 6.721763 -48.221165 -2.682419 1.985076 -59.212875 -62.296707 83.528305 -23.474226 10.225674 -8.213222 75.448418 13.496569 25.332378 71.978508 3.057956 1.458179 39.090054 47.092247 65.247185 2.376307 2.553305 0.602678 2.310530 -1.853541 -1.517510 -4.662024 0.846682 -0.614829 2.206921 -3.085746 -0.644749 2.650610 1.831281 1.545582 -4.841407 -0.873909 1.111763 
最大的问题是如何将数据分配到表的.OBJ文件中?     

解决方法

抱歉,您的问题似乎是如何将3D动画文件应用于3D模型文件。 答案是您不知道,它们都只是文件格式,您可能会问错问题。     ,.obj不支持动画,因此您不能将动画数据放入.obj文件。 现在,如果您将Lua用作3D引擎的脚本语言,则可以加载.bvh,然后将这些移动应用于3D引擎中加载的.obj模型,但这是一个关于3D引擎的问题,而不是关于a     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-