diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2011-02-09 15:04:25 -0500 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2011-02-09 15:04:25 -0500 |
commit | 64e017fc6b19006c893b4766be05c18ddb3b5593 (patch) | |
tree | 2753e519602225e40e74ca53b05f0ba653ad8fc6 | |
parent | 04ddae45b284b8f535aa6cdc6b90af2088e82334 (diff) |
SH-915 WIP - allow flycam control in autopilot record/playback
-rwxr-xr-x[-rw-r--r--] | indra/newview/llagent.cpp | 8 | ||||
-rwxr-xr-x[-rw-r--r--] | indra/newview/llagentpilot.cpp | 70 | ||||
-rwxr-xr-x[-rw-r--r--] | indra/newview/llagentpilot.h | 14 | ||||
-rwxr-xr-x[-rw-r--r--] | indra/newview/llappviewer.cpp | 11 |
4 files changed, 98 insertions, 5 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index de7073be24..3f1bf4c5c2 100644..100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -1213,7 +1213,13 @@ BOOL LLAgent::getBusy() const //----------------------------------------------------------------------------- // startAutoPilotGlobal() //----------------------------------------------------------------------------- -void LLAgent::startAutoPilotGlobal(const LLVector3d &target_global, const std::string& behavior_name, const LLQuaternion *target_rotation, void (*finish_callback)(BOOL, void *), void *callback_data, F32 stop_distance, F32 rot_threshold) +void LLAgent::startAutoPilotGlobal( + const LLVector3d &target_global, + const std::string& behavior_name, + const LLQuaternion *target_rotation, + void (*finish_callback)(BOOL, void *), + void *callback_data, + F32 stop_distance, F32 rot_threshold) { if (!isAgentAvatarValid()) { diff --git a/indra/newview/llagentpilot.cpp b/indra/newview/llagentpilot.cpp index 13e1023185..92e0180b46 100644..100755 --- a/indra/newview/llagentpilot.cpp +++ b/indra/newview/llagentpilot.cpp @@ -34,6 +34,8 @@ #include "llagent.h" #include "llappviewer.h" #include "llviewercontrol.h" +#include "llviewercamera.h" +#include "llviewerjoystick.h" LLAgentPilot gAgentPilot; @@ -47,7 +49,8 @@ LLAgentPilot::LLAgentPilot() : mLastRecordTime(0.f), mStarted(FALSE), mPlaying(FALSE), - mCurrentAction(0) + mCurrentAction(0), + mOverrideCamera(FALSE) { } @@ -55,6 +58,8 @@ LLAgentPilot::~LLAgentPilot() { } +#define CAM_FIELDS 1 + void LLAgentPilot::load(const std::string& filename) { if(filename.empty()) @@ -85,10 +90,30 @@ void LLAgentPilot::load(const std::string& filename) Action new_action; file >> new_action.mTime >> action_type; file >> new_action.mTarget.mdV[VX] >> new_action.mTarget.mdV[VY] >> new_action.mTarget.mdV[VZ]; +#if CAM_FIELDS + file >> new_action.mCameraView; + file >> new_action.mCameraOrigin.mV[VX] + >> new_action.mCameraOrigin.mV[VY] + >> new_action.mCameraOrigin.mV[VZ]; + + file >> new_action.mCameraXAxis.mV[VX] + >> new_action.mCameraXAxis.mV[VY] + >> new_action.mCameraXAxis.mV[VZ]; + + file >> new_action.mCameraYAxis.mV[VX] + >> new_action.mCameraYAxis.mV[VY] + >> new_action.mCameraYAxis.mV[VZ]; + + file >> new_action.mCameraZAxis.mV[VX] + >> new_action.mCameraZAxis.mV[VY] + >> new_action.mCameraZAxis.mV[VZ]; +#endif new_action.mType = (EActionType)action_type; mActions.put(new_action); } + mOverrideCamera = true; + file.close(); } @@ -108,7 +133,27 @@ void LLAgentPilot::save(const std::string& filename) for (i = 0; i < mActions.count(); i++) { file << mActions[i].mTime << "\t" << mActions[i].mType << "\t"; - file << std::setprecision(32) << mActions[i].mTarget.mdV[VX] << "\t" << mActions[i].mTarget.mdV[VY] << "\t" << mActions[i].mTarget.mdV[VZ] << '\n'; + file << std::setprecision(32) << mActions[i].mTarget.mdV[VX] << "\t" << mActions[i].mTarget.mdV[VY] << "\t" << mActions[i].mTarget.mdV[VZ]; +#if CAM_FIELDS + file << "\t" << mActions[i].mCameraView; + + file << "\t" << mActions[i].mCameraOrigin[VX] + << "\t" << mActions[i].mCameraOrigin[VY] + << "\t" << mActions[i].mCameraOrigin[VZ]; + + file << "\t" << mActions[i].mCameraXAxis[VX] + << "\t" << mActions[i].mCameraXAxis[VY] + << "\t" << mActions[i].mCameraXAxis[VZ]; + + file << "\t" << mActions[i].mCameraYAxis[VX] + << "\t" << mActions[i].mCameraYAxis[VY] + << "\t" << mActions[i].mCameraYAxis[VZ]; + + file << "\t" << mActions[i].mCameraZAxis[VX] + << "\t" << mActions[i].mCameraZAxis[VY] + << "\t" << mActions[i].mCameraZAxis[VZ]; +#endif + file << '\n'; } file.close(); @@ -136,6 +181,12 @@ void LLAgentPilot::addAction(enum EActionType action_type) action.mType = action_type; action.mTarget = gAgent.getPositionGlobal(); action.mTime = mTimer.getElapsedTimeF32(); + LLViewerCamera *cam = LLViewerCamera::getInstance(); + action.mCameraView = cam->getView(); + action.mCameraOrigin = cam->getOrigin(); + action.mCameraXAxis = cam->getXAxis(); + action.mCameraYAxis = cam->getYAxis(); + action.mCameraZAxis = cam->getZAxis(); mLastRecordTime = (F32)action.mTime; mActions.put(action); } @@ -151,7 +202,12 @@ void LLAgentPilot::startPlayback() if (mActions.count()) { llinfos << "Starting playback, moving to waypoint 0" << llendl; + if (!LLViewerJoystick::getInstance()->getOverrideCamera()) + { + LLViewerJoystick::getInstance()->toggleFlycam(); + } gAgent.startAutoPilotGlobal(mActions[0].mTarget); + moveCamera(mActions[0]); mStarted = FALSE; } else @@ -178,6 +234,15 @@ void LLAgentPilot::stopPlayback() } } +void LLAgentPilot::moveCamera(Action& action) +{ + LLViewerCamera::getInstance()->setView(action.mCameraView); + LLViewerCamera::getInstance()->setOrigin(action.mCameraOrigin); + LLViewerCamera::getInstance()->mXAxis = LLVector3(action.mCameraXAxis); + LLViewerCamera::getInstance()->mYAxis = LLVector3(action.mCameraYAxis); + LLViewerCamera::getInstance()->mZAxis = LLVector3(action.mCameraZAxis); +} + void LLAgentPilot::updateTarget() { if (mPlaying) @@ -209,6 +274,7 @@ void LLAgentPilot::updateTarget() if (mCurrentAction < mActions.count()) { gAgent.startAutoPilotGlobal(mActions[mCurrentAction].mTarget); + moveCamera(mActions[mCurrentAction]); } else { diff --git a/indra/newview/llagentpilot.h b/indra/newview/llagentpilot.h index f3d34246ae..fd2cb7ee32 100644..100755 --- a/indra/newview/llagentpilot.h +++ b/indra/newview/llagentpilot.h @@ -56,6 +56,11 @@ public: void startPlayback(); void stopPlayback(); + + bool isRecording() { return mRecording; } + bool isPlaying() { return mPlaying; } + bool getOverrideCamera() { return mOverrideCamera; } + void updateTarget(); static void startRecord(void *); @@ -78,6 +83,8 @@ private: BOOL mPlaying; S32 mCurrentAction; + BOOL mOverrideCamera; + class Action { public: @@ -85,10 +92,17 @@ private: EActionType mType; LLVector3d mTarget; F64 mTime; + F32 mCameraView; + LLVector3 mCameraOrigin; + LLVector3 mCameraXAxis; + LLVector3 mCameraYAxis; + LLVector3 mCameraZAxis; }; LLDynamicArray<Action> mActions; LLTimer mTimer; + + void moveCamera(Action& action); }; extern LLAgentPilot gAgentPilot; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index c1a311b170..ec3d775dc7 100644..100755 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4221,8 +4221,15 @@ void LLAppViewer::idle() } if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { - LLViewerJoystick::getInstance()->moveFlycam(); + { + if (gAgentPilot.isPlaying() && gAgentPilot.getOverrideCamera()) + { + // camera positioning handled inside gAgentPilot. + } + else + { + LLViewerJoystick::getInstance()->moveFlycam(); + } } else { |