Paul.Brodin Posted March 26, 2015 Share Posted March 26, 2015 Can anyone tell how to generate the 'handles' required in the TRACK xml. I am trying to import a track from another system, ive got the basic mechanism in place, but cant get the smoothing to work, i was hoping that just setting the parameter type to (automatic) 4, and not provide any handles would work, but that still results in a straightline movement, when the track is playing in uniginescript track object this is what iam currently generating <keys_x> <key time="0" type="1">1192.502</key> <key time="0.159729414707632" type="1">1080.381</key> <key time="0.441480492267639" type="1">892.244</key> <key time="0.441480492267639" type="4">892.244</key> <key time="0.51129575212342" type="4">843.600</key> <key time="0.581110369200729" type="4">787.483</key> <key time="0.65092562905651" type="4">756.765</key> <key time="0.720740246133819" type="4">769.440</key> <key time="0.7905555059896" type="4">818.084</key> <key time="0.86037012306691" type="4">874.201</key> <key time="0.930185382922691" type="4">904.919</key> <key time="1" type="4">892.244</key> </keys_x> this is what seems to be required <key time="0" type="1">1192.5</key> <key time="0.159729" type="1">1080.38</key> <key time="0.44148" type="1">892.244</key> <key time="0.44148" type="4" handles="-0.0116359 8.10734 0.0116359 -8.10734">892.244</key> <key time="0.511296" type="4" handles="-0.0232716 17.4602 0.0232716 -17.4602">843.6</key> <key time="0.58111" type="4" handles="-0.0232717 14.4725 0.0232717 -14.4725">787.483</key> <key time="0.650926" type="4" handles="-0.0232717 3.00716 0.0232717 -3.00716">756.765</key> <key time="0.72074" type="4" handles="-0.0232716 -10.2198 0.0232716 10.2198">769.44</key> <key time="0.790555" type="4" handles="-0.0232716 -17.4602 0.0232716 17.4602">818.084</key> <key time="0.86037" type="4" handles="-0.0232717 -14.4725 0.0232717 14.4725">874.201</key> <key time="0.930185" type="4" handles="-0.0232717 -3.00717 0.0232717 3.00717">904.919</key> <key time="1" type="4" handles="-0.0116358 2.1125 0.0116358 -2.1125">892.244</key> Link to comment
unclebob Posted March 27, 2015 Share Posted March 27, 2015 Hey Paul, All smooth key types require calculated handles. In AUTO mode they're calculated in a very simple way (you can have a look at <sdkroot>/data/core/systems/widgets/widget_track.h file, updateKeys function): forloop(int i = 0; keys.size()) { TrackKey key = keys[i]; if(key.getType() == TRACK_KEY_AUTO) { vec4 handles = vec4_zero; if(i > 0) { TrackKey prev = keys[i - 1]; handles.x = (prev.getTime() - key.getTime()) / 3.0f; handles.y = (prev.getValue() - key.getValue()) / 3.0f; } if(i + 1 < keys.size()) { TrackKey next = keys[i + 1]; handles.z = (next.getTime() - key.getTime()) / 3.0f; handles.w = (next.getValue() - key.getValue()) / 3.0f; } handles.x = (handles.x - handles.z) / 2.0f; handles.y = (handles.y - handles.w) / 2.0f; handles.z = -handles.x; handles.w = -handles.y; key.setHandles(handles); } } Link to comment
Recommended Posts