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

vos/3D/a3dl/texture.hh

Go to the documentation of this file.
00001 /*
00002     This file is part of the Virtual Object System of
00003     the Interreality project (http://interreality.org).
00004 
00005     Copyright (C) 2001, 2002 Peter Amstutz
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020 
00021     Peter Amstutz <tetron@interreality.org>
00022 */
00023 #ifndef _TEXTURE_HH_
00024 #define _TEXTURE_HH_
00025 
00026 #if defined(_WIN32) && defined(_MSC_VER)
00027 # ifdef A3DL_EXPORTS
00028 #  define A3DL_API __declspec(dllexport)
00029 # else
00030 #  define A3DL_API __declspec(dllimport)
00031 # endif
00032 #else
00033 # define A3DL_API
00034 #endif
00035 
00036 #include <vos/corelibs/vos/vos.hh>
00037 #include <vos/metaobjects/property/property.hh>
00038 
00039 namespace A3DL
00040 {
00041     /** Represents a texture layer in a 3D object's Material.
00042      *  @todo Need to add functions for setting shading (CS mixmode |= 
00043      *  CS_FX_GORAUD), keycolor (CS mixmode |= CS_FX_KEYCOLOR), tiling (CS 
00044      *  mixmode |= CS_FX_TILING)
00045      */
00046     class A3DL_API Texture : public virtual MetaObject
00047     {
00048     protected:
00049         PropertyAccessControl* accesscontrol;
00050     public:
00051         Texture(MetaObject* superobject);
00052         virtual ~Texture();
00053 
00054         static MetaObject* new_Texture(MetaObject* superobject, const string& type);
00055         static void registerExtenders();
00056         virtual const string getType();
00057 
00058         void setPropertyAccessControl(PropertyAccessControl* pac) { accesscontrol = pac; }
00059         PropertyAccessControl* getPropertyAccessControl(){ return accesscontrol; }
00060 
00061         virtual Property* getImage();
00062         virtual void setImage(Property* p);
00063 
00064         /** Set a file backend for the image for this texture (using
00065          * FileProperty).
00066          * @see FileProperty
00067          * @throw FileAccessError if there is an error opening the file
00068          */
00069         virtual void setImageToFile(const string& filename, const string& datatype);
00070         virtual void setImageData(const string& data, const string& datatype);
00071 
00072         /** Set special blend mode. Must be one of the following:
00073          *      MeshBase::BLEND_ADD
00074          *      MeshBase::BLEND_MULTIPLY
00075          *      MeshBase::BLEND_DOUBLE_MULTIPLY
00076          *      MeshBase::BLEND_NORMAL
00077          *  These blend modes determine how the background
00078          *  affects the object's material.
00079          */
00080         virtual void setBlendMode(short mode);
00081 
00082         /** Get special blend mode. Will be one of the following:
00083          *      MeshBase::BLEND_ADD
00084          *      MeshBase::BLEND_MULTIPLY
00085          *      MeshBase::BLEND_DOUBLE_MULTIPLY
00086          *      MeshBase::BLEND_NORMAL
00087          *  These blend modes determine how the background affects the
00088          *  object's material.
00089          *  @throws Vobject::NoSuchObjectError if there is no "a3dl:blend-mode"
00090          *  property.
00091          */
00092         virtual short getBlendMode();
00093 
00094         /** Get blend mode property object. */
00095         virtual Property* getBlendModeObj();
00096 
00097         /** Set blend mode property object. */
00098         virtual void setBlendModeObj(Property* p);
00099 
00100         /** Set general transparency of the texture.
00101             @param t    A value between 0 (no transparency) and 1 (fully
00102                         transparent). Some renderers may round to certain
00103                         values (e.g. 1.0, 0.75, 0.5, 0.25, 0.0)
00104                         If t is > 1, 1 will be used. If t < 0, 0 will be
00105                         used.
00106         */
00107         virtual void setTransparency(double t, PropertyAccessControl* ac =
00108             &NoPropertyAccessControl::static_);
00109 
00110         /** Get transparency. Will be between 0 (no transparency) and
00111             1 (fully transparent).
00112             @throws Vobject:NoSuchObjectError if there is no "a3dl:transparency" object.
00113          */
00114         virtual double getTransparency();
00115 
00116         /** Get transparency property. */
00117         virtual Property* getTransparencyObj();
00118 
00119         /** Set transparency property object */
00120         virtual void setTransparencyObj(Property* obj);
00121 
00122         /** Set whether this layer should have shading. */
00123         virtual void setShaded(bool s, PropertyAccessControl* ac = &NoPropertyAccessControl::static_);
00124 
00125         /** Get whether this layer should have shading or not.
00126             @throws Vobject:NoSuchObjectError if there is no "a3dl:shaded" object.
00127          */
00128         virtual bool getShaded();
00129 
00130         /** Get shaded property object 
00131          *  @throws Vobject::NoSuchObjectError if there is no "a3dl:shaded" object
00132          */
00133         virtual Property* getShadedObj();
00134 
00135         /** Set shaded property object */
00136         virtual void setShadedObj(Property* obj);
00137 
00138         /** Set a color in the texture to be rendered transparent */
00139         virtual void setTransparentKeycolor(float r, float g, float b);
00140 
00141         /** Get the color in the texture that is rendered as transparent 
00142          *  If there is no property, sets (r, g, b) to (0, 0, 0)
00143          *  @todo Throw NoSuchObjectError if there is no object-- need to 
00144          *     disable keycolor if the texture image has an alpha channel.
00145          */
00146         virtual void getTransparentKeycolor(float& r, float& g, float& b);
00147 
00148         virtual void setUVScaleAndShift(float uscale, float vscale, float ushift, float vshift);
00149         virtual void getUVScaleAndShift(float& uscale, float& vscale, float& ushift, float& vshift);
00150     };
00151 }
00152 
00153 #endif

Generated on Tue Aug 12 03:55:37 2003 for Interreality Project - VOS by doxygen 1.3.2