appear.H

Go to the documentation of this file.
00001 /*
00002  * This file is part of the "Archon" framework.
00003  * (http://files3d.sourceforge.net)
00004  *
00005  * Copyright © 2002 by Kristian Spangsege and Brian Kristiansen.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and
00008  * its documentation under the terms of the GNU General Public License is
00009  * hereby granted. No representations are made about the suitability of
00010  * this software for any purpose. It is provided "as is" without express
00011  * or implied warranty. See the GNU General Public License
00012  * (http://www.gnu.org/copyleft/gpl.html) for more details.
00013  *
00014  * The characters in this file are ISO8859-1 encoded.
00015  *
00016  * The documentation in this file is in "Doxygen" style
00017  * (http://www.doxygen.org).
00018  */
00019 
00020 #ifndef ARCHON_X3D_APPEAR_H
00021 #define ARCHON_X3D_APPEAR_H
00022 
00033 #include <archon/x3d/server/texture.H>
00034 
00035 namespace Archon
00036 {
00037   namespace X3D
00038   {
00042     struct MaterialNode: AppearanceChildNode
00043     {
00044       static const NodeType *type;
00045 
00046     protected:
00047       MaterialNode() {}
00048     };
00049 
00050 
00054     struct Material: MaterialNode
00055     {
00056       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00057       {
00058         return new Material(c);
00059       }
00060 
00061       static const NodeType *type;
00062       const NodeType *getType() const { return type; }
00063 
00064       Material(BackRef<ExecutionContext> c):
00065         NodeBase(c),
00066         diffuseColor(0.8, 0.8, 0.8), 
00067         specularColor(0, 0, 0),
00068         emissiveColor(0, 0, 0),
00069         ambientIntensity(0.2),
00070         shininess(0.2),
00071         transparency(0),
00072         refractiveIndex(1) {}
00073 
00074       const Vector3 &getDiffuseColor()  const { return diffuseColor; }
00075       const Vector3 &getSpecularColor() const { return specularColor; }
00076       const Vector3 &getEmissiveColor() const { return emissiveColor; }
00077       double getAmbientIntensity() const { return ambientIntensity; }
00078       double getShininess()        const { return shininess; }
00079       double getTransparency()     const { return transparency; }
00080       double getRefractiveIndex()  const { return refractiveIndex; }
00081 
00082     private:
00083       friend void initializeAppearComponent();
00084 
00085       Vector3 diffuseColor;
00086       Vector3 specularColor;
00087       Vector3 emissiveColor;
00088       double ambientIntensity;
00089       double shininess;       // Relates to the Phong exponent
00090       double transparency;
00091       double refractiveIndex; // Not part of WRML or X3D
00092 
00093       EventSource diffuseColorChanged;
00094       EventSource specularColorChanged;
00095       EventSource emissiveColorChanged;
00096       EventSource ambientIntensityChanged;
00097       EventSource shininessChanged;
00098       EventSource transparencyChanged;
00099       EventSource refractiveIndexChanged;
00100 
00101       Time diffuseColorStamp;
00102       Time specularColorStamp;
00103       Time emissiveColorStamp;
00104       Time ambientIntensityStamp;
00105       Time shininessStamp;
00106       Time transparencyStamp;
00107       Time refractiveIndexStamp;
00108     };
00109 
00110 
00114     struct AppearanceNode: virtual Node
00115     {
00116       static const NodeType *type;
00117 
00118     protected:
00119       AppearanceNode() {}
00120     };
00121 
00122 
00126     struct Appearance: AppearanceNode
00127     {
00128       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00129       {
00130         return new Appearance(c);
00131       }
00132 
00133       static const NodeType *type;
00134       const NodeType *getType() const { return type; }
00135 
00136       Appearance(BackRef<ExecutionContext> c): NodeBase(c) {}
00137 
00138       Ref<const MaterialNode> getMaterial() const { return material; }
00139       Ref<      MaterialNode> getMaterial()       { return material; }
00140       Ref<const TextureNode>  getTexture()  const { return texture; }
00141       Ref<      TextureNode>  getTexture()        { return texture; }
00142       Ref<const TextureTransformNode> getTextureTransform() const { return textureTransform; }
00143       Ref<      TextureTransformNode> getTextureTransform()       { return textureTransform; }
00144 
00145     private:
00146       friend void initializeAppearComponent();
00147 
00148       Ref<MaterialNode>         material;
00149       Ref<TextureNode>          texture;
00150       Ref<TextureTransformNode> textureTransform;
00151 
00152       EventSource materialChanged;
00153       EventSource textureChanged;
00154       EventSource textureTransformChanged;
00155 
00156       Time materialStamp;
00157       Time textureStamp;
00158       Time textureTransformStamp;
00159     };
00160 
00161 
00165     struct BindableNode: virtual ChildNode
00166     {
00167       static const NodeType *type;
00168 
00169     protected:
00170       BindableNode(): isBound(false) {}
00171 
00172     private:
00173       friend void initializeAppearComponent();
00174 
00175       bool isBound;
00176       Time bindTime;
00177 
00181       bool setBind(const bool &, const Time &)
00182       {
00183         ARCHON_THROW1(InternalException, "Background.set_bind is not supported yet");
00184       }
00185 
00186       EventSource isBoundChanged;
00187       EventSource bindTimeChanged;
00188 
00189       Time bindStamp;
00190     };
00191 
00192 
00196     struct Background: BindableNode
00197     {
00198       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00199       {
00200         return new Background(c);
00201       }
00202 
00203       static const NodeType *type;
00204       const NodeType *getType() const { return type; }
00205 
00206       Background(BackRef<ExecutionContext> c): NodeBase(c)
00207       {
00208         skyColor.push_back(Vector3(0, 0, 0));
00209       }
00210 
00211     private:
00212       friend void initializeAppearComponent();
00213 
00214       vector<double>  groundAngle;
00215       vector<Vector3> groundColor;
00216       vector<string>  backUrl;
00217       vector<string>  bottomUrl;
00218       vector<string>  frontUrl;
00219       vector<string>  leftUrl;
00220       vector<string>  rightUrl;
00221       vector<string>  topUrl;
00222       vector<double>  skyAngle;
00223       vector<Vector3> skyColor;
00224 
00225       EventSource groundAngleChanged;
00226       EventSource groundColorChanged;
00227       EventSource backUrlChanged;
00228       EventSource bottomUrlChanged;
00229       EventSource frontUrlChanged;
00230       EventSource leftUrlChanged;
00231       EventSource rightUrlChanged;
00232       EventSource topUrlChanged;
00233       EventSource skyAngleChanged;
00234       EventSource skyColorChanged;
00235 
00236       Time groundAngleStamp;
00237       Time groundColorStamp;
00238       Time backUrlStamp;
00239       Time bottomUrlStamp;
00240       Time frontUrlStamp;
00241       Time leftUrlStamp;
00242       Time rightUrlStamp;
00243       Time topUrlStamp;
00244       Time skyAngleStamp;
00245       Time skyColorStamp;
00246     };
00247 
00248 
00252     struct Fog: BindableNode
00253     { 
00254       static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00255       {
00256         return new Fog(c);
00257       }
00258 
00259       static const NodeType *type;
00260       const NodeType *getType() const { return type; }
00261 
00262       Fog(BackRef<ExecutionContext> c):
00263         NodeBase(c), color(1, 1, 1), fogType("LINEAR"),
00264         visibilityRange(0) {}
00265 
00266     private:
00267       friend void initializeAppearComponent();
00268 
00269       Vector3 color;
00270       string fogType;
00271       double visibilityRange;
00272 
00273       EventSource colorChanged;
00274       EventSource fogTypeChanged;
00275       EventSource visibilityRangeChanged;
00276 
00277       Time colorStamp;
00278       Time fogTypeStamp;
00279       Time visibilityRangeStamp;
00280     };
00281   }
00282 }
00283 
00284 #endif // ARCHON_X3D_APPEAR_H

Generated on Sun Jul 30 22:55:48 2006 for Archon by  doxygen 1.4.4