00001 #include "GLAppearance.h" 00002 #include "GLMaterial.h" 00003 #include "X3DGLTextureNode.h" 00004 #include "X3DGLTextureTransformNode.h" 00005 #include "GLLineProperties.h" 00006 #include "GLFillProperties.h" 00007 00008 using namespace X3DTK; 00009 00010 GLAppearance::GLAppearance() 00011 : X3DGLAppearanceNode(), _material(0), _texture(0), _textureTransform(0), _lineProperties(0), _fillProperties(0) 00012 { 00013 defineTagName("GLAppearance", "GLShape"); 00014 } 00015 00016 GLAppearance::GLAppearance(const GLAppearance &A) 00017 : X3DGLAppearanceNode(A), _material(A._material), _texture(A._texture), _textureTransform(A._textureTransform), _lineProperties(A._lineProperties), _fillProperties(A._fillProperties) 00018 { 00019 defineTagName("GLAppearance", "GLShape"); 00020 } 00021 00022 SFNode GLAppearance::clone() const 00023 { 00024 return new GLAppearance(*this); 00025 } 00026 00027 GLAppearance::~GLAppearance() 00028 { 00029 } 00030 00031 void GLAppearance::setMaterial(const GLMaterial *material) 00032 { 00033 _material = (GLMaterial *)material; 00034 } 00035 00036 void GLAppearance::setTexture(const X3DGLTextureNode *texture) 00037 { 00038 _texture = (X3DGLTextureNode *)texture; 00039 } 00040 00041 void GLAppearance::setTextureTransform(const X3DGLTextureTransformNode *textureTransform) 00042 { 00043 _textureTransform = (X3DGLTextureTransformNode *)textureTransform; 00044 } 00045 00046 void GLAppearance::setLineProperties(const GLLineProperties *lineProperties) 00047 { 00048 _lineProperties = (GLLineProperties *)lineProperties; 00049 } 00050 00051 void GLAppearance::setFillProperties(const GLFillProperties *fillProperties) 00052 { 00053 _fillProperties = (GLFillProperties *)fillProperties; 00054 } 00055 00056 bool GLAppearance::addChild(const SFNode &N) 00057 { 00058 if (dynamic_cast<X3DGLMaterialNode *>(N) != 0) 00059 { 00060 if (_material != 0) 00061 return false; 00062 00063 _material = N; 00064 return true; 00065 } 00066 00067 if (dynamic_cast<X3DGLTextureNode *>(N) != 0) 00068 { 00069 if (_texture != 0) 00070 return false; 00071 00072 _texture = N; 00073 return true; 00074 } 00075 00076 if (dynamic_cast<X3DGLTextureTransformNode *>(N) != 0) 00077 { 00078 if (_textureTransform != 0) 00079 return false; 00080 00081 _textureTransform = N; 00082 return true; 00083 } 00084 00085 if (dynamic_cast<GLLineProperties *>(N) != 0) 00086 { 00087 if (_lineProperties != 0) 00088 return false; 00089 00090 _lineProperties = N; 00091 return true; 00092 } 00093 00094 if (dynamic_cast<GLFillProperties *>(N) != 0) 00095 { 00096 if (_fillProperties != 0) 00097 return false; 00098 00099 _fillProperties = N; 00100 return true; 00101 } 00102 00103 return false; 00104 } 00105 00106 bool GLAppearance::setChild(const SFNode &N) 00107 { 00108 if (dynamic_cast<X3DGLMaterialNode *>(N) != 0) 00109 { 00110 _material = N; 00111 return true; 00112 } 00113 00114 if (dynamic_cast<X3DGLTextureNode *>(N) != 0) 00115 { 00116 _texture = N; 00117 return true; 00118 } 00119 00120 if (dynamic_cast<X3DGLTextureTransformNode *>(N) != 0) 00121 { 00122 _textureTransform = N; 00123 return true; 00124 } 00125 00126 if (dynamic_cast<GLLineProperties *>(N) != 0) 00127 { 00128 _lineProperties = N; 00129 return true; 00130 } 00131 00132 if (dynamic_cast<GLFillProperties *>(N) != 0) 00133 { 00134 _fillProperties = N; 00135 return true; 00136 } 00137 00138 return false; 00139 } 00140 00141 bool GLAppearance::removeChild(const SFNode &N) 00142 { 00143 if (_material == N) 00144 { 00145 _material = 0; 00146 return true; 00147 } 00148 00149 if (_texture == N) 00150 { 00151 _texture = 0; 00152 return true; 00153 } 00154 00155 if (_textureTransform == N) 00156 { 00157 _textureTransform = 0; 00158 return true; 00159 } 00160 00161 if (_lineProperties == N) 00162 { 00163 _lineProperties = 0; 00164 return true; 00165 } 00166 00167 if (_fillProperties == N) 00168 { 00169 _fillProperties = 0; 00170 return true; 00171 } 00172 00173 return false; 00174 }