Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre/OgreMain/src/OgreExternalTextureSource.cpp @ 44

Last change on this file since 44 was 5, checked in by anonymous, 17 years ago

=hoffentlich gehts jetzt

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