From: Andrew R. <aar...@us...> - 2004-12-23 19:33:30
|
Update of /cvsroot/planeshift/planeshift/src/common/effects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16418/src/common/effects Modified Files: pseffectanchor.cpp pseffectanchor.h Log Message: - Effect fixes - EEdit fixes - Added a target effect. - Fixed mouse wheel. - PAWS fixes. Index: pseffectanchor.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/effects/pseffectanchor.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pseffectanchor.cpp 18 Dec 2004 03:14:07 -0000 1.1 --- pseffectanchor.cpp 23 Dec 2004 19:33:19 -0000 1.2 *************** *** 49,52 **** --- 49,53 ---- { specAction.Clear(); + SetDefaults(); } *************** *** 65,79 **** if (!prevKeyFrame) ! { ! // this is the first frame, so pretend that everything has been set (if it hasn't, it will use the defaults) ! for (int a=0; a<KA_COUNT; ++a) ! specAction.SetBit(a); ! } // set default values, if these are wrong then they'll be replaced on the second (lerp) pass ! actions[KA_POS_X] = 0; ! actions[KA_POS_Y] = 0; ! actions[KA_POS_Z] = 0; ! actions[KA_TOTARGET] = 0; while (xmlbinds->HasNext()) --- 66,73 ---- if (!prevKeyFrame) ! SetupFirstFrame(); // set default values, if these are wrong then they'll be replaced on the second (lerp) pass ! SetDefaults(); while (xmlbinds->HasNext()) *************** *** 112,115 **** --- 106,124 ---- } + void psEffectAnchorKeyFrame::SetDefaults() + { + actions[KA_POS_X] = 0; + actions[KA_POS_Y] = 0; + actions[KA_POS_Z] = 0; + actions[KA_TOTARGET] = 0; + } + + void psEffectAnchorKeyFrame::SetupFirstFrame() + { + // this is the first frame, so pretend that everything has been set (if it hasn't, it will use the defaults) + for (int a=0; a<KA_COUNT; ++a) + specAction.SetBit(a); + } + psEffectAnchorKeyFrame::~psEffectAnchorKeyFrame() { *************** *** 365,368 **** --- 374,394 ---- } + size_t psEffectAnchor::AddKeyFrame(float time) + { + psEffectAnchorKeyFrame * newKeyFrame = new psEffectAnchorKeyFrame(); + + // if there are no other keys then this is the first frame. + if (keyFrames->Length() == 0) + newKeyFrame->SetupFirstFrame(); + + newKeyFrame->time = time; + + // add it to the list + keyFrames->Push(newKeyFrame); + + // return the index where the new keyframe can be found + return keyFrames->Length()-1; + } + int psEffectAnchor::FindKeyFrameByTime(float time) const { *************** *** 410,417 **** case psEffectAnchorKeyFrame::IT_LERP: keyFrames->Get(b)->actions[k] = lerp(keyFrames->Get(a)->actions[k], ! keyFrames->Get(nextIndex)->actions[k], ! keyFrames->Get(a)->time, ! keyFrames->Get(nextIndex)->time, ! keyFrames->Get(b)->time); break; } --- 436,443 ---- case psEffectAnchorKeyFrame::IT_LERP: keyFrames->Get(b)->actions[k] = lerp(keyFrames->Get(a)->actions[k], ! keyFrames->Get(nextIndex)->actions[k], ! keyFrames->Get(a)->time, ! keyFrames->Get(nextIndex)->time, ! keyFrames->Get(b)->time); break; } *************** *** 419,423 **** a = nextIndex; } ! // no matter what the interpolation type (as long as we have one), just clamp the end if (lerpTypes[k] != psEffectAnchorKeyFrame::IT_NONE) --- 445,449 ---- a = nextIndex; } ! // no matter what the interpolation type (as long as we have one), just clamp the end if (lerpTypes[k] != psEffectAnchorKeyFrame::IT_NONE) Index: pseffectanchor.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/effects/pseffectanchor.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pseffectanchor.h 18 Dec 2004 03:14:07 -0000 1.1 --- pseffectanchor.h 23 Dec 2004 19:33:19 -0000 1.2 *************** *** 47,50 **** --- 47,58 ---- ~psEffectAnchorKeyFrame(); + /** Applies default values to this anchor keyframe. + */ + void SetDefaults(); + + /** Sets up this keyframe for the special case of being the first key frame in the group. + */ + void SetupFirstFrame(); + /// this is the time of the keyframe animation (in seconds) float time; *************** *** 59,63 **** IT_COUNT }; ! enum KEY_ACTION { --- 67,71 ---- IT_COUNT }; ! enum KEY_ACTION { *************** *** 67,73 **** KA_COUNT }; - float actions[KA_COUNT]; /// keep track of which actions were specified for which csBitArray specAction; --- 75,93 ---- KA_COUNT }; float actions[KA_COUNT]; + inline const char * GetActionName(size_t idx) + { + switch (idx) + { + case KA_POS_X: return "Pos X"; + case KA_POS_Y: return "Pos Y"; + case KA_POS_Z: return "Pos Z"; + case KA_TOTARGET: return "To Target"; + } + return ""; + } + + /// keep track of which actions were specified for which csBitArray specAction; *************** *** 230,233 **** --- 250,259 ---- void SetDistScale(const csVector3 & newDistScale) { distScale = newDistScale; } + /** Creates a new keyframe and attaches it to this movable. + * @param time The time of this new keyFrame. + * @return the index where the new keyframe can be reached using GetKeyFrame(index). + */ + size_t AddKeyFrame(float time); + protected: |