- fbx: add ImportSettings to keep track of fbx-specific import settings. The settings are generated by the importer instance and injected into parser and DOM.
parent
6c985b9960
commit
05bc8ab684
|
@ -49,6 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "FBXDocument.h"
|
#include "FBXDocument.h"
|
||||||
#include "FBXUtil.h"
|
#include "FBXUtil.h"
|
||||||
#include "FBXImporter.h"
|
#include "FBXImporter.h"
|
||||||
|
#include "FBXImportSettings.h"
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace FBX {
|
namespace FBX {
|
||||||
|
@ -307,8 +308,9 @@ void ReadVectorDataArray(std::vector<unsigned int>& out, const Element& el)
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LazyObject::LazyObject(const Element& element)
|
LazyObject::LazyObject(const Element& element, const ImportSettings& settings)
|
||||||
: element(element)
|
: settings(settings)
|
||||||
|
, element(element)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -350,7 +352,7 @@ const Object* LazyObject::Get()
|
||||||
if (!strncmp(obtype,"Geometry",static_cast<size_t>(key.end()-key.begin()))) {
|
if (!strncmp(obtype,"Geometry",static_cast<size_t>(key.end()-key.begin()))) {
|
||||||
|
|
||||||
if (!strcmp(classtag.c_str(),"Mesh")) {
|
if (!strcmp(classtag.c_str(),"Mesh")) {
|
||||||
object = new MeshGeometry(element,name);
|
object = new MeshGeometry(element,name,settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +391,7 @@ Geometry::~Geometry()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
MeshGeometry::MeshGeometry(const Element& element, const std::string& name)
|
MeshGeometry::MeshGeometry(const Element& element, const std::string& name, const ImportSettings& settings)
|
||||||
: Geometry(element,name)
|
: Geometry(element,name)
|
||||||
{
|
{
|
||||||
const Scope* sc = element.Compound();
|
const Scope* sc = element.Compound();
|
||||||
|
@ -456,6 +458,8 @@ MeshGeometry::MeshGeometry(const Element& element, const std::string& name)
|
||||||
mappings[mapping_offsets[absi] + mapping_counts[absi]++] = cursor;
|
mappings[mapping_offsets[absi] + mapping_counts[absi]++] = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(settings.readAllLayers)
|
||||||
|
|
||||||
// ignore all but the first layer, but warn about any further layers
|
// ignore all but the first layer, but warn about any further layers
|
||||||
for (ElementMap::const_iterator it = Layer.first; it != Layer.second; ++it) {
|
for (ElementMap::const_iterator it = Layer.first; it != Layer.second; ++it) {
|
||||||
const TokenList& tokens = (*it).second->Tokens();
|
const TokenList& tokens = (*it).second->Tokens();
|
||||||
|
@ -784,8 +788,9 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<unsigned int>& materials_
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Document::Document(const Parser& parser)
|
Document::Document(const Parser& parser, const ImportSettings& settings)
|
||||||
: parser(parser)
|
: parser(parser)
|
||||||
|
, settings(settings)
|
||||||
{
|
{
|
||||||
|
|
||||||
const Scope& sc = parser.GetRootScope();
|
const Scope& sc = parser.GetRootScope();
|
||||||
|
@ -811,7 +816,7 @@ Document::Document(const Parser& parser)
|
||||||
DOMError(err,el.second);
|
DOMError(err,el.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
objects[id] = new LazyObject(*el.second);
|
objects[id] = new LazyObject(*el.second, settings);
|
||||||
// DEBUG - evaluate all objects
|
// DEBUG - evaluate all objects
|
||||||
const Object* o = objects[id]->Get();
|
const Object* o = objects[id]->Get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ namespace FBX {
|
||||||
|
|
||||||
class Parser;
|
class Parser;
|
||||||
class Object;
|
class Object;
|
||||||
|
struct ImportSettings;
|
||||||
|
|
||||||
|
|
||||||
/** Represents a delay-parsed FBX objects. Many objects in the scene
|
/** Represents a delay-parsed FBX objects. Many objects in the scene
|
||||||
|
@ -62,7 +63,7 @@ class LazyObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LazyObject(const Element& element);
|
LazyObject(const Element& element, const ImportSettings& settings);
|
||||||
~LazyObject();
|
~LazyObject();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -77,6 +78,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
const ImportSettings& settings;
|
||||||
const Element& element;
|
const Element& element;
|
||||||
boost::scoped_ptr<const Object> object;
|
boost::scoped_ptr<const Object> object;
|
||||||
};
|
};
|
||||||
|
@ -115,7 +117,7 @@ class MeshGeometry : public Geometry
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MeshGeometry(const Element& element, const std::string& name);
|
MeshGeometry(const Element& element, const std::string& name, const ImportSettings& settings);
|
||||||
~MeshGeometry();
|
~MeshGeometry();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -232,7 +234,7 @@ class Document
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Document(const Parser& parser);
|
Document(const Parser& parser, const ImportSettings& settings);
|
||||||
~Document();
|
~Document();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -241,8 +243,14 @@ public:
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ImportSettings& Settings() const {
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
const ImportSettings& settings;
|
||||||
|
|
||||||
ObjectMap objects;
|
ObjectMap objects;
|
||||||
const Parser& parser;
|
const Parser& parser;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the
|
||||||
|
following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file FBXImportSettings.h
|
||||||
|
* @brief FBX importer runtime configuration
|
||||||
|
*/
|
||||||
|
#ifndef INCLUDED_AI_FBX_IMPORTSETTINGS_H
|
||||||
|
#define INCLUDED_AI_FBX_IMPORTSETTINGS_H
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
namespace FBX {
|
||||||
|
|
||||||
|
/** FBX import settings, parts of which are publicly accessible via their corresponding AI_CONFIG constants */
|
||||||
|
struct ImportSettings
|
||||||
|
{
|
||||||
|
ImportSettings()
|
||||||
|
: readAllLayers(true)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/** specifies whether all geometry layers are read and scanned for
|
||||||
|
* usable data channels. The FBX spec indicates that many readers
|
||||||
|
* will only read the first channel and that this is in some way
|
||||||
|
* the recommended way- in reality, however, it happens a lot that
|
||||||
|
* vertex data is spread among multiple layers. The default
|
||||||
|
* value for this option is true.*/
|
||||||
|
bool readAllLayers;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // !FBX
|
||||||
|
} // !Assimp
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -158,7 +158,7 @@ void FBXImporter::InternReadFile( const std::string& pFile,
|
||||||
Parser parser(tokens);
|
Parser parser(tokens);
|
||||||
|
|
||||||
// take the raw parse-tree and convert it to a FBX DOM
|
// take the raw parse-tree and convert it to a FBX DOM
|
||||||
Document doc(parser);
|
Document doc(parser,settings);
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
std::for_each(tokens.begin(),tokens.end(),Util::delete_fun<Token>());
|
std::for_each(tokens.begin(),tokens.end(),Util::delete_fun<Token>());
|
||||||
|
|
|
@ -47,6 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
#include "LogAux.h"
|
#include "LogAux.h"
|
||||||
|
|
||||||
|
#include "FBXImportSettings.h"
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
// TinyFormatter.h
|
// TinyFormatter.h
|
||||||
|
@ -94,22 +96,9 @@ protected:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
// loader settings, publicly accessible via their corresponding AI_CONFIG constants
|
|
||||||
struct Settings
|
|
||||||
{
|
|
||||||
Settings()
|
|
||||||
|
|
||||||
{}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Settings settings;
|
FBX::ImportSettings settings;
|
||||||
|
|
||||||
}; // !class FBXImporter
|
}; // !class FBXImporter
|
||||||
|
|
||||||
|
|
|
@ -2075,6 +2075,10 @@
|
||||||
RelativePath="..\..\code\FBXImporter.h"
|
RelativePath="..\..\code\FBXImporter.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\code\FBXImportSettings.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\code\FBXParser.cpp"
|
RelativePath="..\..\code\FBXParser.cpp"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue