Hi,
Not sure does this will help, but here an example how I apply
rotation for node:
void lib3ds_node_rotate_y(Lib3dsNode *node, float fAngle) {
lib3ds_object_data_rotate_y(&node->data.object, fAngle);
}
void lib3ds_object_data_rotate_y(Lib3dsObjectData *n, float fAngle) {
Lib3dsVector axis;
axis[0] = 0.;
axis[1] = 1.;
axis[2] = 0.;
lib3ds_object_data_rotate(n, fAngle, axis);
}
// fAngle -> radians
void lib3ds_object_data_rotate(Lib3dsObjectData *n, float fAngle,
Lib3dsVector axis)
{
lib3ds_quat_track_free_keys(&n->rot_track);
Lib3dsQuatKey *rot = lib3ds_quat_key_new();
lib3ds_quat_zero(rot->q);
// lib3ds_quat_zero(rot->dd);
// lib3ds_quat_zero(rot->ds);
rot->angle = fAngle;
lib3ds_vector_copy(rot->axis, axis);
lib3ds_quat_track_insert(&n->rot_track, rot);
lib3ds_quat_track_setup(&n->rot_track);
lib3ds_empty_trans(n);
lib3ds_empty_scale(n);
}
void lib3ds_empty_trans(Lib3dsObjectData *n) {
lib3ds_lin3_track_free_keys(&n->pos_track);
n->pos_track.keyL = 0;
Lib3dsLin3Key *key_l = lib3ds_lin3_key_new();
lib3ds_lin3_track_insert(&n->pos_track, key_l);
lib3ds_lin3_track_setup(&n->pos_track);
}
void lib3ds_empty_scale(Lib3dsObjectData *n) {
lib3ds_lin3_track_free_keys(&n->scl_track);
n->scl_track.keyL = 0;
Lib3dsLin3Key *key_l = lib3ds_lin3_key_new();
key_l->value[0] = 1;
key_l->value[1] = 1;
key_l->value[2] = 1;
lib3ds_lin3_track_insert(&n->scl_track, key_l);
lib3ds_lin3_track_setup(&n->scl_track);
}
void lib3ds_quat_zero(Lib3dsQuat q) {
q[0] = 0;
q[1] = 0;
q[2] = 0;
q[3] = 1;
}
Tomas
P.S. (C++ version, but you can modify this to C language)
thomas pleyber wrote:
> Hi developers
>
>
> I successfully load hierarchical 3ds models using the
> EvalTransformMatrix() workaround.
>
> Now, when I want to export a mesh, I fill its LCS matrix, but its
> obviously not
> enough : when I re-load the exported model, the file evaluation computes the
> node's matrix accordingly to its pos/rot/scl_track fields, and
> EvalTransformMatrix()
> ends up providing me a wrong result.
>
> So I tried to fill these "track" fields with the local transformation
> components (T,R,S) of
> the mesh, but it seems not to be the solution.
>
> My question is : what information should contain the "track" fields of a
> node when
> exporting a model so that transformations are retained when I reload the
> file ?
>
>
> Thank you for any enlightening explanation
>
>
> Thomas
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> lib3ds-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/lib3ds-devel
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
lib3ds-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lib3ds-devel