Comments (15)
I'm trying to apply the flip (rotation) in my VOX importer (C#, Unity) and stumbled over this issue.
I already figured out the (_r) dictionary value is made up of two bytes - but what does that actually mean for the "byte-encoded" rotation? Is the second byte to be discarded, how does it relate to the table of bit/value's in the documentation?I'm also trying to figure out how to apply the rotation, I'm a really rusty on the math.
If I have to apply this rotation to every voxel in my model, could you give me a hint on how the formula needs to look?
(I'm sitting over the Math Primer by Dunn & Parberry, but I just can't map this to the solutions in the book)[rx1, ry1, rz1] [x1, y1, z1] * [rx2, ry2, rz2] = ? [rx3, ry3, rz3]
@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#.
from voxel-model.
@spaarmann yeah, I documented that in my pull request #33, I’m waiting on @ephtracy’s feedback
from voxel-model.
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.
from voxel-model.
Yeah, I suppose I can edit that, what should exactly clarify? That these are in ASCII?
from voxel-model.
Sorry, this
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.
was commenting on the current text in the repository, not the text in your PR :)
from voxel-model.
Ahhh, thanks for clarifying 😅
from voxel-model.
I'm trying to apply the flip (rotation) in my VOX importer (C#, Unity) and stumbled over this issue.
I already figured out the (_r) dictionary value is made up of two bytes - but what does that actually mean for the "byte-encoded" rotation? Is the second byte to be discarded, how does it relate to the table of bit/value's in the documentation?
I'm also trying to figure out how to apply the rotation, I'm a really rusty on the math.
If I have to apply this rotation to every voxel in my model, could you give me a hint on how the formula needs to look?
(I'm sitting over the Math Primer by Dunn & Parberry, but I just can't map this to the solutions in the book)
[rx1, ry1, rz1]
[x1, y1, z1] * [rx2, ry2, rz2] = ?
[rx3, ry3, rz3]
from voxel-model.
@mchorse I converted your code to C# and it seems to work, thanks!
Do you by any chance have a link or something on how to apply the rotation?
from voxel-model.
@mchorse I converted your code to C# and it seems to work, thanks!
No problem!
Do you by any chance have a link or something on how to apply the rotation?
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 (this.transform
should be the rotation matrix that was parsed from the rotation
byte).
from voxel-model.
I found this to be a good explanation of what I needed:
https://computergraphics.stackexchange.com/questions/5232/row-and-column-majored-rotation-matrix-pre-or-post-multiplied
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.
from voxel-model.
I found this to be a good explanation of what I needed:
https://computergraphics.stackexchange.com/questions/5232/row-and-column-majored-rotation-matrix-pre-or-post-multipliedThe 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).
from voxel-model.
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.
from voxel-model.
https://github.com/FuckPomelo/DeepCore/tree/master/DeepCore.Voxel/Extensions/MagicaVoxel
from voxel-model.
using DeepCore;
using DeepCore.Reflection;
using DeepCore.Voxel.Data;
using DeepCore.Voxel.Extensions.MagicaVoxel;
using DeepEditor.Common.G2D;
using DeepEditor.Common.G2D.DataGrid;
using DeepEditor.Common.Voxel;
using System;
using System.IO;
using System.Windows.Forms;
namespace SampleBattle2D.Win32
{
static class Program
{
[STAThread]
static void Main(string[] args)
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
ViewVOX(@"E:\dev\DeepWorkspace\DeepSamples2D\SampleEditors\GameEditor\voxel\MagicaVoxel\untitled.vox");
}
public static void ViewVOX(string path)
{
var file = new FileInfo(path);
var vox = MagicaVoxelFile.Load(file);
var world = vox.ConvertToVoxelWorld();
var dialog = new FormVoxelViewer();
dialog.Load += (s, e) =>
{
dialog.LoadVoxelWorld(world);
};
Application.Run(dialog);
}
}
}
from voxel-model.
Why this Shape Translatoin X is 1 ?
from voxel-model.
Related Issues (20)
- Render mode has great features but can not export to Unity with same effects HOT 1
- Rendering does not work. (Direct X 11)
- Texture is too small for some programs HOT 1
- File Format 1x4 HOT 1
- How to relate nSHP to corresponding SIZE/XYZI ? HOT 6
- Object mode: move tool. Shift+select do not work HOT 1
- language changing not working on MacOS HOT 3
- PACK chunk is absent, but I have 22 saved models in the file HOT 2
- What are the nTRN, nGRP, and nSHP chunks for?
- How to check if a nTRN chunk is a duplicate of geometry? HOT 1
- can I get Render property value?
- Image Import not working
- Exporting materials from MagicaVoxel
- Optional optimised format HOT 7
- Support densely packed index chunk?
- Document changes to the file format more thoroughly HOT 1
- DX,DY,DZ,I format HOT 1
- Performance issues with backups HOT 2
- Feature request about importing 16-32 bit PNGs
- P
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from voxel-model.