Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreExternalTextureSource.cpp

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright © 2000-2004 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 
00026 /***************************************************************************
00027 OgreExternalTextureSource.cpp  -  
00028     Implementation of texture controller class
00029 
00030 -------------------
00031 date                 : Jan 1 2004
00032 email                : pjcast@yahoo.com
00033 ***************************************************************************/
00034 
00035 #include "OgreStableHeaders.h"
00036 #include "OgreExternalTextureSource.h"
00037 #include "OgreStringConverter.h"
00038 #include "OgreLogManager.h"
00039 
00040 namespace Ogre
00041 {
00042     //String interface commands for setting some basic commands
00043     ExternalTextureSource::CmdInputFileName ExternalTextureSource::msCmdInputFile;
00044     ExternalTextureSource::CmdFPS           ExternalTextureSource::msCmdFramesPerSecond;
00045     ExternalTextureSource::CmdPlayMode      ExternalTextureSource::msCmdPlayMode;
00046     ExternalTextureSource::CmdTecPassState  ExternalTextureSource::msCmdTecPassState;
00047 
00048     //---------------------------------------------------------------------------------------//
00049 
00050     ExternalTextureSource::ExternalTextureSource()
00051     {
00052         mInputFileName = "None";
00053         mDictionaryName = "ExternalTextureSourcePlugins";
00054         mUpdateEveryFrame = false;
00055         mFramesPerSecond = 24;
00056         mMode = TextureEffectPause;
00057     }
00058 
00059     //---------------------------------------------------------------------------------------//
00060 
00061     void ExternalTextureSource::addBaseParams()
00062     {
00063         //Create Dictionary Here
00064         if (createParamDictionary( mDictionaryName ))
00065         {
00066             ParamDictionary* dict = getParamDictionary();
00067             
00068             dict->addParameter(ParameterDef("filename", 
00069                 "A source for the texture effect (only certain plugins require this)"
00070                 , PT_STRING),
00071                 &ExternalTextureSource::msCmdInputFile);
00072             dict->addParameter(ParameterDef("frames_per_second", 
00073                 "How fast should playback be (only certain plugins use this)"
00074                 , PT_INT),
00075                 &ExternalTextureSource::msCmdFramesPerSecond);
00076             dict->addParameter(ParameterDef("play_mode", 
00077                 "How the playback starts(only certain plugins use this)"
00078                 , PT_STRING),
00079                 &ExternalTextureSource::msCmdPlayMode);
00080             dict->addParameter(ParameterDef("set_T_P_S", 
00081                 "Set the technique, pass, and state level of this texture_unit (eg. 0 0 0 )"
00082                 , PT_STRING),
00083                 &ExternalTextureSource::msCmdTecPassState);
00084         }
00085     }
00086 
00087     //---------------------------------------------------------------------------------------//
00088     //*** String Interface Command Class Definitions *****************************************/
00089     String ExternalTextureSource::CmdInputFileName::doGet(const void* target) const
00090     {
00091         return static_cast<const ExternalTextureSource*>(target)->getInputName();
00092     }
00093     void ExternalTextureSource::CmdInputFileName::doSet(void* target, const String& val)
00094     {
00095         static_cast<ExternalTextureSource*>(target)->setInputName( val );
00096     }
00097     
00098     //------------------------------------------------------------------------------//
00099     String ExternalTextureSource::CmdFPS::doGet(const void* target) const
00100     {
00101         return StringConverter::toString(
00102             static_cast<const ExternalTextureSource*>(target)->getFPS() );
00103     }
00104     void ExternalTextureSource::CmdFPS::doSet(void* target, const String& val)
00105     {
00106         static_cast<ExternalTextureSource*>(target)->setFPS(StringConverter::parseInt(val));
00107     }
00108     //------------------------------------------------------------------------------//
00109     String ExternalTextureSource::CmdPlayMode::doGet(const void* target) const
00110     {
00111         eTexturePlayMode eMode = static_cast<const ExternalTextureSource*>(target)->getPlayMode();
00112         String val;
00113 
00114         switch(eMode)
00115         {
00116         case TextureEffectPlay_ASAP:
00117             val = "play";
00118             break;
00119         case TextureEffectPlay_Looping: 
00120             val = "loop";
00121             break;
00122         case TextureEffectPause:
00123             val = "pause";
00124             break;
00125         default: 
00126             val = "error"; 
00127             break;
00128         }
00129 
00130         return val;
00131     }
00132     void ExternalTextureSource::CmdPlayMode::doSet(void* target, const String& val)
00133     {
00134         eTexturePlayMode eMode = TextureEffectPause;
00135 
00136         if( val == "play" )
00137             eMode = TextureEffectPlay_ASAP;
00138         if( val == "loop" )
00139             eMode = TextureEffectPlay_Looping;
00140         if( val == "pause" )
00141             eMode = TextureEffectPause;
00142 
00143         static_cast<ExternalTextureSource*>(target)->setPlayMode( eMode );
00144     }
00145 
00146     //------------------------------------------------------------------------------//
00147     String ExternalTextureSource::CmdTecPassState::doGet(const void* target) const
00148     {
00149         int t = 0, p = 0, s = 0;
00150 
00151         static_cast<const ExternalTextureSource*>(target)->getTextureTecPassStateLevel(t, p, s);
00152 
00153         String ret = StringConverter::toString( t ) + " " 
00154                     + StringConverter::toString( p ) + " " 
00155                     + StringConverter::toString( s );
00156         
00157         return ret;         
00158     }
00159 
00160     void ExternalTextureSource::CmdTecPassState::doSet(void* target, const String& val)
00161     {
00162         int t = 0, p = 0, s = 0;
00163 
00164         StringVector vecparams = val.split(" \t");
00165 
00166         if( vecparams.size() == 3 )
00167         {
00168             t = StringConverter::parseInt( vecparams[0] );
00169             p = StringConverter::parseInt( vecparams[1] );
00170             s = StringConverter::parseInt( vecparams[2] );
00171         }
00172         else
00173         {
00174             LogManager::getSingleton().logMessage("Texture controller had problems extracting technique, pass, and state level... Default to 0, 0, 0");
00175             t = p = s = 0;
00176         }
00177 
00178         static_cast<ExternalTextureSource*>(target)->setTextureTecPassStateLevel(t,p,s);
00179     }
00180 }
00181 

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:09 2004