# HG changeset patch # User John Tsiombikas # Date 1397987006 -10800 # Node ID 8ecaf9cd3ce7eabe9969d7f9fa1643e5b355011f # Parent 8970ca3d55e01e372637e0228bb7c167b431f220 progress on the exporter diff -r 8970ca3d55e0 -r 8ecaf9cd3ce7 exporters/maxgoat/src/maxgoat.cc --- a/exporters/maxgoat/src/maxgoat.cc Sat Apr 19 08:01:37 2014 +0300 +++ b/exporters/maxgoat/src/maxgoat.cc Sun Apr 20 12:43:26 2014 +0300 @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include "max.h" @@ -39,6 +40,11 @@ static INT_PTR CALLBACK scene_gui_handler(HWND win, unsigned int msg, WPARAM wparam, LPARAM lparam); static INT_PTR CALLBACK anim_gui_handler(HWND win, unsigned int msg, WPARAM wparam, LPARAM lparam); +static void get_position_keys(IGameControl *ctrl, goat3d_node *node); +static void get_xyz_position_keys(IGameControl *ctrl, goat3d_node *node); +static void get_rotation_keys(IGameControl *ctrl, goat3d_node *node); +static void get_euler_keys(IGameControl *ctrl, goat3d_node *node); +static void get_scaling_keys(IGameControl *ctrl, goat3d_node *node); static const char *max_string(const MCHAR *wstr); HINSTANCE hinst; @@ -294,21 +300,199 @@ // grab the animation data IGameControl *ctrl = maxnode->GetIGameControl(); - IGameKeyTab tm_keys; - if(ctrl->GetFullSampledKeys(tm_keys, 1, IGAME_TM)) { - maxlog("node: %s has %d keys\n", name, tm_keys.Count()); - /*for(int i=0; iIsAnimated(IGAME_POS) || ctrl->IsAnimated(IGAME_POS_X) || + ctrl->IsAnimated(IGAME_POS_Y) || ctrl->IsAnimated(IGAME_POS_Z)) { + get_position_keys(ctrl, node); + } + if(ctrl->IsAnimated(IGAME_ROT) || ctrl->IsAnimated(IGAME_EULER_X) || + ctrl->IsAnimated(IGAME_EULER_Y) || ctrl->IsAnimated(IGAME_EULER_Z)) { + get_rotation_keys(ctrl, node); + } + if(ctrl->IsAnimated(IGAME_SCALE)) { + get_scaling_keys(ctrl, node); + } for(int i=0; iGetChildCount(); i++) { process_node(goat, node, maxnode->GetNodeChild(i)); } } +#define KEY_TIME(key) ((long)(TicksToSec(key.t) * 1000.0)) + +static void get_position_keys(IGameControl *ctrl, goat3d_node *node) +{ + const char *nodename = goat3d_get_node_name(node); + IGameKeyTab keys; + + if(ctrl->GetLinearKeys(keys, IGAME_POS)) { + maxlog("node %s: getting %d linear position keys\n", nodename, keys.Count()); + for(int i=0; iGetBezierKeys(keys, IGAME_POS)) { + maxlog("node %s: getting %d bezier position keys\n", nodename, keys.Count()); + for(int i=0; iGetTCBKeys(keys, IGAME_POS)) { + maxlog("node %s: getting %d tcb position keys\n", nodename, keys.Count()); + for(int i=0; i pos; + + for(int i=0; i<3; i++) { + if(ctrl->GetLinearKeys(keys, postype[i])) { + maxlog("node %s: getting %d linear position %c keys\n", nodename, keys.Count(), "xyz"[i]); + for(int j=0; jGetBezierKeys(keys, postype[i])) { + maxlog("node %s: getting %d bezier position %c keys\n", nodename, keys.Count(), "xyz"[i]); + for(int j=0; jGetTCBKeys(keys, postype[i])) { + maxlog("node %s: getting %d tcb position %c keys\n", nodename, keys.Count(), "xyz"[i]); + for(int j=0; j::iterator it = pos.begin(); + while(it != pos.end()) { + Point3 p = it->second; + goat3d_set_node_position(node, p.x, p.y, p.z, it->first); + ++it; + } +} + +static void get_rotation_keys(IGameControl *ctrl, goat3d_node *node) +{ + const char *nodename = goat3d_get_node_name(node); + IGameKeyTab rkeys; + + if(ctrl->GetLinearKeys(rkeys, IGAME_ROT)) { + maxlog("node %s: getting %d linear rotation keys\n", nodename, rkeys.Count()); + for(int i=0; iGetBezierKeys(rkeys, IGAME_ROT)) { + maxlog("node %s: getting %d bezier rotation keys\n", nodename, rkeys.Count()); + for(int i=0; iGetTCBKeys(rkeys, IGAME_ROT)) { + maxlog("node %s: getting %d TCB rotation keys\n", nodename, rkeys.Count()); + for(int i=0; i euler; + + for(int i=0; i<3; i++) { + if(ctrl->GetLinearKeys(keys, eulertype[i])) { + maxlog("node %s: getting %d linear euler %c keys\n", nodename, keys.Count(), "xyz"[i]); + for(int j=0; jGetBezierKeys(keys, eulertype[i])) { + maxlog("node %s: getting %d bezier euler %c keys\n", nodename, keys.Count(), "xyz"[i]); + for(int j=0; jGetTCBKeys(keys, eulertype[i])) { + maxlog("node %s: getting %d tcb euler %c keys\n", nodename, keys.Count(), "xyz"[i]); + for(int j=0; jGetEulerOrder(); + std::map::iterator it = euler.begin(); + while(it != euler.end()) { + Quat q; + EulerToQuat(it->second, q, order); + goat3d_set_node_rotation(node, q.x, q.y, q.z, q.w, it->first); + ++it; + } +} + +static void get_scaling_keys(IGameControl *ctrl, goat3d_node *node) +{ + const char *nodename = goat3d_get_node_name(node); + IGameKeyTab keys; + + // XXX the way I'm using the ScaleValue is wrong, but fuck it... + + if(ctrl->GetLinearKeys(keys, IGAME_SCALE)) { + maxlog("node %s: getting %d linear scaling keys\n", nodename, keys.Count()); + for(int i=0; iGetBezierKeys(keys, IGAME_SCALE)) { + maxlog("node %s: getting %d bezier scaling keys\n", nodename, keys.Count()); + for(int i=0; iGetTCBKeys(keys, IGAME_SCALE)) { + maxlog("node %s: getting %d tcb scaling keys\n", nodename, keys.Count()); + for(int i=0; itracks[track_type_base[trackid]].count; + if(anim) { + return anim->tracks[track_type_base[trackid]].count; + } + return 0; } int XFormNode::get_position_key_count() const