Changed the error reporting so that it directs it all via osg::notify, and
only uses the INFO level for reporting that the file to load is not recognised. Also add check for LWO2 loading so that it returns FILE_NOT_HANDLED message correctly.
This commit is contained in:
parent
cab49a9307
commit
93403a54db
@ -67,7 +67,7 @@ Lwo2::ReadFile( const string& filename )
|
|||||||
_fin.open(filename.c_str(), ios::in | ios::binary );
|
_fin.open(filename.c_str(), ios::in | ios::binary );
|
||||||
if (!_fin.is_open())
|
if (!_fin.is_open())
|
||||||
{
|
{
|
||||||
notify(FATAL) << "Can't open file '" << filename << "'" << endl;
|
notify(NOTICE) << "Can't open file '" << filename << "'" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ Lwo2::ReadFile( const string& filename )
|
|||||||
// http://www.lightwave3d.com/developer/75lwsdk/docs/filefmts/eaiff85.html
|
// http://www.lightwave3d.com/developer/75lwsdk/docs/filefmts/eaiff85.html
|
||||||
if (_read_long() != tag_FORM)
|
if (_read_long() != tag_FORM)
|
||||||
{
|
{
|
||||||
notify(FATAL) << "File '" << filename << "' is not IFF format file." << endl;
|
notify(INFO) << "File '" << filename << "' is not IFF format file." << endl;
|
||||||
_fin.close();
|
_fin.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -70,11 +70,11 @@ osgDB::RegisterReaderWriterProxy<ReaderWriterLWO> g_lwoReaderWriterProxy;
|
|||||||
osgDB::ReaderWriter::ReadResult ReaderWriterLWO::readNode_LWO2(const std::string& fileName, const osgDB::ReaderWriter::Options*)
|
osgDB::ReaderWriter::ReadResult ReaderWriterLWO::readNode_LWO2(const std::string& fileName, const osgDB::ReaderWriter::Options*)
|
||||||
{
|
{
|
||||||
std::auto_ptr<Lwo2> lwo2(new Lwo2());
|
std::auto_ptr<Lwo2> lwo2(new Lwo2());
|
||||||
lwo2->ReadFile(fileName);
|
if (lwo2->ReadFile(fileName))
|
||||||
|
{
|
||||||
osg::ref_ptr<Group> group = new osg::Group();
|
osg::ref_ptr<Group> group = new osg::Group();
|
||||||
if (lwo2->GenerateGroup(*group)) return group.take();
|
if (lwo2->GenerateGroup(*group)) return group.take();
|
||||||
|
}
|
||||||
return ReadResult::FILE_NOT_HANDLED;
|
return ReadResult::FILE_NOT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ struct GeometryCollection
|
|||||||
// read file and convert to OSG.
|
// read file and convert to OSG.
|
||||||
osgDB::ReaderWriter::ReadResult ReaderWriterLWO::readNode_LWO1(const std::string& fileName, const osgDB::ReaderWriter::Options*)
|
osgDB::ReaderWriter::ReadResult ReaderWriterLWO::readNode_LWO1(const std::string& fileName, const osgDB::ReaderWriter::Options*)
|
||||||
{
|
{
|
||||||
lwObject* lw = lw_object_read(fileName.c_str());
|
lwObject* lw = lw_object_read(fileName.c_str(),osg::notify(osg::INFO));
|
||||||
if (!lw)
|
if (!lw)
|
||||||
return ReadResult::FILE_NOT_HANDLED;
|
return ReadResult::FILE_NOT_HANDLED;
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ gint lw_is_lwobject(const char *lw_file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lwObject *lw_object_read(const char *lw_file)
|
lwObject *lw_object_read(const char *lw_file, std::ostream& output)
|
||||||
{
|
{
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
lwObject *lw_object = NULL;
|
lwObject *lw_object = NULL;
|
||||||
@ -250,13 +250,13 @@ lwObject *lw_object_read(const char *lw_file)
|
|||||||
/* open file */
|
/* open file */
|
||||||
f = fopen(lw_file, "rb");
|
f = fopen(lw_file, "rb");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
g_warning("can't open file %s", lw_file);
|
output << "can't open file "<<lw_file<<std::endl;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for headers */
|
/* check for headers */
|
||||||
if (read_long(f) != ID_FORM) {
|
if (read_long(f) != ID_FORM) {
|
||||||
g_warning("file %s is not an IFF file", lw_file);
|
output << "file "<<lw_file<<" is not an IFF file"<<std::endl;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -264,7 +264,7 @@ lwObject *lw_object_read(const char *lw_file)
|
|||||||
read_bytes += 4;
|
read_bytes += 4;
|
||||||
|
|
||||||
if (read_long(f) != ID_LWOB) {
|
if (read_long(f) != ID_LWOB) {
|
||||||
g_warning("file %s is not a LWOB file", lw_file);
|
output << "file "<<lw_file<<" is not a LWOB file"<<std::endl;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#define LW_H
|
#define LW_H
|
||||||
|
|
||||||
#include <osg/GL>
|
#include <osg/GL>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#define LW_MAX_POINTS 200
|
#define LW_MAX_POINTS 200
|
||||||
#define LW_MAX_NAME_LEN 500
|
#define LW_MAX_NAME_LEN 500
|
||||||
@ -88,7 +89,7 @@ typedef int gint;
|
|||||||
|
|
||||||
|
|
||||||
gint lw_is_lwobject(const char *lw_file);
|
gint lw_is_lwobject(const char *lw_file);
|
||||||
lwObject *lw_object_read(const char *lw_file);
|
lwObject *lw_object_read(const char *lw_file, std::ostream& output);
|
||||||
void lw_object_free( lwObject *lw_object);
|
void lw_object_free( lwObject *lw_object);
|
||||||
|
|
||||||
GLfloat lw_object_radius(const lwObject *lw_object);
|
GLfloat lw_object_radius(const lwObject *lw_object);
|
||||||
|
Loading…
Reference in New Issue
Block a user