-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translation and rotation format #34
Comments
@spaarmann yeah, I documented that in my pull request #33, I’m waiting on @ephtracy’s feedback |
Ah, I didn't see that. I searched through the issues here, but not the PRs, I really wish I would've done that, would've saved me some time :) I also just realized the documentation does say that DICT values are strings, so it's not exactly wrong... Still think it'd be nice to make this a bit more explicit though. |
Yeah, I suppose I can edit that, what should exactly clarify? That these are in ASCII? |
Sorry, this
was commenting on the current text in the repository, not the text in your PR :) |
Ahhh, thanks for clarifying 😅 |
I'm trying to apply the flip (rotation) in my VOX importer (C#, Unity) and stumbled over this issue. I'm also trying to figure out how to apply the rotation, I'm a really rusty on the math.
|
@TomWor, I replied to you in the comments on my PR with this code excerpt. I think this wouldn’t be too hard convert to C#. |
@mchorse I converted your code to C# and it seems to work, thanks! |
No problem!
Well, when you'll be constructing a mesh, you'll need to transform your vertices through the transformation matrix, that's how I do it ( |
I found this to be a good explanation of what I needed: The mesh geometry is flipped/rotated fine now, only now the translation seems a little off (applying before or after rotation?) and my Normals are flipped. But it looks like I'm getting there. |
As far as I remember, you need to apply matrix transformations from the mid point of the voxel chunk. I.e. if you have 16^3 object, you need to apply transformations relative to (8,8,8). |
You're right. With translations I was able to get around that issue easily so far, but with flip and rotate it's a whole different story. So much so that I think I have to restructure my importer to cleanly integrate it. |
using DeepCore; namespace SampleBattle2D.Win32 |
Hi there.
While writing a parser for the .vox files, I discovered that the documentation doesn't quite match what MagicaVoxel actually produces for the translation and rotation of
nTRN
chunks.(Tested in the most recent, unstable 0.99.5).
voxel-model/MagicaVoxel-file-format-vox-extension.txt
Lines 77 to 78 in eed2ea1
Both of these are actually ASCII encoded versions of what they describe.
For the translation, instead of just three
int32
packed after each other, there is a string of the format"x y z"
, i.e. the three integers encoded as ASCII and separated by a space.Similarly, for the rotation, instead of a single byte, there is a string containing a decimal representation of that byte which then matches the format described in the documentation:
voxel-model/MagicaVoxel-file-format-vox-extension.txt
Lines 24 to 41 in eed2ea1
As an example,
is packed into
0b0010001
which is then written into the file as the string"17"
, i.e. the bytes0x31 0x37
.Hope this helps anybody stumbling across the same issue, or that @ephtracy perhaps updates the repository to include this information.
The text was updated successfully, but these errors were encountered: