Comments (4)
Oh interesting, I wasn't aware that magicavoxel can support transform flips. I'll look into that. Thanks!
from opengametools.
Hey @mgerhardy - so I'm able to import that vox file into my own engine and it looks identical to what is visible in magicavoxel when I open it there. Is there anything particular about the way you're importing it in your vengi tools?
from opengametools.
hm. I only do the coordinate conversion with this matrix
glm::mat4 {
-1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
which is basically this
glm::rotate(glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f)), glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f));
and here is my per voxel transform:
static inline glm::vec4 calcTransform(const glm::mat4x4 &mat, const glm::ivec3 &pos, const glm::vec4 &pivot) {
return glm::floor(mat * (glm::vec4((float)pos.x + 0.5f, (float)pos.y + 0.5f, (float)pos.z + 0.5f, 1.0f) - pivot));
}
pivot is this:
glm::vec4 pivot((float)(int)(ogtModel->size_x / 2), (float)(int)(ogtModel->size_y / 2), (float)(int)(ogtModel->size_z / 2), 0.0f);
and the last step is basically this
for (uint32_t k = 0; k < ogtModel->size_z; ++k) {
for (uint32_t j = 0; j < ogtModel->size_y; ++j) {
for (uint32_t i = 0; i < ogtModel->size_x; ++i, ++ogtVoxel) {
if (ogtVoxel[0] == 0) {
continue;
}
const voxel::Voxel voxel = voxel::createVoxel(palette, ogtVoxel[0] - 1);
const glm::ivec3 &pos = calcTransform(ogtMat, glm::ivec3(i, j, k), pivot);
const glm::ivec3 &poszUp = calcTransform(zUpMat, pos, glm::ivec4(0));
const glm::ivec3 ®ionPos = poszUp - shift;
v->setVoxel(regionPos, voxel);
}
}
}
there I iterate over all voxels and do the transform - the first for the ogt_vox transform matrix and the second for the coordinate system change.
I wonder if you are doing the transformation on a per-voxel basis - or if you just load the model and apply the transformation matrix to the vertices? Asking because I move the rotated volume back to 0,0,0 (that's the strange shift
value in the for loop above) - but I would rather prefer to apply the transforms only to the scene graph nodes - and thus the vertices.
from opengametools.
this is not an issue of ogt_vox - but an issue on my side - sorry for the noise.
i've now compiled vox2obj and can see that ogt_vox handles everything correctly.
from opengametools.
Related Issues (20)
- ogt_vox: material chunk is only loaded - but not saved
- ogt_vox: getting access to the dict key/value entries
- ogt_vox: expose animation looping status HOT 2
- ogt_vox: parse _color field from LAYR chunk dictionary and expose for read/merge/write in ogt_vox_layer HOT 1
- Any writing of voxels object to Wavefront obj? HOT 3
- ogt_vox: group instances are not preserved when writing scenes
- ogt_vox: group references broken by commit: flatten animations ... HOT 1
- ogt_vox : add formal test cases HOT 2
- ogt_vox : materials are not merged correctly HOT 1
- ogt_vox: instance order differences between file versions HOT 5
- ogt_vox: Compiler warnings in release mode HOT 1
- ogt_vox: setting k_read_scene_flags_groups false looses hidden and layer information HOT 2
- ogt_vox: assert hit on invalid node id HOT 1
- ogt_vox: specify the target coordinate system and do the conversions inside the lib HOT 4
- ogt_vox: ogt_assert in nTRN chunk for voxedit.io models HOT 5
- ogt_vox: segfault when accessing invalid group indices HOT 2
- An instances layer_index can be 0xFFFFFFFF (k_invalid_group_index)
- Crashes due to unaligned memory access HOT 2
- ogt_vox: material property _media_type not handled yet
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 opengametools.