source: OGRE/trunk/ogrenew/Docs/manual/manual_61.html @ 692

Revision 692, 9.6 KB checked in by mattausch, 18 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1<HTML>
2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3<!-- Created on , 12 2006 by texi2html 1.64 -->
4<!--
5Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
6            Karl Berry  <karl@freefriends.org>
7            Olaf Bachmann <obachman@mathematik.uni-kl.de>
8            and many others.
9Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
10Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
11 
12-->
13<HEAD>
14<TITLE>OGRE Manual v1.2.0 ('Dagon'): External Texture Sources</TITLE>
15
16<META NAME="description" CONTENT="OGRE Manual v1.2.0 ('Dagon'): External Texture Sources">
17<META NAME="keywords" CONTENT="OGRE Manual v1.2.0 ('Dagon'): External Texture Sources">
18<META NAME="resource-type" CONTENT="document">
19<META NAME="distribution" CONTENT="global">
20<META NAME="Generator" CONTENT="texi2html 1.64">
21<LINK TYPE="text/css" rel="stylesheet" href="../style.css"> 
22</HEAD>
23
24<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
25
26<A NAME="SEC263"></A>
27<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
28<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_60.html#SEC262"> &lt; </A>]</TD>
29<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top"> Up </A>]</TD>
30<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_62.html#SEC270"> &gt; </A>]</TD>
31<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
32<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD>
33<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
34<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD>
35</TR></TABLE>
36<HR SIZE=1>
37<H1> 6. External Texture Sources </H1>
38<!--docid::SEC263::-->
39<P>
40
41<A NAME="SEC264"></A>
42<H2> Introduction   </H2>
43<!--docid::SEC264::-->
44<P>
45
46This tutorial will provide a brief introduction of ExternalTextureSource and ExternalTextureSourceManager classes, their relationship, and how the PlugIns work. For those interested in developing a Texture Source Plugin or maybe just wanting to know more about this system, take a look the ffmpegVideoSystem plugin, which you can find more about on the OGRE forums.
47</P><P>
48
49<A NAME="SEC265"></A>
50<H2> What Is An External Texture Source? </H2>
51<!--docid::SEC265::-->
52What is a texture source? Well, a texture source could be anything - png, bmp, jpeg, etc. However, loading textures from traditional bitmap files is already handled by another part OGRE. There are, however, other types of sources to get texture data from - ie. mpeg/avi/etc movie files, flash, run-time generated source, user defined, etc.<BR><BR>
53<P>
54
55How do external texture source plugins benifit OGRE? Well, the main answer is: addding support for any type of texture source does not require changing OGRE to support it... all that is involved is writting a new plugin. Additionally, because the manager uses the StringInterface class to issue commands/params, no change to the material script reader is needs to be made. As a result, if a plugin needs a special parameter set, it just creates a new command in it's Parameter Dictionary. - see ffmpegVideoSystem plugin for an example. To make this work, two classes have been added to OGRE: ExternalTextureSource &#38; ExternalTextureSourceManager.
56</P><P>
57
58<A NAME="SEC266"></A>
59<H2> ExternalTextureSource Class </H2>
60<!--docid::SEC266::-->
61The ExternalTextureSource class is the base class that Texture Source PlugIns must be derived from. It provides a generic framework (via StringInterface class) with a very limited amount of functionality. The most common of parameters can be set through the TexturePlugInSource class interface or via the StringInterface commands contained within this class. While this may seem like duplication of code, it is not. By using the string command interface, it becomes extremly easy for derived plugins to add any new types of parameters that it may need.<BR><BR>
62<P>
63
64Default Command Parameters defined in ExternalTextureSource base class are:
65<UL>
66<LI>Parameter Name: "filename" Argument Type: Ogre::String
67Sets a filename plugin will read from
68<LI>Parameter Name: "play_mode" Argument Type: Ogre::String
69Sets initial play mode to be used by the plugin - "play", "loop", "pause"
70<LI>Parameter Name: "set_T_P_S" Argument Type: Ogre::String
71Used to set the technique, pass, and texture unit level to apply this texture to. As an example: To set a technique level of 1, a pass level of 2, and a texture unit level of 3, send this string "1 2 3".
72<LI>Parameter Name: "frames_per_second" Argument Type: Ogre::String
73Set a Frames per second update speed. (Integer Values only)
74</UL>
75<P>
76
77<A NAME="SEC267"></A>
78<H2> ExternalTextureSourceManager Class </H2>
79<!--docid::SEC267::-->
80ExternalTextureSourceManager is responsible for keeping track of loaded Texture Source PlugIns. It also aids in the creation of texture source textures from scripts. It also is the interface you should use when dealing with texture source plugins.<BR><BR>
81<P>
82
83Note: The function prototypes shown below are mockups - param names are simplified to better illustrate purpose here...
84Steps needed to create a new texture via ExternalTextureSourceManager:
85</P><P>
86
87<UL>
88<LI>Obviously, the first step is to have the desired plugin included in plugin.cfg for it to be loaded.
89<LI>Set the desired PlugIn as Active via AdvancedTextureManager::getSingleton().SetCurrentPlugIn( String Type ); -- type is whatever the plugin registers as handling (eg. "video", "flash", "whatever", etc).
90<LI>Note: Consult Desired PlugIn to see what params it needs/expects.
91Set params/value pairs via AdvancedTextureManager::getSingleton().getCurrentPlugIn()-&#62;setParameter( String Param, String Value );
92<LI>After required params are set, a simple call to AdvancedTextureManager::getSingleton().getCurrentPlugIn()-&#62;createDefinedTexture( sMaterialName ); will create a texture to the material name given.
93</UL>
94<BR><BR>
95<P>
96
97The manager also provides a method for deleting a texture source material: AdvancedTextureManager::DestroyAdvancedTexture( String sTextureName ); The destroy method works by broadcasting the material name to all loaded TextureSourcePlugIns, and the PlugIn who actually created the material is responsible for the deletion, while other PlugIns will just ignore the request. What this means is that you do not need to worry about which PlugIn created the material, or activating the PlugIn yourself. Just call the manager method to remove the material. Also, all texture plugins should handle cleanup when they are shutdown.
98</P><P>
99
100<A NAME="SEC268"></A>
101<H2> Texture Source Material Script </H2>
102<!--docid::SEC268::-->
103As mentioned earlier, the process of defining/creating texture sources can be done within material script file. Here is an example of a material script definition - Note: This example is based off the ffmpegVideoSystem plugin parameters.
104<TABLE><tr><td>&nbsp;</td><td class=example><pre>material Example/MyVideoExample
105{
106        technique
107        {
108                pass
109                {
110                        texture_unit
111                        {
112                                texture_source video
113                                {
114                                        filename mymovie.mpeg
115                                        play_mode play
116                                        sound_mode on
117                                }
118                        }
119                }
120        }               
121}
122</pre></td></tr></table>Notice that the first two param/value pairs are defined in the ExternalTextureSource base class and that the third parameter/value pair is not defined in the base class... That parameter is added to the param dictionary by the ffmpegVideoPlugin... This shows that extending the functionality with the plugins is extremely easy. Also, pay particular attention to the line: texture_source video. This line identifies that this texture unit will come from a texture source plugin. It requires one parameter that determines which texture plugin will be used. In the example shown, the plugin requested is one that registered with "video" name.
123<P>
124
125<A NAME="SEC269"></A>
126<H2> Simplified Diagram of Process </H2>
127<!--docid::SEC269::-->
128<P>
129
130This diagram uses ffmpegVideoPlugin as example, but all plug ins will work the same in how they are registered/used here. Also note that TextureSource Plugins are loaded/registered before scripts are parsed. This does not mean that they are initialized... Plugins are not initialized until they are set active! This is to ensure that a rendersystem is setup before the plugins might make a call the rendersystem.
131</P><P>
132
133<CENTER><IMG SRC="images/TextureSource.jpg" ALT="images/TextureSource"></CENTER>
134<A NAME="Shadows"></A>
135<HR SIZE=1>
136<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
137<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_60.html#SEC262"> &lt; </A>]</TD>
138<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top"> Up </A>]</TD>
139<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_62.html#SEC270"> &gt; </A>]</TD>
140<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
141<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD>
142<TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD>
143<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD>
144</TR></TABLE>
145<BR> 
146<FONT SIZE="-1">
147This document was generated
148by <I>Steve Streeting</I> on <I>, 12 2006</I>
149using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
150"><I>texi2html</I></A>
151
152</BODY>
153</HTML>
Note: See TracBrowser for help on using the repository browser.