/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ struct ObjEPoseStr = [ EPOSE_child : SO3_OBJECT, EPOSE_lLines : [SO3_OBJECT r1], EPOSE_tPose : [[F F F] [F F F F] [F F F] [F F F] F], EPOSE_strKey : EdTLKey ]mkObjEPoseStr;; struct ObjETrackStr = [ ETRACK_inst : PInstance, ETRACK_ctrlTimeLine : EdControl, ETRACK_poseCtrls : [[EdControl EdControl EdControl] [EdControl EdControl EdControl] [EdControl EdControl EdControl] [EdControl EdControl EdControl EdControl]], ETRACK_inipos : [[F F F] [F F F F] [F F F]], ETRACK_child : SO3_OBJECT, ETRACK_path : SO3_OBJECT, ETRACK_lPoses : [[EdTLKey ObjEPoseStr] r1], ETRACK_nbKeys : F, ETRACK_fKps : F, ETRACK_trmUpdate : Timer, ETRACK_oldindex : I, ETRACK_angcoef : F, ETRACK_angstep : F, ETRACK_coef : F, ETRACK_fDirection : F, ETRACK_bPingPong : I, ETRACK_bToTarget : I, ETRACK_iToAxis : I, ETRACK_bLocal : I, ETRACK_bLoop : I, ETRACK_iTick : I, ETRACK_iCurIndex : I, ETRACK_iEditMode : I ]mkObjETrackStr;; typeof lObjTrackInst = [[PInstance ObjETrackStr] r1];; proto cbSetPose = fun [ObjETrackStr I] I;; proto UpdatePosKey = fun [ObjETrackStr ObjEPoseStr] I;; fun removeInstFromList(l, inst)= if l==nil then nil else let hd l -> [cinst _] in if inst == cinst then tl l else (hd l)::removeInstFromList tl l inst;; fun removePoseFromList(l, posestr)= if l==nil then nil else let hd l -> [_ cposestr] in if posestr == cposestr then tl l else (hd l)::removePoseFromList tl l posestr;; fun getPosInListByKey(l, eltstr)= let nil -> pos in let 0 -> i in ( while ((l != nil) && (pos == nil)) do ( let hd l -> [feltstr _] in if (feltstr != eltstr) then nil else set pos = i; set l = tl l; set i = i + 1; ); pos; );; fun getPosInListByPose(l, eltstr)= let nil -> pos in let 0 -> i in ( while ((l != nil) && (pos == nil)) do ( let hd l -> [_ feltstr] in if (feltstr != eltstr) then nil else set pos = i; set l = tl l; set i = i + 1; ); pos; );; fun getPrevAndNextPoses(edstr, posestr)= let getPosInListByPose edstr.ETRACK_lPoses posestr -> pos in let nth_list edstr.ETRACK_lPoses (pos - 1) -> [_ pposestr] in let nth_list edstr.ETRACK_lPoses (pos + 1) -> [_ nposestr] in [pos pposestr nposestr];; fun cbDestroyEdit(p)= let p -> [inst edstr viewstr] in ( set lObjTrackInst = removeInstFromList lObjTrackInst inst; if (lObjTrackInst) != nil then nil else setEditorModeState viewstr 1; if (edstr.ETRACK_trmUpdate == nil) then nil else ( _deltimer edstr.ETRACK_trmUpdate; set edstr.ETRACK_trmUpdate = nil; ); setPluginInstanceEditorCbPreRender inst nil; SO3ObjectDestroy edstr.ETRACK_path; set edstr.ETRACK_path = nil; let edstr.ETRACK_inipos -> [pos quat scale] in ( SO3ObjectSetPosition edstr.ETRACK_child pos; SO3ObjectSetOrientation edstr.ETRACK_child quat; SO3ObjectSetScale edstr.ETRACK_child scale; ); while (edstr.ETRACK_lPoses != nil) do ( let hd edstr.ETRACK_lPoses -> [_ posestr] in ( while (posestr.EPOSE_lLines != nil) do ( SO3ObjectDestroy hd posestr.EPOSE_lLines; set posestr.EPOSE_lLines = tl posestr.EPOSE_lLines; ); V3DshowObjectAxis (V3DgetSessionView c3dXsession) c3dXsession posestr.EPOSE_child 1 0; SO3ObjectDestroy posestr.EPOSE_child; set posestr.EPOSE_child = nil; ); set edstr.ETRACK_lPoses = tl edstr.ETRACK_lPoses; ); ); 0;; // 2t3 - 3t2 + 1 fun H1(coef)= (2.0 *. (pow coef 3.0)) -. (3.0 *. (pow coef 2.0)) +. 1.0;; // -2t3 + 3t2 fun H2(coef)= (-. 2.0 *. (pow coef 3.0)) +. (3.0 *. (pow coef 2.0));; // t3 - 2t2 +t fun H3(coef)= (pow coef 3.0) -. (2.0 *. (pow coef 2.0)) +. coef;; // t3 - t2 fun H4(coef)= (pow coef 3.0) -. (pow coef 2.0);; fun getInterpolateCurve(vec1, vec2, ang1, ang2, coef)= let vec1 -> [x1 y1 z1] in let vec2 -> [x2 y2 z2] in let ang1 -> [ax1 ay1 az1] in let ang2 -> [ax2 ay2 az2] in let ((H1 coef) *. x1) +. ((H2 coef) *. x2) +. ((H3 coef) *. ax1) +. ((H4 coef) *. ax2) -> x in let ((H1 coef) *. y1) +. ((H2 coef) *. y2) +. ((H3 coef) *. ay1) +. ((H4 coef) *. ay2) -> y in let ((H1 coef) *. z1) +. ((H2 coef) *. z2) +. ((H3 coef) *. az1) +. ((H4 coef) *. az2) -> z in [x y z] ;; fun getPosTime(pos)= let pos -> [_ _ _ _ ti] in ti;; fun getPosTension(pos)= let pos -> [_ _ _ [t c b] _] in t;; fun getPosContinuity(pos)= let pos -> [_ _ _ [t c b] _] in c;; fun getPosBias(pos)= let pos -> [_ _ _ [t c b] _] in b;; fun getPosX(pos)= let pos -> [[x y z] _ _ _ _] in x;; fun getPosY(pos)= let pos -> [[x y z] _ _ _ _] in y;; fun getPosZ(pos)= let pos -> [[x y z] _ _ _ _] in z;; fun getPosXYZ(pos)= let pos -> [[x y z] _ _ _ _] in [x y z];; fun getPosRotation(pos)= let pos -> [_ quat _ _ _] in quat;; fun getPosScale(pos)= let pos -> [_ _ [sx sy sz] _ _] in [sx sy sz];; fun vecLerpF(v1, v2, coef)= let multiplyVectorF v2 [coef coef coef] -> v1t in let multiplyVectorF v1 [(1.0 -. coef) (1.0 -. coef) (1.0 -. coef)] -> v2t in addVectorF v1t v2t;; fun getInterpolateTCB(lpos, t)= let sizelist lpos -> size in let size - 1 -> sizeminus in let 0 -> i in let nil -> outvec in ( if (t == 0.0) then ( let hd lpos -> [_ posestr] in set outvec = [1 (getPosXYZ posestr.EPOSE_tPose)]; 0; ) else ( while ((i < size) && (outvec == nil)) do ( let nth_list lpos i -> [_ posestr] in let posestr.EPOSE_tPose -> nextpos in if ((t -. 0.00001) <=. (getPosTime nextpos)) then ( let nth_list lpos (i - 1) -> [_ cposestr] in let if (cposestr == nil) then nextpos else cposestr.EPOSE_tPose -> curpos in let nth_list lpos (i - 2) -> [_ pposestr] in let if (pposestr == nil) then curpos else pposestr.EPOSE_tPose -> prevpos in let nth_list lpos (i + 1) -> [_ nnposestr] in let if (nnposestr == nil) then nextpos else nnposestr.EPOSE_tPose -> nextnextpos in let (getPosTime nextpos) -. (getPosTime curpos) -> pdiff in let if (pdiff <=. 0.0) then 1.0 else pdiff -> pdiff in let ((t -. (getPosTime curpos)) /. pdiff) -> coef in //Update values from TCB let (1.0 -. (getPosTension curpos)) -> OneMinusTension in let (1.0 -. (getPosContinuity curpos)) -> OneMinusContinuity in let (1.0 +. (getPosContinuity curpos)) -> OnePlusContinuity in let (1.0 -. (getPosBias curpos)) -> OneMinusBias in let (1.0 +. (getPosBias curpos)) -> OnePlusBias in let (OneMinusTension *. 0.5) +. ((1.0 -. (getPosTension nextpos)) *. 0.5) -> OneMinusTension in let (OneMinusContinuity *. 0.5) +. ((1.0 -. (getPosContinuity nextpos)) *. 0.5) -> OneMinusContinuity in let (OnePlusContinuity *. 0.5) +. ((1.0 +. (getPosContinuity nextpos)) *. 0.5) -> OnePlusContinuity in let (OneMinusBias *. 0.5) +. ((1.0 -. (getPosBias nextpos)) *. 0.5) -> OneMinusBias in let (OneMinusBias *. 0.5) +. ((1.0 +. (getPosBias nextpos)) *. 0.5) -> OnePlusBias in let (0.5 *. ((OneMinusTension *. OnePlusContinuity *. OnePlusBias) *. ((getPosX curpos) -. (getPosX prevpos))) +. (0.5 *. (OneMinusTension *. OneMinusContinuity *. OneMinusBias) *. ((getPosX nextpos) -. (getPosX curpos)))) -> tancurposx in let (0.5 *. ((OneMinusTension *. OnePlusContinuity *. OnePlusBias) *. ((getPosY curpos) -. (getPosY prevpos))) +. (0.5 *. (OneMinusTension *. OneMinusContinuity *. OneMinusBias) *. ((getPosY nextpos) -. (getPosY curpos)))) -> tancurposy in let (0.5 *. ((OneMinusTension *. OnePlusContinuity *. OnePlusBias) *. ((getPosZ curpos) -. (getPosZ prevpos))) +. (0.5 *. (OneMinusTension *. OneMinusContinuity *. OneMinusBias) *. ((getPosZ nextpos) -. (getPosZ curpos)))) -> tancurposz in let (0.5 *. ((OneMinusTension *. OneMinusContinuity *. OnePlusBias) *. ((getPosX nextpos) -. (getPosX curpos))) +. (0.5 *. (OneMinusTension *. OnePlusContinuity *. OneMinusBias) *. ((getPosX nextnextpos) -. (getPosX nextpos)))) -> tannextposx in let (0.5 *. ((OneMinusTension *. OneMinusContinuity *. OnePlusBias) *. ((getPosY nextpos) -. (getPosY curpos))) +. (0.5 *. (OneMinusTension *. OnePlusContinuity *. OneMinusBias) *. ((getPosY nextnextpos) -. (getPosY nextpos)))) -> tannextposy in let (0.5 *. ((OneMinusTension *. OneMinusContinuity *. OnePlusBias) *. ((getPosZ nextpos) -. (getPosZ curpos))) +. (0.5 *. (OneMinusTension *. OnePlusContinuity *. OneMinusBias) *. ((getPosZ nextnextpos) -. (getPosZ nextpos)))) -> tannextposz in let getInterpolateCurve (getPosXYZ curpos) (getPosXYZ nextpos) [tancurposx tancurposy tancurposz] [tannextposx tannextposy tannextposz] coef -> [x y z] in set outvec = [i [x y z]]; 0; ) else nil; set i = i + 1; ); ); outvec; );; fun getPosesData(l)= let sizelist l -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( let nth_list l i -> [_ posestr] in let posestr.EPOSE_tPose -> [[px py pz] quat [sx sy sz] [t c b] d] in //let SO3MathsQuatToEulerDegreePYR quat -> [ax ay az] in let SO3MathsQuatToEulerYXZ quat -> [ax ay az] in let SO3MathsRadianToDegree ax -> ax in let SO3MathsRadianToDegree ay -> ay in let SO3MathsRadianToDegree az -> az in ( set ndata = [(strcat "posx_" (itoa i)) (ftoa px)]::ndata; set ndata = [(strcat "posy_" (itoa i)) (ftoa py)]::ndata; set ndata = [(strcat "posz_" (itoa i)) (ftoa pz)]::ndata; set ndata = [(strcat "angx_" (itoa i)) (ftoa ax)]::ndata; set ndata = [(strcat "angy_" (itoa i)) (ftoa ay)]::ndata; set ndata = [(strcat "angz_" (itoa i)) (ftoa az)]::ndata; set ndata = [(strcat "scalex_" (itoa i)) (ftoa sx)]::ndata; set ndata = [(strcat "scaley_" (itoa i)) (ftoa sy)]::ndata; set ndata = [(strcat "scalez_" (itoa i)) (ftoa sz)]::ndata; set ndata = [(strcat "T_" (itoa i)) (ftoa t)]::ndata; set ndata = [(strcat "C_" (itoa i)) (ftoa c)]::ndata; set ndata = [(strcat "B_" (itoa i)) (ftoa b)]::ndata; set ndata = [(strcat "D_" (itoa i)) (ftoa d)]::ndata; ); set i = i + 1; ); ndata; );; fun getEvents(l)= let sizelist l -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( set ndata = ["EVENT" strcat "Key " (itoa (i + 1))]::ndata; set i = i + 1; ); ndata; );; fun cbCloseEdit(p)= let p -> [edstr ctrlsourcename ctrlkps ctrlnbkeys ctrlloop ctrlping ctrltarget ctrlaxis ctrllocal ctrlinit] in let getEdCtrlTextLineValue ctrlsourcename -> sourcename in let getEdCtrlFloatValue ctrlkps -> kps in let getEdCtrlFloatValue ctrlnbkeys -> nbkeys in let getEdCtrlCheckState ctrlloop -> loop in let getEdCtrlCheckState ctrlping -> ping in let getEdCtrlCheckState ctrltarget -> target in let getSelectedEdCtrlSelectPos ctrlaxis -> axis in let getEdCtrlCheckState ctrllocal -> local in let getEdCtrlCheckState ctrlinit -> init in ["sourceobject" sourcename]:: ["kps" ftoa kps]:: ["nbkeys" ftoa nbkeys]:: ["loop" itoa loop]:: ["ping" itoa ping]:: ["target" itoa target]:: ["axis" itoa axis]:: ["local" itoa local]:: ["init" itoa init]:: lcat (getPosesData edstr.ETRACK_lPoses) (getEvents edstr.ETRACK_lPoses);; fun cbSelectObj(val, type, p)= let p -> [inst edstr winstr viewstr ctrldestname] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> obj in if (obj != nil) || (!strcmpi "Current camera" val) || (!strcmpi "Current camera shell" val) then ( let edstr.ETRACK_inipos -> [pos quat scale] in ( SO3ObjectSetPosition edstr.ETRACK_child pos; SO3ObjectSetOrientation edstr.ETRACK_child quat; SO3ObjectSetScale edstr.ETRACK_child scale; ); set edstr.ETRACK_child = V3DgetObjectByName c3dXsession val; set edstr.ETRACK_inipos = [(SO3ObjectGetPosition edstr.ETRACK_child) (SO3ObjectGetOrientation edstr.ETRACK_child) (SO3ObjectGetScale edstr.ETRACK_child)]; setEdCtrlTextLineValue ctrldestname val; ) else nil; 0;; fun cbCloseRes(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; fun cbBtnPickObj(ctrlbtn, p)= let p -> [inst edstr winstr viewstr ctrldestname objname] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeGroup|iTypeEntity|iTypeNode|iTypeLight|iTypeCamera|iTypeParticle|iTypeBone|iTypeCubeMap objname mkfun3 @cbSelectObj [inst edstr winstr viewstr ctrldestname] mkfun1 @cbCloseRes ctrlbtn 0; ); 0;; fun cbRefreshBtn(pickbtn, p)= let p -> [ctrlobjname] in setEdCtrlTextLineValue ctrlobjname ""; 0;; fun getTrackDuration(edstr)= let edstr.ETRACK_nbKeys /. edstr.ETRACK_fKps -> dur in if (dur <=. 0.0) then 0.1 else dur;; fun getKeyDuration(edstr)= (240.0 /. (itof getEdCtrlTimeLinePixelPerUnit edstr.ETRACK_ctrlTimeLine)) /. 38.0;; fun getKeyPosInTimeFromCoef(edstr, d)= let getTrackDuration edstr -> dur in let getKeyDuration edstr -> kdur in (d *. dur) -. (kdur *. 0.5);; fun getKeyPosInTime(edstr, posestr)= let getPosTime posestr.EPOSE_tPose -> d in getKeyPosInTimeFromCoef edstr d;; fun updateKeysInTimeline(edstr)= let edstr.ETRACK_lPoses -> lposes in while (lposes != nil) do ( let hd lposes -> [_ posestr] in let getKeyPosInTime edstr posestr -> pos in setEdCtrlTimeLinekeyParamsEx edstr.ETRACK_ctrlTimeLine posestr.EPOSE_strKey pos (getKeyDuration edstr) 0; set lposes = tl lposes; ); updateEdCtrlTimeLineTracks edstr.ETRACK_ctrlTimeLine 1; 0;; fun cbDotAxisMove(sessionstr, axisstr, axis, x, y, btn, coef, p)= let axisstr.V3D_axisFather -> obj in let p -> [edstr selected] in let edstr.ETRACK_poseCtrls -> [[ctrlposx ctrlposy ctrlposz] [ctrlangx ctrlangy ctrlangz] [ctrlscalex ctrlscaley ctrlscalez] [ctrlT ctrlC ctrlB ctrlD]] in let if (axisstr.V3D_iAxisRef == 0) then SO3_LOCAL_TS else if (axisstr.V3D_iAxisRef == 1) then SO3_WORLD_TS else SO3_LOCAL_TS -> rep in if (btn & 1) && (edstr.ETRACK_iEditMode == 1) then ( let if axis == V3DAXIS_X then [coef 0.0 0.0] else if axis == V3DAXIS_Y then [0.0 coef 0.0] else if axis == V3DAXIS_Z then [0.0 0.0 coef] else nil -> trans in //adjust trans direction to avoid scale error let if (rep == SO3_LOCAL_TS) then SO3MathsQuatGetDirection (SO3ObjectGetGlobalOrientation obj) trans else trans -> trans in SO3ObjectTranslate obj trans SO3_WORLD_TS; let if edstr.ETRACK_bLocal && (edstr.ETRACK_child != nil) then SO3ObjectGetPositionInObjectRef obj SO3ObjectGetParent edstr.ETRACK_child else SO3ObjectGetPosition obj -> [opx opy opz] in ( setEdCtrlFloatValueWithoutCallback ctrlposx opx; setEdCtrlFloatValueWithoutCallback ctrlposy opy; setEdCtrlFloatValueWithoutCallback ctrlposz opz; cbSetPose edstr 1; ); 0; ) else if (btn & 1) && (edstr.ETRACK_iEditMode == 2) then ( if axis == V3DAXIS_X then SO3ObjectRotatePitch obj (SO3MathsDegreeToRadian (itof y + x)) rep else if axis == V3DAXIS_Y then SO3ObjectRotateYaw obj (SO3MathsDegreeToRadian (itof y + x)) rep else if axis == V3DAXIS_Z then SO3ObjectRotateRoll obj (SO3MathsDegreeToRadian (itof y + x)) rep else nil; //let SO3MathsQuatToEulerDegreePYR (SO3ObjectGetOrientation obj) -> [ex ey ez] in let if edstr.ETRACK_bLocal && (edstr.ETRACK_child != nil) then SO3MathsQuatSubstract SO3ObjectGetGlobalOrientation (SO3ObjectGetParent edstr.ETRACK_child) (SO3ObjectGetOrientation obj) else (SO3ObjectGetOrientation obj) -> quat in let SO3MathsQuatToEulerYXZ quat -> [ex ey ez] in let SO3MathsRadianToDegree ex -> ex in let SO3MathsRadianToDegree ey -> ey in let SO3MathsRadianToDegree ez -> ez in ( setEdCtrlFloatValueWithoutCallback ctrlangx ex; setEdCtrlFloatValueWithoutCallback ctrlangy ey; setEdCtrlFloatValueWithoutCallback ctrlangz ez; cbSetPose edstr 0; ); 0; ) else if (btn & 1) && (edstr.ETRACK_iEditMode == 3) then ( let SO3ObjectGetGlobalOrientation obj -> gquat in let SO3ObjectGetGlobalScale obj -> cscale in let if (axisstr.V3D_iAxisRef == 0) || ((_keybdstate &4) || (axis == V3DAXIS_H)) then cscale else SO3MathsQuatGetDirection gquat cscale -> [csx csy csz] in let axisstr.V3D_tAxisClickPRS -> [_ _ [bsc bsy bsz]] in let [(coef *. (bsc *. (itof iGlobalUnit))) (coef *. (bsy *. (itof iGlobalUnit))) (coef *. (bsz *. (itof iGlobalUnit)))] -> [coefx coefy coefz] in let if ((_keybdstate &4) || (axis == V3DAXIS_H)) then //alt [(csx +. coefx) (csy +. coefy) (csz +. coefz)] else if axis == V3DAXIS_X then [(csx +. coefx) csy csz] else if axis == V3DAXIS_Y then [csx (csy +. coefy) csz] else if axis == V3DAXIS_Z then [csx csy (csz +. coefz)] else nil -> [nsx nsy nsz] in let if (axisstr.V3D_iAxisRef == 0) || ((_keybdstate &4) || (axis == V3DAXIS_H)) then [nsx nsy nsz] else SO3MathsQuatGetDirection (quatInverse gquat) [nsx nsy nsz] -> [nsx nsy nsz] in let [(if (nsx <=. 0.000001) then 0.00001 else nsx) (if (nsy <=. 0.00001) then 0.00001 else nsy) (if (nsz <=. 0.00001) then 0.00001 else nsz)] -> scale in SO3ObjectSetGlobalScale obj scale; let SO3ObjectGetScale obj -> [sx sy sz] in ( setEdCtrlFloatValueWithoutCallback ctrlscalex sx; setEdCtrlFloatValueWithoutCallback ctrlscaley sy; setEdCtrlFloatValueWithoutCallback ctrlscalez sz; cbSetPose edstr 0; ); 0; ) else nil; 0;; fun cbDotAxisUnClick(sessionstr, obj, axis, x, y, btn, p)= let p -> [edstr selected] in cbSetPose edstr 1; 0;; fun cbDotAxisClick(axisstr, sessionstr, obj, axis, x, y, btn, p)= let p -> [edstr selected] in ( V3DsetCbAxisMove axisstr mkfun8 @cbDotAxisMove p; V3DsetCbAxisUnClick axisstr mkfun7 @cbDotAxisUnClick p; ); 0;; fun getTargetAxis(edstr)= if (edstr.ETRACK_iToAxis == 0) then [1.0 0.0 0.0] else if (edstr.ETRACK_iToAxis == 1) then [(-.1.0) 0.0 0.0] else if (edstr.ETRACK_iToAxis == 2) then [0.0 1.0 0.0] else if (edstr.ETRACK_iToAxis == 3) then [0.0 (-.1.0) 0.0] else if (edstr.ETRACK_iToAxis == 4) then [0.0 0.0 1.0] else [0.0 0.0 (-.1.0)];; fun getViewDirection(strobj, ovec, oang, tvec)= let ovec -> [vx vy vz] in let tvec -> [dx dy dz] in //TODO enable vertors XYZ XZ let normalizeVectorF (subVectorF [dx vy dz] ovec) -> dir in let normalizeVectorF (SO3MathsQuatGetDirection oang getTargetAxis strobj) -> src in let SO3MathsQuatToEulerPYR (SO3MathsGetRotationTo src dir) -> [pitch yaw roll] in let if ((1.0 +. dotVectorF src dir) <. 0.0001) then PIf *. 2.0 else yaw -> yaw in let SO3MathsQuatAdd SO3MathsEulerPYRToQuat [0.0 yaw 0.0] oang -> nquat in ( nquat; );; fun updatePreview(edstr)= if (edstr.ETRACK_child == nil) then nil else ( let getInterpolateTCB edstr.ETRACK_lPoses edstr.ETRACK_coef -> [index tvec] in let (SO3ObjectGetGlobalPosition edstr.ETRACK_child) -> ovec in let (SO3ObjectGetGlobalOrientation edstr.ETRACK_child) -> oang in let nth_list edstr.ETRACK_lPoses (index - 1) -> [_ sposestr] in let sposestr.EPOSE_tPose -> [spos sang sscale _ t1] in let nth_list edstr.ETRACK_lPoses index -> [_ dposestr] in let dposestr.EPOSE_tPose -> [dpos dang dscale _ t2] in let if (dposestr == nil) then [spos sang sscale t1] else [dpos dang dscale t2] -> [dpos dang dscale t2] in let (if t1 == nil then 0.0 else t1) -> t1 in let (if t2 == nil then 1.0 else t2) -> t2 in let t2 -. t1 -> lenght in let if (lenght == 0.0) then 1.0 else (lenght /. (1.0 /. edstr.ETRACK_nbKeys)) -> nbk in let (1.0 /. nbk) -> angstep in let if (lenght == 0.0) then 1.0 else (((lenght -. (t2 -. edstr.ETRACK_coef)) /. (lenght /. nbk)) *. angstep) -> angcoef in let vecLerpF sscale dscale angcoef -> tscale in let if (edstr.ETRACK_bToTarget) then getViewDirection edstr ovec oang tvec else SO3MathsQuatInterpolate sang dang angcoef 1 -> tang in ( if (edstr.ETRACK_bLocal) then ( SO3ObjectSetPosition edstr.ETRACK_child tvec; SO3ObjectSetOrientation edstr.ETRACK_child tang; ) else ( SO3ObjectSetGlobalPosition edstr.ETRACK_child tvec; SO3ObjectSetGlobalOrientation edstr.ETRACK_child tang; ); SO3ObjectSetScale edstr.ETRACK_child tscale; ); ); 0;; fun refreshPoses(edstr, selected)= let edstr.ETRACK_lPoses -> lposes in let 0 -> i in while (lposes != nil) do ( let hd lposes -> [_ posestr] in let posestr.EPOSE_tPose -> dot in let if edstr.ETRACK_bLocal && (edstr.ETRACK_child != nil) then SO3ObjectGetGlobalPosition SO3ObjectGetParent edstr.ETRACK_child else [0.0 0.0 0.0] -> offset in let if edstr.ETRACK_bLocal && (edstr.ETRACK_child != nil) then SO3ObjectGetGlobalScale SO3ObjectGetParent edstr.ETRACK_child else [1.0 1.0 1.0] -> oscale in let if edstr.ETRACK_bLocal && (edstr.ETRACK_child != nil) then addVectorF (SO3MathsQuatGetDirection (SO3ObjectGetGlobalOrientation SO3ObjectGetParent edstr.ETRACK_child) multiplyVectorF oscale (getPosXYZ dot)) offset else (getPosXYZ dot) -> [px py pz] in let getPosRotation dot -> quat in let getPosScale dot -> scale in let nil -> lpoints in let nil -> lpoints2 in let if posestr == selected then 0x00ff0000 else 0x0000ff00 -> color in let 0xff000000 -> colorx in let 0x00ff0000 -> colory in let 0x0000ff00 -> colorz in ( let 0.05 -> r in let (2.0 *. PIf) /. 4.0 -> step in let 0.0 -> pv in ( while (pv <=. (2.0 *. PIf)) do ( let [(px +. (r *. cos(pv))) py (pz +. (r *. sin(pv)))] -> ppos in set lpoints = ppos::lpoints; set pv = pv +. step; ); set pv = 0.0; while (pv <=. (2.0 *. PIf)) do ( let [(px +. (r *. cos(pv))) (py +. (r *. sin(pv))) pz] -> ppos in set lpoints = ppos::lpoints; set pv = pv +. step; ); set pv = 0.0; while (pv <=. (2.0 *. PIf)) do ( let [px (py +. (r *. sin(pv))) (pz +. (r *. cos(pv)))] -> ppos in set lpoints2 = ppos::lpoints2; set pv = pv +. step; ); ); let SO3MathsQuatGetDirection quat multiplyVectorF [0.1 0.0 0.0] scale -> xdir in let SO3MathsQuatGetDirection quat multiplyVectorF [0.0 0.1 0.0] scale -> ydir in let SO3MathsQuatGetDirection quat multiplyVectorF [0.0 0.0 0.1] scale -> zdir in if (posestr.EPOSE_lLines == nil) then ( set edstr.ETRACK_iCurIndex = edstr.ETRACK_iCurIndex + 1; set posestr.EPOSE_lLines = lcat posestr.EPOSE_lLines (SO3LineEntityCreate (V3DgetSession c3dXsession) (strcatn (getPluginInstanceName edstr.ETRACK_inst)::(itoa edstr.ETRACK_iCurIndex)::"_"::(itoa 1)::nil) lpoints color)::nil; set posestr.EPOSE_lLines = lcat posestr.EPOSE_lLines (SO3LineEntityCreate (V3DgetSession c3dXsession) (strcatn (getPluginInstanceName edstr.ETRACK_inst)::(itoa edstr.ETRACK_iCurIndex)::"_"::(itoa 2)::nil) lpoints2 color)::nil; set posestr.EPOSE_lLines = lcat posestr.EPOSE_lLines (SO3LineEntityCreate (V3DgetSession c3dXsession) (strcatn (getPluginInstanceName edstr.ETRACK_inst)::(itoa edstr.ETRACK_iCurIndex)::"_"::(itoa 3)::nil) [px py pz]::(addVectorF [px py pz] xdir)::nil colorx)::nil; set posestr.EPOSE_lLines = lcat posestr.EPOSE_lLines (SO3LineEntityCreate (V3DgetSession c3dXsession) (strcatn (getPluginInstanceName edstr.ETRACK_inst)::(itoa edstr.ETRACK_iCurIndex)::"_"::(itoa 4)::nil) [px py pz]::(addVectorF [px py pz] ydir)::nil colory)::nil; set posestr.EPOSE_lLines = lcat posestr.EPOSE_lLines (SO3LineEntityCreate (V3DgetSession c3dXsession) (strcatn (getPluginInstanceName edstr.ETRACK_inst)::(itoa edstr.ETRACK_iCurIndex)::"_"::(itoa 5)::nil) [px py pz]::(addVectorF [px py pz] zdir)::nil colorz)::nil; 0; ) else ( SO3LineEntitySetPoints nth_list posestr.EPOSE_lLines 0 lpoints; SO3LineEntitySetPoints nth_list posestr.EPOSE_lLines 1 lpoints2; SO3LineEntitySetDiffuse nth_list posestr.EPOSE_lLines 0 color; SO3LineEntitySetDiffuse nth_list posestr.EPOSE_lLines 1 color; SO3LineEntitySetPoints nth_list posestr.EPOSE_lLines 2 [px py pz]::(addVectorF [px py pz] xdir)::nil; SO3LineEntitySetPoints nth_list posestr.EPOSE_lLines 3 [px py pz]::(addVectorF [px py pz] ydir)::nil; SO3LineEntitySetPoints nth_list posestr.EPOSE_lLines 4 [px py pz]::(addVectorF [px py pz] zdir)::nil; 0; ); if (posestr.EPOSE_child != nil) then nil else set posestr.EPOSE_child = V3DaddShell c3dXsession strcat (getPluginInstanceName edstr.ETRACK_inst) "_dot" (itoa edstr.ETRACK_iCurIndex) nil [px py pz] quat; SO3ObjectSetPosition posestr.EPOSE_child [px py pz]; SO3ObjectSetOrientation posestr.EPOSE_child if edstr.ETRACK_bLocal && (edstr.ETRACK_child != nil) then SO3MathsQuatAdd SO3ObjectGetGlobalOrientation SO3ObjectGetParent edstr.ETRACK_child quat else quat; SO3ObjectSetScale posestr.EPOSE_child scale; if (posestr == selected) then V3DupdateObjectAxis (V3DgetSessionView c3dXsession) c3dXsession V3DsetCbAxisClick (V3DshowObjectAxis (V3DgetSessionView c3dXsession) c3dXsession posestr.EPOSE_child edstr.ETRACK_iEditMode 1) mkfun8 @cbDotAxisClick [edstr selected] else V3DshowObjectAxis (V3DgetSessionView c3dXsession) c3dXsession posestr.EPOSE_child 1 0; ); set lposes = tl lposes; set i = i + 1; ); updatePreview edstr; 0;; fun cbTimerDot(trm, p)= let p -> [edstr selected] in ( _deltimer trm; set edstr.ETRACK_trmUpdate = nil; if ((SO3LineEntityGetNumberOfPoints edstr.ETRACK_path) == (ftoi edstr.ETRACK_nbKeys)) then nil else ( SO3ObjectDestroy edstr.ETRACK_path; set edstr.ETRACK_path = nil; ); refreshPoses edstr selected; let if edstr.ETRACK_bLocal && (edstr.ETRACK_child != nil) then SO3ObjectGetGlobalPosition SO3ObjectGetParent edstr.ETRACK_child else [0.0 0.0 0.0] -> offset in let if edstr.ETRACK_bLocal && (edstr.ETRACK_child != nil) then SO3ObjectGetGlobalScale SO3ObjectGetParent edstr.ETRACK_child else [1.0 1.0 1.0] -> oscale in let (1.0 /. edstr.ETRACK_nbKeys) -> stp in let stp -> t in let nil -> ldots in ( while (t <. 1.0) do ( let getInterpolateTCB edstr.ETRACK_lPoses t -> [index tvec] in let if edstr.ETRACK_bLocal && (edstr.ETRACK_child != nil) then addVectorF (SO3MathsQuatGetDirection (SO3ObjectGetGlobalOrientation SO3ObjectGetParent edstr.ETRACK_child) multiplyVectorF oscale tvec) offset else tvec -> tvec in if index == nil then nil else set ldots = tvec::ldots; set t = t +. stp; ); if (edstr.ETRACK_path == nil) then ( set edstr.ETRACK_path = SO3LineEntityCreateDashed (V3DgetSession c3dXsession) (strcat (getPluginInstanceName edstr.ETRACK_inst) (itoa 1)) ldots 0xff000000; 0; ) else ( SO3LineEntitySetPoints edstr.ETRACK_path ldots; 0; ); ); updatePreview edstr; ); 0;; fun refreshDots(edstr, selected)= // use a very quick timer to prevent to much updates if (edstr.ETRACK_trmUpdate != nil) then nil else set edstr.ETRACK_trmUpdate = _rfltimer _starttimer _channel 5 @cbTimerDot [edstr selected]; 0;; fun stopPreview(edstr, p)= let p -> [tbstr chkplaypause] in ( setEdToolBarCheckState tbstr chkplaypause 0; setPluginInstanceEditorCbPreRender edstr.ETRACK_inst nil; set edstr.ETRACK_angcoef = 0.0; set edstr.ETRACK_coef = 0.0; set edstr.ETRACK_iTick = 0; set edstr.ETRACK_fDirection = 1.0; ); 0;; fun restartPreview(edstr)= set edstr.ETRACK_angcoef = 0.0; set edstr.ETRACK_coef = 0.0; set edstr.ETRACK_fDirection = 1.0; 0;; fun cbEditorPreRender(inst, sessionstr, etime, p)= let p -> [edstr tbstr chkplaypause] in if ((sizelist edstr.ETRACK_lPoses) < 2) then nil else let (edstr.ETRACK_fKps *. ((itof (set edstr.ETRACK_iTick = edstr.ETRACK_iTick + etime)) /. 1000.0)) /. 1000.0 -> rtick in if (rtick == 0.0) then nil else ( if ((edstr.ETRACK_coef >=. 1.0) && (edstr.ETRACK_fDirection == 1.0)) || ((edstr.ETRACK_coef <=. 0.0) && (edstr.ETRACK_fDirection == (-.1.0))) then ( set edstr.ETRACK_iTick = 0; // event if (!edstr.ETRACK_bLoop) then ( if ((!edstr.ETRACK_bPingPong) || ((edstr.ETRACK_bPingPong && (edstr.ETRACK_fDirection == (-.1.0))))) then ( stopPreview edstr [tbstr chkplaypause]; 0; ) else ( set edstr.ETRACK_fDirection = edstr.ETRACK_fDirection *. (-.1.0); 0; ); ) else if (!edstr.ETRACK_bPingPong) then ( restartPreview edstr; 0; ) else ( set edstr.ETRACK_fDirection = edstr.ETRACK_fDirection *. (-.1.0); 0; ); 0; ) else ( let rtick *. (1.0 /. edstr.ETRACK_nbKeys) *. edstr.ETRACK_fDirection -> nstep in set edstr.ETRACK_coef = if (edstr.ETRACK_coef +. nstep) >. 1.0 then 1.0 else if (edstr.ETRACK_coef +. nstep) <. 0.0 then 0.0 else edstr.ETRACK_coef +. nstep; setEdCtrlTimeLineValue edstr.ETRACK_ctrlTimeLine edstr.ETRACK_coef *. (getTrackDuration edstr); let getInterpolateTCB edstr.ETRACK_lPoses edstr.ETRACK_coef -> [index tvec] in let nth_list edstr.ETRACK_lPoses (index - 1) -> [_ sposestr] in let sposestr.EPOSE_tPose -> [spos sang sscale _ t1] in let nth_list edstr.ETRACK_lPoses index -> [_ dposestr] in let dposestr.EPOSE_tPose -> [dpos dang dscale _ t2] in let if (dposestr == nil) then [spos sang sscale t1] else [dpos dang dscale t2] -> [dpos dang dscale t2] in let if edstr.ETRACK_bLocal && (edstr.ETRACK_child != nil) then SO3ObjectGetPosition edstr.ETRACK_child else SO3ObjectGetGlobalPosition edstr.ETRACK_child -> ovec in let if edstr.ETRACK_bLocal && (edstr.ETRACK_child != nil) then SO3ObjectGetOrientation edstr.ETRACK_child else SO3ObjectGetGlobalOrientation edstr.ETRACK_child -> oang in ( if (edstr.ETRACK_oldindex != index) then ( let (if t1 == nil then 0.0 else t1) -> t1 in let (if t2 == nil then 1.0 else t2) -> t2 in let t2 -. t1 -> lenght in if (lenght == 0.0) then ( set edstr.ETRACK_angstep = 1.0; ) else ( let lenght /. (1.0 /. edstr.ETRACK_nbKeys) -> nbk in set edstr.ETRACK_angstep = 1.0 /. nbk; ); set edstr.ETRACK_oldindex = index; set edstr.ETRACK_angcoef = if (edstr.ETRACK_fDirection == 1.0) then 0.0 else 1.0; ) else nil; let rtick *. edstr.ETRACK_angstep *. edstr.ETRACK_fDirection -> nangstep in set edstr.ETRACK_angcoef = if (edstr.ETRACK_angcoef +. nangstep) >. 1.0 then 1.0 else if (edstr.ETRACK_angcoef +. nangstep) <. 0.0 then 0.0 else edstr.ETRACK_angcoef +. nangstep; if (edstr.ETRACK_child == nil) then nil else ( let if edstr.ETRACK_bToTarget then getViewDirection edstr ovec oang tvec else SO3MathsQuatInterpolate sang dang edstr.ETRACK_angcoef 1 -> tang in let vecLerpF sscale dscale edstr.ETRACK_angcoef -> tscale in ( if (edstr.ETRACK_bLocal) then ( SO3ObjectSetPosition edstr.ETRACK_child tvec; SO3ObjectSetOrientation edstr.ETRACK_child tang; ) else ( SO3ObjectSetGlobalPosition edstr.ETRACK_child tvec; SO3ObjectSetGlobalOrientation edstr.ETRACK_child tang; ); SO3ObjectSetScale edstr.ETRACK_child tscale; ); ); 0; ); ); set edstr.ETRACK_iTick = 0; ); 0;; fun loadDots(inst, edstr)= let 0 -> i in ( let getPluginInstanceParam inst (strcat "posx_" (itoa i)) -> posx in let getPluginInstanceParam inst (strcat "posy_" (itoa i)) -> posy in let getPluginInstanceParam inst (strcat "posz_" (itoa i)) -> posz in let getPluginInstanceParam inst (strcat "angx_" (itoa i)) -> angx in let getPluginInstanceParam inst (strcat "angy_" (itoa i)) -> angy in let getPluginInstanceParam inst (strcat "angz_" (itoa i)) -> angz in let getPluginInstanceParam inst (strcat "scalex_" (itoa i)) -> scalex in let getPluginInstanceParam inst (strcat "scaley_" (itoa i)) -> scaley in let getPluginInstanceParam inst (strcat "scalez_" (itoa i)) -> scalez in let getPluginInstanceParam inst (strcat "T_" (itoa i)) -> T in let getPluginInstanceParam inst (strcat "C_" (itoa i)) -> C in let getPluginInstanceParam inst (strcat "B_" (itoa i)) -> B in let getPluginInstanceParam inst (strcat "D_" (itoa i)) -> D in while (posx != nil) do ( let addEdCtrlTimeLineKey edstr.ETRACK_ctrlTimeLine 0 " " (getKeyPosInTimeFromCoef edstr (atof D)) (getKeyDuration edstr) 0 -> keystr in let SO3MathsEulerYXZToQuat [(SO3MathsDegreeToRadian atof angx) (SO3MathsDegreeToRadian atof angy) (SO3MathsDegreeToRadian atof angz)] -> quat in let mkObjEPoseStr [nil nil [[atof posx atof posy atof posz] quat [atof scalex atof scaley atof scalez] [atof T atof C atof B] atof D] keystr] -> posestr in set edstr.ETRACK_lPoses = [keystr posestr]::edstr.ETRACK_lPoses; set i = i + 1; set posx = getPluginInstanceParam inst (strcat "posx_" (itoa i)); set posy = getPluginInstanceParam inst (strcat "posy_" (itoa i)); set posz = getPluginInstanceParam inst (strcat "posz_" (itoa i)); set angx = getPluginInstanceParam inst (strcat "angx_" (itoa i)); set angy = getPluginInstanceParam inst (strcat "angy_" (itoa i)); set angz = getPluginInstanceParam inst (strcat "angz_" (itoa i)); set scalex = getPluginInstanceParam inst (strcat "scalex_" (itoa i)); set scaley = getPluginInstanceParam inst (strcat "scaley_" (itoa i)); set scalez = getPluginInstanceParam inst (strcat "scalez_" (itoa i)); set T = getPluginInstanceParam inst (strcat "T_" (itoa i)); set C = getPluginInstanceParam inst (strcat "C_" (itoa i)); set B = getPluginInstanceParam inst (strcat "B_" (itoa i)); set D = getPluginInstanceParam inst (strcat "D_" (itoa i)); ); set edstr.ETRACK_lPoses = revertlist edstr.ETRACK_lPoses; let hd edstr.ETRACK_lPoses -> [_ selpos] in refreshDots edstr selpos; updateEdCtrlTimeLineTracks edstr.ETRACK_ctrlTimeLine 1; selectEdCtrlTimeLineTrack edstr.ETRACK_ctrlTimeLine (getEdCtrlTimeLineTrackByPos edstr.ETRACK_ctrlTimeLine 0); 0; );; fun cbSetPose(edstr, updateall)= let edstr.ETRACK_poseCtrls -> [ctrlpos ctrlang ctrlscale ctrltcb] in let ctrlpos -> [ctrlposx ctrlposy ctrlposz] in let ctrlang -> [ctrlangx ctrlangy ctrlangz] in let ctrlscale -> [ctrlscalex ctrlscaley ctrlscalez] in let ctrltcb -> [ctrlT ctrlC ctrlB ctrlD] in let getEdCtrlTimeLineSelectedKey edstr.ETRACK_ctrlTimeLine -> selkey in let switch edstr.ETRACK_lPoses selkey -> posestr in ( let getEdCtrlFloatValue ctrlposx -> px in let getEdCtrlFloatValue ctrlposy -> py in let getEdCtrlFloatValue ctrlposz -> pz in let getEdCtrlFloatValue ctrlangx -> ax in let getEdCtrlFloatValue ctrlangy -> ay in let getEdCtrlFloatValue ctrlangz -> az in let SO3MathsEulerYXZToQuat [SO3MathsDegreeToRadian ax SO3MathsDegreeToRadian ay SO3MathsDegreeToRadian az] -> quat in let getEdCtrlFloatValue ctrlscalex -> sx in let getEdCtrlFloatValue ctrlscaley -> sy in let getEdCtrlFloatValue ctrlscalez -> sz in let getEdCtrlFloatValue ctrlT -> t in let getEdCtrlFloatValue ctrlC -> c in let getEdCtrlFloatValue ctrlB -> b in let getEdCtrlFloatValue ctrlD -> d in set posestr.EPOSE_tPose = [[px py pz] quat [sx sy sz] [t c b] (d *. 0.01)]; if (updateall) then refreshDots edstr posestr else refreshPoses edstr posestr; ); 0;; fun fillDotsCtrls(edstr, posestr)= let edstr.ETRACK_poseCtrls -> [ctrlpos ctrlang ctrlscale ctrltcb] in let ctrlpos -> [ctrlposx ctrlposy ctrlposz] in let ctrlang -> [ctrlangx ctrlangy ctrlangz] in let ctrlscale -> [ctrlscalex ctrlscaley ctrlscalez] in let ctrltcb -> [ctrlT ctrlC ctrlB ctrlD] in if (posestr == nil) then ( setEdCtrlFloatEnable ctrlposx 0; setEdCtrlFloatEnable ctrlposy 0; setEdCtrlFloatEnable ctrlposz 0; setEdCtrlFloatEnable ctrlangx 0; setEdCtrlFloatEnable ctrlangy 0; setEdCtrlFloatEnable ctrlangz 0; setEdCtrlFloatEnable ctrlscalex 0; setEdCtrlFloatEnable ctrlscaley 0; setEdCtrlFloatEnable ctrlscalez 0; setEdCtrlFloatEnable ctrlT 0; setEdCtrlFloatEnable ctrlC 0; setEdCtrlFloatEnable ctrlB 0; setEdCtrlFloatEnable ctrlD 0; 0; ) else ( setEdCtrlFloatEnable ctrlposx 1; setEdCtrlFloatEnable ctrlposy 1; setEdCtrlFloatEnable ctrlposz 1; setEdCtrlFloatEnable ctrlangx 1; setEdCtrlFloatEnable ctrlangy 1; setEdCtrlFloatEnable ctrlangz 1; setEdCtrlFloatEnable ctrlscalex 1; setEdCtrlFloatEnable ctrlscaley 1; setEdCtrlFloatEnable ctrlscalez 1; setEdCtrlFloatEnable ctrlT 1; setEdCtrlFloatEnable ctrlC 1; setEdCtrlFloatEnable ctrlB 1; setEdCtrlFloatEnable ctrlD 1; let posestr.EPOSE_tPose -> [[px py pz] quat [sx sy sz] [t c b] d] in //let SO3MathsQuatToEulerDegreePYR quat -> [ax ay az] in let SO3MathsQuatToEulerYXZ quat -> [ax ay az] in let SO3MathsRadianToDegree ax -> ax in let SO3MathsRadianToDegree ay -> ay in let SO3MathsRadianToDegree az -> az in ( setEdCtrlFloatValueWithoutCallback ctrlposx px; setEdCtrlFloatValueWithoutCallback ctrlposy py; setEdCtrlFloatValueWithoutCallback ctrlposz pz; setEdCtrlFloatValueWithoutCallback ctrlangx ax; setEdCtrlFloatValueWithoutCallback ctrlangy ay; setEdCtrlFloatValueWithoutCallback ctrlangz az; setEdCtrlFloatValueWithoutCallback ctrlscalex sx; setEdCtrlFloatValueWithoutCallback ctrlscaley sy; setEdCtrlFloatValueWithoutCallback ctrlscalez sz; setEdCtrlFloatValueWithoutCallback ctrlT t; setEdCtrlFloatValueWithoutCallback ctrlC c; setEdCtrlFloatValueWithoutCallback ctrlB b; let getPrevAndNextPoses edstr posestr -> [pos sposestr dposestr] in let sposestr.EPOSE_tPose -> [_ _ _ _ pt] in let dposestr.EPOSE_tPose -> [_ _ _ _ nt] in let if (pt == nil) then 0.0 else pt +. 0.00001 -> mintime in let if (nt == nil) then 1.0 else nt -. 0.00001 -> maxtime in let maxf 0.0 minf 1.0 mintime -> mintime in let maxf 0.0 minf 1.0 maxtime -> maxtime in ( setEdCtrlFloatValueWithoutCallback ctrlD d *. 100.0; setEdCtrlFloatMinValue ctrlD mintime *. 100.0; setEdCtrlFloatMaxValue ctrlD maxtime *. 100.0; setEdCtrlTimeLineValue edstr.ETRACK_ctrlTimeLine d *. (getTrackDuration edstr); set edstr.ETRACK_coef = d; updatePreview edstr; ); ); 0; ); 0;; fun cbUpdateDots(ctrl, value, p)= let p -> [posestr edstr] in let edstr.ETRACK_poseCtrls -> [ctrlpos ctrlang ctrlscale ctrltcb] in let ctrltcb -> [ctrlT ctrlC ctrlB ctrlD] in let (getEdCtrlFloatValue ctrlD) *. 0.01 -> d in ( setEdCtrlTimeLineValue edstr.ETRACK_ctrlTimeLine d *. (getTrackDuration edstr); setEdCtrlTimeLinekeyPos edstr.ETRACK_ctrlTimeLine posestr.EPOSE_strKey (getKeyPosInTimeFromCoef edstr d) 1; cbSetPose edstr 1; set edstr.ETRACK_coef = d; updatePreview edstr; ); 0;; fun cbUpdateDotOnly(ctrl, value, p)= let p -> [posestr edstr] in cbSetPose edstr 0; 0;; fun cbAddPose(tbstr, check, btn, mask, p)= let p -> [edstr chkplaypause] in let edstr.ETRACK_poseCtrls -> [[ctrlposx ctrlposy ctrlposz] [ctrlangx ctrlangy ctrlangz] [ctrlscalex ctrlscaley ctrlscalez] [ctrlT ctrlC ctrlB ctrlD]] in let getEdCtrlTimeLineSelectedKey edstr.ETRACK_ctrlTimeLine -> selkey in let switch edstr.ETRACK_lPoses selkey -> fposestr in //get last if no selection let if (fposestr == nil) then let nth_list edstr.ETRACK_lPoses ((sizelist edstr.ETRACK_lPoses) - 1) -> [_ frposestr] in frposestr else fposestr -> fposestr in ( stopPreview edstr [tbstr chkplaypause]; let if (edstr.ETRACK_child == nil) then [0.0 0.0 0.0] else if edstr.ETRACK_bLocal then SO3ObjectGetPosition edstr.ETRACK_child else SO3ObjectGetGlobalPosition edstr.ETRACK_child -> pos in let if (edstr.ETRACK_child == nil) then [0.0 0.0 0.0 1.0] else if edstr.ETRACK_bLocal then SO3ObjectGetOrientation edstr.ETRACK_child else SO3ObjectGetGlobalOrientation edstr.ETRACK_child -> quat in let if (edstr.ETRACK_child == nil) then [1.0 1.0 1.0] else SO3ObjectGetScale edstr.ETRACK_child -> scale in let if (fposestr == nil) then [pos quat scale [0.0 0.0 0.0] 0.0] else fposestr.EPOSE_tPose -> [pos quat scale [t c b] d] in let getPrevAndNextPoses edstr fposestr -> [ipos sposestr dposestr] in let if (fposestr == nil) then 0.0 else if (dposestr == nil) then (d +. 0.1) else let dposestr.EPOSE_tPose -> [_ _ _ _ nd] in d +. ((nd -. d) *. 0.5) -> d in let (maxf 0.0 minf 1.0 d) -> d in ( let addEdCtrlTimeLineKeyAfterKey edstr.ETRACK_ctrlTimeLine 0 fposestr.EPOSE_strKey " " (getKeyPosInTimeFromCoef edstr d) (getKeyDuration edstr) 1 -> keystr in let mkObjEPoseStr [nil nil [pos quat scale [t c b] d] keystr] -> posestr in ( if (edstr.ETRACK_lPoses == nil) then ( set edstr.ETRACK_lPoses = [keystr posestr]::nil; ) else if (dposestr == nil) then ( set edstr.ETRACK_lPoses = lcat edstr.ETRACK_lPoses [keystr posestr]::nil; ) else ( let splitList edstr.ETRACK_lPoses ipos + 1 -> [lf ln] in set edstr.ETRACK_lPoses = lcat lf [keystr posestr]::ln; ); selectEdCtrlTimeLineKey edstr.ETRACK_ctrlTimeLine keystr; ); ); ); 0;; fun cbDelPose(tbstr, check, btn, mask, p)= let p -> [edstr chkplaypause] in let getEdCtrlTimeLineSelectedKey edstr.ETRACK_ctrlTimeLine -> selkey in let switch edstr.ETRACK_lPoses selkey -> posestr in let getPosInListByPose edstr.ETRACK_lPoses posestr -> ipos in ( stopPreview edstr [tbstr chkplaypause]; while (posestr.EPOSE_lLines != nil) do ( SO3ObjectDestroy hd posestr.EPOSE_lLines; set posestr.EPOSE_lLines = tl posestr.EPOSE_lLines; ); V3DshowObjectAxis (V3DgetSessionView c3dXsession) c3dXsession posestr.EPOSE_child 1 0; SO3ObjectDestroy posestr.EPOSE_child; set posestr.EPOSE_child = nil; removeEdCtrlTimeLineKey edstr.ETRACK_ctrlTimeLine posestr.EPOSE_strKey 1; set edstr.ETRACK_lPoses = removePoseFromList edstr.ETRACK_lPoses posestr; let nth_list edstr.ETRACK_lPoses ipos -> [_ nposestr] in let if (nposestr != nil) then [nil nposestr] else nth_list edstr.ETRACK_lPoses (ipos - 1) -> [_ nposestr] in ( selectEdCtrlTimeLineKey edstr.ETRACK_ctrlTimeLine nposestr.EPOSE_strKey; fillDotsCtrls edstr nposestr; refreshDots edstr nposestr; ); ); 0;; fun switchPositions(p, posestr1, posestr2)= let p -> [edstr chkplaypause] in let posestr1.EPOSE_tPose -> [coords1 quat1 scale1 tcb1 d1] in let posestr2.EPOSE_tPose -> [coords2 quat2 scale2 tcb2 d2] in let getPosInListByPose edstr.ETRACK_lPoses posestr1 -> pos1 in let getPosInListByPose edstr.ETRACK_lPoses posestr2 -> pos2 in ( set posestr1.EPOSE_tPose = [coords2 quat2 scale2 tcb2 d1]; set posestr2.EPOSE_tPose = [coords1 quat1 scale1 tcb1 d2]; selectEdCtrlTimeLineKey edstr.ETRACK_ctrlTimeLine posestr2.EPOSE_strKey; ); 0;; fun cbMoveLeft(tbstr, check, btn, mask, p)= let p -> [edstr chkplaypause] in let getEdCtrlTimeLineSelectedKey edstr.ETRACK_ctrlTimeLine -> selkey in let switch edstr.ETRACK_lPoses selkey -> posestr in let getPrevAndNextPoses edstr posestr -> [ipos prevstr nextstr] in if ((ipos == 0) || (prevstr == nil)) then nil else ( stopPreview edstr [tbstr chkplaypause]; switchPositions p posestr prevstr; ); 0;; fun cbMoveRight(tbstr, check, btn, mask, p)= let p -> [edstr chkplaypause] in let getEdCtrlTimeLineSelectedKey edstr.ETRACK_ctrlTimeLine -> selkey in let switch edstr.ETRACK_lPoses selkey -> posestr in let getPrevAndNextPoses edstr posestr -> [ipos prevstr nextstr] in if ((ipos == ((sizelist edstr.ETRACK_lPoses) - 1)) || (nextstr == nil)) then nil else ( stopPreview edstr [tbstr chkplaypause]; switchPositions p posestr nextstr; ); 0;; fun cbEditKps(ctrl, value, edstr)= if (value <=. 0.0) then nil else ( set edstr.ETRACK_fKps = value; let getTrackDuration edstr -> length in let (max 5 (ftoi ((itof 420) /. length))) -> msize in ( setEdCtrlTimeLinePixelPerUnit edstr.ETRACK_ctrlTimeLine msize 0; setEdCtrlTimeLineLength edstr.ETRACK_ctrlTimeLine length; updateKeysInTimeline edstr; ); ); 0;; fun cbEditNbKeys(ctrl, value, edstr)= if (value <=. 2.0) then nil else ( set edstr.ETRACK_nbKeys = value; let getTrackDuration edstr -> length in let (max 5 (ftoi ((itof 420) /. length))) -> msize in ( setEdCtrlTimeLinePixelPerUnit edstr.ETRACK_ctrlTimeLine msize 0; setEdCtrlTimeLineLength edstr.ETRACK_ctrlTimeLine length; updateKeysInTimeline edstr; let getEdCtrlTimeLineSelectedKey edstr.ETRACK_ctrlTimeLine -> selkey in let switch edstr.ETRACK_lPoses selkey -> posestr in refreshDots edstr posestr; ); ); 0;; fun cbChangeEditMode(tbstr, check, btn, mask, state, p)= let p -> [edstr [chkmove chkrotate chkscale]] in ( if check == chkmove then ( set edstr.ETRACK_iEditMode = 1; setEdToolBarCheckState tbstr chkmove 1; setEdToolBarCheckState tbstr chkrotate 0; setEdToolBarCheckState tbstr chkscale 0; ) else if check == chkrotate then ( set edstr.ETRACK_iEditMode = 2; setEdToolBarCheckState tbstr chkmove 0; setEdToolBarCheckState tbstr chkrotate 1; setEdToolBarCheckState tbstr chkscale 0; ) else if check == chkscale then ( set edstr.ETRACK_iEditMode = 3; setEdToolBarCheckState tbstr chkmove 0; setEdToolBarCheckState tbstr chkrotate 0; setEdToolBarCheckState tbstr chkscale 1; ) else nil; cbSetPose edstr 0; ); 0;; fun cbPlayPreview(tbstr, check, btn, mask, state, edstr)= if (state) then setPluginInstanceEditorCbPreRender edstr.ETRACK_inst mkfun4 @cbEditorPreRender [edstr tbstr check] else setPluginInstanceEditorCbPreRender edstr.ETRACK_inst nil; set edstr.ETRACK_iTick = 0; 0;; fun cbStopPreview(tbstr, check, btn, mask, p)= let p -> [edstr chkplaypause] in ( setEdToolBarCheckState tbstr chkplaypause 0; setPluginInstanceEditorCbPreRender edstr.ETRACK_inst nil; set edstr.ETRACK_angcoef = 0.0; set edstr.ETRACK_coef = 0.0; set edstr.ETRACK_iTick = 0; setEdCtrlTimeLineValue edstr.ETRACK_ctrlTimeLine 0.0; ); 0;; fun cbPrevKey(tbstr, check, btn, mask, p)= let p -> [edstr chkplaypause] in ( setEdToolBarCheckState tbstr chkplaypause 0; setPluginInstanceEditorCbPreRender edstr.ETRACK_inst nil; set edstr.ETRACK_angcoef = 0.0; set edstr.ETRACK_coef = 0.0; set edstr.ETRACK_iTick = 0; setEdCtrlTimeLineValue edstr.ETRACK_ctrlTimeLine 0.0; let getEdCtrlTimeLineSelectedKey edstr.ETRACK_ctrlTimeLine -> selkey in let switch edstr.ETRACK_lPoses selkey -> posestr in let getPosInListByPose edstr.ETRACK_lPoses posestr -> ipos in let nth_list edstr.ETRACK_lPoses ipos - 1 -> [keystr nposestr] in if (nposestr == nil) then ( let getPosTime posestr.EPOSE_tPose -> d in ( setEdCtrlTimeLineValue edstr.ETRACK_ctrlTimeLine d *. (getTrackDuration edstr); set edstr.ETRACK_coef = d; ); 0; ) else ( selectEdCtrlTimeLineKey edstr.ETRACK_ctrlTimeLine keystr; 0; ); ); 0;; fun cbNextKey(tbstr, check, btn, mask, p)= let p -> [edstr chkplaypause] in ( setEdToolBarCheckState tbstr chkplaypause 0; setPluginInstanceEditorCbPreRender edstr.ETRACK_inst nil; set edstr.ETRACK_angcoef = 0.0; set edstr.ETRACK_coef = 0.0; set edstr.ETRACK_iTick = 0; setEdCtrlTimeLineValue edstr.ETRACK_ctrlTimeLine 0.0; let getEdCtrlTimeLineSelectedKey edstr.ETRACK_ctrlTimeLine -> selkey in let switch edstr.ETRACK_lPoses selkey -> posestr in let getPosInListByPose edstr.ETRACK_lPoses posestr -> ipos in let nth_list edstr.ETRACK_lPoses ipos + 1 -> [keystr nposestr] in if (nposestr == nil) then ( let getPosTime posestr.EPOSE_tPose -> d in ( setEdCtrlTimeLineValue edstr.ETRACK_ctrlTimeLine d *. (getTrackDuration edstr); set edstr.ETRACK_coef = d; ); 0; ) else ( selectEdCtrlTimeLineKey edstr.ETRACK_ctrlTimeLine keystr; 0; ); ); 0;; fun cbEdCtrlTimeLineValue(sliderstr, value, p)= let p -> [edstr tbstr chkplaypause] in ( setEdToolBarCheckState tbstr chkplaypause 0; setPluginInstanceEditorCbPreRender edstr.ETRACK_inst nil; set edstr.ETRACK_angcoef = 0.0; set edstr.ETRACK_coef = value /. (getTrackDuration edstr); set edstr.ETRACK_iTick = 0; updatePreview edstr; ); 0;; fun UpdatePosKey(edstr, posestr)= let edstr.ETRACK_poseCtrls -> [[ctrlposx ctrlposy ctrlposz] [ctrlangx ctrlangy ctrlangz] [ctrlscalex ctrlscaley ctrlscalez] [ctrlT ctrlC ctrlB ctrlD]] in ( setEdCtrlFloatCbChange ctrlposx nil; setEdCtrlFloatCbChange ctrlposy nil; setEdCtrlFloatCbChange ctrlposz nil; setEdCtrlFloatCbChange ctrlangx nil; setEdCtrlFloatCbChange ctrlangy nil; setEdCtrlFloatCbChange ctrlangz nil; setEdCtrlFloatCbChange ctrlscalex nil; setEdCtrlFloatCbChange ctrlscaley nil; setEdCtrlFloatCbChange ctrlscalez nil; setEdCtrlFloatCbChange ctrlT nil; setEdCtrlFloatCbChange ctrlC nil; setEdCtrlFloatCbChange ctrlB nil; setEdCtrlFloatCbChange ctrlD nil; fillDotsCtrls edstr posestr; setEdCtrlFloatCbChange ctrlposx mkfun3 @cbUpdateDots [posestr edstr]; setEdCtrlFloatCbChange ctrlposy mkfun3 @cbUpdateDots [posestr edstr]; setEdCtrlFloatCbChange ctrlposz mkfun3 @cbUpdateDots [posestr edstr]; setEdCtrlFloatCbChange ctrlangx mkfun3 @cbUpdateDotOnly [posestr edstr]; setEdCtrlFloatCbChange ctrlangy mkfun3 @cbUpdateDotOnly [posestr edstr]; setEdCtrlFloatCbChange ctrlangz mkfun3 @cbUpdateDotOnly [posestr edstr]; setEdCtrlFloatCbChange ctrlscalex mkfun3 @cbUpdateDotOnly [posestr edstr]; setEdCtrlFloatCbChange ctrlscaley mkfun3 @cbUpdateDotOnly [posestr edstr]; setEdCtrlFloatCbChange ctrlscalez mkfun3 @cbUpdateDotOnly [posestr edstr]; setEdCtrlFloatCbChange ctrlT mkfun3 @cbUpdateDots [posestr edstr]; setEdCtrlFloatCbChange ctrlC mkfun3 @cbUpdateDots [posestr edstr]; setEdCtrlFloatCbChange ctrlB mkfun3 @cbUpdateDots [posestr edstr]; setEdCtrlFloatCbChange ctrlD mkfun3 @cbUpdateDots [posestr edstr]; refreshPoses edstr posestr; ); 0;; fun cbEdCtrlTimeLineSelectKey(ctrlstr, keystr, edstr)= let switch edstr.ETRACK_lPoses keystr -> posestr in UpdatePosKey edstr posestr; 0;; fun cbLoopCheck(ctrl, state, edstr)= set edstr.ETRACK_bLoop = state; 0;; fun cbPingCheck(ctrl, state, edstr)= set edstr.ETRACK_bPingPong = state; 0;; fun cbTargetCheck(ctrl, state, edstr)= set edstr.ETRACK_bToTarget = state; 0;; fun cbLocalCheck(ctrl, state, edstr)= set edstr.ETRACK_bLocal = state; let getEdCtrlTimeLineSelectedKey edstr.ETRACK_ctrlTimeLine -> selkey in let switch edstr.ETRACK_lPoses selkey -> posestr in refreshDots edstr posestr; 0;; fun cbTargetAxis(ctrl, state, elem, edstr)= set edstr.ETRACK_iToAxis = state; 0;; fun cbTimelineZoomIn(tbstr, check, btn, mask, edstr)= let (getEdCtrlTimeLinePixelPerUnit edstr.ETRACK_ctrlTimeLine) -> cursize in if cursize >= 200 then nil else ( setEdCtrlTimeLinePixelPerUnit edstr.ETRACK_ctrlTimeLine cursize * 2 0; updateKeysInTimeline edstr; ); 0;; fun cbTimelineZoomOut(tbstr, check, btn, mask, edstr)= let (getEdCtrlTimeLinePixelPerUnit edstr.ETRACK_ctrlTimeLine) -> cursize in let max (max 5 (ftoi ((itof 420) /. getTrackDuration edstr))) (cursize / 2) -> msize in if (msize == cursize) then nil else ( setEdCtrlTimeLinePixelPerUnit edstr.ETRACK_ctrlTimeLine msize 0; updateKeysInTimeline edstr; ); 0;; fun setAxisVisibleState(edstr, state)= let if !state then nil else getEdCtrlTimeLineSelectedKey edstr.ETRACK_ctrlTimeLine -> selkey in let if !state then nil else switch edstr.ETRACK_lPoses selkey -> selected in let edstr.ETRACK_lPoses -> l in while (l != nil) do ( let hd l -> [_ posestr] in if (posestr.EPOSE_child == nil) then nil else if (state && (selected == posestr)) then V3DupdateObjectAxis (V3DgetSessionView c3dXsession) c3dXsession V3DsetCbAxisClick (V3DshowObjectAxis (V3DgetSessionView c3dXsession) c3dXsession posestr.EPOSE_child edstr.ETRACK_iEditMode 1) mkfun8 @cbDotAxisClick [edstr selected] else V3DshowObjectAxis (V3DgetSessionView c3dXsession) c3dXsession posestr.EPOSE_child 1 0; set l = tl l; ); 0;; fun cbFocusEditor(winstr, edstr)= let lObjTrackInst -> l in while (l != nil) do ( let hd l -> [inst oedstr] in let if (inst == edstr.ETRACK_inst) then 1 else 0 -> state in setAxisVisibleState oedstr state; set l = tl l; ); 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let mkObjETrackStr [inst nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil 0 1] -> edstr in let [420 715] -> [iw ih] in let 10 -> ypos in ( setEdwindowCbFocus ewinstr.EDW_father.EDW_father mkfun2 @cbFocusEditor edstr; cbFocusEditor ewinstr.EDW_father.EDW_father edstr; setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "sourceobject") -> sourcename in let atof (getPluginInstanceParam inst "kps") -> kps in let atof (getPluginInstanceParam inst "nbkeys") -> nbkeys in let atoi (getPluginInstanceParam inst "loop") -> loop in let if loop == nil then 1 else loop -> loop in let atoi (getPluginInstanceParam inst "ping") -> ping in let if ping == nil then 0 else ping -> ping in let atoi (getPluginInstanceParam inst "target") -> target in let if target == nil then 0 else target -> target in let atoi (getPluginInstanceParam inst "axis") -> axis in let if axis == nil then 4 else axis -> axis in let atoi (getPluginInstanceParam inst "local") -> local in let if (local == nil) then 1 else local -> local in let atoi (getPluginInstanceParam inst "init") -> init in let if init == nil then 1 else init -> init in let if kps == nil then 60.0 else kps -> kps in let if nbkeys == nil then 200.0 else nbkeys -> nbkeys in let crEdFrameWindow _channel ewinstr 0 0 iw 55 EDWIN_RESIZE_MW nil (loc "OS3DOBJECTTRACK_0019") (loc "OS3DOBJECTTRACK_0012") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 35 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DOBJECTTRACK_0031") nil -> labelobj in let crEdCtrlTextLine winstr 180 ypos 140 20 sourcename nil EDWIN_RESIZE_MW -> ctrlsourcename in let crEdCtrlButton winstr 325 ypos 55 20 "..." nil -> pickbtn2 in let crEdCtrlButton winstr 385 ypos 35 20 "X" nil -> refreshsourcename in let crEdFrameWindow _channel ewinstr 0 0 iw 180 EDWIN_RESIZE_MW nil (loc "OS3DOBJECTTRACK_0003") (loc "OS3DOBJECTTRACK_0012") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 160 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DOBJECTTRACK_0010") nil -> labelkps in let crEdCtrlFloat winstr 180 ypos 100 20 kps 1.0 200.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlkps in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DOBJECTTRACK_0018") nil -> labelnbkeys in let crEdCtrlFloat winstr 180 ypos 100 20 nbkeys 2.0 9999999.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlnbkeys in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DOBJECTTRACK_0011") EDWIN_RESIZE_MW -> ctrlloop in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DOBJECTTRACK_0021") EDWIN_RESIZE_MW -> ctrlping in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 160 20 (loc "OS3DOBJECTTRACK_0004") EDWIN_RESIZE_MW -> ctrltarget in let crEdCtrlSelect winstr 180 ypos 100 120 EDWIN_RESIZE_MW -> ctrlaxis in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DOBJECTTRACK_0026") EDWIN_RESIZE_MW -> ctrllocal in let crEdFrameWindow _channel ewinstr 0 0 iw 425 EDWIN_RESIZE_MW nil (loc "OS3DOBJECTTRACK_0027") (loc "OS3DOBJECTTRACK_0012") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 405 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_playpause.png" -> aplaypause in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_stop.png" -> astop in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_prev.png" -> aprev in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_next.png" -> anext in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_addkey.png" -> aaddkey in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_delkey.png" -> adelkey in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_movekey_left.png" -> amvleftkey in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_movekey_right.png" -> amvrightkey in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_move.png" -> amove in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_rotate.png" -> arotate in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_scale.png" -> ascale in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_hseparator.png" -> asep in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_zoomin.png" -> azoomin in let _LDalphaBitmap _channel _checkpack strcat APPBASEDIR "os3deditor/res/tb_zoomout.png" -> azoomout in let crEdWindowToolBar winstr 0 (set ypos = 0) iw 28 5 1 EdDefaultTheme.EDT_iToolBarColor ETB_HORIZONTAL -> tbstr in let crEdToolBarCheck tbstr aplaypause ETB_ALIGN_LEFT (loc "OS3DOBJECTTRACK_0022") nil -> chkplaypause in let crEdToolBarButton tbstr astop ETB_ALIGN_LEFT (loc "OS3DOBJECTTRACK_0032") nil -> chkstop in let crEdToolBarButton tbstr aprev ETB_ALIGN_LEFT (loc "OS3DOBJECTTRACK_0038") nil -> chkprev in let crEdToolBarButton tbstr anext ETB_ALIGN_LEFT (loc "OS3DOBJECTTRACK_0037") nil -> chknext in let crEdToolBarBitmap tbstr asep ETB_ALIGN_LEFT nil nil -> hsep in let crEdToolBarButton tbstr aaddkey ETB_ALIGN_LEFT (loc "OS3DOBJECTTRACK_0001") nil -> chkaddkey in let crEdToolBarButton tbstr adelkey ETB_ALIGN_LEFT (loc "OS3DOBJECTTRACK_0009") nil -> chkdelkey in let crEdToolBarButton tbstr amvleftkey ETB_ALIGN_LEFT (loc "OS3DOBJECTTRACK_0035") nil -> chkmvleftkey in let crEdToolBarButton tbstr amvrightkey ETB_ALIGN_LEFT (loc "OS3DOBJECTTRACK_0036") nil -> chkmvrightkey in let crEdToolBarBitmap tbstr asep ETB_ALIGN_LEFT nil nil -> hsep in let crEdToolBarCheck tbstr amove ETB_ALIGN_LEFT (loc "OS3DOBJECTTRACK_0014") nil -> chkmove in let crEdToolBarCheck tbstr arotate ETB_ALIGN_LEFT (loc "OS3DOBJECTTRACK_0028") nil -> chkrotate in let crEdToolBarCheck tbstr ascale ETB_ALIGN_LEFT (loc "OS3DOBJECTTRACK_0029") nil -> chkscale in let crEdToolBarBitmap tbstr asep ETB_ALIGN_LEFT nil nil -> hsep in let crEdToolBarButton tbstr azoomin ETB_ALIGN_LEFT (loc "OS3DOBJECTTRACK_0039") nil -> chkzoomin in let crEdToolBarButton tbstr azoomout ETB_ALIGN_LEFT (loc "OS3DOBJECTTRACK_0040") nil -> chkzoomout in let crEdCtrlTimeLineEditorEx winstr 0 (set ypos = ypos + 29) iw 140 50 (max 5 (ftoi ((itof iw) /. (nbkeys /. kps)))) (nbkeys /. kps) 0 EDWIN_RESIZE_MW|EDWIN_RESIZE_MH nil 0 -> ctrltimeline in let selectEdCtrlTimeLineTrack ctrltimeline (addEdCtrlTimeLineTrack ctrltimeline 1) -> trackstr in let ypos + 130 -> ypos in let ypos -> pypos in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 80 20 (loc "OS3DOBJECTTRACK_0025") nil -> labelpos in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 20 20 "X" nil -> labelpx in let crEdCtrlFloat winstr 30 ypos 90 20 0.0 (-.1000000.0) 1000000.0 0.001 4 nil EDWIN_RESIZE_MW -> ctrlposx in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 20 20 "Y" nil -> labelpy in let crEdCtrlFloat winstr 30 ypos 90 20 0.0 (-.1000000.0) 1000000.0 0.001 4 nil EDWIN_RESIZE_MW -> ctrlposy in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 20 20 "Z" nil -> labelpz in let crEdCtrlFloat winstr 30 ypos 90 20 0.0 (-.1000000.0) 1000000.0 0.001 4 nil EDWIN_RESIZE_MW -> ctrlposz in let crEdCtrlLabel winstr 140 ((set ypos = pypos + 25) + 2) 80 20 (loc "OS3DOBJECTTRACK_0020") nil -> labelang in let crEdCtrlLabel winstr 140 ((set ypos = ypos + 25) + 2) 20 20 "X" nil -> labelax in let crEdCtrlFloat winstr 160 ypos 90 20 0.0 (-.180.0) 180.0 0.01 4 nil EDWIN_RESIZE_MW -> ctrlangx in let crEdCtrlLabel winstr 140 ((set ypos = ypos + 25) + 2) 20 20 "Y" nil -> labelay in let crEdCtrlFloat winstr 160 ypos 90 20 0.0 (-.180.0) 180.0 0.01 4 nil EDWIN_RESIZE_MW -> ctrlangy in let crEdCtrlLabel winstr 140 ((set ypos = ypos + 25) + 2) 20 20 "Z" nil -> labelaz in let crEdCtrlFloat winstr 160 ypos 90 20 0.0 (-.180.0) 180.0 0.01 4 nil EDWIN_RESIZE_MW -> ctrlangz in let crEdCtrlLabel winstr 270 ((set ypos = pypos + 25) + 2) 80 20 (loc "OS3DOBJECTTRACK_0030") nil -> labelscale in let crEdCtrlLabel winstr 270 ((set ypos = ypos + 25) + 2) 20 20 "X" nil -> labelsx in let crEdCtrlFloat winstr 290 ypos 90 20 1.0 0.0 1000000.0 0.01 4 nil EDWIN_RESIZE_MW -> ctrlscalex in let crEdCtrlLabel winstr 270 ((set ypos = ypos + 25) + 2) 20 20 "Y" nil -> labelsy in let crEdCtrlFloat winstr 290 ypos 90 20 1.0 0.0 1000000.0 0.01 4 nil EDWIN_RESIZE_MW -> ctrlscaley in let crEdCtrlLabel winstr 270 ((set ypos = ypos + 25) + 2) 20 20 "Z" nil -> labelsz in let crEdCtrlFloat winstr 290 ypos 90 20 1.0 0.0 1000000.0 0.01 4 nil EDWIN_RESIZE_MW -> ctrlscalez in let ypos -> pypos in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 35) + 2) 160 20 (loc "OS3DOBJECTTRACK_0002") nil -> labeltcb in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 60 20 (loc "OS3DOBJECTTRACK_0033") nil -> labelT in let crEdCtrlFloat winstr 85 ypos 90 20 0.0 (-.100.0) 100.0 0.001 4 nil EDWIN_RESIZE_MW -> ctrlT in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 60 20 (loc "OS3DOBJECTTRACK_0006") nil -> labelC in let crEdCtrlFloat winstr 85 ypos 90 20 0.0 (-.100.0) 100.0 0.001 4 nil EDWIN_RESIZE_MW -> ctrlC in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 60 20 (loc "OS3DOBJECTTRACK_0005") nil -> labelB in let crEdCtrlFloat winstr 85 ypos 90 20 0.0 (-.100.0) 100.0 0.001 4 nil EDWIN_RESIZE_MW -> ctrlB in let ypos -> nypos in let crEdCtrlLabel winstr 230 ((set ypos = pypos + 35) + 2) 160 20 (loc "OS3DOBJECTTRACK_0024") nil -> labelpath in let crEdCtrlLabel winstr 230 ((set ypos = ypos + 25) + 2) 60 20 (loc "OS3DOBJECTTRACK_0034") nil -> labeltm in let crEdCtrlFloat winstr 285 ypos 90 20 0.0 0.0 100.0 0.01 6 nil EDWIN_RESIZE_MW -> ctrlD in //let _DLGMessageBox _channel nil "debug" itoa (set ypos = ypos + 35) 0 -> _ in let crEdFrameWindow _channel ewinstr 0 0 iw 55 EDWIN_RESIZE_MW nil (loc "OS3DOBJECTTRACK_0013") (loc "OS3DOBJECTTRACK_0012") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 35 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DOBJECTTRACK_0023") EDWIN_RESIZE_MW -> ctrlinit in ( set edstr.ETRACK_ctrlTimeLine = ctrltimeline; set edstr.ETRACK_poseCtrls = [[ctrlposx ctrlposy ctrlposz] [ctrlangx ctrlangy ctrlangz] [ctrlscalex ctrlscaley ctrlscalez] [ctrlT ctrlC ctrlB ctrlD]]; set edstr.ETRACK_nbKeys = nbkeys; set edstr.ETRACK_fKps = kps; set edstr.ETRACK_child = V3DgetObjectByName c3dXsession sourcename; set edstr.ETRACK_oldindex = nil; set edstr.ETRACK_angcoef = 0.0; set edstr.ETRACK_coef = 0.0; set edstr.ETRACK_iTick = 0; set edstr.ETRACK_angstep = 0.0; set edstr.ETRACK_fDirection = 1.0; set edstr.ETRACK_bPingPong = ping; set edstr.ETRACK_bToTarget = target; set edstr.ETRACK_iToAxis = axis; set edstr.ETRACK_bLoop = loop; set edstr.ETRACK_bLocal = local; set edstr.ETRACK_inipos = [(SO3ObjectGetPosition edstr.ETRACK_child) (SO3ObjectGetOrientation edstr.ETRACK_child) (SO3ObjectGetScale edstr.ETRACK_child)]; //load dot keys loadDots inst edstr; setEdToolBarCheckState tbstr chkmove 1; setEdToolBarCheckCbClick tbstr chkmove mkfun6 @cbChangeEditMode [edstr [chkmove chkrotate chkscale]]; setEdToolBarCheckCbClick tbstr chkrotate mkfun6 @cbChangeEditMode [edstr [chkmove chkrotate chkscale]]; setEdToolBarCheckCbClick tbstr chkscale mkfun6 @cbChangeEditMode [edstr [chkmove chkrotate chkscale]]; setEdToolBarCheckCbClick tbstr chkplaypause mkfun6 @cbPlayPreview edstr; setEdToolBarButtonCbClick tbstr chkstop mkfun5 @cbStopPreview [edstr chkplaypause]; setEdToolBarButtonCbClick tbstr chkprev mkfun5 @cbPrevKey [edstr chkplaypause]; setEdToolBarButtonCbClick tbstr chknext mkfun5 @cbNextKey [edstr chkplaypause]; setEdToolBarButtonCbClick tbstr chkaddkey mkfun5 @cbAddPose [edstr chkplaypause]; setEdToolBarButtonCbClick tbstr chkdelkey mkfun5 @cbDelPose [edstr chkplaypause]; setEdToolBarButtonCbClick tbstr chkmvleftkey mkfun5 @cbMoveLeft [edstr chkplaypause]; setEdToolBarButtonCbClick tbstr chkmvrightkey mkfun5 @cbMoveRight [edstr chkplaypause]; setEdToolBarButtonCbClick tbstr chkzoomin mkfun5 @cbTimelineZoomIn edstr; setEdToolBarButtonCbClick tbstr chkzoomout mkfun5 @cbTimelineZoomOut edstr; setEdCtrlTimeLineCbValue ctrltimeline mkfun3 @cbEdCtrlTimeLineValue [edstr tbstr chkplaypause]; setEdCtrlTimeLineCbSelectKey ctrltimeline mkfun3 @cbEdCtrlTimeLineSelectKey edstr; let hd edstr.ETRACK_lPoses -> [_ posestr] in let if (edstr.ETRACK_lPoses == nil) then 0 else 1 -> state in ( selectEdCtrlTimeLineKey ctrltimeline posestr.EPOSE_strKey; setEdCtrlFloatEnable ctrlposx state; setEdCtrlFloatEnable ctrlposy state; setEdCtrlFloatEnable ctrlposz state; setEdCtrlFloatEnable ctrlangx state; setEdCtrlFloatEnable ctrlangy state; setEdCtrlFloatEnable ctrlangz state; setEdCtrlFloatEnable ctrlscalex state; setEdCtrlFloatEnable ctrlscaley state; setEdCtrlFloatEnable ctrlscalez state; setEdCtrlFloatEnable ctrlT state; setEdCtrlFloatEnable ctrlC state; setEdCtrlFloatEnable ctrlB state; setEdCtrlFloatEnable ctrlD state; setEdCtrlFloatCbChange ctrlposx mkfun3 @cbUpdateDots [posestr edstr]; setEdCtrlFloatCbChange ctrlposy mkfun3 @cbUpdateDots [posestr edstr]; setEdCtrlFloatCbChange ctrlposz mkfun3 @cbUpdateDots [posestr edstr]; setEdCtrlFloatCbChange ctrlangx mkfun3 @cbUpdateDotOnly [posestr edstr]; setEdCtrlFloatCbChange ctrlangy mkfun3 @cbUpdateDotOnly [posestr edstr]; setEdCtrlFloatCbChange ctrlangz mkfun3 @cbUpdateDotOnly [posestr edstr]; setEdCtrlFloatCbChange ctrlscalex mkfun3 @cbUpdateDotOnly [posestr edstr]; setEdCtrlFloatCbChange ctrlscaley mkfun3 @cbUpdateDotOnly [posestr edstr]; setEdCtrlFloatCbChange ctrlscalez mkfun3 @cbUpdateDotOnly [posestr edstr]; setEdCtrlFloatCbChange ctrlT mkfun3 @cbUpdateDots [posestr edstr]; setEdCtrlFloatCbChange ctrlC mkfun3 @cbUpdateDots [posestr edstr]; setEdCtrlFloatCbChange ctrlB mkfun3 @cbUpdateDots [posestr edstr]; setEdCtrlFloatCbChange ctrlD mkfun3 @cbUpdateDots [posestr edstr]; ); setEdCtrlButtonCb pickbtn2 mkfun2 @cbBtnPickObj [inst edstr winstr viewstr ctrlsourcename sourcename]; setEdCtrlButtonCb refreshsourcename mkfun2 @cbRefreshBtn [ctrlsourcename]; setEdCtrlTextLineEnable ctrlsourcename 0; setEdCtrlCheckState ctrlinit init; setEdCtrlCheckState ctrllocal local; setEdCtrlCheckState ctrlloop loop; setEdCtrlCheckState ctrlping ping; setEdCtrlCheckState ctrltarget target; setEdCtrlCheckCbState ctrlloop mkfun3 @cbLoopCheck edstr; setEdCtrlCheckCbState ctrlping mkfun3 @cbPingCheck edstr; setEdCtrlCheckCbState ctrltarget mkfun3 @cbTargetCheck edstr; setEdCtrlCheckCbState ctrllocal mkfun3 @cbLocalCheck edstr; fillEdCtrlSelect ctrlaxis "X"::(loc "OS3DOBJECTTRACK_0015")::"Y"::(loc "OS3DOBJECTTRACK_0016")::"Z"::(loc "OS3DOBJECTTRACK_0017")::nil; selectEdCtrlSelectByPos ctrlaxis axis; setEdCtrlSelectCb ctrlaxis mkfun4 @cbTargetAxis edstr; setEdCtrlFloatCbChange ctrlkps mkfun3 @cbEditKps edstr; setEdCtrlFloatCbChange ctrlnbkeys mkfun3 @cbEditNbKeys edstr; setEditorModeState viewstr 0; set lObjTrackInst = [inst edstr]::lObjTrackInst; [mkfun1 @cbCloseEdit [edstr ctrlsourcename ctrlkps ctrlnbkeys ctrlloop ctrlping ctrltarget ctrlaxis ctrllocal ctrlinit] mkfun1 @cbDestroyEdit [inst edstr viewstr]]; ); );;