I have to say that im looking at the Xith3d engine code at the moment to know how im going to build my own engine. Im probably going to change everything including the vecmath api that is a little confusing for me (the method naming) and doesn’t support much about nio buffers. I also want to make the render process more independent of the scenegraph and the engine sheduler and task manager more independent of the renderer (that is the renderer is not the engine controller). So im planning to change everything however i understand if you want to keep it backwards compatible. I think this is possible without removing any methods from the older classes.
So to keep backward compatibility my revised sugestion would be:
- Create a new class called Transform and expand it with a new hierarchy of transformations.
Transform = A generic transformation.
AffineTransform = An affine generic transformation.
TranslationAffineTransform = A translation.
ScaleAffineTransform = Scaling.
RotationAffineTransform = Rotation.
ShearAffineTransform = Shearing.
Projection = A projection.
PerspectiveProjection = A non-affine perspective projection.
OrtigraphicTransform = A non-affine ortographic projection.
This way you can build a rotation for example with whatever arguments you want.
TranslationAffineTransform transl = new TranslationAffineTransform(x,y,z,angle);
TranslationAffineTransform transl = new TranslationAffineTransform(new Vector3f(---) ,angle);
TranslationAffineTransform transl = new TranslationAffineTransform(new Vector4f(---) ,angle);
TranslationAffineTransform transl = new TranslationAffineTransform(new AxisAngle4f(---));
TranslationAffineTransform transl = new TranslationAffineTransform(new Quaternion4f(---));
TranslationAffineTransform transl = new TranslationAffineTransform(new Matrix3f(---) );
TranslationAffineTransform transl = new TranslationAffineTransform(new Matrix4f(---) );
I don’t think this would break anything since it would be new code and nothing would be removed.
- Enrich TransformGroup with new methods to make it easier to work with (so the user doesn’t have to deal with “middle-man” classes if he doesn’t need to and for the most common operations):
TransformGroup tg = new TransformGroup();
tg.setIdentityTransform();
tg.setTransform(transform);
tg.setTranslation(transform);
tg.setRotation(transform);
tg.setScale(transform);
tg.setShear(transform);
tg.getTransform(transform);
tg.getTranslation(transform);
tg.getRotation(transform);
tg.getScale(transform);
tg.getShear(transform);
tg.transform(transform);
tg.swapTransform(transform);
tg.rotate(transform);
tg.scale(transform);
tg.shear(transform);
tg.translate(transform);