in Education by
I'm trying to read data from scene.bin files using Microsoft::glTF SDK. TinyGLTF is not an option. When I try to read MeshPrimitive attribute called TEXCOORD_0 i get a situation where BufferView byteOffset is greater than byteLength. Therefore, I don't know how to properly read given data and my program crashes. I tried reading data using IStreamReader which is a part of SDK, and is a must when reading bin files using this SDK. I calculate data offset by adding accessor.byteOffset + bufferView.byteOffset which is > byteLength. struct BuffersAccessors { Microsoft::glTF::Accessor accessor; Microsoft::glTF::BufferView view; Microsoft::glTF::Buffer buffer; void operator=(BuffersAccessors accessors); }; template struct BufferInfo { BuffersAccessors buffersAccessors; std::vector bufferData; BufferInfo(); BufferInfo(BuffersAccessors buffersAccessors, std::vector bufferData); const void operator=(const BufferInfo &info) { buffersAccessors = info.buffersAccessors; bufferData = info.bufferData; }; }; template std::vector readBufferData(Microsoft::glTF::Document document, BufferInfo bufferInfo, std::filesystem::path path) { std::vector stream; if (bufferInfo.buffersAccessors.buffer.uri.length() > 0 || bufferInfo.buffersAccessors.buffer.byteLength > 0) { Microsoft::glTF::Buffer buffer = bufferInfo.buffersAccessors.buffer; path += bufferInfo.buffersAccessors.buffer.uri; path = std::filesystem::absolute(path); buffer.uri = path.string(); std::shared_ptr streamReader = std::make_shared(path); Microsoft::glTF::GLTFResourceReader reader(streamReader); stream = reader.ReadBinaryData(buffer, bufferInfo.buffersAccessors.view); } return stream; } template BufferInfo getFullBufferData(Microsoft::glTF::Document document, std::string accessorKey, std::filesystem::path path) { BufferInfo bufferInfo{}; BuffersAccessors mainPart = getBufferAccessorFromDocument(document, accessorKey); bufferInfo.buffersAccessors = mainPart; std::vector bufferData = vkglTF::readBufferData(document, bufferInfo, path); const size_t bufferDataOffset = mainPart.accessor.byteOffset + mainPart.view.byteOffset; //How to properly calculate offset? bufferData.erase(bufferData.begin(), bufferData.begin() + bufferDataOffset); bufferInfo.bufferData = bufferData; return bufferInfo; } I expect data in formats like uint8 and uint16 but my program crashes when trying to do bufferData.erase(..). Edit: This happens while reading WEIGHTS_0 too. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I think the most likely error with your code is the mixing of byte offsets and vector element indices. Have you tried dividing bufferDataOffset by sizeof(T)? Second, if you only want to read an accessor's data then try using the ReadBinaryData overload that accepts an Accessor parameter instead. That way the glTF SDK will handle all of the offset calculations for you. There is no documentation but the deserialize sample demonstrates the basic code structure recommended when using the glTF SDK.

Related questions

0 votes
    Is the following code supposed to compile? #include void foo() { const std::pair x = {1, 2}; ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    Is the following code supposed to compile? #include void foo() { const std::pair x = {1, 2}; ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    A byte addressable direct-mapped cache with 1024 blocks/lines, and with each block are having 8 32-bit words. How many bits are required ... 32-bit address? (a)10 (b)15 (c)3 (d)5...
asked Oct 6, 2020 in Technology by JackTerrance
0 votes
    CRAN package ecosystem has more than ______ packages. (a) 5000 (b) 4000 (c) 6000 (d) 8000 I got this ... and Debugging of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    When there are more than one independent variables in the model, then the linear model is termed as _______ (a ... of R Programming Select the correct answer from above options...
asked Feb 10, 2022 in Education by JackTerrance
0 votes
    Why does a sorted array get processed faster than an unsorted array, even though the size of the arrays are ... processed faster. Why? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Which of these methods of DatagramPacket is used to find the length of byte array? (a) getnumber() ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Ether provides greater flexibility than bitcoin. A. True B. False...
asked Nov 30, 2022 in Education by JackTerrance
0 votes
    When I want to launch some code serverless, I use AWS Lambda. However, this time my deployment package ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    What should we use to access elements with a value greater than five? (a) Subsetting commands (b) Use ... Out of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    I have the df df = pd.DataFrame({'col1': [1,2,3,4,5,6]}) and I would like to use df.isin() and ... help me find the solution to it? Select the correct answer from above options...
asked Jan 10, 2022 in Education by JackTerrance
0 votes
    Write a program in Java to input any age and determine whether the age is valid or  invalid. If age is ... is valid otherwise invalid. Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    Null Hypothesis must be rejected if P-Value is __________ than Significance Level. Greater Lesser Select the correct answer from above options...
asked Dec 12, 2021 in Education by JackTerrance
0 votes
    A black and a red dice are rolled. (a) Find the conditional probability of obtaining a sum greater than 9, ... number less than 4. Select the correct answer from above options...
asked Nov 25, 2021 in Education by JackTerrance
...