1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 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 //-------------------------------
41 //-------------------------------
46 #include "OSGConfig.h"
54 #include "OSGGeometry.h"
55 #include "OSGSimpleMaterial.h"
56 #include "OSGTypedGeoIntegralProperty.h"
57 #include "OSGTypedGeoVectorProperty.h"
59 #include "OSGRAWSceneFileType.h"
63 #if defined(OSG_WIN32_ICL) && !defined(OSG_CHECK_FIELDSETARG)
64 #pragma warning (disable : 383)
68 /*! \class OSG::RAWSceneFileType
69 \ingroup GrpSystemFileIO
73 /*****************************
75 *****************************/
76 // Static Class Varible implementations:
78 const Char8
*RAWSceneFileType::_suffixA
[] = {"raw"};
81 RAWSceneFileType
RAWSceneFileType::_the(_suffixA
,
85 SceneFileType::OSG_READ_SUPPORTED
);
87 /*****************************
89 *****************************/
92 /********************************
94 *******************************/
97 /*******************************
99 *******************************/
101 //----------------------------
102 // Function name: read
103 //----------------------------
106 //p: Scene &image, const char *fileName
116 //d: read the image from the given file
120 //------------------------------
123 #pragma set woff 1209
126 NodeTransitPtr
RAWSceneFileType::read( std::istream
&is
,
131 GeometryUnrecPtr geo
;
132 GeoPnt3fPropertyUnrecPtr points
;
133 GeoVec3fPropertyUnrecPtr normals
;
134 GeoIntegralPropertyUnrecPtr index
;
135 GeoIntegralPropertyUnrecPtr lens
;
136 GeoIntegralPropertyUnrecPtr type
;
140 UInt32 i
= 0, n
, triCount
= 0;
146 root
= Node ::create();
147 geo
= Geometry::create();
149 root
->setCore( geo
);
151 points
= GeoPnt3fProperty::create();
153 geo
->setPositions(points
);
155 normals
= GeoVec3fProperty::create();
157 geo
->setNormals(normals
);
172 points
->editFieldPtr()->push_back(Pnt3f(x
, y
, z
));
174 vec
[i
].setValues(x
,y
,z
);
176 std::cerr
<< x
<< " " << y
<< " " << z
<< std::endl
;
182 vec
[0].crossThis(vec
[1]);
185 normals
->editFieldPtr()->push_back(vec
[0]);
186 normals
->editFieldPtr()->push_back(vec
[0]);
187 normals
->editFieldPtr()->push_back(vec
[0]);
201 index
= GeoUInt32Property::create();
203 geo
->setIndex(index
, Geometry::PositionsIndex
);
204 geo
->setIndex(index
, Geometry::NormalsIndex
);
208 for(i
= 0; i
< n
; i
++)
213 lens
= GeoUInt32Property::create();
215 geo
->setLengths(lens
);
219 type
= GeoUInt8Property::create();
223 type
->push_back(GL_TRIANGLES
);
226 SimpleMaterialUnrecPtr mat
= SimpleMaterial::create();
228 mat
->setDiffuse (Color3f( .8f
, .8f
, .8f
));
229 mat
->setSpecular (Color3f( 1.f
, 1.f
, 1.f
));
230 mat
->setShininess(20.f
);
232 geo
->setMaterial(mat
);
237 SNOTICE
<< triCount
<< " triangle read " << std::endl
;
246 #pragma reset woff 1209
249 /******************************
251 ******************************/
254 /******************************
256 ******************************/
259 /***************************
261 ***************************/
264 /***************************
266 ***************************/
269 /**constructors & destructors**/
272 RAWSceneFileType::RAWSceneFileType(const Char8
*suffixArray
[],
273 UInt16 suffixByteCount
,
275 UInt32 overridePriority
,
277 SceneFileType(suffixArray
,
285 RAWSceneFileType
&RAWSceneFileType::the(void)
290 const Char8
*RAWSceneFileType::getName(void) const
292 return "RAW Geometry";
296 RAWSceneFileType::~RAWSceneFileType (void )