1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2009 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
40 #pragma GCC diagnostic ignored "-Wold-style-cast"
43 #include "OSGColladaSurface.h"
45 #if defined(OSG_WITH_COLLADA) || defined(OSG_DO_DOC)
47 #include "OSGColladaLog.h"
48 #include "OSGColladaImage.h"
50 #include <dom/domFx_surface_common.h>
51 #include <dom/domImage.h>
55 ColladaElementRegistrationHelper
ColladaSurface::_regHelper(
56 &ColladaSurface::create
, "surface");
59 ColladaElementTransitPtr
60 ColladaSurface::create(daeElement
*elem
, ColladaGlobal
*global
)
62 return ColladaElementTransitPtr(new ColladaSurface(elem
, global
));
66 ColladaSurface::read(ColladaElement
*colElemParent
)
68 OSG_COLLADA_LOG(("ColladaSurface::read\n"));
70 domFx_surface_commonRef surface
= getDOMElementAs
<domFx_surface_common
>();
72 switch(surface
->getType())
74 case FX_SURFACE_TYPE_ENUM_UNTYPED
:
78 case FX_SURFACE_TYPE_ENUM_1D
:
82 case FX_SURFACE_TYPE_ENUM_2D
:
86 case FX_SURFACE_TYPE_ENUM_3D
:
90 case FX_SURFACE_TYPE_ENUM_RECT
:
94 case FX_SURFACE_TYPE_ENUM_CUBE
:
98 case FX_SURFACE_TYPE_ENUM_DEPTH
:
101 case FX_SURFACE_TYPE_ENUM_COUNT
:
102 SWARNING
<< "ColladaSurface::read FX_SURFACE_TYPE_ENUM_COUNT "
110 ColladaSurface::getImage(void) const
115 ColladaSurface::ColladaSurface(daeElement
*elem
, ColladaGlobal
*global
)
116 : Inherited(elem
, global
)
121 ColladaSurface::~ColladaSurface(void)
126 ColladaSurface::readUntyped(domFx_surface_common
*surface
)
128 SWARNING
<< "ColladaSurface::readUntyped: NIY" << std::endl
;
132 ColladaSurface::read1D(domFx_surface_common
*surface
)
134 SWARNING
<< "ColladaSurface::read1D: NIY" << std::endl
;
138 ColladaSurface::read2D(domFx_surface_common
*surface
)
140 domFx_surface_init_commonRef init
= surface
->getFx_surface_init_common();
142 domFx_surface_init_common::domInit_as_nullRef initNull
=
143 init
->getInit_as_null();
144 domFx_surface_init_common::domInit_as_targetRef initTarget
=
145 init
->getInit_as_target();
146 domFx_surface_init_planar_commonRef initPlanar
=
147 init
->getInit_planar();
148 const domFx_surface_init_from_common_Array
&initFroms
=
149 init
->getInit_from_array();
153 SWARNING
<< "ColladaSurface::read2D: <init_as_null>: NIY"
156 else if(initTarget
!= NULL
)
158 SWARNING
<< "ColladaSurface::read2D: <init_as_target>: NIY"
161 else if(initPlanar
!= NULL
)
163 SWARNING
<< "ColladaSurface::read2D: <init_planar>: NIY"
166 else if(initFroms
.getCount() > 0)
168 if(initFroms
.getCount() > 1)
170 SWARNING
<< "ColladaSurface::read2D: only one "
171 << "<init_from> supported." << std::endl
;
174 daeElementRef imageElem
= initFroms
[0]->getValue().getElement();
176 if(imageElem
== NULL
)
179 domImageRef image
= daeSafeCast
<domImage
>(imageElem
);
180 ColladaImageRefPtr colImage
= getUserDataAs
<ColladaImage
>(image
);
184 colImage
= dynamic_pointer_cast
<ColladaImage
>(
185 ColladaElementFactory::the()->create(image
, getGlobal()));
187 colImage
->read(this);
190 _image
= colImage
->getImage();
195 ColladaSurface::read3D(domFx_surface_common
*surface
)
197 SWARNING
<< "ColladaSurface::read3D: NIY" << std::endl
;
201 ColladaSurface::readRect(domFx_surface_common
*surface
)
203 SWARNING
<< "ColladaSurface::readRect: NIY" << std::endl
;
207 ColladaSurface::readCube(domFx_surface_common
*surface
)
209 SWARNING
<< "ColladaSurface::readCube: NIY" << std::endl
;
213 ColladaSurface::readDepth(domFx_surface_common
*surface
)
215 SWARNING
<< "ColladaSurface::readDepth: NIY" << std::endl
;
220 #endif // OSG_WITH_COLLADA