Comments from Till: I started the project at the end of february with a simple idea: move all 3d-model loading to the DatabasePager-thread. my first attempts looked promising, though they were a little too optimistic (or naive?). the patch has evolved a lot since. currently it does the following things: 1. revive SGModelLib, move functions for xml-model-loading there 2. replace all calls to sgLoad3dModel with calls to either SGModelLib::loadModel() or SGModelLib::loadPagedModel() almost all models will be loaded by the DatabasePager. the few exceptions are: your own plane, shared models in scenery, random objects, AIBallistic models. 3. simplify mode-loading functions (avoid passing around fg_root) 4. avoid supurious MatrixTransform nodes in loaded models 5. fix some memory leaks
61 lines
1.7 KiB
C++
61 lines
1.7 KiB
C++
// model.hxx - manage a 3D aircraft model.
|
|
// Written by David Megginson, started 2002.
|
|
//
|
|
// This file is in the Public Domain, and comes with no warranty.
|
|
|
|
#ifndef __MODEL_HXX
|
|
#define __MODEL_HXX 1
|
|
|
|
#ifndef __cplusplus
|
|
# error This library requires C++
|
|
#endif
|
|
|
|
#include <simgear/compiler.h>
|
|
|
|
#include <vector>
|
|
#include <set>
|
|
|
|
SG_USING_STD(vector);
|
|
SG_USING_STD(set);
|
|
|
|
#include <osg/Node>
|
|
#include <osg/Texture2D>
|
|
#include <osgDB/ReaderWriter>
|
|
|
|
#include <simgear/misc/sg_path.hxx>
|
|
|
|
osg::Texture2D*
|
|
SGLoadTexture2D(bool staticTexture, const std::string& path,
|
|
const osgDB::ReaderWriter::Options* options = 0,
|
|
bool wrapu = true, bool wrapv = true, int mipmaplevels = -1);
|
|
|
|
inline osg::Texture2D*
|
|
SGLoadTexture2D(const std::string& path,
|
|
const osgDB::ReaderWriter::Options* options = 0,
|
|
bool wrapu = true, bool wrapv = true, int mipmaplevels = -1)
|
|
{
|
|
return SGLoadTexture2D(true, path, options, wrapu, wrapv, mipmaplevels);
|
|
}
|
|
|
|
inline osg::Texture2D*
|
|
SGLoadTexture2D(const SGPath& path,
|
|
const osgDB::ReaderWriter::Options* options = 0,
|
|
bool wrapu = true, bool wrapv = true,
|
|
int mipmaplevels = -1)
|
|
{
|
|
return SGLoadTexture2D(true, path.str(), options, wrapu, wrapv,
|
|
mipmaplevels);
|
|
}
|
|
|
|
inline osg::Texture2D*
|
|
SGLoadTexture2D(bool staticTexture, const SGPath& path,
|
|
const osgDB::ReaderWriter::Options* options = 0,
|
|
bool wrapu = true, bool wrapv = true,
|
|
int mipmaplevels = -1)
|
|
{
|
|
return SGLoadTexture2D(staticTexture, path.str(), options, wrapu, wrapv,
|
|
mipmaplevels);
|
|
}
|
|
|
|
#endif // __MODEL_HXX
|