PageRenderTime 42ms CodeModel.GetById 20ms app.highlight 6ms RepoModel.GetById 14ms app.codeStats 0ms

/indra/newview/llwlanimator.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 139 lines | 77 code | 27 blank | 35 comment | 3 complexity | 939cbaad8687eb53f705c7438623d5a3 MD5 | raw file
  1/**
  2 * @file llwlanimator.h
  3 * @brief Interface for the LLWLAnimator class.
  4 *
  5 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_WL_ANIMATOR_H
 28#define LL_WL_ANIMATOR_H
 29
 30#include "llwlparamset.h"
 31#include "llwaterparamset.h"
 32#include <string>
 33#include <map>
 34
 35struct LLWLParamKey;
 36
 37class LLWLAnimator {
 38public:
 39	typedef enum e_time
 40	{
 41		TIME_LINDEN,
 42		TIME_LOCAL,
 43		TIME_CUSTOM
 44	} ETime;
 45
 46	F64 mStartTime;
 47	F32 mDayRate;
 48	F64 mDayTime;
 49	
 50	// track to play
 51	std::map<F32, LLWLParamKey> mTimeTrack;
 52	std::map<F32, LLWLParamKey>::iterator mFirstIt, mSecondIt;
 53
 54	// simple constructor
 55	LLWLAnimator();
 56
 57	~LLWLAnimator()
 58	{
 59		delete mInterpBeginWL;
 60		delete mInterpBeginWater;
 61		delete mInterpEndWater;
 62	}
 63
 64	// update the parameters
 65	void update(LLWLParamSet& curParams);
 66
 67	// get time in seconds
 68	//F64 getTime(void);
 69
 70	// returns a float 0 - 1 saying what time of day is it?
 71	F64 getDayTime(void);
 72
 73	// sets a float 0 - 1 saying what time of day it is
 74	void setDayTime(F64 dayTime);
 75
 76	// set an animation track
 77	void setTrack(std::map<F32, LLWLParamKey>& track,
 78		F32 dayRate, F64 dayTime = 0, bool run = true);
 79
 80	void deactivate()
 81	{
 82		mIsRunning = false;
 83	}
 84
 85	void activate(ETime time)
 86	{
 87		mIsRunning = true;
 88		mTimeType = time;
 89	}
 90
 91	void startInterpolation(const LLSD& targetWater);
 92
 93	bool getIsRunning()
 94	{
 95		return mIsRunning;
 96	}
 97
 98	bool getUseCustomTime()
 99	{
100		return mTimeType == TIME_CUSTOM;
101	}
102
103	bool getUseLocalTime()
104	{
105		return mTimeType == TIME_LOCAL;
106	}
107
108	bool getUseLindenTime()
109	{
110		return mTimeType == TIME_LINDEN;
111	}
112
113	void setTimeType(ETime time)
114	{
115		mTimeType = time;
116	}
117
118	ETime getTimeType()
119	{
120		return mTimeType;
121	}
122
123	/// convert the present time to a digital clock time
124	static std::string timeToString(F32 curTime);
125
126	/// get local time between 0 and 1
127	static F64 getLocalTime();
128
129private:
130	ETime mTimeType;
131	bool mIsRunning, mIsInterpolating;
132	LLWLParamSet *mInterpBeginWL;
133	LLWaterParamSet *mInterpBeginWater, *mInterpEndWater;
134	clock_t mInterpStartTime, mInterpEndTime;
135
136	static F64 INTERP_TOTAL_SECONDS;
137};
138
139#endif // LL_WL_ANIMATOR_H