- Home /
Using Matrix4x4 to derive indices from offset of a given voxel index considering rotation.
Hi, sorry if the title is a bit of a mouthful.
In short, what I have is a voxel data structure stored as a 3D array, I'm now adding blocks that are larger than 1x1 and may have a specific amount/configuration of connecting faces on any grid location that they occupy. What I need is to find, for example, the array index of a child 'node', offset by (0,0,1) on the x, y and z axes from the main index of the block, and then derive what the node index is, taking into account that any object in the game can be rotated in 90° increments on all axes.
Matrix4x4 seems to be a little beyond me, sadly. I've tried setting up a TRS matrix as follows
Matrix4x4 nodeMatrix = Matrix4x4.TRS(nodeOffset, rotation, Vector3.one);
I've then tried various ways of deriving the node index. I assumed it would be by using one of the Multiply functions and feeding in the main index, I'm not sure if that's not the case or I'm just doing it wrong but it's certainly throwing some odd results.
Apologies if it's just a stupid oversight, but I've been banging my head against the wall over this for a while now and I'm at a loss.
Your answer
Follow this Question
Related Questions
When does a Quaternion become invalid? 1 Answer
[C#] How would I create skeleton bone transforms from a TRS matrix? 0 Answers
Save Matrix 4x4? 1 Answer
How can I check if a point(Vector3) is in Matrix4x4 1 Answer
How to get Transformation Matrix 0 Answers