[657] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://www.ogre3d.org/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 |
|
---|
| 26 | /***************************************************************************
|
---|
| 27 | OgreExternalTextureSource.cpp -
|
---|
| 28 | Implementation of texture controller class
|
---|
| 29 |
|
---|
| 30 | -------------------
|
---|
| 31 | date : Jan 1 2004
|
---|
| 32 | email : pjcast@yahoo.com
|
---|
| 33 | ***************************************************************************/
|
---|
| 34 |
|
---|
| 35 | #include "OgreStableHeaders.h"
|
---|
| 36 | #include "OgreExternalTextureSource.h"
|
---|
| 37 | #include "OgreStringConverter.h"
|
---|
| 38 | #include "OgreLogManager.h"
|
---|
| 39 | #include "OgreException.h"
|
---|
| 40 |
|
---|
| 41 | namespace Ogre
|
---|
| 42 | {
|
---|
| 43 | //String interface commands for setting some basic commands
|
---|
| 44 | ExternalTextureSource::CmdInputFileName ExternalTextureSource::msCmdInputFile;
|
---|
| 45 | ExternalTextureSource::CmdFPS ExternalTextureSource::msCmdFramesPerSecond;
|
---|
| 46 | ExternalTextureSource::CmdPlayMode ExternalTextureSource::msCmdPlayMode;
|
---|
| 47 | ExternalTextureSource::CmdTecPassState ExternalTextureSource::msCmdTecPassState;
|
---|
| 48 |
|
---|
| 49 | //---------------------------------------------------------------------------------------//
|
---|
| 50 |
|
---|
| 51 | ExternalTextureSource::ExternalTextureSource()
|
---|
| 52 | {
|
---|
| 53 | mInputFileName = "None";
|
---|
| 54 | mDictionaryName = "NotAssigned";
|
---|
| 55 | mUpdateEveryFrame = false;
|
---|
| 56 | mFramesPerSecond = 24;
|
---|
| 57 | mMode = TextureEffectPause;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | //---------------------------------------------------------------------------------------//
|
---|
| 61 |
|
---|
| 62 | void ExternalTextureSource::addBaseParams()
|
---|
| 63 | {
|
---|
| 64 | if( mDictionaryName == "NotAssigned" )
|
---|
| 65 | OGRE_EXCEPT(Exception::ERR_FILE_NOT_FOUND,
|
---|
| 66 | "Plugin " + mPlugInName +
|
---|
| 67 | " needs to override default mDictionaryName",
|
---|
| 68 | "ExternalTextureSource::addBaseParams");
|
---|
| 69 |
|
---|
| 70 | //Create Dictionary Here
|
---|
| 71 | if (createParamDictionary( mDictionaryName ))
|
---|
| 72 | {
|
---|
| 73 | ParamDictionary* dict = getParamDictionary();
|
---|
| 74 |
|
---|
| 75 | dict->addParameter(ParameterDef("filename",
|
---|
| 76 | "A source for the texture effect (only certain plugins require this)"
|
---|
| 77 | , PT_STRING),
|
---|
| 78 | &ExternalTextureSource::msCmdInputFile);
|
---|
| 79 | dict->addParameter(ParameterDef("frames_per_second",
|
---|
| 80 | "How fast should playback be (only certain plugins use this)"
|
---|
| 81 | , PT_INT),
|
---|
| 82 | &ExternalTextureSource::msCmdFramesPerSecond);
|
---|
| 83 | dict->addParameter(ParameterDef("play_mode",
|
---|
| 84 | "How the playback starts(only certain plugins use this)"
|
---|
| 85 | , PT_STRING),
|
---|
| 86 | &ExternalTextureSource::msCmdPlayMode);
|
---|
| 87 | dict->addParameter(ParameterDef("set_T_P_S",
|
---|
| 88 | "Set the technique, pass, and state level of this texture_unit (eg. 0 0 0 )"
|
---|
| 89 | , PT_STRING),
|
---|
| 90 | &ExternalTextureSource::msCmdTecPassState);
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | //---------------------------------------------------------------------------------------//
|
---|
| 95 | //*** String Interface Command Class Definitions *****************************************/
|
---|
| 96 | String ExternalTextureSource::CmdInputFileName::doGet(const void* target) const
|
---|
| 97 | {
|
---|
| 98 | return static_cast<const ExternalTextureSource*>(target)->getInputName();
|
---|
| 99 | }
|
---|
| 100 | void ExternalTextureSource::CmdInputFileName::doSet(void* target, const String& val)
|
---|
| 101 | {
|
---|
| 102 | static_cast<ExternalTextureSource*>(target)->setInputName( val );
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | //------------------------------------------------------------------------------//
|
---|
| 106 | String ExternalTextureSource::CmdFPS::doGet(const void* target) const
|
---|
| 107 | {
|
---|
| 108 | return StringConverter::toString(
|
---|
| 109 | static_cast<const ExternalTextureSource*>(target)->getFPS() );
|
---|
| 110 | }
|
---|
| 111 | void ExternalTextureSource::CmdFPS::doSet(void* target, const String& val)
|
---|
| 112 | {
|
---|
| 113 | static_cast<ExternalTextureSource*>(target)->setFPS(StringConverter::parseInt(val));
|
---|
| 114 | }
|
---|
| 115 | //------------------------------------------------------------------------------//
|
---|
| 116 | String ExternalTextureSource::CmdPlayMode::doGet(const void* target) const
|
---|
| 117 | {
|
---|
| 118 | eTexturePlayMode eMode = static_cast<const ExternalTextureSource*>(target)->getPlayMode();
|
---|
| 119 | String val;
|
---|
| 120 |
|
---|
| 121 | switch(eMode)
|
---|
| 122 | {
|
---|
| 123 | case TextureEffectPlay_ASAP:
|
---|
| 124 | val = "play";
|
---|
| 125 | break;
|
---|
| 126 | case TextureEffectPlay_Looping:
|
---|
| 127 | val = "loop";
|
---|
| 128 | break;
|
---|
| 129 | case TextureEffectPause:
|
---|
| 130 | val = "pause";
|
---|
| 131 | break;
|
---|
| 132 | default:
|
---|
| 133 | val = "error";
|
---|
| 134 | break;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | return val;
|
---|
| 138 | }
|
---|
| 139 | void ExternalTextureSource::CmdPlayMode::doSet(void* target, const String& val)
|
---|
| 140 | {
|
---|
| 141 | eTexturePlayMode eMode = TextureEffectPause;
|
---|
| 142 |
|
---|
| 143 | if( val == "play" )
|
---|
| 144 | eMode = TextureEffectPlay_ASAP;
|
---|
| 145 | if( val == "loop" )
|
---|
| 146 | eMode = TextureEffectPlay_Looping;
|
---|
| 147 | if( val == "pause" )
|
---|
| 148 | eMode = TextureEffectPause;
|
---|
| 149 |
|
---|
| 150 | static_cast<ExternalTextureSource*>(target)->setPlayMode( eMode );
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 | //------------------------------------------------------------------------------//
|
---|
| 154 | String ExternalTextureSource::CmdTecPassState::doGet(const void* target) const
|
---|
| 155 | {
|
---|
| 156 | int t = 0, p = 0, s = 0;
|
---|
| 157 |
|
---|
| 158 | static_cast<const ExternalTextureSource*>(target)->getTextureTecPassStateLevel(t, p, s);
|
---|
| 159 |
|
---|
| 160 | String ret = StringConverter::toString( t ) + " "
|
---|
| 161 | + StringConverter::toString( p ) + " "
|
---|
| 162 | + StringConverter::toString( s );
|
---|
| 163 |
|
---|
| 164 | return ret;
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | void ExternalTextureSource::CmdTecPassState::doSet(void* target, const String& val)
|
---|
| 168 | {
|
---|
| 169 | int t = 0, p = 0, s = 0;
|
---|
| 170 |
|
---|
| 171 | StringVector vecparams = StringUtil::split(val, " \t");
|
---|
| 172 |
|
---|
| 173 | if( vecparams.size() == 3 )
|
---|
| 174 | {
|
---|
| 175 | t = StringConverter::parseInt( vecparams[0] );
|
---|
| 176 | p = StringConverter::parseInt( vecparams[1] );
|
---|
| 177 | s = StringConverter::parseInt( vecparams[2] );
|
---|
| 178 | }
|
---|
| 179 | else
|
---|
| 180 | {
|
---|
| 181 | LogManager::getSingleton().logMessage("Texture controller had problems extracting technique, pass, and state level... Default to 0, 0, 0");
|
---|
| 182 | t = p = s = 0;
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | static_cast<ExternalTextureSource*>(target)->setTextureTecPassStateLevel(t,p,s);
|
---|
| 186 | }
|
---|
| 187 | }
|
---|
| 188 |
|
---|