From ba9ccd91a10368c33d15deb56931bda2c3e1cfdc Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 24 Jun 2013 12:51:02 +0000 Subject: [PATCH] From Cedric Pinson, "I fixed a little issue with the lightwave scene loader. On the version 5 there are id on the command LoadObjectLayer in the scene file and of this version the current code use this field as a part of the filename, and it fails because the file is not found. I just added a field version_ to read it at the beginning and added extra code to check it and read the extra field if needed and read the good filename" --- src/osgPlugins/lws/SceneLoader.cpp | 16 ++++++++++++++++ src/osgPlugins/lws/SceneLoader.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/osgPlugins/lws/SceneLoader.cpp b/src/osgPlugins/lws/SceneLoader.cpp index f5d737cbf..568f56ebd 100644 --- a/src/osgPlugins/lws/SceneLoader.cpp +++ b/src/osgPlugins/lws/SceneLoader.cpp @@ -97,6 +97,17 @@ osg::Group *SceneLoader::load(const std::string &filename, const osgDB::ReaderWr clear(); + std::string field; + std::getline(ifs, field); + if (field.substr(0,4) != "LWSC") { + osg::notify(osg::WARN) << filename << " is not a LWSC file, " << field << std::endl; + return 0; + } + + std::getline(ifs, field); + version_ = atoi(field.c_str()); + + std::string identifier; while (ifs >> identifier) { if (identifier == "{") { @@ -220,6 +231,11 @@ bool SceneLoader::parse_block(const std::string &name, const std::string &data) if (name == "LoadObjectLayer") { unsigned layer; iss >> layer; + + std::string id; + if (version_ >= 5) { + iss >> id; + } std::ws(iss); std::string filename; std::getline(iss, filename); diff --git a/src/osgPlugins/lws/SceneLoader.h b/src/osgPlugins/lws/SceneLoader.h index e74ab1042..d384eefd4 100644 --- a/src/osgPlugins/lws/SceneLoader.h +++ b/src/osgPlugins/lws/SceneLoader.h @@ -126,6 +126,7 @@ namespace lwosg bool capture_cam_motion_; Options options_; + unsigned int version_; }; // INLINE METHODS