当前位置: 首页 > 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/202053/

相关文章:

  • 关于对网站建设情况的通报东南亚跨境电商有哪些平台
  • 如需郑州网站建设长沙微网站制作
  • html格式网站网站搜索排名优化软件
  • 定制 网站天津做网站要多少钱
  • 免费做问卷的网站网站建设 好发信息网
  • 网站职能建设论文网页跳转链接怎么制作
  • 专题网站开发工具有哪些wordpress迁移500
  • 酒泉网站建设费用磁力搜索引擎不死鸟
  • 有网站是做水果原产地代发的吗临沂哪家做网站最好
  • 网站建设的背景wordpress htaccess
  • 如何在百度上注册自己的网站郓城做网站哪家好
  • 企业电子商务网站建设总结安徽建设工程信息网查询平台公司
  • 推荐常州微信网站建设做外汇看的网站
  • 网站页面优化方案网页设计培训费用多少
  • 落寞文学网单本多本小说wordpress主题哈尔滨网站优化指导
  • 网站域名使用费用网站在vps能访问 在本地访问不了
  • wordpress可以做成企业站吗一个域名可以建设几个网站
  • 企业网站备案需要什么资料工装装饰公司
  • 网站建设精美模板下载邢台165信息交友
  • 普陀区建设工程质检网站网站关键词优化排名
  • 云服务器多网站解析企业网站打不开了
  • 搭建flv视频网站如何注册域名步骤
  • 平面设计公司网站单页模板
  • 网站模板 代码免费建设部网站有项目经理资质查询系统
  • 网站建设注意哪些方面wordpress 做手机站
  • 淄博网站制作定制推广网站程序源代码
  • 二手房地产中介网站建设wordpress改背景图片
  • 可以自己做安卓app的网站Wordpress会员插件出错
  • 做网站优化有前景吗可信网站验证服务中心
  • 韩国设计欣赏网站天津工程建设网官方网站