Comments (9)
_t
and _r
are not handled properly across the whole scenegraph. Loading a complex scene doesn't put the volumes at the right offset or the right rotation.
The saving is broken: https://github.com/mgerhardy/engine/blob/master/src/modules/voxelformat/VoxFormat.cpp#L67 as well as the loading https://github.com/mgerhardy/engine/blob/master/src/modules/voxelformat/VoxFormat.cpp#L722
from vengi.
Found this in #dev-talk of MV Community (Discord) (User Eisenwave)
If anybody's trying to figure out how to correctly apply the transformations of Vox chunks to the positions inside, this is how you do it.
i32 div2Floor(i32 n) { return (n - (n < 0)) / 2 ; } Vec3i32 applyTransform(Matrix3i32 matrix, Vec3i32 translation, Vec3i32 pointInChunk, Vec3i32 chunkSize) { Vec3i32 doublePivot = Vec3i32{chunkSize[0] & ~1, chunkSize[1] & ~1, chunkSize[2] & ~1} + Vec3i32{1, 1, 1} Vec3i32 doublePointRelToCenter = pointInChunk + pointInChunk - ; Vec3i32 rotated = { div2Floor(dot(matrix.row(0), doublePointRelToCenter)), div2Floor(dot(matrix.row(1), doublePointRelToCenter)), div2Floor(dot(matrix.row(2), doublePointRelToCenter)) }; return rotated + translation; }
from vengi.
https://gist.github.com/Eisenwave/aca18b48fdaea3259894ceb4d8e0b846
from vengi.
The rotation is fixed now.
The scenegraph is still not support though - I misunderstood some of the concepts while implementing it. The problem is, that I've assigned each layer a volume - this is not correct. The layers and objects in the scene graph share the volume with other objects - but have different translation and rotation assigned by the scene graph node properties.
from vengi.
from vengi.
https://godotengine.org/asset-library/asset/341
from vengi.
Info from mv Discord:
Hey <@!529750511977627648> , so the trick is that the transform stored in _r/_t for each nTRN node is a local_transform (ie. transforms from local coordinates into parent coordinates), not a world_transform (converts from local coordinates into world coordinates), so it's defined relative to the transform for the parent nTRN node. So if you have this node hierarchy:
- nTRN0
- nTRN1
- nTRN2
- nTRN1
You find the "world space" transform of nTRN2 by computing the world transform for its parent node, something like so:
nTRN0.world_transform = nTRN0.local_transform; // it has no parent,
nTRN1.world_transform = nTRN1.local_transform * nTRN0.world_transform
nTRN2.world_transform = nTRN2.local_transform * nTRN1.world_transform
In ogt_vox, this is done (admittedly hard to decipher) and implicitly in recursive calls to generate_instances_for_node:
- the local_transform for an nTRN node is obtained by passing the _r/_t strings from the node dictionary to _vox_make_transform_from_dict_strings.
- the world_transform ultimately assigned to a (model) instance is obtained by a matrix multiply against the parent nTRN's world_transform here:
_vox_transform_multiply(node->u.transform.transform, transform);
-- the LHS in this multiply is the local transform in this context,
-- the RHS in this multiply is the world transform of the parent nTRN node
Hope this helps
from vengi.
c298633 should fix this issue. Feedback welcome.
from vengi.
0fd8613 should fix the remaining issue
from vengi.
Related Issues (20)
- OSX: create brew casks HOT 4
- VOXELFORMAT: 3ZH: failed to load some files HOT 1
- CUBZH: add support for b64 files transforms and references HOT 1
- MAKE: format and other targets don't work on osx
- VOXEDIT: grayscale option is not correctly updated when toggled
- VOXEDIT: center camera doesn't center on active node
- SCENEGRAPH: adding a reference to a model node with children
- VOXEDIT: switch to edit mode for references model node
- VOXELFORMAT: MESH: add meshoptimizer support
- SHADERTOOL: use #pragma foo instead of $foo
- VOXEDIT: paint modifier should be able to paint with gradients HOT 1
- VOXELFORMAT: GLTF: UV coordinates are wrong HOT 1
- VOXEDIT: MementoHandler should support Undo-Groups
- VOXEDIT: Save vengi with reordered palette colors
- VOXEDIT: Bindings for brush switch commands
- VOXEDIT: Select by color (fuzzy select, magic wand)
- EMSCRIPTEN: errors when launching 0.0.28 HOT 1
- VOXEDIT: issue for model saving on re-sorted palettes HOT 1
- VOXCONVERT: add progress bar support
- VOXCONVERT: creates invalid output and returns with code 0 even on failure
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 vengi.