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

互联网产品设计廊坊关键词优化服务

互联网产品设计,廊坊关键词优化服务,实惠网外贸论坛,做网站的是外包公司吗推荐#xff1a;使用NSDT场景编辑器快速搭建3D应用场景 文件类型 GLTF文件有两种不同的主要文件类型#xff1a;.gltf和.glb。 GLTF文件本质上只是一个重新命名的json文件#xff0c;它们通常与包含顶点数据等内容的.bin文件相提并论#xff0c;但这些内容也可以直接包含…推荐使用NSDT场景编辑器快速搭建3D应用场景 文件类型 GLTF文件有两种不同的主要文件类型.gltf和.glb。 GLTF文件本质上只是一个重新命名的json文件它们通常与包含顶点数据等内容的.bin文件相提并论但这些内容也可以直接包含在json中。 GLB 文件类似于 GLTF 文件但所有内容都包含在同一个文件中。它分为三个部分一个小标头、json 字符串和二进制缓冲区。 图片来自官方gltf github GLTF 格式 在 GLTF 中与网格、动画和蒙皮相关的一切都存储在缓冲区中虽然一开始在没有库的情况下从原始二进制文件中读取似乎令人生畏但实际上并不太难。我们将逐步进行。 在本文中我们将介绍如何从 .gltf 和 .glb 文件中从单个网格读取顶点位置数据。 在我们获得实际代码之前我们需要了解如何使用文件的 json 部分来查找我们想要的内容因为我们必须跳来跳去才能找到任何东西。你可以从场景级别开始如果需要也可以逐步向下工作但由于我计划只对单个网格使用格式所以我将从图形的网格节点开始。 假设我们的 GLTF 文件看起来像这样请注意实际文件将包含更多数据 {accessors : [{bufferView: 0,byteOffset: 0,componentType: 5126,count: 197,max: [ -0.004780198, 0.0003038254, 0.007360002 ],min: [ -0.008092392, -0.008303153, -0.007400591 ],type: VEC3}],buffers: [{byteLength: 2460034,uri: example.bin}],bufferViews: [{buffer: 0,byteLength: 306642,target: 34963,byteOffset: 2153392},],meshes: [{name: example mesh,primitives: [{attributes: {POSITION: 0,NORMAL: 1,TEXCOORD_0: 2,TANGENT: 3},indices: 4,material: 0,mode: 4}]}] } 要查找网格的位置数据我们首先需要访问索引 0 处的 “meshes” 键然后访问第一个基元。据我所知基元本质上只是子网格。然后我们将检索“属性”-“位置”。这将为我们提供访问器的索引。插入它我们可以从第一个访问器获取“bufferView”值。然后这为我们提供了缓冲区视图的索引我们最终可以使用它来获取缓冲区以从中检索数据。在这种情况下缓冲区存储在外部文件“example.bin”中。打开该文件后我们将转到访问器中“byteOffset”提供给我们的位置最后读取缓冲区数据。 下面开始分别介绍如何从gltf/glb文件中读取数据 在此过程中你可以用GLTF编辑器对3D模型文件进行编辑和验证模型数据。 从 GLTF 文件读取 我将在我的示例代码中使用 c 但对于任何其他语言步骤应该大致相同。 // First define our filname, would probbably be better to prompt the user for one const std::string gltfFilename example.gltf// open the gltf file std::ifstream jsonFile(gltfFilename, std::ios::binary);// parse the json so we can use it later Json::Value json;try{jsonFile json; }catch(const std::exception e){std::cerr Json parsing error: e.what() std::endl; } jsonFile.close();// Extract the name of the bin file, for the sake of simplicity Im assuming theres only one std::string binFilename json[buffers][0][uri].asString();// Open it with the cursor at the end of the file so we can determine its size, // We could techincally read the filesize from the gltf file, but I trust the file itself more std::ifstream binFile std::ifstream(binFilename, std::ios::binary | std::ios::ate);// Read file length and then reset cursor size_t binLength binFile.tellg(); binFile.seekg(0);std::vectorchar bin(binLength); binFile.read(bin.data(), binLength); binFile.close();// Now that we have the files read out, lets actually do something with them // This code prints out all the vertex positions for the first primitive// Get the primitve we want to print out: Json::Value primitive json[meshes][0][primitives][0];// Get the accessor for position: Json::Value positionAccessor json[accessors][primitive[attributes][POSITION].asInt()];// Get the bufferView Json::Value bufferView json[bufferViews][positionAccessor[bufferView].asInt()];// Now get the start of the float3 array by adding the bufferView byte offset to the bin pointer // Its a little sketchy to cast to a raw float array, but hey, it works. float* buffer (float*)(bin.data() bufferView[byteOffset].asInt());// Print out all the vertex positions for (int i 0; i positionAccessor[count].asInt(); i) {std::cout ( buffer[i*3] , buffer[i*3 1] , buffer[i*3 2] ) std::endl; }// And as a cherry on top, lets print out the total number of verticies std::cout vertices: positionAccessor[count].asInt() std::endl; 从 GLB 文件读取 从 .glb 文件中读取有点困难因为我们不能只是将其放入 JSON 解析器中但它是可行的。在文件类型部分中参考上图我们可以找到有关所需文件格式的所有信息 std::ifstream binFile std::ifstream(glbFilename, std::ios::binary); binFile.seekg(12); //Skip past the 12 byte header, to the json header uint32_t jsonLength; binFile.read((char*)jsonLength, sizeof(uint32_t)); //Read the length of the json file from its headerstd::string jsonStr; jsonStr.resize(jsonLength); binFile.seekg(20); // Skip the rest of the JSON header to the start of the string binFile.read(jsonStr.data(), jsonLength); // Read out the json string// Parse the json Json::Reader reader; if(!reader.parse(jsonStr, _json))std::cerr Problem parsing assetData: jsonStr std::endl;// After reading from the json, the file cusor will automatically be at the start of the binary headeruint32_t binLength; binFile.read((char*)binLength, sizeof(binLength)); // Read out the bin length from its header binFile.seekg(sizeof(uint32_t), std::ios_base::cur); // skip chunk typestd::vectorchar bin(binLength); binFile.read(bin.data(), binLength);//Now youre free to use the data the same way we did above 总结 希望这对您有所帮助。我知道它在某些方面有点缺乏细节所以一旦我了解更多我可能会回来更新它提供更多关于动画和皮肤的信息。但在那之前再见。 原文链接了解 glTF 2.0 格式
http://www.pierceye.com/news/957999/

相关文章:

  • 做网站发布网网站需求建设书
  • 咖啡店网站建设模版四川建设网四川住建厅
  • 官方网站建设怎么样郑州搜索引擎优化
  • 三只松鼠网站谁做的大学网页设计作业
  • 关于建设网站的请示做哪种类型的网站赚钱呢
  • 西安网站seo优化做cpa广告建什么网站好
  • 南京手机网站开发网站建设需要哪些岗位
  • 青白江区网站开发招聘宿迁网站设计
  • 做暧暖爱视频每一刻网站wordpress头条采集
  • 海淀网站开发如何免费推广网站
  • 建设音乐网站宣传片拍摄总结
  • 个人网站推广中国制造网建站
  • 怎么管理好自己的网站自建vps和买机场哪个好
  • 站长之家素材网站郴州建网站
  • 服装微商城网站建设贵州建设考试网站
  • 安徽省建设安全协会网站htm5移动网站开发
  • 棋盘游戏类网站开发wordpress副标题怎么写
  • 重庆城市关键词优化ppt
  • 网站营销外包公司简介wordpress 微信二维码
  • 做酒业网站的要求软件开发app的公司
  • 可以做超链接或锚文本的网站有哪些口碑营销的本质是什么
  • 网上下载的网站模板怎么用莱芜金点子招聘网
  • 网站建设首先要免费游戏网站制作
  • 小橘子被做h网站注册帐号
  • 汉川网站推广服务PHP网站建设的课后笔记
  • 中国建设银行网站功能模块多少钱才算有钱人
  • 毕业设计网站成品wordpress 发布模块
  • 网站推广 济南江西 网站 建设 开发
  • 视频 播放网站怎么做的ppt模板大师
  • 桂林北站到象鼻山景区怎么坐车wordpress更改上传