1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12 */
13
14 #include <osg/Notify>
15 #include <osg/Object>
16 #include <osg/Image>
17 #include <osg/Node>
18 #include <osg/Group>
19 #include <osg/Geode>
20
21 #include <osgDB/Registry>
22 #include <osgDB/WriteFile>
23
24 using namespace osg;
25 using namespace osgDB;
26
writeObjectFile(const Object & object,const std::string & filename,const Options * options)27 bool osgDB::writeObjectFile(const Object& object,const std::string& filename, const Options* options )
28 {
29 ReaderWriter::WriteResult wr = Registry::instance()->writeObject( object, filename, options );
30 if (wr.error()) OSG_WARN << "Error writing file " << filename << ": " << wr.message() << std::endl;
31 return wr.success();
32 }
33
34
writeImageFile(const Image & image,const std::string & filename,const Options * options)35 bool osgDB::writeImageFile(const Image& image,const std::string& filename, const Options* options )
36 {
37 ReaderWriter::WriteResult wr = Registry::instance()->writeImage( image, filename, options );
38 if (wr.error()) OSG_WARN << "Error writing file " << filename << ": " << wr.message() << std::endl;
39 return wr.success();
40 }
41
42
writeHeightFieldFile(const HeightField & HeightField,const std::string & filename,const Options * options)43 bool osgDB::writeHeightFieldFile(const HeightField& HeightField,const std::string& filename, const Options* options )
44 {
45 ReaderWriter::WriteResult wr = Registry::instance()->writeHeightField( HeightField, filename, options );
46 if (wr.error()) OSG_WARN << "Error writing file " << filename << ": " << wr.message() << std::endl;
47 return wr.success();
48 }
49
writeNodeFile(const Node & node,const std::string & filename,const Options * options)50 bool osgDB::writeNodeFile(const Node& node,const std::string& filename, const Options* options )
51 {
52 ReaderWriter::WriteResult wr = Registry::instance()->writeNode( node, filename, options );
53 if (wr.error()) OSG_WARN << "Error writing file " << filename << ": " << wr.message() << std::endl;
54 return wr.success();
55 }
56
writeShaderFile(const Shader & shader,const std::string & filename,const Options * options)57 bool osgDB::writeShaderFile(const Shader& shader,const std::string& filename, const Options* options )
58 {
59 ReaderWriter::WriteResult wr = Registry::instance()->writeShader( shader, filename, options );
60 if (wr.error()) OSG_WARN << "Error writing file " << filename << ": " << wr.message() << std::endl;
61 return wr.success();
62 }
63
writeScriptFile(const Script & image,const std::string & filename,const Options * options)64 bool osgDB::writeScriptFile(const Script& image,const std::string& filename, const Options* options )
65 {
66 ReaderWriter::WriteResult wr = Registry::instance()->writeScript( image, filename, options );
67 if (wr.error()) OSG_WARN << "Error writing file " << filename << ": " << wr.message() << std::endl;
68 return wr.success();
69 }
70
71