ephtracy / voxel-model

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to relate nSHP to corresponding SIZE/XYZI ?

TomWor opened this issue · comments

Hi,
I'm currently working through all the documentation and wrote my own VOX importer in C# for Unity.
Everything works so far except the correct positioning of the models in world space.
I can get the translation information from the frame attributes of the nTRN chunks (?) but how do those relate to the actual voxel data in SIZE/XYZI?
Can't find it.

Have you looked into #33? I also encountered some problems in how it works, hopefully additional notes will help you. Otherwise, feel free to check my VOX parsing code.

I've looked at your code but I still can't see if/or how you mapped the voxel data to the nTRN/nSHP to SIZE/XYZI - there is AFAIS no ID field connecting the SIZE/XYZI chunks to the node tree. Do you know how this works?

I can't remember how I exactly did it, it been a year since I wrote that code, but it looks like you need to read first all chunks in the vox file, and then once you read them all, you can start by traversing the first transform node like described in the scene graph.

nSHP once you go over nSHP nodes, they contain the index of the SIZE/XYZI voxel cube (i.e. an object that stores up to 256^3 voxel data).

I see. It's called "model id" in the documentation. If that's the index of the vox data chunks read before I could put that together with the nTRN translation information to offset the voxel data.
Thanks for the hint, will try that.

If you need more examples, you could check out this: https://github.com/Eisenwave/voxel-io
Or my code here: https://github.com/mgerhardy/engine/blob/master/src/modules/voxelformat/VoxFormat.cpp (but I still have problems with layers.)

Just to finish this off:
It indeed worked liked I described in the comment above: The model id is the index of the vox data chunk being read before.
In my case I go through all the vox data chunks and save the reference to each in an array. Later I can use the model id as an array index to get the referenced data.