source: GTP/trunk/Lib/Geom/OgreStuff/include/OgreExternalTextureSource.h @ 1809

Revision 1809, 7.6 KB checked in by gumbau, 18 years ago (diff)
RevLine 
[1809]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-2005 The OGRE Team
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-----------------------------------------------------------------------------
24*/
25#ifndef _OgreExternalTextureSource_H
26#define _OgreExternalTextureSource_H
27 
28/***************************************************************************
29OgreExternalTextureSource.h  - 
30        Base class that texture plugins need to derive from. This provides the hooks
31        neccessary for a plugin developer to easily extend the functionality of dynamic textures.
32        It makes creation/destruction of dynamic textures more streamlined. While the plugin
33        will need to talk with Ogre for the actual modification of textures, this class allows
34        easy integration with Ogre apps. Material script files can be used to aid in the
35        creation of dynamic textures. Functionality can be added that is not defined here
36        through the use of the base dictionary. For an exmaple of how to use this class and the
37        string interface see ffmpegVideoPlugIn.
38
39-------------------
40date                 : Jan 1 2004
41email                : pjcast@yahoo.com
42***************************************************************************/
43
44#include "OgreStringInterface.h"
45#include "OgreResourceGroupManager.h"
46
47namespace Ogre
48{
49        /** Enum for type of texture play mode */
50        enum eTexturePlayMode
51        {
52                TextureEffectPause = 0,                 //! Video starts out paused
53                TextureEffectPlay_ASAP = 1,             //! Video starts playing as soon as posible
54                TextureEffectPlay_Looping = 2   //! Video Plays Instantly && Loops
55        };
56
57        /** IMPORTANT: **Plugins must override default dictionary name!**
58        Base class that texture plugins derive from. Any specific
59        requirements that the plugin needs to have defined before
60        texture/material creation must be define using the stringinterface
61        before calling create defined texture... or it will fail, though, it
62        is up to the plugin to report errors to the log file, or raise an
63        exception if need be. */
64        class _OgreExport ExternalTextureSource : public StringInterface
65        {
66        public:
67                /** Constructor */
68                ExternalTextureSource();
69                /** Virtual destructor */
70                virtual ~ExternalTextureSource() {}
71
72                //------------------------------------------------------------------------------//
73                /* Command objects for specifying some base features                                                    */
74                /* Any PlugIns wishing to add more specific params to "ExternalTextureSourcePlugins"*/
75                /* dictionary, feel free to do so, that's why this is here                                              */
76        class _OgrePrivate CmdInputFileName : public ParamCommand
77        {
78        public:
79                        String doGet(const void* target) const;
80            void doSet(void* target, const String& val);
81        };
82        class _OgrePrivate CmdFPS : public ParamCommand
83        {
84        public:
85                        String doGet(const void* target) const;
86            void doSet(void* target, const String& val);
87        };
88        class _OgrePrivate CmdPlayMode : public ParamCommand
89        {
90        public:
91                        String doGet(const void* target) const;
92            void doSet(void* target, const String& val);
93        };
94        class _OgrePrivate CmdTecPassState : public ParamCommand
95        {
96        public:
97                        String doGet(const void* target) const;
98            void doSet(void* target, const String& val);
99        };
100                //--------------------------------------------------------//
101                //Base Functions that work with Command String Interface... Or can be called
102                //manually to create video through code
103
104                //! Sets an input file name - if needed by plugin
105                void setInputName( String sIN ) { mInputFileName = sIN; }
106                //! Gets currently set input file name
107                const String& getInputName( ) const     { return mInputFileName; }
108                //! Sets the frames per second - plugin may or may not use this
109                void setFPS( int iFPS ) { mFramesPerSecond = iFPS; }
110                //! Gets currently set frames per second
111                const int getFPS( ) const { return mFramesPerSecond; }
112                //! Sets a play mode
113                void setPlayMode( eTexturePlayMode eMode )      { mMode = eMode; }
114                //! Gets currently set play mode
115                eTexturePlayMode getPlayMode() const { return mMode; }
116
117                //! Used for attaching texture to Technique, State, and texture unit layer
118                void setTextureTecPassStateLevel( int t, int p, int s )
119                                { mTechniqueLevel = t;mPassLevel = p;mStateLevel = s; }
120                //! Get currently selected Textute attribs.
121                void getTextureTecPassStateLevel( int& t, int& p, int& s ) const
122                                {t = mTechniqueLevel;   p = mPassLevel; s = mStateLevel;}
123               
124                /** Call from derived classes to ensure the dictionary is setup */
125                void addBaseParams();
126
127                /** Returns the string name of this PlugIn (as set by the PlugIn)*/
128                const String& getPlugInStringName( void ) const { return mPlugInName; }
129                /** Returns dictionary name */
130                const String& getDictionaryStringName( void ) const { return mDictionaryName; }
131
132                //Pure virtual functions that plugins must Override
133                /** Call this function from manager to init system */
134                virtual bool initialise() = 0;
135                /** Shuts down PlugIn */
136                virtual void shutDown() = 0;
137
138                /** Creates a texture into an already defined material or one that is created new
139                (it's up to plugin to use a material or create one)
140                Before calling, ensure that needed params have been defined via the stringInterface
141                or regular methods */
142                virtual void createDefinedTexture( const String& sMaterialName,
143                        const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME) = 0;
144                /** What this destroys is dependent on the plugin... See specific plugin
145                doc to know what is all destroyed (normally, plugins will destroy only
146                what they created, or used directly - ie. just texture unit) */
147                virtual void destroyAdvancedTexture( const String& sTextureName,
148                        const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME) = 0;
149
150        protected:
151        static CmdInputFileName msCmdInputFile;         //! Command for setting input file name
152                static CmdFPS msCmdFramesPerSecond;                     //! Command for setting frames per second
153                static CmdPlayMode msCmdPlayMode;                       //! Command for setting play mode
154                static CmdTecPassState msCmdTecPassState;       //! Command for setting the tecnique, pass, & state level
155
156
157                //! String Name of this PlugIn
158                String mPlugInName;
159       
160                //------ Vars used for setting/getting dictionary stuff -----------//
161                eTexturePlayMode mMode;
162               
163                String mInputFileName;
164               
165                bool mUpdateEveryFrame;
166               
167                int mFramesPerSecond,
168                        mTechniqueLevel,
169                        mPassLevel,     
170                        mStateLevel;
171                //------------------------------------------------------------------//
172
173        protected:
174                /** The string name of the dictionary name - each plugin
175                must override default name */
176                String mDictionaryName;
177        };
178}
179
180#endif
Note: See TracBrowser for help on using the repository browser.