Closed mgerhardy closed 1 year ago
I'm not sure we should scope the library to do coordinate system conversions within the existing APIs. I think it's probably okay if you added an API that would modify the transforms in a writeable scene, but I'd have to see the API first to see whether it's likely to be broadly useful for many folk. Any examples of what you had in mind?
it could also go into a separated ogt_vox_tools.h
header. Or if the context discussion from the other tickets gets implemented, it would also be possible to add this to the context without changing any api.
the ufbx library allows to specify the coordinate axes like this
// Coordinate axes the scene is represented in.
// NOTE: `front` is the _opposite_ from forward!
typedef struct ufbx_coordinate_axes {
ufbx_coordinate_axis right;
ufbx_coordinate_axis up;
ufbx_coordinate_axis front;
} ufbx_coordinate_axes;
and defines some defaults like this
const ufbx_coordinate_axes ufbx_axes_right_handed_y_up = {
UFBX_COORDINATE_AXIS_POSITIVE_X, UFBX_COORDINATE_AXIS_POSITIVE_Y, UFBX_COORDINATE_AXIS_POSITIVE_Z,
};
const ufbx_coordinate_axes ufbx_axes_right_handed_z_up = {
UFBX_COORDINATE_AXIS_POSITIVE_X, UFBX_COORDINATE_AXIS_POSITIVE_Z, UFBX_COORDINATE_AXIS_NEGATIVE_Y,
};
const ufbx_coordinate_axes ufbx_axes_left_handed_y_up = {
UFBX_COORDINATE_AXIS_POSITIVE_X, UFBX_COORDINATE_AXIS_POSITIVE_Y, UFBX_COORDINATE_AXIS_NEGATIVE_Z,
};
const ufbx_coordinate_axes ufbx_axes_left_handed_z_up = {
UFBX_COORDINATE_AXIS_POSITIVE_X, UFBX_COORDINATE_AXIS_POSITIVE_Z, UFBX_COORDINATE_AXIS_POSITIVE_Y,
};
this would maybe also be useful for tools like vox2obj
I'd like to avoid coordinate conversion in this library - keeping it narrowly scoped to reading/writing and merging lets it stay simple and good at those things without becoming too complicated.
As a bit of a middle-ground, I've actually exposed the ogt_vox_transform_multiply function in this PR: https://github.com/jpaver/opengametools/pull/56 - it'll allow the client to do whatever coordinate conversion they like by just doing another multiply on top of a global/flattened transform. eg.
const ogt_vox_transform coordinate_transform = { whatevs... };
ogt_vox_transform instance_transform = ogt_vox_transform_multiply( instance->transform, coordinate_transform );
that would most likely ease the life of the users that are doing this on their own each time. I have a lot of code doing this conversion and I suppose a lot of other users suffer from the same code duplication.