Giter Club home page Giter Club logo

Comments (15)

mchorse avatar mchorse commented on July 28, 2024 1

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.

mchorse avatar mchorse commented on July 28, 2024

@spaarmann yeah, I documented that in my pull request #33, I’m waiting on @ephtracy’s feedback ☺️

from voxel-model.

spaarmann avatar spaarmann commented on July 28, 2024

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.

mchorse avatar mchorse commented on July 28, 2024

Yeah, I suppose I can edit that, what should exactly clarify? That these are in ASCII?

from voxel-model.

spaarmann avatar spaarmann commented on July 28, 2024

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.

mchorse avatar mchorse commented on July 28, 2024

Ahhh, thanks for clarifying 😅

from voxel-model.

TomWor avatar TomWor commented on July 28, 2024

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.

TomWor avatar TomWor commented on July 28, 2024

@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 avatar mchorse commented on July 28, 2024

@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.

TomWor avatar TomWor commented on July 28, 2024

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.

mchorse avatar mchorse commented on July 28, 2024

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.

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.

TomWor avatar TomWor commented on July 28, 2024

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.

wazazhang avatar wazazhang commented on July 28, 2024

https://github.com/FuckPomelo/DeepCore/tree/master/DeepCore.Voxel/Extensions/MagicaVoxel

from voxel-model.

wazazhang avatar wazazhang commented on July 28, 2024

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.

wazazhang avatar wazazhang commented on July 28, 2024

image
image
Why this Shape Translatoin X is 1 ?

from voxel-model.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.