Initial pieces for full OBJ support.
Needs testing by aircraft developers, this is just the first piece.
This commit is contained in:
@@ -44,6 +44,8 @@
|
|||||||
#include <osgDB/SharedStateManager>
|
#include <osgDB/SharedStateManager>
|
||||||
#include <osgUtil/Optimizer>
|
#include <osgUtil/Optimizer>
|
||||||
|
|
||||||
|
#include <simgear/sg_inlines.h>
|
||||||
|
|
||||||
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
||||||
#include <simgear/scene/util/SGStateAttributeVisitor.hxx>
|
#include <simgear/scene/util/SGStateAttributeVisitor.hxx>
|
||||||
#include <simgear/scene/util/SGTextureStateAttributeVisitor.hxx>
|
#include <simgear/scene/util/SGTextureStateAttributeVisitor.hxx>
|
||||||
@@ -489,7 +491,27 @@ typedef ModelRegistryCallback<ACProcessPolicy, DefaultCachePolicy,
|
|||||||
OSGSubstitutePolicy, BuildLeafBVHPolicy>
|
OSGSubstitutePolicy, BuildLeafBVHPolicy>
|
||||||
ACCallback;
|
ACCallback;
|
||||||
|
|
||||||
|
struct OBJProcessPolicy {
|
||||||
|
OBJProcessPolicy(const string& extension) {}
|
||||||
|
Node* process(Node* node, const string& filename,
|
||||||
|
const Options* opt)
|
||||||
|
{
|
||||||
|
SG_UNUSED(filename);
|
||||||
|
SG_UNUSED(opt);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef ModelRegistryCallback<OBJProcessPolicy,
|
||||||
|
DefaultCachePolicy,
|
||||||
|
ACOptimizePolicy,
|
||||||
|
OSGSubstitutePolicy, BuildLeafBVHPolicy>
|
||||||
|
OBJCallback;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
ModelRegistryCallbackProxy<ACCallback> g_acRegister("ac");
|
ModelRegistryCallbackProxy<ACCallback> g_acRegister("ac");
|
||||||
|
ModelRegistryCallbackProxy<OBJCallback> g_objRegister("obj");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,8 +97,10 @@ osg::Node* loadFile(const string& path, SGReaderWriterOptions* options)
|
|||||||
{
|
{
|
||||||
using namespace osg;
|
using namespace osg;
|
||||||
using namespace osgDB;
|
using namespace osgDB;
|
||||||
if (boost::iends_with(path, ".ac"))
|
if (boost::iends_with(path, ".ac") || boost::iends_with(path, ".obj")) {
|
||||||
options->setInstantiateEffects(true);
|
options->setInstantiateEffects(true);
|
||||||
|
}
|
||||||
|
|
||||||
ref_ptr<Node> model = readRefNodeFile(path, options);
|
ref_ptr<Node> model = readRefNodeFile(path, options);
|
||||||
if (!model)
|
if (!model)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -145,8 +147,11 @@ SGModelLib::loadDeferredModel(const string &path, SGPropertyNode *prop_root,
|
|||||||
opt->setPropertyNode(prop_root ? prop_root: static_propRoot.get());
|
opt->setPropertyNode(prop_root ? prop_root: static_propRoot.get());
|
||||||
opt->setModelData(data);
|
opt->setModelData(data);
|
||||||
opt->setLoadPanel(static_panelFunc);
|
opt->setLoadPanel(static_panelFunc);
|
||||||
if (SGPath(path).lower_extension() == "ac")
|
std::string lext = SGPath(path).lower_extension();
|
||||||
|
if ((lext == "ac") || (lext == "obj")) {
|
||||||
opt->setInstantiateEffects(true);
|
opt->setInstantiateEffects(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (!prop_root || prop_root->getBoolValue("/sim/rendering/cache", true))
|
if (!prop_root || prop_root->getBoolValue("/sim/rendering/cache", true))
|
||||||
opt->setObjectCacheHint(osgDB::Options::CACHE_ALL);
|
opt->setObjectCacheHint(osgDB::Options::CACHE_ALL);
|
||||||
else
|
else
|
||||||
@@ -171,8 +176,12 @@ SGModelLib::loadPagedModel(const string &path, SGPropertyNode *prop_root,
|
|||||||
opt->setPropertyNode(prop_root ? prop_root: static_propRoot.get());
|
opt->setPropertyNode(prop_root ? prop_root: static_propRoot.get());
|
||||||
opt->setModelData(data);
|
opt->setModelData(data);
|
||||||
opt->setLoadPanel(static_panelFunc);
|
opt->setLoadPanel(static_panelFunc);
|
||||||
if (SGPath(path).lower_extension() == "ac")
|
std::string lext = SGPath(path).lower_extension();
|
||||||
|
|
||||||
|
if ((lext == "ac") || (lext == "obj")) {
|
||||||
opt->setInstantiateEffects(true);
|
opt->setInstantiateEffects(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (!prop_root || prop_root->getBoolValue("/sim/rendering/cache", true))
|
if (!prop_root || prop_root->getBoolValue("/sim/rendering/cache", true))
|
||||||
opt->setObjectCacheHint(osgDB::Options::CACHE_ALL);
|
opt->setObjectCacheHint(osgDB::Options::CACHE_ALL);
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user