Question

I've been working on a 3D space game (an early demo is here... www.sugarspook.com/darkmatters/demo.html) and I'm in the process of adding code to allow space stations to be built out of multiple meshes. I've got the meshes included and working. Now I want to be able to position each mesh section relative to the central space station object (an Orbital Class).
Each OrbitalSection has a _matrixOffset:Matrix3D which I manipulate to determine where it will be positioned. In the 3D drawing stage the OrbitalSection copies it's 'parent' Orbital Matrix3D raw data and then appends its own _matrixOffset:

transform.matrix3D.copyFrom(_orbitalMatrix);
transform.matrix3D.append(_matrixOffset);

This all works fine - if the OrbitalSection's _matrixOffset has only a position translation, eg:

_matrixOffset.appendTranslation(0, 0.1, 0);

But, as soon as I include a rotation to the _matrixOffset, the in-game positioning is messed up.
All I want to do is ADD the _matrixOffset to a copy of the parent Orbital's transform.matrix3D. I have tried both prependRotation and appendRotation, before AND after the translation.
Does anyone know how to add 2 Matrix3Ds comulatively? Thanks.

Was it helpful?

Solution

Apparently you want your OrbitalSection to be located in a certain position relative to its main base. This means, you have to first populate your matrix, and then append the parent matrix.

transform.matrix3D.copyFrom(_matrixOffset);
transform.matrix3D.append(_orbitalMatrix);

This should also save your skin if your Orbital instance would decide to rotate somehow.

OTHER TIPS

What do you exactely mean with "add" the _matrixOffset to a copy of the parent's matrix?

I'd suggest to read more about "homogeneus transformation".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top