Merge branch 'next' of git://gitorious.org/fg/simgear into next
This commit is contained in:
@@ -439,6 +439,22 @@
|
|||||||
<Filter
|
<Filter
|
||||||
Name="Lib_sgio"
|
Name="Lib_sgio"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\simgear\io\HTTPClient.cxx"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\simgear\io\HTTPClient.hxx"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\simgear\io\HTTPRequest.cxx"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\simgear\io\HTTPRequest.hxx"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\simgear\io\iochannel.cxx"
|
RelativePath="..\..\simgear\io\iochannel.cxx"
|
||||||
>
|
>
|
||||||
@@ -527,10 +543,6 @@
|
|||||||
RelativePath="..\..\simgear\io\sg_socket_udp.hxx"
|
RelativePath="..\..\simgear\io\sg_socket_udp.hxx"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File RelativePath="..\..\simgear\io\HTTPClient.cxx" ></File>
|
|
||||||
<File RelativePath="..\..\simgear\io\HTTPClient.hxx" ></File>
|
|
||||||
<File RelativePath="..\..\simgear\io\HTTPRequest.cxx" ></File>
|
|
||||||
<File RelativePath="..\..\simgear\io\HTTPRequest.hxx" ></File>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Lib_sgmagvar"
|
Name="Lib_sgmagvar"
|
||||||
@@ -1011,10 +1023,6 @@
|
|||||||
RelativePath="..\..\simgear\props\propertyObject.hxx"
|
RelativePath="..\..\simgear\props\propertyObject.hxx"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\simgear\props\tiedpropertylist.hxx"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\simgear\props\props.cxx"
|
RelativePath="..\..\simgear\props\props.cxx"
|
||||||
>
|
>
|
||||||
@@ -1031,6 +1039,10 @@
|
|||||||
RelativePath="..\..\simgear\props\props_io.hxx"
|
RelativePath="..\..\simgear\props\props_io.hxx"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\simgear\props\tiedpropertylist.hxx"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Lib_sgmodel"
|
Name="Lib_sgmodel"
|
||||||
@@ -1147,10 +1159,6 @@
|
|||||||
RelativePath="..\..\simgear\scene\model\SGReaderWriterXML.hxx"
|
RelativePath="..\..\simgear\scene\model\SGReaderWriterXML.hxx"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\simgear\scene\model\SGReaderWriterXMLOptions.hxx"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\simgear\scene\model\SGRotateTransform.cxx"
|
RelativePath="..\..\simgear\scene\model\SGRotateTransform.cxx"
|
||||||
>
|
>
|
||||||
@@ -1395,10 +1403,6 @@
|
|||||||
RelativePath="..\..\simgear\scene\tgdb\SGReaderWriterBTG.hxx"
|
RelativePath="..\..\simgear\scene\tgdb\SGReaderWriterBTG.hxx"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\simgear\scene\tgdb\SGReaderWriterBTGOptions.hxx"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\simgear\scene\tgdb\SGVasiDrawable.cxx"
|
RelativePath="..\..\simgear\scene\tgdb\SGVasiDrawable.cxx"
|
||||||
>
|
>
|
||||||
@@ -1447,7 +1451,7 @@
|
|||||||
RelativePath="..\..\simgear\scene\tgdb\userdata.hxx"
|
RelativePath="..\..\simgear\scene\tgdb\userdata.hxx"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Lib_sgtsync"
|
Name="Lib_sgtsync"
|
||||||
>
|
>
|
||||||
@@ -1472,25 +1476,17 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\simgear\threads\SGThread.hxx"
|
RelativePath="..\..\simgear\threads\SGThread.cxx"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\simgear\threads\SGThread.cxx"
|
RelativePath="..\..\simgear\threads\SGThread.hxx"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Lib_sgstructure"
|
Name="Lib_sgstructure"
|
||||||
>
|
>
|
||||||
<File
|
|
||||||
RelativePath="..\..\simgear\structure\SGAtomic.hxx"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\simgear\structure\SGAtomic.cxx"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\simgear\structure\callback.hxx"
|
RelativePath="..\..\simgear\structure\callback.hxx"
|
||||||
>
|
>
|
||||||
@@ -1555,6 +1551,14 @@
|
|||||||
RelativePath="..\..\simgear\structure\OSGVersion.hxx"
|
RelativePath="..\..\simgear\structure\OSGVersion.hxx"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\simgear\structure\SGAtomic.cxx"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\simgear\structure\SGAtomic.hxx"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\simgear\structure\SGBinding.cxx"
|
RelativePath="..\..\simgear\structure\SGBinding.cxx"
|
||||||
>
|
>
|
||||||
@@ -1571,6 +1575,14 @@
|
|||||||
RelativePath="..\..\simgear\structure\SGExpression.hxx"
|
RelativePath="..\..\simgear\structure\SGExpression.hxx"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\simgear\structure\SGPerfMon.cxx"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\simgear\structure\SGPerfMon.hxx"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\simgear\structure\SGReferenced.hxx"
|
RelativePath="..\..\simgear\structure\SGReferenced.hxx"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -461,7 +461,7 @@ bool SGBinObject::read_bin( const string& file ) {
|
|||||||
//cout << "Total objects to read = " << nobjects << endl;
|
//cout << "Total objects to read = " << nobjects << endl;
|
||||||
|
|
||||||
if ( sgReadError() ) {
|
if ( sgReadError() ) {
|
||||||
cout << "We detected an error while reading the file header" << endl;
|
cout << "Error while reading header of file " << file << "(.gz)" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -612,7 +612,7 @@ bool SGBinObject::read_bin( const string& file ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( sgReadError() ) {
|
if ( sgReadError() ) {
|
||||||
cout << "We detected an error while reading object:" << i << endl;
|
cout << "Error while reading object:" << i << " in file " << file << "(.gz)" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -621,7 +621,7 @@ bool SGBinObject::read_bin( const string& file ) {
|
|||||||
gzclose(fp);
|
gzclose(fp);
|
||||||
|
|
||||||
if ( sgReadError() ) {
|
if ( sgReadError() ) {
|
||||||
cout << "We detected an error while reading the file." << endl;
|
cout << "Error while reading file " << file << "(.gz)" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -829,7 +829,7 @@ bool SGBinObject::write_bin_file(const SGPath& file)
|
|||||||
gzclose(fp);
|
gzclose(fp);
|
||||||
|
|
||||||
if ( sgWriteError() ) {
|
if ( sgWriteError() ) {
|
||||||
cout << "We detected an error while writing the file." << endl;
|
cout << "Error while writing file " << file.str() << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
#include <osgDB/ReadFile>
|
#include <osgDB/ReadFile>
|
||||||
#include <osgDB/Registry>
|
#include <osgDB/Registry>
|
||||||
|
|
||||||
#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/scene/tgdb/userdata.hxx>
|
#include <simgear/scene/tgdb/userdata.hxx>
|
||||||
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
||||||
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
||||||
@@ -154,7 +154,7 @@ Effect::~Effect()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void buildPass(Effect* effect, Technique* tniq, const SGPropertyNode* prop,
|
void buildPass(Effect* effect, Technique* tniq, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
Pass* pass = new Pass;
|
Pass* pass = new Pass;
|
||||||
tniq->passes.push_back(pass);
|
tniq->passes.push_back(pass);
|
||||||
@@ -203,12 +203,12 @@ osg::Vec4f getColor(const SGPropertyNode* prop)
|
|||||||
struct LightingBuilder : public PassAttributeBuilder
|
struct LightingBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
};
|
};
|
||||||
|
|
||||||
void LightingBuilder::buildAttribute(Effect* effect, Pass* pass,
|
void LightingBuilder::buildAttribute(Effect* effect, Pass* pass,
|
||||||
const SGPropertyNode* prop,
|
const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
||||||
if (!realProp)
|
if (!realProp)
|
||||||
@@ -222,7 +222,7 @@ InstallAttributeBuilder<LightingBuilder> installLighting("lighting");
|
|||||||
struct ShadeModelBuilder : public PassAttributeBuilder
|
struct ShadeModelBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
||||||
if (!realProp)
|
if (!realProp)
|
||||||
@@ -244,7 +244,7 @@ InstallAttributeBuilder<ShadeModelBuilder> installShadeModel("shade-model");
|
|||||||
struct CullFaceBuilder : PassAttributeBuilder
|
struct CullFaceBuilder : PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
||||||
if (!realProp) {
|
if (!realProp) {
|
||||||
@@ -272,7 +272,7 @@ InstallAttributeBuilder<CullFaceBuilder> installCullFace("cull-face");
|
|||||||
struct ColorMaskBuilder : PassAttributeBuilder
|
struct ColorMaskBuilder : PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
||||||
if (!realProp)
|
if (!realProp)
|
||||||
@@ -299,7 +299,7 @@ EffectPropertyMap<StateSet::RenderingHint> renderingHints(renderingHintInit);
|
|||||||
struct HintBuilder : public PassAttributeBuilder
|
struct HintBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
||||||
if (!realProp)
|
if (!realProp)
|
||||||
@@ -315,7 +315,7 @@ InstallAttributeBuilder<HintBuilder> installHint("rendering-hint");
|
|||||||
struct RenderBinBuilder : public PassAttributeBuilder
|
struct RenderBinBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
if (!isAttributeActive(effect, prop))
|
if (!isAttributeActive(effect, prop))
|
||||||
return;
|
return;
|
||||||
@@ -342,7 +342,7 @@ InstallAttributeBuilder<RenderBinBuilder> installRenderBin("render-bin");
|
|||||||
struct MaterialBuilder : public PassAttributeBuilder
|
struct MaterialBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
};
|
};
|
||||||
|
|
||||||
EffectNameValue<Material::ColorMode> colorModeInit[] =
|
EffectNameValue<Material::ColorMode> colorModeInit[] =
|
||||||
@@ -358,7 +358,7 @@ EffectPropertyMap<Material::ColorMode> colorModes(colorModeInit);
|
|||||||
|
|
||||||
void MaterialBuilder::buildAttribute(Effect* effect, Pass* pass,
|
void MaterialBuilder::buildAttribute(Effect* effect, Pass* pass,
|
||||||
const SGPropertyNode* prop,
|
const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
if (!isAttributeActive(effect, prop))
|
if (!isAttributeActive(effect, prop))
|
||||||
return;
|
return;
|
||||||
@@ -428,7 +428,7 @@ EffectPropertyMap<BlendFunc::BlendFuncMode> blendFuncModes(blendFuncModesInit);
|
|||||||
struct BlendBuilder : public PassAttributeBuilder
|
struct BlendBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
if (!isAttributeActive(effect, prop))
|
if (!isAttributeActive(effect, prop))
|
||||||
return;
|
return;
|
||||||
@@ -541,7 +541,7 @@ EffectPropertyMap<Stencil::Operation> stencilOperation(stencilOperationInit);
|
|||||||
struct StencilBuilder : public PassAttributeBuilder
|
struct StencilBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
if (!isAttributeActive(effect, prop))
|
if (!isAttributeActive(effect, prop))
|
||||||
return;
|
return;
|
||||||
@@ -619,7 +619,7 @@ alphaComparison(alphaComparisonInit);
|
|||||||
struct AlphaTestBuilder : public PassAttributeBuilder
|
struct AlphaTestBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
if (!isAttributeActive(effect, prop))
|
if (!isAttributeActive(effect, prop))
|
||||||
return;
|
return;
|
||||||
@@ -736,7 +736,7 @@ void reload_shaders()
|
|||||||
struct ShaderProgramBuilder : PassAttributeBuilder
|
struct ShaderProgramBuilder : PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -763,7 +763,7 @@ geometryOutputType(geometryOutputTypeInit);
|
|||||||
|
|
||||||
void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
|
void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
|
||||||
const SGPropertyNode* prop,
|
const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions*
|
const SGReaderWriterOptions*
|
||||||
options)
|
options)
|
||||||
{
|
{
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
@@ -899,7 +899,7 @@ ref_ptr<Uniform> colorMode[3];
|
|||||||
struct UniformBuilder :public PassAttributeBuilder
|
struct UniformBuilder :public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
if (!texture0.valid()) {
|
if (!texture0.valid()) {
|
||||||
texture0 = new Uniform(Uniform::SAMPLER_2D, "texture");
|
texture0 = new Uniform(Uniform::SAMPLER_2D, "texture");
|
||||||
@@ -1013,7 +1013,7 @@ InstallAttributeBuilder<UniformBuilder> installUniform("uniform");
|
|||||||
struct NameBuilder : public PassAttributeBuilder
|
struct NameBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
// name can't use <use>
|
// name can't use <use>
|
||||||
string name = prop->getStringValue();
|
string name = prop->getStringValue();
|
||||||
@@ -1035,7 +1035,7 @@ EffectPropertyMap<PolygonMode::Mode> polygonModeModes(polygonModeModesInit);
|
|||||||
struct PolygonModeBuilder : public PassAttributeBuilder
|
struct PolygonModeBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
if (!isAttributeActive(effect, prop))
|
if (!isAttributeActive(effect, prop))
|
||||||
return;
|
return;
|
||||||
@@ -1063,7 +1063,7 @@ InstallAttributeBuilder<PolygonModeBuilder> installPolygonMode("polygon-mode");
|
|||||||
struct PolygonOffsetBuilder : public PassAttributeBuilder
|
struct PolygonOffsetBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
if (!isAttributeActive(effect, prop))
|
if (!isAttributeActive(effect, prop))
|
||||||
return;
|
return;
|
||||||
@@ -1091,7 +1091,7 @@ InstallAttributeBuilder<PolygonOffsetBuilder> installPolygonOffset("polygon-offs
|
|||||||
struct VertexProgramTwoSideBuilder : public PassAttributeBuilder
|
struct VertexProgramTwoSideBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
||||||
if (!realProp)
|
if (!realProp)
|
||||||
@@ -1108,7 +1108,7 @@ installTwoSide("vertex-program-two-side");
|
|||||||
struct VertexProgramPointSizeBuilder : public PassAttributeBuilder
|
struct VertexProgramPointSizeBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
|
||||||
if (!realProp)
|
if (!realProp)
|
||||||
@@ -1138,7 +1138,7 @@ EffectPropertyMap<Depth::Function> depthFunction(depthFunctionInit);
|
|||||||
struct DepthBuilder : public PassAttributeBuilder
|
struct DepthBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
if (!isAttributeActive(effect, prop))
|
if (!isAttributeActive(effect, prop))
|
||||||
return;
|
return;
|
||||||
@@ -1169,7 +1169,7 @@ struct DepthBuilder : public PassAttributeBuilder
|
|||||||
InstallAttributeBuilder<DepthBuilder> installDepth("depth");
|
InstallAttributeBuilder<DepthBuilder> installDepth("depth");
|
||||||
|
|
||||||
void buildTechnique(Effect* effect, const SGPropertyNode* prop,
|
void buildTechnique(Effect* effect, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
Technique* tniq = new Technique;
|
Technique* tniq = new Technique;
|
||||||
effect->techniques.push_back(tniq);
|
effect->techniques.push_back(tniq);
|
||||||
@@ -1278,7 +1278,7 @@ bool makeParametersFromStateSet(SGPropertyNode* effectRoot, const StateSet* ss)
|
|||||||
|
|
||||||
// Walk the techniques property tree, building techniques and
|
// Walk the techniques property tree, building techniques and
|
||||||
// passes.
|
// passes.
|
||||||
bool Effect::realizeTechniques(const SGReaderWriterXMLOptions* options)
|
bool Effect::realizeTechniques(const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
if (_isRealized)
|
if (_isRealized)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace simgear
|
|||||||
{
|
{
|
||||||
class Technique;
|
class Technique;
|
||||||
class Effect;
|
class Effect;
|
||||||
class SGReaderWriterXMLOptions;
|
class SGReaderWriterOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object to be initialized at some point after an effect -- and its
|
* Object to be initialized at some point after an effect -- and its
|
||||||
@@ -102,7 +102,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Build the techniques from the effect properties.
|
* Build the techniques from the effect properties.
|
||||||
*/
|
*/
|
||||||
bool realizeTechniques(const SGReaderWriterXMLOptions* options = 0);
|
bool realizeTechniques(const SGReaderWriterOptions* options = 0);
|
||||||
/**
|
/**
|
||||||
* Updaters that should be derefed when the effect is
|
* Updaters that should be derefed when the effect is
|
||||||
* deleted. Updaters arrange to be run by listening on properties
|
* deleted. Updaters arrange to be run by listening on properties
|
||||||
@@ -157,7 +157,7 @@ protected:
|
|||||||
Cache* _cache;
|
Cache* _cache;
|
||||||
friend size_t hash_value(const Key& key);
|
friend size_t hash_value(const Key& key);
|
||||||
friend Effect* makeEffect(SGPropertyNode* prop, bool realizeTechniques,
|
friend Effect* makeEffect(SGPropertyNode* prop, bool realizeTechniques,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
bool _isRealized;
|
bool _isRealized;
|
||||||
};
|
};
|
||||||
// Automatic support for boost hash function
|
// Automatic support for boost hash function
|
||||||
@@ -166,11 +166,11 @@ size_t hash_value(const Effect::Key&);
|
|||||||
|
|
||||||
Effect* makeEffect(const std::string& name,
|
Effect* makeEffect(const std::string& name,
|
||||||
bool realizeTechniques,
|
bool realizeTechniques,
|
||||||
const SGReaderWriterXMLOptions* options = 0);
|
const SGReaderWriterOptions* options = 0);
|
||||||
|
|
||||||
Effect* makeEffect(SGPropertyNode* prop,
|
Effect* makeEffect(SGPropertyNode* prop,
|
||||||
bool realizeTechniques,
|
bool realizeTechniques,
|
||||||
const SGReaderWriterXMLOptions* options = 0);
|
const SGReaderWriterOptions* options = 0);
|
||||||
|
|
||||||
bool makeParametersFromStateSet(SGPropertyNode* paramRoot,
|
bool makeParametersFromStateSet(SGPropertyNode* paramRoot,
|
||||||
const osg::StateSet* ss);
|
const osg::StateSet* ss);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# include <simgear_config.h>
|
# include <simgear_config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/scene/tgdb/userdata.hxx>
|
#include <simgear/scene/tgdb/userdata.hxx>
|
||||||
|
|
||||||
#include <simgear/math/SGMath.hxx>
|
#include <simgear/math/SGMath.hxx>
|
||||||
@@ -43,7 +43,7 @@ const SGPropertyNode* getEffectPropertyChild(Effect* effect,
|
|||||||
}
|
}
|
||||||
|
|
||||||
string getGlobalProperty(const SGPropertyNode* prop,
|
string getGlobalProperty(const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
if (!prop)
|
if (!prop)
|
||||||
return string();
|
return string();
|
||||||
@@ -54,7 +54,7 @@ string getGlobalProperty(const SGPropertyNode* prop,
|
|||||||
SGPropertyNode_ptr propRoot;
|
SGPropertyNode_ptr propRoot;
|
||||||
if (propName[0] == '/') {
|
if (propName[0] == '/') {
|
||||||
return propName;
|
return propName;
|
||||||
} else if ((propRoot = options->getPropRoot())) {
|
} else if ((propRoot = options->getPropertyNode())) {
|
||||||
string result = propRoot->getPath();
|
string result = propRoot->getPath();
|
||||||
result.append("/");
|
result.append("/");
|
||||||
result.append(propName);
|
result.append(propName);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
#include <simgear/math/SGMath.hxx>
|
#include <simgear/math/SGMath.hxx>
|
||||||
#include <simgear/props/AtomicChangeListener.hxx>
|
#include <simgear/props/AtomicChangeListener.hxx>
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/structure/exception.hxx>
|
#include <simgear/structure/exception.hxx>
|
||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
#include <simgear/structure/Singleton.hxx>
|
#include <simgear/structure/Singleton.hxx>
|
||||||
@@ -48,7 +48,7 @@ namespace simgear
|
|||||||
{
|
{
|
||||||
class Effect;
|
class Effect;
|
||||||
class Pass;
|
class Pass;
|
||||||
class SGReaderWriterXMLOptions;
|
class SGReaderWriterOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder that returns an object, probably an OSG object.
|
* Builder that returns an object, probably an OSG object.
|
||||||
@@ -59,10 +59,10 @@ class EffectBuilder : public SGReferenced
|
|||||||
public:
|
public:
|
||||||
virtual ~EffectBuilder() {}
|
virtual ~EffectBuilder() {}
|
||||||
virtual T* build(Effect* effect, const SGPropertyNode*,
|
virtual T* build(Effect* effect, const SGPropertyNode*,
|
||||||
const SGReaderWriterXMLOptions* options) = 0;
|
const SGReaderWriterOptions* options) = 0;
|
||||||
static T* buildFromType(Effect* effect, const std::string& type,
|
static T* buildFromType(Effect* effect, const std::string& type,
|
||||||
const SGPropertyNode*props,
|
const SGPropertyNode*props,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
BuilderMap& builderMap = getMap();
|
BuilderMap& builderMap = getMap();
|
||||||
typename BuilderMap::iterator iter = builderMap.find(type);
|
typename BuilderMap::iterator iter = builderMap.find(type);
|
||||||
@@ -302,12 +302,12 @@ const SGPropertyNode* getEffectPropertyChild(Effect* effect,
|
|||||||
* mentioned node name.
|
* mentioned node name.
|
||||||
*/
|
*/
|
||||||
std::string getGlobalProperty(const SGPropertyNode* prop,
|
std::string getGlobalProperty(const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions *);
|
const SGReaderWriterOptions *);
|
||||||
|
|
||||||
template<typename NameItr>
|
template<typename NameItr>
|
||||||
std::vector<std::string>
|
std::vector<std::string>
|
||||||
getVectorProperties(const SGPropertyNode* prop,
|
getVectorProperties(const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions *options, size_t vecSize,
|
const SGReaderWriterOptions *options, size_t vecSize,
|
||||||
NameItr defaultNames)
|
NameItr defaultNames)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -318,7 +318,7 @@ getVectorProperties(const SGPropertyNode* prop,
|
|||||||
if (useProps.size() == 1) {
|
if (useProps.size() == 1) {
|
||||||
string parentName = useProps[0]->getStringValue();
|
string parentName = useProps[0]->getStringValue();
|
||||||
if (parentName.size() == 0 || parentName[0] != '/')
|
if (parentName.size() == 0 || parentName[0] != '/')
|
||||||
parentName = options->getPropRoot()->getPath() + "/" + parentName;
|
parentName = options->getPropertyNode()->getPath() + "/" + parentName;
|
||||||
if (parentName[parentName.size() - 1] != '/')
|
if (parentName[parentName.size() - 1] != '/')
|
||||||
parentName.append("/");
|
parentName.append("/");
|
||||||
NameItr itr = defaultNames;
|
NameItr itr = defaultNames;
|
||||||
@@ -357,7 +357,7 @@ public:
|
|||||||
|
|
||||||
virtual void buildAttribute(Effect* effect, Pass* pass,
|
virtual void buildAttribute(Effect* effect, Pass* pass,
|
||||||
const SGPropertyNode* prop,
|
const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
= 0;
|
= 0;
|
||||||
static PassAttributeBuilder* find(const std::string& str)
|
static PassAttributeBuilder* find(const std::string& str)
|
||||||
{
|
{
|
||||||
@@ -610,7 +610,7 @@ inline void setDynamicVariance(osg::Object* obj)
|
|||||||
template<typename OSGParamType, typename ObjType, typename F>
|
template<typename OSGParamType, typename ObjType, typename F>
|
||||||
void
|
void
|
||||||
initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
|
initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
|
||||||
const F& setter, const SGReaderWriterXMLOptions* options)
|
const F& setter, const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
const SGPropertyNode* valProp = getEffectPropertyNode(effect, prop);
|
const SGPropertyNode* valProp = getEffectPropertyNode(effect, prop);
|
||||||
if (!valProp)
|
if (!valProp)
|
||||||
@@ -631,7 +631,7 @@ template<typename OSGParamType, typename ObjType, typename SetterReturn>
|
|||||||
inline void
|
inline void
|
||||||
initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
|
initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
|
||||||
SetterReturn (ObjType::*setter)(const OSGParamType),
|
SetterReturn (ObjType::*setter)(const OSGParamType),
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
initFromParameters<OSGParamType>(effect, prop, obj,
|
initFromParameters<OSGParamType>(effect, prop, obj,
|
||||||
boost::bind(setter, _1, _2), options);
|
boost::bind(setter, _1, _2), options);
|
||||||
@@ -661,7 +661,7 @@ template<typename OSGParamType, typename ObjType, typename NameItrType,
|
|||||||
void
|
void
|
||||||
initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
|
initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
|
||||||
const F& setter,
|
const F& setter,
|
||||||
NameItrType nameItr, const SGReaderWriterXMLOptions* options)
|
NameItrType nameItr, const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
typedef typename Bridge<OSGParamType>::sg_type sg_type;
|
typedef typename Bridge<OSGParamType>::sg_type sg_type;
|
||||||
const int numComponents = props::NumComponents<sg_type>::num_components;
|
const int numComponents = props::NumComponents<sg_type>::num_components;
|
||||||
@@ -690,7 +690,7 @@ template<typename OSGParamType, typename ObjType, typename NameItrType,
|
|||||||
inline void
|
inline void
|
||||||
initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
|
initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
|
||||||
SetterReturn (ObjType::*setter)(const OSGParamType&),
|
SetterReturn (ObjType::*setter)(const OSGParamType&),
|
||||||
NameItrType nameItr, const SGReaderWriterXMLOptions* options)
|
NameItrType nameItr, const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
initFromParameters<OSGParamType>(effect, prop, obj,
|
initFromParameters<OSGParamType>(effect, prop, obj,
|
||||||
boost::bind(setter, _1, _2), nameItr,
|
boost::bind(setter, _1, _2), nameItr,
|
||||||
|
|||||||
@@ -32,12 +32,13 @@
|
|||||||
#include <osg/TextureRectangle>
|
#include <osg/TextureRectangle>
|
||||||
#include <osg/TextureCubeMap>
|
#include <osg/TextureCubeMap>
|
||||||
#include <osgDB/FileUtils>
|
#include <osgDB/FileUtils>
|
||||||
|
#include <osgDB/ReadFile>
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
#include <boost/tuple/tuple_comparison.hpp>
|
#include <boost/tuple/tuple_comparison.hpp>
|
||||||
|
|
||||||
#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
||||||
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
||||||
#include <simgear/math/SGMath.hxx>
|
#include <simgear/math/SGMath.hxx>
|
||||||
@@ -54,13 +55,13 @@ using namespace effect;
|
|||||||
|
|
||||||
TexEnvCombine* buildTexEnvCombine(Effect* effect,
|
TexEnvCombine* buildTexEnvCombine(Effect* effect,
|
||||||
const SGPropertyNode* envProp,
|
const SGPropertyNode* envProp,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
TexGen* buildTexGen(Effect* Effect, const SGPropertyNode* tgenProp);
|
TexGen* buildTexGen(Effect* Effect, const SGPropertyNode* tgenProp);
|
||||||
|
|
||||||
// Hack to force inclusion of TextureBuilder.cxx in library
|
// Hack to force inclusion of TextureBuilder.cxx in library
|
||||||
osg::Texture* TextureBuilder::buildFromType(Effect* effect, const string& type,
|
osg::Texture* TextureBuilder::buildFromType(Effect* effect, const string& type,
|
||||||
const SGPropertyNode*props,
|
const SGPropertyNode*props,
|
||||||
const SGReaderWriterXMLOptions*
|
const SGReaderWriterOptions*
|
||||||
options)
|
options)
|
||||||
{
|
{
|
||||||
return EffectBuilder<Texture>::buildFromType(effect, type, props, options);
|
return EffectBuilder<Texture>::buildFromType(effect, type, props, options);
|
||||||
@@ -102,7 +103,7 @@ TexEnv* buildTexEnv(Effect* effect, const SGPropertyNode* prop)
|
|||||||
|
|
||||||
void TextureUnitBuilder::buildAttribute(Effect* effect, Pass* pass,
|
void TextureUnitBuilder::buildAttribute(Effect* effect, Pass* pass,
|
||||||
const SGPropertyNode* prop,
|
const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
if (!isAttributeActive(effect, prop))
|
if (!isAttributeActive(effect, prop))
|
||||||
return;
|
return;
|
||||||
@@ -183,7 +184,7 @@ EffectNameValue<Texture::WrapMode> wrapModesInit[] =
|
|||||||
EffectPropertyMap<Texture::WrapMode> wrapModes(wrapModesInit);
|
EffectPropertyMap<Texture::WrapMode> wrapModes(wrapModesInit);
|
||||||
|
|
||||||
TexTuple makeTexTuple(Effect* effect, const SGPropertyNode* props,
|
TexTuple makeTexTuple(Effect* effect, const SGPropertyNode* props,
|
||||||
const SGReaderWriterXMLOptions* options,
|
const SGReaderWriterOptions* options,
|
||||||
const string& texType)
|
const string& texType)
|
||||||
{
|
{
|
||||||
Texture::FilterMode minFilter = Texture::LINEAR_MIPMAP_LINEAR;
|
Texture::FilterMode minFilter = Texture::LINEAR_MIPMAP_LINEAR;
|
||||||
@@ -234,14 +235,14 @@ TexTuple makeTexTuple(Effect* effect, const SGPropertyNode* props,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setAttrs(const TexTuple& attrs, Texture* tex,
|
void setAttrs(const TexTuple& attrs, Texture* tex,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
const string& imageName = attrs.get<0>();
|
const string& imageName = attrs.get<0>();
|
||||||
if (imageName.empty()) {
|
if (imageName.empty()) {
|
||||||
throw BuilderException("no image file");
|
throw BuilderException("no image file");
|
||||||
} else {
|
} else {
|
||||||
osgDB::ReaderWriter::ReadResult result
|
osgDB::ReaderWriter::ReadResult result;
|
||||||
= osgDB::Registry::instance()->readImage(imageName, options);
|
result = osgDB::readImageFile(imageName, options);
|
||||||
if (result.success()) {
|
if (result.success()) {
|
||||||
osg::ref_ptr<osg::Image> image = result.getImage();
|
osg::ref_ptr<osg::Image> image = result.getImage();
|
||||||
image = computeMipmap( image.get(), attrs.get<7>() );
|
image = computeMipmap( image.get(), attrs.get<7>() );
|
||||||
@@ -275,7 +276,7 @@ class TexBuilder : public TextureBuilder
|
|||||||
public:
|
public:
|
||||||
TexBuilder(const string& texType) : _type(texType) {}
|
TexBuilder(const string& texType) : _type(texType) {}
|
||||||
Texture* build(Effect* effect, const SGPropertyNode*,
|
Texture* build(Effect* effect, const SGPropertyNode*,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
protected:
|
protected:
|
||||||
typedef map<TexTuple, ref_ptr<T> > TexMap;
|
typedef map<TexTuple, ref_ptr<T> > TexMap;
|
||||||
TexMap texMap;
|
TexMap texMap;
|
||||||
@@ -284,7 +285,7 @@ protected:
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Texture* TexBuilder<T>::build(Effect* effect, const SGPropertyNode* props,
|
Texture* TexBuilder<T>::build(Effect* effect, const SGPropertyNode* props,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
TexTuple attrs = makeTexTuple(effect, props, options, _type);
|
TexTuple attrs = makeTexTuple(effect, props, options, _type);
|
||||||
typename TexMap::iterator itr = texMap.find(attrs);
|
typename TexMap::iterator itr = texMap.find(attrs);
|
||||||
@@ -308,11 +309,11 @@ class WhiteTextureBuilder : public TextureBuilder
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Texture* build(Effect* effect, const SGPropertyNode*,
|
Texture* build(Effect* effect, const SGPropertyNode*,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
};
|
};
|
||||||
|
|
||||||
Texture* WhiteTextureBuilder::build(Effect* effect, const SGPropertyNode*,
|
Texture* WhiteTextureBuilder::build(Effect* effect, const SGPropertyNode*,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
return StateAttributeFactory::instance()->getWhiteTexture();
|
return StateAttributeFactory::instance()->getWhiteTexture();
|
||||||
}
|
}
|
||||||
@@ -326,11 +327,11 @@ class TransparentTextureBuilder : public TextureBuilder
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Texture* build(Effect* effect, const SGPropertyNode*,
|
Texture* build(Effect* effect, const SGPropertyNode*,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
};
|
};
|
||||||
|
|
||||||
Texture* TransparentTextureBuilder::build(Effect* effect, const SGPropertyNode*,
|
Texture* TransparentTextureBuilder::build(Effect* effect, const SGPropertyNode*,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
return StateAttributeFactory::instance()->getTransparentTexture();
|
return StateAttributeFactory::instance()->getTransparentTexture();
|
||||||
}
|
}
|
||||||
@@ -390,14 +391,14 @@ class NoiseBuilder : public TextureBuilder
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Texture* build(Effect* effect, const SGPropertyNode*,
|
Texture* build(Effect* effect, const SGPropertyNode*,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
protected:
|
protected:
|
||||||
typedef map<int, ref_ptr<Texture3D> > NoiseMap;
|
typedef map<int, ref_ptr<Texture3D> > NoiseMap;
|
||||||
NoiseMap _noises;
|
NoiseMap _noises;
|
||||||
};
|
};
|
||||||
|
|
||||||
Texture* NoiseBuilder::build(Effect* effect, const SGPropertyNode* props,
|
Texture* NoiseBuilder::build(Effect* effect, const SGPropertyNode* props,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
int texSize = 64;
|
int texSize = 64;
|
||||||
const SGPropertyNode* sizeProp = getEffectPropertyChild(effect, props,
|
const SGPropertyNode* sizeProp = getEffectPropertyChild(effect, props,
|
||||||
@@ -458,7 +459,7 @@ class CubeMapBuilder : public TextureBuilder
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Texture* build(Effect* effect, const SGPropertyNode*,
|
Texture* build(Effect* effect, const SGPropertyNode*,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
protected:
|
protected:
|
||||||
typedef map<CubeMapTuple, ref_ptr<TextureCubeMap> > CubeMap;
|
typedef map<CubeMapTuple, ref_ptr<TextureCubeMap> > CubeMap;
|
||||||
typedef map<string, ref_ptr<TextureCubeMap> > CrossCubeMap;
|
typedef map<string, ref_ptr<TextureCubeMap> > CrossCubeMap;
|
||||||
@@ -481,7 +482,7 @@ void copySubImage(const osg::Image* srcImage, int src_s, int src_t, int width, i
|
|||||||
|
|
||||||
|
|
||||||
Texture* CubeMapBuilder::build(Effect* effect, const SGPropertyNode* props,
|
Texture* CubeMapBuilder::build(Effect* effect, const SGPropertyNode* props,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
// First check that there is a <images> tag
|
// First check that there is a <images> tag
|
||||||
const SGPropertyNode* texturesProp = getEffectPropertyChild(effect, props, "images");
|
const SGPropertyNode* texturesProp = getEffectPropertyChild(effect, props, "images");
|
||||||
@@ -511,33 +512,33 @@ Texture* CubeMapBuilder::build(Effect* effect, const SGPropertyNode* props,
|
|||||||
cubeTexture->setWrap(osg::Texture3D::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
|
cubeTexture->setWrap(osg::Texture3D::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
|
||||||
cubeTexture->setWrap(osg::Texture3D::WRAP_R, osg::Texture::CLAMP_TO_EDGE);
|
cubeTexture->setWrap(osg::Texture3D::WRAP_R, osg::Texture::CLAMP_TO_EDGE);
|
||||||
|
|
||||||
osgDB::ReaderWriter::ReadResult result =
|
osgDB::ReaderWriter::ReadResult result;
|
||||||
osgDB::Registry::instance()->readImage(_tuple.get<0>(), options);
|
result = osgDB::readImageFile(_tuple.get<0>(), options);
|
||||||
if(result.success()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
cubeTexture->setImage(TextureCubeMap::POSITIVE_X, image);
|
cubeTexture->setImage(TextureCubeMap::POSITIVE_X, image);
|
||||||
}
|
}
|
||||||
result = osgDB::Registry::instance()->readImage(_tuple.get<1>(), options);
|
result = osgDB::readImageFile(_tuple.get<1>(), options);
|
||||||
if(result.success()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
cubeTexture->setImage(TextureCubeMap::NEGATIVE_X, image);
|
cubeTexture->setImage(TextureCubeMap::NEGATIVE_X, image);
|
||||||
}
|
}
|
||||||
result = osgDB::Registry::instance()->readImage(_tuple.get<2>(), options);
|
result = osgDB::readImageFile(_tuple.get<2>(), options);
|
||||||
if(result.success()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
cubeTexture->setImage(TextureCubeMap::POSITIVE_Y, image);
|
cubeTexture->setImage(TextureCubeMap::POSITIVE_Y, image);
|
||||||
}
|
}
|
||||||
result = osgDB::Registry::instance()->readImage(_tuple.get<3>(), options);
|
result = osgDB::readImageFile(_tuple.get<3>(), options);
|
||||||
if(result.success()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
cubeTexture->setImage(TextureCubeMap::NEGATIVE_Y, image);
|
cubeTexture->setImage(TextureCubeMap::NEGATIVE_Y, image);
|
||||||
}
|
}
|
||||||
result = osgDB::Registry::instance()->readImage(_tuple.get<4>(), options);
|
result = osgDB::readImageFile(_tuple.get<4>(), options);
|
||||||
if(result.success()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
cubeTexture->setImage(TextureCubeMap::POSITIVE_Z, image);
|
cubeTexture->setImage(TextureCubeMap::POSITIVE_Z, image);
|
||||||
}
|
}
|
||||||
result = osgDB::Registry::instance()->readImage(_tuple.get<5>(), options);
|
result = osgDB::readImageFile(_tuple.get<5>(), options);
|
||||||
if(result.success()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
cubeTexture->setImage(TextureCubeMap::NEGATIVE_Z, image);
|
cubeTexture->setImage(TextureCubeMap::NEGATIVE_Z, image);
|
||||||
@@ -560,8 +561,8 @@ Texture* CubeMapBuilder::build(Effect* effect, const SGPropertyNode* props,
|
|||||||
if (itr != _crossmaps.end())
|
if (itr != _crossmaps.end())
|
||||||
return itr->second.get();
|
return itr->second.get();
|
||||||
|
|
||||||
osgDB::ReaderWriter::ReadResult result =
|
osgDB::ReaderWriter::ReadResult result;
|
||||||
osgDB::Registry::instance()->readImage(texname, options);
|
result = osgDB::readImageFile(texname, options);
|
||||||
if(result.success()) {
|
if(result.success()) {
|
||||||
osg::Image* image = result.getImage();
|
osg::Image* image = result.getImage();
|
||||||
image->flipVertical(); // Seems like the image coordinates are somewhat funny, flip to get better ones
|
image->flipVertical(); // Seems like the image coordinates are somewhat funny, flip to get better ones
|
||||||
@@ -690,7 +691,7 @@ EffectNameValue<TexEnvCombine::OperandParam> opParamInit[] =
|
|||||||
EffectPropertyMap<TexEnvCombine::OperandParam> operandParams(opParamInit);
|
EffectPropertyMap<TexEnvCombine::OperandParam> operandParams(opParamInit);
|
||||||
|
|
||||||
TexEnvCombine* buildTexEnvCombine(Effect* effect, const SGPropertyNode* envProp,
|
TexEnvCombine* buildTexEnvCombine(Effect* effect, const SGPropertyNode* envProp,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
if (!isAttributeActive(effect, envProp))
|
if (!isAttributeActive(effect, envProp))
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ public:
|
|||||||
// Hack to force inclusion of TextureBuilder.cxx in library
|
// Hack to force inclusion of TextureBuilder.cxx in library
|
||||||
static osg::Texture* buildFromType(Effect* effect, const std::string& type,
|
static osg::Texture* buildFromType(Effect* effect, const std::string& type,
|
||||||
const SGPropertyNode*props,
|
const SGPropertyNode*props,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TextureUnitBuilder : public PassAttributeBuilder
|
struct TextureUnitBuilder : public PassAttributeBuilder
|
||||||
{
|
{
|
||||||
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
#include <osgDB/Registry>
|
#include <osgDB/Registry>
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/props/props_io.hxx>
|
#include <simgear/props/props_io.hxx>
|
||||||
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
||||||
#include <simgear/scene/util/SplicingVisitor.hxx>
|
#include <simgear/scene/util/SplicingVisitor.hxx>
|
||||||
@@ -117,7 +117,7 @@ void mergePropertyTrees(SGPropertyNode* resultNode,
|
|||||||
|
|
||||||
Effect* makeEffect(const string& name,
|
Effect* makeEffect(const string& name,
|
||||||
bool realizeTechniques,
|
bool realizeTechniques,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(effectMutex);
|
OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(effectMutex);
|
||||||
@@ -160,7 +160,7 @@ Effect* makeEffect(const string& name,
|
|||||||
|
|
||||||
Effect* makeEffect(SGPropertyNode* prop,
|
Effect* makeEffect(SGPropertyNode* prop,
|
||||||
bool realizeTechniques,
|
bool realizeTechniques,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
// Give default names to techniques and passes
|
// Give default names to techniques and passes
|
||||||
vector<SGPropertyNode_ptr> techniques = prop->getChildren("technique");
|
vector<SGPropertyNode_ptr> techniques = prop->getChildren("technique");
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
#include <simgear/misc/sgstream.hxx>
|
#include <simgear/misc/sgstream.hxx>
|
||||||
#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/props/props_io.hxx>
|
#include <simgear/props/props_io.hxx>
|
||||||
#include <simgear/scene/model/model.hxx>
|
#include <simgear/scene/model/model.hxx>
|
||||||
#include <simgear/scene/util/RenderConstants.hxx>
|
#include <simgear/scene/util/RenderConstants.hxx>
|
||||||
@@ -69,13 +69,13 @@ using namespace simgear;
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SGMaterial::_internal_state::_internal_state(Effect *e, bool l,
|
SGMaterial::_internal_state::_internal_state(Effect *e, bool l,
|
||||||
const SGReaderWriterXMLOptions* o)
|
const SGReaderWriterOptions* o)
|
||||||
: effect(e), effect_realized(l), options(o)
|
: effect(e), effect_realized(l), options(o)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SGMaterial::_internal_state::_internal_state(Effect *e, const string &t, bool l,
|
SGMaterial::_internal_state::_internal_state(Effect *e, const string &t, bool l,
|
||||||
const SGReaderWriterXMLOptions* o)
|
const SGReaderWriterOptions* o)
|
||||||
: effect(e), effect_realized(l), options(o)
|
: effect(e), effect_realized(l), options(o)
|
||||||
{
|
{
|
||||||
texture_paths.push_back(std::make_pair(t,0));
|
texture_paths.push_back(std::make_pair(t,0));
|
||||||
@@ -86,7 +86,7 @@ void SGMaterial::_internal_state::add_texture(const std::string &t, int i)
|
|||||||
texture_paths.push_back(std::make_pair(t,i));
|
texture_paths.push_back(std::make_pair(t,i));
|
||||||
}
|
}
|
||||||
|
|
||||||
SGMaterial::SGMaterial( const SGReaderWriterXMLOptions* options,
|
SGMaterial::SGMaterial( const SGReaderWriterOptions* options,
|
||||||
const SGPropertyNode *props )
|
const SGPropertyNode *props )
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
@@ -97,9 +97,9 @@ SGMaterial::SGMaterial( const SGReaderWriterXMLOptions* options,
|
|||||||
SGMaterial::SGMaterial( const osgDB::ReaderWriter::Options* options,
|
SGMaterial::SGMaterial( const osgDB::ReaderWriter::Options* options,
|
||||||
const SGPropertyNode *props )
|
const SGPropertyNode *props )
|
||||||
{
|
{
|
||||||
osg::ref_ptr<const SGReaderWriterXMLOptions> sgOptions;
|
osg::ref_ptr<const SGReaderWriterOptions> sgOptions;
|
||||||
if (options)
|
if (options)
|
||||||
sgOptions = new SGReaderWriterXMLOptions(*options);
|
sgOptions = new SGReaderWriterOptions(*options);
|
||||||
init();
|
init();
|
||||||
read_properties( sgOptions.get(), props );
|
read_properties( sgOptions.get(), props );
|
||||||
buildEffectProperties(sgOptions.get());
|
buildEffectProperties(sgOptions.get());
|
||||||
@@ -115,7 +115,7 @@ SGMaterial::~SGMaterial (void)
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void
|
void
|
||||||
SGMaterial::read_properties(const SGReaderWriterXMLOptions* options,
|
SGMaterial::read_properties(const SGReaderWriterOptions* options,
|
||||||
const SGPropertyNode *props)
|
const SGPropertyNode *props)
|
||||||
{
|
{
|
||||||
// Gather the path(s) to the texture(s)
|
// Gather the path(s) to the texture(s)
|
||||||
@@ -296,12 +296,12 @@ Effect* SGMaterial::get_effect(int n)
|
|||||||
return _status[i].effect.get();
|
return _status[i].effect.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SGMaterial::buildEffectProperties(const SGReaderWriterXMLOptions* options)
|
void SGMaterial::buildEffectProperties(const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
using namespace osg;
|
using namespace osg;
|
||||||
ref_ptr<SGReaderWriterXMLOptions> xmlOptions;
|
ref_ptr<SGReaderWriterOptions> xmlOptions;
|
||||||
if (options)
|
if (options)
|
||||||
xmlOptions = new SGReaderWriterXMLOptions(*options);
|
xmlOptions = new SGReaderWriterOptions(*options);
|
||||||
ref_ptr<SGMaterialUserData> user = new SGMaterialUserData(this);
|
ref_ptr<SGMaterialUserData> user = new SGMaterialUserData(this);
|
||||||
SGPropertyNode_ptr propRoot = new SGPropertyNode();
|
SGPropertyNode_ptr propRoot = new SGPropertyNode();
|
||||||
makeChild(propRoot, "inherits-from")->setStringValue(effect);
|
makeChild(propRoot, "inherits-from")->setStringValue(effect);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace osg
|
|||||||
class StateSet;
|
class StateSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
||||||
@@ -87,7 +87,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
SGMaterial( const osgDB::ReaderWriter::Options*, const SGPropertyNode *props);
|
SGMaterial( const osgDB::ReaderWriter::Options*, const SGPropertyNode *props);
|
||||||
|
|
||||||
SGMaterial(const simgear::SGReaderWriterXMLOptions*,
|
SGMaterial(const simgear::SGReaderWriterOptions*,
|
||||||
const SGPropertyNode *props);
|
const SGPropertyNode *props);
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
@@ -273,14 +273,14 @@ protected:
|
|||||||
|
|
||||||
struct _internal_state {
|
struct _internal_state {
|
||||||
_internal_state(simgear::Effect *e, bool l,
|
_internal_state(simgear::Effect *e, bool l,
|
||||||
const simgear::SGReaderWriterXMLOptions *o);
|
const simgear::SGReaderWriterOptions *o);
|
||||||
_internal_state(simgear::Effect *e, const std::string &t, bool l,
|
_internal_state(simgear::Effect *e, const std::string &t, bool l,
|
||||||
const simgear::SGReaderWriterXMLOptions *o);
|
const simgear::SGReaderWriterOptions *o);
|
||||||
void add_texture(const std::string &t, int i);
|
void add_texture(const std::string &t, int i);
|
||||||
osg::ref_ptr<simgear::Effect> effect;
|
osg::ref_ptr<simgear::Effect> effect;
|
||||||
std::vector<std::pair<std::string,int> > texture_paths;
|
std::vector<std::pair<std::string,int> > texture_paths;
|
||||||
bool effect_realized;
|
bool effect_realized;
|
||||||
osg::ref_ptr<const simgear::SGReaderWriterXMLOptions> options;
|
osg::ref_ptr<const simgear::SGReaderWriterOptions> options;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -366,9 +366,9 @@ private:
|
|||||||
// Internal constructors and methods.
|
// Internal constructors and methods.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void read_properties(const simgear::SGReaderWriterXMLOptions* options,
|
void read_properties(const simgear::SGReaderWriterOptions* options,
|
||||||
const SGPropertyNode *props);
|
const SGPropertyNode *props);
|
||||||
void buildEffectProperties(const simgear::SGReaderWriterXMLOptions* options);
|
void buildEffectProperties(const simgear::SGReaderWriterOptions* options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ EffectNameValue<MipMapFunction> mipmapFunctionsInit[] =
|
|||||||
EffectPropertyMap<MipMapFunction> mipmapFunctions(mipmapFunctionsInit);
|
EffectPropertyMap<MipMapFunction> mipmapFunctions(mipmapFunctionsInit);
|
||||||
|
|
||||||
MipMapTuple makeMipMapTuple(Effect* effect, const SGPropertyNode* props,
|
MipMapTuple makeMipMapTuple(Effect* effect, const SGPropertyNode* props,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
const SGPropertyNode* pMipmapR
|
const SGPropertyNode* pMipmapR
|
||||||
= getEffectPropertyChild(effect, props, "function-r");
|
= getEffectPropertyChild(effect, props, "function-r");
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace osg {
|
|||||||
namespace simgear
|
namespace simgear
|
||||||
{
|
{
|
||||||
class Effect;
|
class Effect;
|
||||||
class SGReaderWriterXMLOptions;
|
class SGReaderWriterOptions;
|
||||||
|
|
||||||
namespace effect {
|
namespace effect {
|
||||||
enum MipMapFunction {
|
enum MipMapFunction {
|
||||||
@@ -43,7 +43,7 @@ enum MipMapFunction {
|
|||||||
typedef boost::tuple<MipMapFunction, MipMapFunction, MipMapFunction, MipMapFunction> MipMapTuple;
|
typedef boost::tuple<MipMapFunction, MipMapFunction, MipMapFunction, MipMapFunction> MipMapTuple;
|
||||||
|
|
||||||
MipMapTuple makeMipMapTuple(Effect* effect, const SGPropertyNode* props,
|
MipMapTuple makeMipMapTuple(Effect* effect, const SGPropertyNode* props,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
osg::Image* computeMipmap( osg::Image* image, MipMapTuple attrs );
|
osg::Image* computeMipmap( osg::Image* image, MipMapTuple attrs );
|
||||||
} }
|
} }
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ set(HEADERS
|
|||||||
SGMaterialAnimation.hxx
|
SGMaterialAnimation.hxx
|
||||||
SGOffsetTransform.hxx
|
SGOffsetTransform.hxx
|
||||||
SGReaderWriterXML.hxx
|
SGReaderWriterXML.hxx
|
||||||
SGReaderWriterXMLOptions.hxx
|
|
||||||
SGRotateTransform.hxx
|
SGRotateTransform.hxx
|
||||||
SGScaleTransform.hxx
|
SGScaleTransform.hxx
|
||||||
SGText.hxx
|
SGText.hxx
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#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>
|
||||||
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/scene/util/NodeAndDrawableVisitor.hxx>
|
#include <simgear/scene/util/NodeAndDrawableVisitor.hxx>
|
||||||
|
|
||||||
#include <simgear/structure/exception.hxx>
|
#include <simgear/structure/exception.hxx>
|
||||||
@@ -56,7 +57,6 @@
|
|||||||
|
|
||||||
#include "BoundingVolumeBuildVisitor.hxx"
|
#include "BoundingVolumeBuildVisitor.hxx"
|
||||||
#include "model.hxx"
|
#include "model.hxx"
|
||||||
#include "SGReaderWriterXMLOptions.hxx"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace osg;
|
using namespace osg;
|
||||||
@@ -410,8 +410,8 @@ struct ACOptimizePolicy : public OptimizeModelPolicy {
|
|||||||
&& group->getNumChildren() == 1)
|
&& group->getNumChildren() == 1)
|
||||||
optimized = static_cast<Node*>(group->getChild(0));
|
optimized = static_cast<Node*>(group->getChild(0));
|
||||||
}
|
}
|
||||||
const SGReaderWriterXMLOptions* sgopt
|
const SGReaderWriterOptions* sgopt
|
||||||
= dynamic_cast<const SGReaderWriterXMLOptions*>(opt);
|
= dynamic_cast<const SGReaderWriterOptions*>(opt);
|
||||||
if (sgopt && sgopt->getInstantiateEffects())
|
if (sgopt && sgopt->getInstantiateEffects())
|
||||||
optimized = instantiateEffects(optimized.get(), sgopt);
|
optimized = instantiateEffects(optimized.get(), sgopt);
|
||||||
return optimized.release();
|
return optimized.release();
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <osg/Geode>
|
#include <osg/Geode>
|
||||||
#include <osg/MatrixTransform>
|
#include <osg/MatrixTransform>
|
||||||
|
#include <osgDB/ReadFile>
|
||||||
#include <osgDB/WriteFile>
|
#include <osgDB/WriteFile>
|
||||||
#include <osgDB/Registry>
|
#include <osgDB/Registry>
|
||||||
#include <osg/Switch>
|
#include <osg/Switch>
|
||||||
@@ -40,10 +41,10 @@
|
|||||||
#include <simgear/props/props_io.hxx>
|
#include <simgear/props/props_io.hxx>
|
||||||
#include <simgear/props/condition.hxx>
|
#include <simgear/props/condition.hxx>
|
||||||
#include <simgear/scene/util/SGNodeMasks.hxx>
|
#include <simgear/scene/util/SGNodeMasks.hxx>
|
||||||
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
|
|
||||||
#include "modellib.hxx"
|
#include "modellib.hxx"
|
||||||
#include "SGReaderWriterXML.hxx"
|
#include "SGReaderWriterXML.hxx"
|
||||||
#include "SGReaderWriterXMLOptions.hxx"
|
|
||||||
|
|
||||||
#include "animation.hxx"
|
#include "animation.hxx"
|
||||||
#include "particles.hxx"
|
#include "particles.hxx"
|
||||||
@@ -207,8 +208,8 @@ sgLoad3DModel_internal(const SGPath& path,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SGReaderWriterXMLOptions* xmlOptions;
|
const SGReaderWriterOptions* xmlOptions;
|
||||||
xmlOptions = dynamic_cast<const SGReaderWriterXMLOptions*>(options_);
|
xmlOptions = dynamic_cast<const SGReaderWriterOptions*>(options_);
|
||||||
|
|
||||||
SGSharedPtr<SGPropertyNode> prop_root;
|
SGSharedPtr<SGPropertyNode> prop_root;
|
||||||
osg::Node *(*load_panel)(SGPropertyNode *)=0;
|
osg::Node *(*load_panel)(SGPropertyNode *)=0;
|
||||||
@@ -218,7 +219,7 @@ sgLoad3DModel_internal(const SGPath& path,
|
|||||||
SGPath modelDir(modelpath.dir());
|
SGPath modelDir(modelpath.dir());
|
||||||
|
|
||||||
if (xmlOptions) {
|
if (xmlOptions) {
|
||||||
prop_root = xmlOptions->getPropRoot();
|
prop_root = xmlOptions->getPropertyNode();
|
||||||
load_panel = xmlOptions->getLoadPanel();
|
load_panel = xmlOptions->getLoadPanel();
|
||||||
data = xmlOptions->getModelData();
|
data = xmlOptions->getModelData();
|
||||||
}
|
}
|
||||||
@@ -268,9 +269,9 @@ sgLoad3DModel_internal(const SGPath& path,
|
|||||||
// model without wrapper
|
// model without wrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<SGReaderWriterXMLOptions> options
|
osg::ref_ptr<SGReaderWriterOptions> options
|
||||||
= new SGReaderWriterXMLOptions(*options_);
|
= new SGReaderWriterOptions(*options_);
|
||||||
options->setPropRoot(prop_root);
|
options->setPropertyNode(prop_root);
|
||||||
options->setLoadPanel(load_panel);
|
options->setLoadPanel(load_panel);
|
||||||
|
|
||||||
// Assume that textures are in
|
// Assume that textures are in
|
||||||
@@ -280,9 +281,8 @@ sgLoad3DModel_internal(const SGPath& path,
|
|||||||
texturepath = texturepath.dir();
|
texturepath = texturepath.dir();
|
||||||
|
|
||||||
options->setDatabasePath(texturepath.str());
|
options->setDatabasePath(texturepath.str());
|
||||||
osgDB::ReaderWriter::ReadResult modelResult
|
osgDB::ReaderWriter::ReadResult modelResult;
|
||||||
= osgDB::Registry::instance()->readNode(modelpath.str(),
|
modelResult = osgDB::readNodeFile(modelpath.str(), options.get());
|
||||||
options.get());
|
|
||||||
if (!modelResult.validNode())
|
if (!modelResult.validNode())
|
||||||
throw sg_io_exception("Failed to load 3D model:" + modelResult.message(),
|
throw sg_io_exception("Failed to load 3D model:" + modelResult.message(),
|
||||||
modelpath.str());
|
modelpath.str());
|
||||||
@@ -353,9 +353,9 @@ sgLoad3DModel_internal(const SGPath& path,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<SGReaderWriterXMLOptions> options;
|
osg::ref_ptr<SGReaderWriterOptions> options;
|
||||||
options = new SGReaderWriterXMLOptions(*options_);
|
options = new SGReaderWriterOptions(*options_);
|
||||||
options->setPropRoot(prop_root);
|
options->setPropertyNode(prop_root);
|
||||||
options->setLoadPanel(load_panel);
|
options->setLoadPanel(load_panel);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,110 +0,0 @@
|
|||||||
// Copyright (C) 2007 Tim Moore timoore@redhat.com
|
|
||||||
// Copyright (C) 2008 Till Busch buti@bux.at
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2 of the
|
|
||||||
// License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful, but
|
|
||||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
// General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
//
|
|
||||||
#ifndef SGREADERWRITERXMLOPTIONS_HXX
|
|
||||||
#define SGREADERWRITERXMLOPTIONS_HXX 1
|
|
||||||
|
|
||||||
#include <osgDB/Registry>
|
|
||||||
#include <simgear/scene/model/modellib.hxx>
|
|
||||||
#include <simgear/props/props.hxx>
|
|
||||||
|
|
||||||
class SGPropertyNode;
|
|
||||||
|
|
||||||
namespace simgear
|
|
||||||
{
|
|
||||||
class SGModelData;
|
|
||||||
|
|
||||||
class SGReaderWriterXMLOptions : public osgDB::ReaderWriter::Options
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef osg::Node *(*panel_func)(SGPropertyNode *);
|
|
||||||
META_Object(simgear, SGReaderWriterXMLOptions);
|
|
||||||
|
|
||||||
SGReaderWriterXMLOptions():
|
|
||||||
osgDB::ReaderWriter::Options(),
|
|
||||||
_prop_root(0),
|
|
||||||
_load_panel(0),
|
|
||||||
_model_data(0),
|
|
||||||
_instantiateEffects(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
SGReaderWriterXMLOptions(const std::string& str):
|
|
||||||
osgDB::ReaderWriter::Options(str),
|
|
||||||
_prop_root(0),
|
|
||||||
_load_panel(0),
|
|
||||||
_model_data(0),
|
|
||||||
_instantiateEffects(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
SGReaderWriterXMLOptions(const SGReaderWriterXMLOptions& options,
|
|
||||||
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
|
||||||
osgDB::ReaderWriter::Options(options, copyop),
|
|
||||||
_prop_root(options._prop_root),
|
|
||||||
_load_panel(options._load_panel),
|
|
||||||
_model_data(options._model_data),
|
|
||||||
_instantiateEffects(options._instantiateEffects)
|
|
||||||
{}
|
|
||||||
|
|
||||||
SGReaderWriterXMLOptions(const osgDB::ReaderWriter::Options& options,
|
|
||||||
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
|
||||||
osgDB::ReaderWriter::Options(options, copyop),
|
|
||||||
_prop_root(0),
|
|
||||||
_load_panel(0),
|
|
||||||
_model_data(0),
|
|
||||||
_instantiateEffects(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
SGPropertyNode *getPropRoot() const {
|
|
||||||
return _prop_root;
|
|
||||||
}
|
|
||||||
panel_func getLoadPanel() const {
|
|
||||||
return _load_panel;
|
|
||||||
}
|
|
||||||
SGModelData *getModelData() const {
|
|
||||||
return _model_data.get();
|
|
||||||
}
|
|
||||||
bool getInstantiateEffects() const
|
|
||||||
{
|
|
||||||
return _instantiateEffects;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPropRoot(SGPropertyNode *p) {
|
|
||||||
_prop_root=p;
|
|
||||||
}
|
|
||||||
void setLoadPanel(panel_func pf) {
|
|
||||||
_load_panel=pf;
|
|
||||||
}
|
|
||||||
void setModelData(SGModelData *d) {
|
|
||||||
_model_data=d;
|
|
||||||
}
|
|
||||||
void setInstantiateEffects(bool doit)
|
|
||||||
{
|
|
||||||
_instantiateEffects = doit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual ~SGReaderWriterXMLOptions() {}
|
|
||||||
|
|
||||||
SGPropertyNode_ptr _prop_root;
|
|
||||||
osg::Node *(*_load_panel)(SGPropertyNode *);
|
|
||||||
osg::ref_ptr<SGModelData> _model_data;
|
|
||||||
bool _instantiateEffects;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <simgear/scene/util/SGSceneUserData.hxx>
|
#include <simgear/scene/util/SGSceneUserData.hxx>
|
||||||
#include <simgear/scene/util/CopyOp.hxx>
|
#include <simgear/scene/util/CopyOp.hxx>
|
||||||
#include <simgear/scene/util/SplicingVisitor.hxx>
|
#include <simgear/scene/util/SplicingVisitor.hxx>
|
||||||
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
|
|
||||||
#include <simgear/structure/exception.hxx>
|
#include <simgear/structure/exception.hxx>
|
||||||
#include <simgear/structure/Singleton.hxx>
|
#include <simgear/structure/Singleton.hxx>
|
||||||
@@ -33,7 +33,6 @@
|
|||||||
#include <simgear/props/props_io.hxx>
|
#include <simgear/props/props_io.hxx>
|
||||||
#include <simgear/props/condition.hxx>
|
#include <simgear/props/condition.hxx>
|
||||||
|
|
||||||
#include "SGReaderWriterXMLOptions.hxx"
|
|
||||||
#include "model.hxx"
|
#include "model.hxx"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
@@ -210,7 +209,7 @@ class MakeEffectVisitor : public SplicingVisitor
|
|||||||
public:
|
public:
|
||||||
typedef std::map<string, SGPropertyNode_ptr> EffectMap;
|
typedef std::map<string, SGPropertyNode_ptr> EffectMap;
|
||||||
using SplicingVisitor::apply;
|
using SplicingVisitor::apply;
|
||||||
MakeEffectVisitor(const SGReaderWriterXMLOptions* options = 0)
|
MakeEffectVisitor(const SGReaderWriterOptions* options = 0)
|
||||||
: _options(options)
|
: _options(options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -226,7 +225,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
EffectMap _effectMap;
|
EffectMap _effectMap;
|
||||||
SGPropertyNode_ptr _currentEffectParent;
|
SGPropertyNode_ptr _currentEffectParent;
|
||||||
osg::ref_ptr<const SGReaderWriterXMLOptions> _options;
|
osg::ref_ptr<const SGReaderWriterOptions> _options;
|
||||||
};
|
};
|
||||||
|
|
||||||
void MakeEffectVisitor::apply(osg::Group& node)
|
void MakeEffectVisitor::apply(osg::Group& node)
|
||||||
@@ -309,7 +308,7 @@ protected:
|
|||||||
|
|
||||||
ref_ptr<Node> instantiateEffects(osg::Node* modelGroup,
|
ref_ptr<Node> instantiateEffects(osg::Node* modelGroup,
|
||||||
PropertyList& effectProps,
|
PropertyList& effectProps,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
SGPropertyNode_ptr defaultEffectPropRoot;
|
SGPropertyNode_ptr defaultEffectPropRoot;
|
||||||
MakeEffectVisitor visitor(options);
|
MakeEffectVisitor visitor(options);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
{
|
{
|
||||||
class SGReaderWriterXMLOptions;
|
class SGReaderWriterOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Texture2D*
|
osg::Texture2D*
|
||||||
@@ -102,7 +102,7 @@ public:
|
|||||||
osg::ref_ptr<osg::Node>
|
osg::ref_ptr<osg::Node>
|
||||||
instantiateEffects(osg::Node* model,
|
instantiateEffects(osg::Node* model,
|
||||||
PropertyList& effectProps,
|
PropertyList& effectProps,
|
||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterOptions* options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform an OSG subgraph by substituting the Effects and
|
* Transform an OSG subgraph by substituting the Effects and
|
||||||
@@ -115,7 +115,7 @@ instantiateEffects(osg::Node* model,
|
|||||||
|
|
||||||
inline osg::ref_ptr<osg::Node>
|
inline osg::ref_ptr<osg::Node>
|
||||||
instantiateEffects(osg::Node* model,
|
instantiateEffects(osg::Node* model,
|
||||||
const SGReaderWriterXMLOptions* options)
|
const SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
PropertyList effectProps;
|
PropertyList effectProps;
|
||||||
return instantiateEffects(model, effectProps, options);
|
return instantiateEffects(model, effectProps, options);
|
||||||
|
|||||||
@@ -32,10 +32,10 @@
|
|||||||
#include <simgear/props/props_io.hxx>
|
#include <simgear/props/props_io.hxx>
|
||||||
#include <simgear/scene/model/model.hxx>
|
#include <simgear/scene/model/model.hxx>
|
||||||
#include <simgear/scene/model/ModelRegistry.hxx>
|
#include <simgear/scene/model/ModelRegistry.hxx>
|
||||||
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/misc/ResourceManager.hxx>
|
#include <simgear/misc/ResourceManager.hxx>
|
||||||
|
|
||||||
#include "SGReaderWriterXML.hxx"
|
#include "SGReaderWriterXML.hxx"
|
||||||
#include "SGReaderWriterXMLOptions.hxx"
|
|
||||||
|
|
||||||
#include "modellib.hxx"
|
#include "modellib.hxx"
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ SGModelLib::~SGModelLib()
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
osg::Node* loadFile(const string& path, SGReaderWriterXMLOptions* options)
|
osg::Node* loadFile(const string& path, SGReaderWriterOptions* options)
|
||||||
{
|
{
|
||||||
using namespace osg;
|
using namespace osg;
|
||||||
using namespace osgDB;
|
using namespace osgDB;
|
||||||
@@ -107,8 +107,8 @@ SGModelLib::loadModel(const string &path,
|
|||||||
SGModelData *data,
|
SGModelData *data,
|
||||||
bool load2DPanels)
|
bool load2DPanels)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<SGReaderWriterXMLOptions> opt = new SGReaderWriterXMLOptions(*(osgDB::Registry::instance()->getOptions()));
|
osg::ref_ptr<SGReaderWriterOptions> opt = new SGReaderWriterOptions(*(osgDB::Registry::instance()->getOptions()));
|
||||||
opt->setPropRoot(prop_root ? prop_root: static_propRoot.get());
|
opt->setPropertyNode(prop_root ? prop_root: static_propRoot.get());
|
||||||
opt->setModelData(data);
|
opt->setModelData(data);
|
||||||
|
|
||||||
if (load2DPanels) {
|
if (load2DPanels) {
|
||||||
@@ -123,17 +123,17 @@ SGModelLib::loadModel(const string &path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
osg::Node*
|
osg::Node*
|
||||||
SGModelLib::loadDeferedModel(const string &path, SGPropertyNode *prop_root,
|
SGModelLib::loadDeferredModel(const string &path, SGPropertyNode *prop_root,
|
||||||
SGModelData *data)
|
SGModelData *data)
|
||||||
{
|
{
|
||||||
osg::ProxyNode* proxyNode = new osg::ProxyNode;
|
osg::ProxyNode* proxyNode = new osg::ProxyNode;
|
||||||
proxyNode->setLoadingExternalReferenceMode(osg::ProxyNode::DEFER_LOADING_TO_DATABASE_PAGER);
|
proxyNode->setLoadingExternalReferenceMode(osg::ProxyNode::DEFER_LOADING_TO_DATABASE_PAGER);
|
||||||
proxyNode->setFileName(0, path);
|
proxyNode->setFileName(0, path);
|
||||||
|
|
||||||
osg::ref_ptr<SGReaderWriterXMLOptions> opt
|
osg::ref_ptr<SGReaderWriterOptions> opt
|
||||||
= new SGReaderWriterXMLOptions(*(osgDB::Registry::instance()
|
= new SGReaderWriterOptions(*(osgDB::Registry::instance()
|
||||||
->getOptions()));
|
->getOptions()));
|
||||||
opt->setPropRoot(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")
|
if (SGPath(path).lower_extension() == "ac")
|
||||||
@@ -156,10 +156,10 @@ SGModelLib::loadPagedModel(const string &path, SGPropertyNode *prop_root,
|
|||||||
plod->setFileName(0, path);
|
plod->setFileName(0, path);
|
||||||
plod->setRange(0, 0.0, 50.0*SG_NM_TO_METER);
|
plod->setRange(0, 0.0, 50.0*SG_NM_TO_METER);
|
||||||
|
|
||||||
osg::ref_ptr<SGReaderWriterXMLOptions> opt
|
osg::ref_ptr<SGReaderWriterOptions> opt
|
||||||
= new SGReaderWriterXMLOptions(*(osgDB::Registry::instance()
|
= new SGReaderWriterOptions(*(osgDB::Registry::instance()
|
||||||
->getOptions()));
|
->getOptions()));
|
||||||
opt->setPropRoot(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")
|
if (SGPath(path).lower_extension() == "ac")
|
||||||
|
|||||||
@@ -58,9 +58,9 @@ public:
|
|||||||
// This function initially just returns a proxy node that refers to
|
// This function initially just returns a proxy node that refers to
|
||||||
// the model file. Once the viewer steps onto that node the
|
// the model file. Once the viewer steps onto that node the
|
||||||
// model will be loaded.
|
// model will be loaded.
|
||||||
static osg::Node* loadDeferedModel(const std::string &path,
|
static osg::Node* loadDeferredModel(const std::string &path,
|
||||||
SGPropertyNode *prop_root = NULL,
|
SGPropertyNode *prop_root = NULL,
|
||||||
SGModelData *data=0);
|
SGModelData *data=0);
|
||||||
// Load a 3D model (any format) through the DatabasePager.
|
// Load a 3D model (any format) through the DatabasePager.
|
||||||
// This function initially just returns a PagedLOD node that refers to
|
// This function initially just returns a PagedLOD node that refers to
|
||||||
// the model file. Once the viewer steps onto that node the
|
// the model file. Once the viewer steps onto that node the
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
#include <simgear/misc/PathOptions.hxx>
|
#include <simgear/misc/PathOptions.hxx>
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/scene/model/model.hxx>
|
#include <simgear/scene/model/model.hxx>
|
||||||
#include <simgear/scene/model/SGReaderWriterXMLOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
||||||
#include <simgear/scene/util/SGUpdateVisitor.hxx>
|
#include <simgear/scene/util/SGUpdateVisitor.hxx>
|
||||||
|
|
||||||
@@ -112,8 +112,8 @@ SGNewCloud::SGNewCloud(const SGPath &texture_root, const SGPropertyNode *cld_def
|
|||||||
texture);
|
texture);
|
||||||
ref_ptr<osgDB::ReaderWriter::Options> options
|
ref_ptr<osgDB::ReaderWriter::Options> options
|
||||||
= makeOptionsFromPath(texture_root);
|
= makeOptionsFromPath(texture_root);
|
||||||
ref_ptr<SGReaderWriterXMLOptions> sgOptions
|
ref_ptr<SGReaderWriterOptions> sgOptions
|
||||||
= new SGReaderWriterXMLOptions(*options.get());
|
= new SGReaderWriterOptions(*options.get());
|
||||||
if ((effect = makeEffect(pcloudEffect, true, sgOptions.get())))
|
if ((effect = makeEffect(pcloudEffect, true, sgOptions.get())))
|
||||||
effectMap.insert(EffectMap::value_type(texture, effect));
|
effectMap.insert(EffectMap::value_type(texture, effect));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -53,14 +53,11 @@
|
|||||||
#include <simgear/scene/sky/oursun.hxx>
|
#include <simgear/scene/sky/oursun.hxx>
|
||||||
#include <simgear/scene/sky/stars.hxx>
|
#include <simgear/scene/sky/stars.hxx>
|
||||||
|
|
||||||
using std::vector;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SGVec3d pos;
|
SGVec3d pos;
|
||||||
SGGeod pos_geod;
|
SGGeod pos_geod;
|
||||||
SGQuatd ori;
|
SGQuatd ori;
|
||||||
double spin;
|
double spin;
|
||||||
double gst;
|
double gst;
|
||||||
double sun_dist;
|
double sun_dist;
|
||||||
double moon_dist;
|
double moon_dist;
|
||||||
@@ -69,8 +66,8 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SGVec3f sky_color;
|
SGVec3f sky_color;
|
||||||
SGVec3f adj_sky_color;
|
SGVec3f adj_sky_color;
|
||||||
SGVec3f fog_color;
|
SGVec3f fog_color;
|
||||||
SGVec3f cloud_color;
|
SGVec3f cloud_color;
|
||||||
double sun_angle, moon_angle;
|
double sun_angle, moon_angle;
|
||||||
} SGSkyColor;
|
} SGSkyColor;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ set(HEADERS
|
|||||||
SGModelBin.hxx
|
SGModelBin.hxx
|
||||||
SGOceanTile.hxx
|
SGOceanTile.hxx
|
||||||
SGReaderWriterBTG.hxx
|
SGReaderWriterBTG.hxx
|
||||||
SGReaderWriterBTGOptions.hxx
|
|
||||||
SGTexturedTriangleBin.hxx
|
SGTexturedTriangleBin.hxx
|
||||||
SGTriangleBin.hxx
|
SGTriangleBin.hxx
|
||||||
SGVasiDrawable.hxx
|
SGVasiDrawable.hxx
|
||||||
|
|||||||
@@ -15,12 +15,17 @@
|
|||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <simgear_config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <osgDB/FileNameUtils>
|
#include <osgDB/FileNameUtils>
|
||||||
#include <osgDB/Registry>
|
#include <osgDB/Registry>
|
||||||
|
|
||||||
#include <simgear/scene/model/ModelRegistry.hxx>
|
#include <simgear/scene/model/ModelRegistry.hxx>
|
||||||
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
|
#include <simgear/math/SGMath.hxx>
|
||||||
|
|
||||||
#include "SGReaderWriterBTGOptions.hxx"
|
|
||||||
#include "SGReaderWriterBTG.hxx"
|
#include "SGReaderWriterBTG.hxx"
|
||||||
#include "obj.hxx"
|
#include "obj.hxx"
|
||||||
|
|
||||||
@@ -29,6 +34,7 @@ using namespace simgear;
|
|||||||
SGReaderWriterBTG::SGReaderWriterBTG()
|
SGReaderWriterBTG::SGReaderWriterBTG()
|
||||||
{
|
{
|
||||||
supportsExtension("btg", "SimGear btg database format");
|
supportsExtension("btg", "SimGear btg database format");
|
||||||
|
// supportsExtension("btg.gz", "SimGear btg database format");
|
||||||
}
|
}
|
||||||
|
|
||||||
SGReaderWriterBTG::~SGReaderWriterBTG()
|
SGReaderWriterBTG::~SGReaderWriterBTG()
|
||||||
@@ -43,8 +49,8 @@ const char* SGReaderWriterBTG::className() const
|
|||||||
bool
|
bool
|
||||||
SGReaderWriterBTG::acceptsExtension(const std::string& extension) const
|
SGReaderWriterBTG::acceptsExtension(const std::string& extension) const
|
||||||
{
|
{
|
||||||
std::string lowercase_ext = osgDB::convertToLowerCase(extension);
|
// trick the osg extensions match algorithm to accept btg.gz files.
|
||||||
if (lowercase_ext == "gz")
|
if (osgDB::convertToLowerCase(extension) == "gz")
|
||||||
return true;
|
return true;
|
||||||
return osgDB::ReaderWriter::acceptsExtension(extension);
|
return osgDB::ReaderWriter::acceptsExtension(extension);
|
||||||
}
|
}
|
||||||
@@ -54,18 +60,24 @@ SGReaderWriterBTG::readNode(const std::string& fileName,
|
|||||||
const osgDB::ReaderWriter::Options* options) const
|
const osgDB::ReaderWriter::Options* options) const
|
||||||
{
|
{
|
||||||
SGMaterialLib* matlib = 0;
|
SGMaterialLib* matlib = 0;
|
||||||
bool calcLights = false;
|
|
||||||
bool useRandomObjects = false;
|
bool useRandomObjects = false;
|
||||||
bool useRandomVegetation = false;
|
bool useRandomVegetation = false;
|
||||||
const SGReaderWriterBTGOptions* btgOptions
|
const SGReaderWriterOptions* sgOptions;
|
||||||
= dynamic_cast<const SGReaderWriterBTGOptions*>(options);
|
sgOptions = dynamic_cast<const SGReaderWriterOptions*>(options);
|
||||||
if (btgOptions) {
|
if (sgOptions) {
|
||||||
matlib = btgOptions->getMatlib();
|
matlib = sgOptions->getMaterialLib();
|
||||||
calcLights = btgOptions->getCalcLights();
|
SGPropertyNode* propertyNode = sgOptions->getPropertyNode().get();
|
||||||
useRandomObjects = btgOptions->getUseRandomObjects();
|
if (propertyNode) {
|
||||||
useRandomVegetation = btgOptions->getUseRandomVegetation();
|
useRandomObjects
|
||||||
|
= propertyNode->getBoolValue("/sim/rendering/random-objects",
|
||||||
|
useRandomObjects);
|
||||||
|
useRandomVegetation
|
||||||
|
= propertyNode->getBoolValue("/sim/rendering/random-vegetation",
|
||||||
|
useRandomVegetation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
osg::Node* result = SGLoadBTG(fileName, matlib, calcLights,
|
|
||||||
|
osg::Node* result = SGLoadBTG(fileName, matlib,
|
||||||
useRandomObjects,
|
useRandomObjects,
|
||||||
useRandomVegetation);
|
useRandomVegetation);
|
||||||
if (result)
|
if (result)
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
// Copyright (C) 2007 Tim Moore timoore@redhat.com
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2 of the
|
|
||||||
// License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful, but
|
|
||||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
// General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
//
|
|
||||||
#ifndef SGREADERWRITERBTGOPTIONS_HXX
|
|
||||||
#define SGREADERWRITERBTGOPTIONS_HXX
|
|
||||||
|
|
||||||
#include <osgDB/ReaderWriter>
|
|
||||||
#include <simgear/scene/tgdb/obj.hxx>
|
|
||||||
class SGReaderWriterBTGOptions : public osgDB::ReaderWriter::Options {
|
|
||||||
public:
|
|
||||||
META_Object(simgear,SGReaderWriterBTGOptions);
|
|
||||||
SGReaderWriterBTGOptions(const std::string& str = std::string()) :
|
|
||||||
osgDB::ReaderWriter::Options(str),
|
|
||||||
_matlib(0), _calcLights(true),
|
|
||||||
_useRandomObjects(false),
|
|
||||||
_useRandomVegetation(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
SGReaderWriterBTGOptions(const SGReaderWriterBTGOptions& options,
|
|
||||||
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
|
||||||
osgDB::ReaderWriter::Options(options, copyop),
|
|
||||||
_matlib(options._matlib), _calcLights(options._calcLights),
|
|
||||||
_useRandomObjects(options._useRandomObjects),
|
|
||||||
_useRandomVegetation(options._useRandomVegetation)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
SGMaterialLib* getMatlib() const { return _matlib; }
|
|
||||||
void setMatlib (SGMaterialLib* matlib) { _matlib = matlib; }
|
|
||||||
bool getCalcLights() const { return _calcLights; }
|
|
||||||
void setCalcLights(bool calcLights) { _calcLights = calcLights; }
|
|
||||||
bool getUseRandomObjects() const { return _useRandomObjects; }
|
|
||||||
bool getUseRandomVegetation() const { return _useRandomVegetation; }
|
|
||||||
void setUseRandomObjects(bool useRandomObjects)
|
|
||||||
{
|
|
||||||
_useRandomObjects = useRandomObjects;
|
|
||||||
}
|
|
||||||
void setUseRandomVegetation(bool useRandomVegetation)
|
|
||||||
{
|
|
||||||
_useRandomVegetation = useRandomVegetation;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual ~SGReaderWriterBTGOptions() {}
|
|
||||||
SGMaterialLib* _matlib;
|
|
||||||
bool _calcLights;
|
|
||||||
bool _useRandomObjects;
|
|
||||||
bool _useRandomVegetation;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
#include <simgear/scene/model/ModelRegistry.hxx>
|
#include <simgear/scene/model/ModelRegistry.hxx>
|
||||||
#include <simgear/scene/tgdb/apt_signs.hxx>
|
#include <simgear/scene/tgdb/apt_signs.hxx>
|
||||||
#include <simgear/scene/tgdb/obj.hxx>
|
#include <simgear/scene/tgdb/obj.hxx>
|
||||||
#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
|
|
||||||
#include "ReaderWriterSTG.hxx"
|
#include "ReaderWriterSTG.hxx"
|
||||||
#include "TileEntry.hxx"
|
#include "TileEntry.hxx"
|
||||||
@@ -288,27 +288,26 @@ TileEntry::loadTileByFileName(const string& fileName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SGReaderWriterBTGOptions* btgOpt;
|
const SGReaderWriterOptions* btgOpt;
|
||||||
btgOpt = dynamic_cast<const SGReaderWriterBTGOptions *>(options);
|
btgOpt = dynamic_cast<const SGReaderWriterOptions*>(options);
|
||||||
osg::ref_ptr<SGReaderWriterBTGOptions> opt;
|
osg::ref_ptr<SGReaderWriterOptions> opt;
|
||||||
if (btgOpt)
|
if (btgOpt)
|
||||||
opt = new SGReaderWriterBTGOptions(*btgOpt);
|
opt = new SGReaderWriterOptions(*btgOpt);
|
||||||
else
|
else
|
||||||
opt = new SGReaderWriterBTGOptions;
|
opt = new SGReaderWriterOptions;
|
||||||
|
|
||||||
// obj_load() will generate ground lighting for us ...
|
// obj_load() will generate ground lighting for us ...
|
||||||
osg::Group* new_tile = new osg::Group;
|
osg::Group* new_tile = new osg::Group;
|
||||||
|
|
||||||
if (found_tile_base) {
|
if (found_tile_base) {
|
||||||
// load tile if found ...
|
// load tile if found ...
|
||||||
opt->setCalcLights(true);
|
|
||||||
obj_load( object_base.str(), new_tile, true, opt.get());
|
obj_load( object_base.str(), new_tile, true, opt.get());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// ... or generate an ocean tile on the fly
|
// ... or generate an ocean tile on the fly
|
||||||
SG_LOG(SG_TERRAIN, SG_INFO, " Generating ocean tile");
|
SG_LOG(SG_TERRAIN, SG_INFO, " Generating ocean tile");
|
||||||
if ( !SGGenTile( path_list[0], tile_bucket,
|
if ( !SGGenTile( path_list[0], tile_bucket,
|
||||||
opt->getMatlib(), new_tile ) ) {
|
opt->getMaterialLib(), new_tile ) ) {
|
||||||
SG_LOG( SG_TERRAIN, SG_ALERT,
|
SG_LOG( SG_TERRAIN, SG_ALERT,
|
||||||
"Warning: failed to generate ocean tile!" );
|
"Warning: failed to generate ocean tile!" );
|
||||||
}
|
}
|
||||||
@@ -322,7 +321,6 @@ TileEntry::loadTileByFileName(const string& fileName,
|
|||||||
if (obj->type == OBJECT) {
|
if (obj->type == OBJECT) {
|
||||||
SGPath custom_path = obj->path;
|
SGPath custom_path = obj->path;
|
||||||
custom_path.append( obj->name );
|
custom_path.append( obj->name );
|
||||||
opt->setCalcLights(true);
|
|
||||||
obj_load( custom_path.str(), new_tile, false, opt.get());
|
obj_load( custom_path.str(), new_tile, false, opt.get());
|
||||||
|
|
||||||
} else if (obj->type == OBJECT_SHARED || obj->type == OBJECT_STATIC) {
|
} else if (obj->type == OBJECT_SHARED || obj->type == OBJECT_STATIC) {
|
||||||
@@ -366,9 +364,9 @@ TileEntry::loadTileByFileName(const string& fileName,
|
|||||||
|
|
||||||
osg::Node *custom_obj = 0;
|
osg::Node *custom_obj = 0;
|
||||||
if (obj->type == OBJECT_SIGN)
|
if (obj->type == OBJECT_SIGN)
|
||||||
custom_obj = SGMakeSign(opt->getMatlib(), custom_path.str(), obj->name);
|
custom_obj = SGMakeSign(opt->getMaterialLib(), custom_path.str(), obj->name);
|
||||||
else
|
else
|
||||||
custom_obj = SGMakeRunwaySign(opt->getMatlib(), custom_path.str(), obj->name);
|
custom_obj = SGMakeRunwaySign(opt->getMaterialLib(), custom_path.str(), obj->name);
|
||||||
|
|
||||||
// wire the pieces together
|
// wire the pieces together
|
||||||
if ( custom_obj != NULL ) {
|
if ( custom_obj != NULL ) {
|
||||||
|
|||||||
+30
-32
@@ -579,7 +579,7 @@ typedef QuadTreeBuilder<osg::LOD*, ModelLOD, MakeQuadLeaf, AddModelLOD,
|
|||||||
GetModelLODCoord> RandomObjectsQuadtree;
|
GetModelLODCoord> RandomObjectsQuadtree;
|
||||||
|
|
||||||
osg::Node*
|
osg::Node*
|
||||||
SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool use_random_objects, bool use_random_vegetation)
|
SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool use_random_objects, bool use_random_vegetation)
|
||||||
{
|
{
|
||||||
SGBinObject tile;
|
SGBinObject tile;
|
||||||
if (!tile.read_bin(path))
|
if (!tile.read_bin(path))
|
||||||
@@ -669,38 +669,36 @@ SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (calc_lights) {
|
// FIXME: ugly, has a side effect
|
||||||
// FIXME: ugly, has a side effect
|
if (matlib)
|
||||||
if (matlib)
|
tileGeometryBin.computeRandomSurfaceLights(matlib);
|
||||||
tileGeometryBin.computeRandomSurfaceLights(matlib);
|
|
||||||
|
|
||||||
if (tileGeometryBin.tileLights.getNumLights() > 0
|
if (tileGeometryBin.tileLights.getNumLights() > 0
|
||||||
|| tileGeometryBin.randomTileLights.getNumLights() > 0) {
|
|| tileGeometryBin.randomTileLights.getNumLights() > 0) {
|
||||||
osg::Group* groundLights0 = new osg::Group;
|
osg::Group* groundLights0 = new osg::Group;
|
||||||
groundLights0->setStateSet(lightManager->getGroundLightStateSet());
|
groundLights0->setStateSet(lightManager->getGroundLightStateSet());
|
||||||
groundLights0->setNodeMask(GROUNDLIGHTS0_BIT);
|
groundLights0->setNodeMask(GROUNDLIGHTS0_BIT);
|
||||||
osg::Geode* geode = new osg::Geode;
|
osg::Geode* geode = new osg::Geode;
|
||||||
geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.tileLights));
|
geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.tileLights));
|
||||||
geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights, 4, -0.3f));
|
geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights, 4, -0.3f));
|
||||||
groundLights0->addChild(geode);
|
groundLights0->addChild(geode);
|
||||||
lightGroup->addChild(groundLights0);
|
lightGroup->addChild(groundLights0);
|
||||||
}
|
}
|
||||||
if (tileGeometryBin.randomTileLights.getNumLights() > 0) {
|
if (tileGeometryBin.randomTileLights.getNumLights() > 0) {
|
||||||
osg::Group* groundLights1 = new osg::Group;
|
osg::Group* groundLights1 = new osg::Group;
|
||||||
groundLights1->setStateSet(lightManager->getGroundLightStateSet());
|
groundLights1->setStateSet(lightManager->getGroundLightStateSet());
|
||||||
groundLights1->setNodeMask(GROUNDLIGHTS1_BIT);
|
groundLights1->setNodeMask(GROUNDLIGHTS1_BIT);
|
||||||
osg::Group* groundLights2 = new osg::Group;
|
osg::Group* groundLights2 = new osg::Group;
|
||||||
groundLights2->setStateSet(lightManager->getGroundLightStateSet());
|
groundLights2->setStateSet(lightManager->getGroundLightStateSet());
|
||||||
groundLights2->setNodeMask(GROUNDLIGHTS2_BIT);
|
groundLights2->setNodeMask(GROUNDLIGHTS2_BIT);
|
||||||
osg::Geode* geode = new osg::Geode;
|
osg::Geode* geode = new osg::Geode;
|
||||||
geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights, 2, -0.15f));
|
geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights, 2, -0.15f));
|
||||||
groundLights1->addChild(geode);
|
groundLights1->addChild(geode);
|
||||||
lightGroup->addChild(groundLights1);
|
lightGroup->addChild(groundLights1);
|
||||||
geode = new osg::Geode;
|
geode = new osg::Geode;
|
||||||
geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights));
|
geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights));
|
||||||
groundLights2->addChild(geode);
|
groundLights2->addChild(geode);
|
||||||
lightGroup->addChild(groundLights2);
|
lightGroup->addChild(groundLights2);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tileGeometryBin.vasiLights.empty()) {
|
if (!tileGeometryBin.vasiLights.empty()) {
|
||||||
|
|||||||
@@ -56,6 +56,6 @@ inline bool SGGenTile( const std::string&, const SGBucket& b,
|
|||||||
}
|
}
|
||||||
|
|
||||||
osg::Node*
|
osg::Node*
|
||||||
SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool use_random_objects, bool use_random_vegetation);
|
SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool use_random_objects, bool use_random_vegetation);
|
||||||
|
|
||||||
#endif // _SG_OBJ_HXX
|
#endif // _SG_OBJ_HXX
|
||||||
|
|||||||
@@ -407,8 +407,21 @@ buildVasi(const SGDirectionalLightBin& lights, const SGVec3f& up,
|
|||||||
drawable->addLight(lights.getLight(3).position,
|
drawable->addLight(lights.getLight(3).position,
|
||||||
lights.getLight(3).normal, up, 2.5);
|
lights.getLight(3).normal, up, 2.5);
|
||||||
return drawable;
|
return drawable;
|
||||||
}
|
|
||||||
else if (count == 12) {
|
} else if (count == 6) {
|
||||||
|
SGVasiDrawable* drawable = new SGVasiDrawable(red, white);
|
||||||
|
|
||||||
|
// probably vasi, first 3 are downwind bar (2.5 deg)
|
||||||
|
for (unsigned i = 0; i < 3; ++i)
|
||||||
|
drawable->addLight(lights.getLight(i).position,
|
||||||
|
lights.getLight(i).normal, up, 2.5);
|
||||||
|
// last 3 are upwind bar (3.0 deg)
|
||||||
|
for (unsigned i = 3; i < 6; ++i)
|
||||||
|
drawable->addLight(lights.getLight(i).position,
|
||||||
|
lights.getLight(i).normal, up, 3.0);
|
||||||
|
return drawable;
|
||||||
|
|
||||||
|
} else if (count == 12) {
|
||||||
SGVasiDrawable* drawable = new SGVasiDrawable(red, white);
|
SGVasiDrawable* drawable = new SGVasiDrawable(red, white);
|
||||||
|
|
||||||
// probably vasi, first 6 are downwind bar (2.5 deg)
|
// probably vasi, first 6 are downwind bar (2.5 deg)
|
||||||
@@ -419,8 +432,8 @@ buildVasi(const SGDirectionalLightBin& lights, const SGVec3f& up,
|
|||||||
for (unsigned i = 6; i < 12; ++i)
|
for (unsigned i = 6; i < 12; ++i)
|
||||||
drawable->addLight(lights.getLight(i).position,
|
drawable->addLight(lights.getLight(i).position,
|
||||||
lights.getLight(i).normal, up, 3.0);
|
lights.getLight(i).normal, up, 3.0);
|
||||||
|
|
||||||
return drawable;
|
return drawable;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// fail safe
|
// fail safe
|
||||||
SG_LOG(SG_TERRAIN, SG_ALERT,
|
SG_LOG(SG_TERRAIN, SG_ALERT,
|
||||||
|
|||||||
@@ -59,9 +59,7 @@
|
|||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
#include <simgear/misc/strutils.hxx>
|
#include <simgear/misc/strutils.hxx>
|
||||||
#include <simgear/threads/SGQueue.hxx>
|
#include <simgear/threads/SGQueue.hxx>
|
||||||
#include <simgear/scene/tgdb/TileCache.hxx>
|
|
||||||
#include <simgear/misc/sg_dir.hxx>
|
#include <simgear/misc/sg_dir.hxx>
|
||||||
#include <OpenThreads/Thread>
|
|
||||||
|
|
||||||
#ifdef HAVE_SVN_CLIENT_H
|
#ifdef HAVE_SVN_CLIENT_H
|
||||||
# ifdef HAVE_LIBSVN_CLIENT_1
|
# ifdef HAVE_LIBSVN_CLIENT_1
|
||||||
@@ -141,7 +139,7 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// SGTerraSync::SvnThread /////////////////////////////////////////////////////
|
// SGTerraSync::SvnThread /////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
class SGTerraSync::SvnThread : public OpenThreads::Thread
|
class SGTerraSync::SvnThread : public SGThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SvnThread();
|
SvnThread();
|
||||||
@@ -162,6 +160,7 @@ public:
|
|||||||
void setLocalDir(string dir) { _local_dir = stripPath(dir);}
|
void setLocalDir(string dir) { _local_dir = stripPath(dir);}
|
||||||
string getLocalDir() { return _local_dir;}
|
string getLocalDir() { return _local_dir;}
|
||||||
void setUseSvn(bool use_svn) { _use_svn = use_svn;}
|
void setUseSvn(bool use_svn) { _use_svn = use_svn;}
|
||||||
|
void setAllowedErrorCount(int errors) {_allowed_errors = errors;}
|
||||||
|
|
||||||
#ifdef HAVE_SVN_CLIENT_H
|
#ifdef HAVE_SVN_CLIENT_H
|
||||||
void setUseBuiltin(bool built_in) { _use_built_in = built_in;}
|
void setUseBuiltin(bool built_in) { _use_built_in = built_in;}
|
||||||
@@ -175,6 +174,7 @@ public:
|
|||||||
volatile int _updated_tile_count;
|
volatile int _updated_tile_count;
|
||||||
volatile int _success_count;
|
volatile int _success_count;
|
||||||
volatile int _consecutive_errors;
|
volatile int _consecutive_errors;
|
||||||
|
volatile int _allowed_errors;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void run();
|
virtual void run();
|
||||||
@@ -222,6 +222,7 @@ SGTerraSync::SvnThread::SvnThread() :
|
|||||||
_updated_tile_count(0),
|
_updated_tile_count(0),
|
||||||
_success_count(0),
|
_success_count(0),
|
||||||
_consecutive_errors(0),
|
_consecutive_errors(0),
|
||||||
|
_allowed_errors(6),
|
||||||
#ifdef HAVE_SVN_CLIENT_H
|
#ifdef HAVE_SVN_CLIENT_H
|
||||||
_use_built_in(true),
|
_use_built_in(true),
|
||||||
#endif
|
#endif
|
||||||
@@ -344,7 +345,7 @@ bool SGTerraSync::SvnThread::start()
|
|||||||
<< status
|
<< status
|
||||||
<< "Directory: '" << _local_dir << "'.");
|
<< "Directory: '" << _local_dir << "'.");
|
||||||
|
|
||||||
OpenThreads::Thread::start();
|
SGThread::start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,7 +557,8 @@ void SGTerraSync::SvnThread::run()
|
|||||||
_busy = false;
|
_busy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_consecutive_errors >= 5)
|
if ((_allowed_errors >= 0)&&
|
||||||
|
(_consecutive_errors >= _allowed_errors))
|
||||||
{
|
{
|
||||||
_stalled = true;
|
_stalled = true;
|
||||||
_stop = true;
|
_stop = true;
|
||||||
@@ -670,7 +672,8 @@ SGTerraSync::SGTerraSync(SGPropertyNode_ptr root) :
|
|||||||
last_lat(NOWHERE),
|
last_lat(NOWHERE),
|
||||||
last_lon(NOWHERE),
|
last_lon(NOWHERE),
|
||||||
_terraRoot(root->getNode("/sim/terrasync",true)),
|
_terraRoot(root->getNode("/sim/terrasync",true)),
|
||||||
_tile_cache(NULL)
|
_refreshCb(NULL),
|
||||||
|
_userCbData(NULL)
|
||||||
{
|
{
|
||||||
_svnThread = new SvnThread();
|
_svnThread = new SvnThread();
|
||||||
}
|
}
|
||||||
@@ -684,7 +687,7 @@ SGTerraSync::~SGTerraSync()
|
|||||||
|
|
||||||
void SGTerraSync::init()
|
void SGTerraSync::init()
|
||||||
{
|
{
|
||||||
_refresh_display = _terraRoot->getNode("refresh-display",true);
|
_refreshDisplay = _terraRoot->getNode("refresh-display",true);
|
||||||
_terraRoot->getNode("built-in-svn-available",true)->setBoolValue(svn_built_in_available);
|
_terraRoot->getNode("built-in-svn-available",true)->setBoolValue(svn_built_in_available);
|
||||||
reinit();
|
reinit();
|
||||||
}
|
}
|
||||||
@@ -703,6 +706,7 @@ void SGTerraSync::reinit()
|
|||||||
_svnThread->setSvnServer(_terraRoot->getStringValue("svn-server",""));
|
_svnThread->setSvnServer(_terraRoot->getStringValue("svn-server",""));
|
||||||
_svnThread->setRsyncServer(_terraRoot->getStringValue("rsync-server",""));
|
_svnThread->setRsyncServer(_terraRoot->getStringValue("rsync-server",""));
|
||||||
_svnThread->setLocalDir(_terraRoot->getStringValue("scenery-dir",""));
|
_svnThread->setLocalDir(_terraRoot->getStringValue("scenery-dir",""));
|
||||||
|
_svnThread->setAllowedErrorCount(_terraRoot->getIntValue("max-errors",5));
|
||||||
|
|
||||||
#ifdef HAVE_SVN_CLIENT_H
|
#ifdef HAVE_SVN_CLIENT_H
|
||||||
_svnThread->setUseBuiltin(_terraRoot->getBoolValue("use-built-in-svn",true));
|
_svnThread->setUseBuiltin(_terraRoot->getBoolValue("use-built-in-svn",true));
|
||||||
@@ -727,7 +731,7 @@ void SGTerraSync::reinit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_stalled_node->setBoolValue(_svnThread->_stalled);
|
_stalledNode->setBoolValue(_svnThread->_stalled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SGTerraSync::bind()
|
void SGTerraSync::bind()
|
||||||
@@ -745,9 +749,9 @@ void SGTerraSync::bind()
|
|||||||
_terraRoot->getNode("use-built-in-svn", true)->setAttribute(SGPropertyNode::USERARCHIVE,false);
|
_terraRoot->getNode("use-built-in-svn", true)->setAttribute(SGPropertyNode::USERARCHIVE,false);
|
||||||
_terraRoot->getNode("use-svn", true)->setAttribute(SGPropertyNode::USERARCHIVE,false);
|
_terraRoot->getNode("use-svn", true)->setAttribute(SGPropertyNode::USERARCHIVE,false);
|
||||||
// stalled is used as a signal handler (to connect listeners triggering GUI pop-ups)
|
// stalled is used as a signal handler (to connect listeners triggering GUI pop-ups)
|
||||||
_stalled_node = _terraRoot->getNode("stalled", true);
|
_stalledNode = _terraRoot->getNode("stalled", true);
|
||||||
_stalled_node->setBoolValue(_svnThread->_stalled);
|
_stalledNode->setBoolValue(_svnThread->_stalled);
|
||||||
_stalled_node->setAttribute(SGPropertyNode::PRESERVE,true);
|
_stalledNode->setAttribute(SGPropertyNode::PRESERVE,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SGTerraSync::unbind()
|
void SGTerraSync::unbind()
|
||||||
@@ -774,10 +778,10 @@ void SGTerraSync::update(double)
|
|||||||
SG_LOG(SG_TERRAIN,SG_ALERT,
|
SG_LOG(SG_TERRAIN,SG_ALERT,
|
||||||
"Automatic scenery download/synchronization has stopped.");
|
"Automatic scenery download/synchronization has stopped.");
|
||||||
}
|
}
|
||||||
_stalled_node->setBoolValue(_svnThread->_stalled);
|
_stalledNode->setBoolValue(_svnThread->_stalled);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_refresh_display->getBoolValue())
|
if (!_refreshDisplay->getBoolValue())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (_svnThread->hasNewTiles())
|
while (_svnThread->hasNewTiles())
|
||||||
@@ -794,7 +798,7 @@ void SGTerraSync::update(double)
|
|||||||
void SGTerraSync::refreshScenery(SGPath path,const string& relativeDir)
|
void SGTerraSync::refreshScenery(SGPath path,const string& relativeDir)
|
||||||
{
|
{
|
||||||
// find tiles to be refreshed
|
// find tiles to be refreshed
|
||||||
if (_tile_cache)
|
if (_refreshCb)
|
||||||
{
|
{
|
||||||
path.append(relativeDir);
|
path.append(relativeDir);
|
||||||
if (path.exists())
|
if (path.exists())
|
||||||
@@ -808,7 +812,7 @@ void SGTerraSync::refreshScenery(SGPath path,const string& relativeDir)
|
|||||||
{
|
{
|
||||||
// reload scenery tile
|
// reload scenery tile
|
||||||
long index = atoi(tileList[i].file().c_str());
|
long index = atoi(tileList[i].file().c_str());
|
||||||
_tile_cache->refresh_tile(index);
|
_refreshCb(_userCbData, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -816,9 +820,10 @@ void SGTerraSync::refreshScenery(SGPath path,const string& relativeDir)
|
|||||||
|
|
||||||
bool SGTerraSync::isIdle() {return _svnThread->isIdle();}
|
bool SGTerraSync::isIdle() {return _svnThread->isIdle();}
|
||||||
|
|
||||||
void SGTerraSync::setTileCache(TileCache* tile_cache)
|
void SGTerraSync::setTileRefreshCb(SGTerraSyncCallback refreshCb, void* userCbData)
|
||||||
{
|
{
|
||||||
_tile_cache = tile_cache;
|
_refreshCb = refreshCb;
|
||||||
|
_userCbData = userCbData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SGTerraSync::syncAirportsModels()
|
void SGTerraSync::syncAirportsModels()
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
#include <simgear/props/tiedpropertylist.hxx>
|
#include <simgear/props/tiedpropertylist.hxx>
|
||||||
#include <OpenThreads/Thread>
|
|
||||||
|
|
||||||
class SGPath;
|
class SGPath;
|
||||||
|
|
||||||
@@ -32,7 +31,7 @@ namespace simgear
|
|||||||
{
|
{
|
||||||
const int NOWHERE = -9999;
|
const int NOWHERE = -9999;
|
||||||
|
|
||||||
class TileCache;
|
typedef void (*SGTerraSyncCallback)(void* userData, long tileIndex);
|
||||||
|
|
||||||
class SGTerraSync : public SGSubsystem
|
class SGTerraSync : public SGSubsystem
|
||||||
{
|
{
|
||||||
@@ -48,7 +47,7 @@ public:
|
|||||||
|
|
||||||
bool isIdle();
|
bool isIdle();
|
||||||
bool schedulePosition(int lat, int lon);
|
bool schedulePosition(int lat, int lon);
|
||||||
void setTileCache(TileCache* tile_cache);
|
void setTileRefreshCb(SGTerraSyncCallback refreshCb, void* userData = NULL);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void syncAirportsModels();
|
void syncAirportsModels();
|
||||||
@@ -63,9 +62,10 @@ private:
|
|||||||
int last_lat;
|
int last_lat;
|
||||||
int last_lon;
|
int last_lon;
|
||||||
SGPropertyNode_ptr _terraRoot;
|
SGPropertyNode_ptr _terraRoot;
|
||||||
SGPropertyNode_ptr _refresh_display;
|
SGPropertyNode_ptr _refreshDisplay;
|
||||||
SGPropertyNode_ptr _stalled_node;
|
SGPropertyNode_ptr _stalledNode;
|
||||||
TileCache* _tile_cache;
|
SGTerraSyncCallback _refreshCb;
|
||||||
|
void* _userCbData;
|
||||||
simgear::TiedPropertyList _tiedProperties;
|
simgear::TiedPropertyList _tiedProperties;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ set(HEADERS
|
|||||||
SGEnlargeBoundingBox.hxx
|
SGEnlargeBoundingBox.hxx
|
||||||
SGNodeMasks.hxx
|
SGNodeMasks.hxx
|
||||||
SGPickCallback.hxx
|
SGPickCallback.hxx
|
||||||
|
SGReaderWriterOptions.hxx
|
||||||
SGSceneFeatures.hxx
|
SGSceneFeatures.hxx
|
||||||
SGSceneUserData.hxx
|
SGSceneUserData.hxx
|
||||||
SGStateAttributeVisitor.hxx
|
SGStateAttributeVisitor.hxx
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
// Copyright (C) 2007 Tim Moore timoore@redhat.com
|
||||||
|
// Copyright (C) 2008 Till Busch buti@bux.at
|
||||||
|
// Copyright (C) 2011 Mathias Froehlich
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 2 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef SGREADERWRITEROPTIONS_HXX
|
||||||
|
#define SGREADERWRITEROPTIONS_HXX 1
|
||||||
|
|
||||||
|
#include <osgDB/Options>
|
||||||
|
#include <simgear/scene/model/modellib.hxx>
|
||||||
|
#include <simgear/props/props.hxx>
|
||||||
|
|
||||||
|
class SGPropertyNode;
|
||||||
|
class SGMaterialLib;
|
||||||
|
|
||||||
|
namespace simgear
|
||||||
|
{
|
||||||
|
|
||||||
|
class SGReaderWriterOptions : public osgDB::Options {
|
||||||
|
public:
|
||||||
|
SGReaderWriterOptions() :
|
||||||
|
_materialLib(0),
|
||||||
|
_load_panel(0),
|
||||||
|
_model_data(0),
|
||||||
|
_instantiateEffects(false)
|
||||||
|
{ }
|
||||||
|
SGReaderWriterOptions(const std::string& str) :
|
||||||
|
osgDB::ReaderWriter::Options(str),
|
||||||
|
_materialLib(0),
|
||||||
|
_load_panel(0),
|
||||||
|
_model_data(0),
|
||||||
|
_instantiateEffects(false)
|
||||||
|
{ }
|
||||||
|
SGReaderWriterOptions(const osgDB::Options& options,
|
||||||
|
const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY) :
|
||||||
|
osgDB::ReaderWriter::Options(options, copyop),
|
||||||
|
_materialLib(0),
|
||||||
|
_load_panel(0),
|
||||||
|
_model_data(0),
|
||||||
|
_instantiateEffects(false)
|
||||||
|
{ }
|
||||||
|
SGReaderWriterOptions(const SGReaderWriterOptions& options,
|
||||||
|
const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY) :
|
||||||
|
osgDB::ReaderWriter::Options(options, copyop),
|
||||||
|
_propertyNode(options._propertyNode),
|
||||||
|
_materialLib(options._materialLib),
|
||||||
|
_load_panel(options._load_panel),
|
||||||
|
_model_data(options._model_data),
|
||||||
|
_instantiateEffects(options._instantiateEffects)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
META_Object(simgear, SGReaderWriterOptions);
|
||||||
|
|
||||||
|
const SGSharedPtr<SGPropertyNode>& getPropertyNode() const
|
||||||
|
{ return _propertyNode; }
|
||||||
|
void setPropertyNode(const SGSharedPtr<SGPropertyNode>& propertyNode)
|
||||||
|
{ _propertyNode = propertyNode; }
|
||||||
|
|
||||||
|
SGMaterialLib* getMaterialLib() const
|
||||||
|
{ return _materialLib; }
|
||||||
|
void setMaterialLib(SGMaterialLib* materialLib)
|
||||||
|
{ _materialLib = materialLib; }
|
||||||
|
|
||||||
|
typedef osg::Node *(*panel_func)(SGPropertyNode *);
|
||||||
|
|
||||||
|
panel_func getLoadPanel() const
|
||||||
|
{ return _load_panel; }
|
||||||
|
void setLoadPanel(panel_func pf)
|
||||||
|
{ _load_panel=pf; }
|
||||||
|
|
||||||
|
SGModelData *getModelData() const
|
||||||
|
{ return _model_data.get(); }
|
||||||
|
void setModelData(SGModelData *modelData)
|
||||||
|
{ _model_data=modelData; }
|
||||||
|
|
||||||
|
bool getInstantiateEffects() const
|
||||||
|
{ return _instantiateEffects; }
|
||||||
|
void setInstantiateEffects(bool instantiateEffects)
|
||||||
|
{ _instantiateEffects = instantiateEffects; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~SGReaderWriterOptions() {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
SGSharedPtr<SGPropertyNode> _propertyNode;
|
||||||
|
SGMaterialLib* _materialLib;
|
||||||
|
osg::Node *(*_load_panel)(SGPropertyNode *);
|
||||||
|
osg::ref_ptr<SGModelData> _model_data;
|
||||||
|
bool _instantiateEffects;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -605,7 +605,7 @@ bool SGSoundMgr::load(string &samplepath, void **dbuf, int *fmt,
|
|||||||
// occurs: e.g. -43 on Mac when file is not found.
|
// occurs: e.g. -43 on Mac when file is not found.
|
||||||
// In this case, alGetString() sets 'Invalid Enum' error, so
|
// In this case, alGetString() sets 'Invalid Enum' error, so
|
||||||
// showing with the original error number is helpful.
|
// showing with the original error number is helpful.
|
||||||
stringstream ss;
|
std::stringstream ss;
|
||||||
ss << alGetString(alGetError()) << "(" << error << ")";
|
ss << alGetString(alGetError()) << "(" << error << ")";
|
||||||
msg.append(ss.str());
|
msg.append(ss.str());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ set(HEADERS
|
|||||||
SGSmplstat.hxx
|
SGSmplstat.hxx
|
||||||
SGWeakPtr.hxx
|
SGWeakPtr.hxx
|
||||||
SGWeakReferenced.hxx
|
SGWeakReferenced.hxx
|
||||||
|
SGPerfMon.hxx
|
||||||
Singleton.hxx
|
Singleton.hxx
|
||||||
StringTable.hxx
|
StringTable.hxx
|
||||||
callback.hxx
|
callback.hxx
|
||||||
@@ -29,6 +30,7 @@ set(SOURCES
|
|||||||
SGExpression.cxx
|
SGExpression.cxx
|
||||||
SGSmplhist.cxx
|
SGSmplhist.cxx
|
||||||
SGSmplstat.cxx
|
SGSmplstat.cxx
|
||||||
|
SGPerfMon.cxx
|
||||||
StringTable.cxx
|
StringTable.cxx
|
||||||
commands.cxx
|
commands.cxx
|
||||||
event_mgr.cxx
|
event_mgr.cxx
|
||||||
|
|||||||
@@ -0,0 +1,130 @@
|
|||||||
|
// SGPerfMon.cxx -- Performance Monitoring
|
||||||
|
//
|
||||||
|
// Written by Thorsten Brehm, started November 2011.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2011 Thorsten Brehm - brehmt (at) gmail com
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 2 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <simgear_config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "SGPerfMon.hxx"
|
||||||
|
#include <simgear/structure/SGSmplstat.hxx>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <simgear/constants.h>
|
||||||
|
#include <simgear/sg_inlines.h>
|
||||||
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
#include <simgear/math/sg_geodesy.hxx>
|
||||||
|
#include <simgear/sound/soundmgr_openal.hxx>
|
||||||
|
#include <simgear/structure/exception.hxx>
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
SGPerformanceMonitor::SGPerformanceMonitor(SGSubsystemMgr* subSysMgr, SGPropertyNode_ptr root) :
|
||||||
|
_isEnabled(false),
|
||||||
|
_count(0)
|
||||||
|
{
|
||||||
|
_root = root;
|
||||||
|
_subSysMgr = subSysMgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SGPerformanceMonitor::bind(void)
|
||||||
|
{
|
||||||
|
_statiticsSubsystems = _root->getChild("subsystems", 0, true);
|
||||||
|
_statisticsFlag = _root->getChild("enabled", 0, true);
|
||||||
|
_statisticsInterval = _root->getChild("interval-s", 0, true);
|
||||||
|
// _statiticsMinJitter = _root->getChild("min-jitter-ms", 0, true);
|
||||||
|
// _statiticsMinTime = _root->getChild("min-time-ms", 0, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SGPerformanceMonitor::unbind(void)
|
||||||
|
{
|
||||||
|
_statiticsSubsystems = 0;
|
||||||
|
_statisticsFlag = 0;
|
||||||
|
_statisticsInterval = 0;
|
||||||
|
// _statiticsMinJitter = 0;
|
||||||
|
// _statiticsMinTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SGPerformanceMonitor::init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SGPerformanceMonitor::update(double dt)
|
||||||
|
{
|
||||||
|
if (_isEnabled != _statisticsFlag->getBoolValue())
|
||||||
|
{
|
||||||
|
// flag has changed, update subsystem manager
|
||||||
|
_isEnabled = _statisticsFlag->getBoolValue();
|
||||||
|
if (_isEnabled)
|
||||||
|
_subSysMgr->setReportTimingCb(this,&subSystemMgrHook);
|
||||||
|
else
|
||||||
|
_subSysMgr->setReportTimingCb(this,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_isEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_lastUpdate.elapsedMSec() > 1000 * _statisticsInterval->getDoubleValue())
|
||||||
|
{
|
||||||
|
_count = 0;
|
||||||
|
// grab timing statistics
|
||||||
|
_subSysMgr->reportTiming();
|
||||||
|
_lastUpdate.stamp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Callback hooked into the subsystem manager. */
|
||||||
|
void
|
||||||
|
SGPerformanceMonitor::subSystemMgrHook(void* userData, const std::string& name, SampleStatistic* timeStat)
|
||||||
|
{
|
||||||
|
((SGPerformanceMonitor*) userData)->reportTiming(name, timeStat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Grabs and exposes timing information to properties */
|
||||||
|
void
|
||||||
|
SGPerformanceMonitor::reportTiming(const string& name, SampleStatistic* timeStat)
|
||||||
|
{
|
||||||
|
SGPropertyNode* node = _statiticsSubsystems->getChild("subsystem",_count++,true);
|
||||||
|
|
||||||
|
double minMs = timeStat->min() / 1000;
|
||||||
|
double maxMs = timeStat->max() / 1000;
|
||||||
|
double meanMs = timeStat->mean() / 1000;
|
||||||
|
double stdDevMs = timeStat->stdDev() / 1000;
|
||||||
|
double totalMs = timeStat->total() / 1000;
|
||||||
|
int samples = timeStat->samples();
|
||||||
|
|
||||||
|
node->setStringValue("name", name);
|
||||||
|
node->setDoubleValue("min-ms", minMs);
|
||||||
|
node->setDoubleValue("max-ms", maxMs);
|
||||||
|
node->setDoubleValue("mean-ms", meanMs);
|
||||||
|
node->setDoubleValue("stddev-ms", stdDevMs);
|
||||||
|
node->setDoubleValue("total-ms", totalMs);
|
||||||
|
node->setDoubleValue("count",samples);
|
||||||
|
|
||||||
|
timeStat->reset();
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
// SGPerfMon.hxx -- Performance Tracing
|
||||||
|
//
|
||||||
|
// Written by Thorsten Brehm, started November 2011.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2011 Thorsten Brehm - brehmt (at) gmail com
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 2 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __SGPERFMON_HXX
|
||||||
|
#define __SGPERFMON_HXX
|
||||||
|
|
||||||
|
#include <simgear/props/props.hxx>
|
||||||
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
|
#include <simgear/timing/timestamp.hxx>
|
||||||
|
|
||||||
|
class SampleStatistic;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// SG Performance Monitor ////////////////////////////////////////////////////
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class SGPerformanceMonitor : public SGSubsystem
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
SGPerformanceMonitor(SGSubsystemMgr* subSysMgr, SGPropertyNode_ptr root);
|
||||||
|
|
||||||
|
virtual void bind (void);
|
||||||
|
virtual void unbind (void);
|
||||||
|
virtual void init (void);
|
||||||
|
virtual void update (double dt);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void subSystemMgrHook(void* userData, const std::string& name, SampleStatistic* timeStat);
|
||||||
|
|
||||||
|
void reportTiming(const std::string& name, SampleStatistic* timeStat);
|
||||||
|
|
||||||
|
SGTimeStamp _lastUpdate;
|
||||||
|
SGSubsystemMgr* _subSysMgr;
|
||||||
|
SGPropertyNode_ptr _root;
|
||||||
|
SGPropertyNode_ptr _statiticsSubsystems;
|
||||||
|
SGPropertyNode_ptr _statisticsFlag;
|
||||||
|
SGPropertyNode_ptr _statisticsInterval;
|
||||||
|
// SGPropertyNode_ptr _statiticsMinJitter;
|
||||||
|
// SGPropertyNode_ptr _statiticsMinTime;
|
||||||
|
|
||||||
|
bool _isEnabled;
|
||||||
|
int _count;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __SGPERFMON_HXX
|
||||||
@@ -15,9 +15,11 @@ You should have received a copy of the GNU Library General Public
|
|||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma implementation
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <simgear_config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "SGSmplhist.hxx"
|
#include "SGSmplhist.hxx"
|
||||||
@@ -94,7 +96,7 @@ int SampleHistogram::similarSamples (double d)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SampleHistogram::printBuckets (ostream & s)
|
void SampleHistogram::printBuckets (std::ostream & s)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < howManyBuckets; i++)
|
for (int i = 0; i < howManyBuckets; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,13 +16,7 @@ License along with this library; if not, write to the Free Software
|
|||||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include <simgear_config.h>
|
|
||||||
#endif
|
|
||||||
#ifndef SampleHistogram_h
|
#ifndef SampleHistogram_h
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma interface
|
|
||||||
#endif
|
|
||||||
#define SampleHistogram_h 1
|
#define SampleHistogram_h 1
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ You should have received a copy of the GNU Library General Public
|
|||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma implementation
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@@ -84,6 +81,7 @@ void SampleStatistic::operator += (double value)
|
|||||||
{
|
{
|
||||||
n += 1;
|
n += 1;
|
||||||
x += value;
|
x += value;
|
||||||
|
allTimeTotal += value;
|
||||||
x2 += (value * value);
|
x2 += (value * value);
|
||||||
if (minValue > value)
|
if (minValue > value)
|
||||||
minValue = value;
|
minValue = value;
|
||||||
|
|||||||
@@ -16,17 +16,13 @@ License along with this library; if not, write to the Free Software
|
|||||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
#ifndef SampleStatistic_h
|
#ifndef SampleStatistic_h
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma interface
|
|
||||||
#endif
|
|
||||||
#define SampleStatistic_h 1
|
#define SampleStatistic_h 1
|
||||||
|
|
||||||
|
|
||||||
#undef min
|
#undef min
|
||||||
#undef max
|
#undef max
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class SampleStatistic
|
class SampleStatistic
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@@ -34,6 +30,7 @@ protected:
|
|||||||
double x;
|
double x;
|
||||||
double x2;
|
double x2;
|
||||||
double minValue, maxValue;
|
double minValue, maxValue;
|
||||||
|
double allTimeTotal;
|
||||||
|
|
||||||
public: SampleStatistic ();
|
public: SampleStatistic ();
|
||||||
inline virtual ~ SampleStatistic ();
|
inline virtual ~ SampleStatistic ();
|
||||||
@@ -46,6 +43,7 @@ public: SampleStatistic ();
|
|||||||
double var () const;
|
double var () const;
|
||||||
double min () const;
|
double min () const;
|
||||||
double max () const;
|
double max () const;
|
||||||
|
double total () const;
|
||||||
double confidence (int p_percentage) const;
|
double confidence (int p_percentage) const;
|
||||||
double confidence (double p_value) const;
|
double confidence (double p_value) const;
|
||||||
|
|
||||||
@@ -62,6 +60,7 @@ public: SampleStatistic ();
|
|||||||
|
|
||||||
inline SampleStatistic::SampleStatistic ()
|
inline SampleStatistic::SampleStatistic ()
|
||||||
{
|
{
|
||||||
|
allTimeTotal = 0;
|
||||||
reset ();
|
reset ();
|
||||||
}
|
}
|
||||||
inline int SampleStatistic::samples () const
|
inline int SampleStatistic::samples () const
|
||||||
@@ -76,6 +75,10 @@ inline double SampleStatistic::max () const
|
|||||||
{
|
{
|
||||||
return (maxValue);
|
return (maxValue);
|
||||||
}
|
}
|
||||||
|
inline double SampleStatistic::total () const
|
||||||
|
{
|
||||||
|
return (allTimeTotal);
|
||||||
|
}
|
||||||
|
|
||||||
inline SampleStatistic::~SampleStatistic ()
|
inline SampleStatistic::~SampleStatistic ()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,13 +29,16 @@
|
|||||||
#include "subsystem_mgr.hxx"
|
#include "subsystem_mgr.hxx"
|
||||||
|
|
||||||
#include <simgear/math/SGMath.hxx>
|
#include <simgear/math/SGMath.hxx>
|
||||||
|
#include "SGSmplstat.hxx"
|
||||||
|
|
||||||
|
const int SG_MAX_SUBSYSTEM_EXCEPTIONS = 4;
|
||||||
|
|
||||||
const int SG_MAX_SUBSYSTEM_EXCEPTIONS = 4;
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of SGSubsystem
|
// Implementation of SGSubsystem
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
SGSubsystemTimingCb SGSubsystem::reportTimingCb = NULL;
|
||||||
|
void* SGSubsystem::reportTimingUserData = NULL;
|
||||||
|
|
||||||
SGSubsystem::SGSubsystem ()
|
SGSubsystem::SGSubsystem ()
|
||||||
: _suspended(false)
|
: _suspended(false)
|
||||||
@@ -100,28 +103,6 @@ SGSubsystem::is_suspended () const
|
|||||||
return _suspended;
|
return _suspended;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SGSubsystem::printTimingInformation ()
|
|
||||||
{
|
|
||||||
SGTimeStamp startTime;
|
|
||||||
for ( eventTimeVecIterator i = timingInfo.begin();
|
|
||||||
i != timingInfo.end();
|
|
||||||
++i) {
|
|
||||||
if (i == timingInfo.begin()) {
|
|
||||||
startTime = i->getTime();
|
|
||||||
} else {
|
|
||||||
SGTimeStamp endTime = i->getTime();
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "- Getting to timestamp : "
|
|
||||||
<< i->getName() << " takes " << endTime - startTime
|
|
||||||
<< " sec.");
|
|
||||||
startTime = endTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SGSubsystem::stamp(const string& name)
|
void SGSubsystem::stamp(const string& name)
|
||||||
{
|
{
|
||||||
timingInfo.push_back(TimingInfo(name, SGTimeStamp::now()));
|
timingInfo.push_back(TimingInfo(name, SGTimeStamp::now()));
|
||||||
@@ -132,6 +113,30 @@ void SGSubsystem::stamp(const string& name)
|
|||||||
// Implementation of SGSubsystemGroup.
|
// Implementation of SGSubsystemGroup.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class SGSubsystemGroup::Member
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
Member (const Member &member);
|
||||||
|
public:
|
||||||
|
Member ();
|
||||||
|
virtual ~Member ();
|
||||||
|
|
||||||
|
virtual void update (double delta_time_sec);
|
||||||
|
|
||||||
|
void reportTiming(void) { if (reportTimingCb) reportTimingCb(reportTimingUserData, name, &timeStat); }
|
||||||
|
void updateExecutionTime(double time) { timeStat += time;}
|
||||||
|
|
||||||
|
SampleStatistic timeStat;
|
||||||
|
std::string name;
|
||||||
|
SGSubsystem * subsystem;
|
||||||
|
double min_step_sec;
|
||||||
|
double elapsed_sec;
|
||||||
|
bool collectTimeStats;
|
||||||
|
int exceptionCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SGSubsystemGroup::SGSubsystemGroup () :
|
SGSubsystemGroup::SGSubsystemGroup () :
|
||||||
_fixedUpdateTime(-1.0),
|
_fixedUpdateTime(-1.0),
|
||||||
_updateTimeRemainder(0.0)
|
_updateTimeRemainder(0.0)
|
||||||
@@ -140,8 +145,6 @@ SGSubsystemGroup::SGSubsystemGroup () :
|
|||||||
|
|
||||||
SGSubsystemGroup::~SGSubsystemGroup ()
|
SGSubsystemGroup::~SGSubsystemGroup ()
|
||||||
{
|
{
|
||||||
printTimingStatistics();
|
|
||||||
|
|
||||||
// reverse order to prevent order dependency problems
|
// reverse order to prevent order dependency problems
|
||||||
for (unsigned int i = _members.size(); i > 0; i--)
|
for (unsigned int i = _members.size(); i > 0; i--)
|
||||||
{
|
{
|
||||||
@@ -207,38 +210,31 @@ SGSubsystemGroup::update (double delta_time_sec)
|
|||||||
delta_time_sec = _fixedUpdateTime;
|
delta_time_sec = _fixedUpdateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SGTimeStamp timeStamp;
|
||||||
while (loopCount-- > 0) {
|
while (loopCount-- > 0) {
|
||||||
for (unsigned int i = 0; i < _members.size(); i++)
|
for (unsigned int i = 0; i < _members.size(); i++)
|
||||||
{
|
{
|
||||||
SGTimeStamp timeStamp = SGTimeStamp::now();
|
bool recordTime = (reportTimingCb != NULL);
|
||||||
_members[i]->update(delta_time_sec); // indirect call
|
if (recordTime)
|
||||||
timeStamp = SGTimeStamp::now() - timeStamp;
|
timeStamp = SGTimeStamp::now();
|
||||||
double b = timeStamp.toUSecs();
|
|
||||||
_members[i]->updateExecutionTime(b);
|
_members[i]->update(delta_time_sec); // indirect call
|
||||||
double threshold = _members[i]->getTimeWarningThreshold();
|
|
||||||
if (( b > threshold ) && (b > 10000)) {
|
if ((recordTime)&&(reportTimingCb))
|
||||||
_members[i]->printTimingInformation(b);
|
{
|
||||||
}
|
timeStamp = SGTimeStamp::now() - timeStamp;
|
||||||
|
_members[i]->updateExecutionTime(timeStamp.toUSecs());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // of multiple update loop
|
} // of multiple update loop
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SGSubsystemGroup::collectDebugTiming(bool collect)
|
SGSubsystemGroup::reportTiming(void)
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < _members.size(); i++)
|
|
||||||
{
|
|
||||||
_members[i]->collectDebugTiming(collect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SGSubsystemGroup::printTimingStatistics(double minMaxTime,double minJitter)
|
|
||||||
{
|
{
|
||||||
for (unsigned int i = _members.size(); i > 0; i--)
|
for (unsigned int i = _members.size(); i > 0; i--)
|
||||||
{
|
{
|
||||||
_members[i-1]->printTimingStatistics(minMaxTime, minJitter);
|
_members[i-1]->reportTiming();
|
||||||
_members[i-1]->timeStat.reset();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,35 +297,6 @@ SGSubsystemGroup::set_fixed_update_time(double dt)
|
|||||||
_fixedUpdateTime = dt;
|
_fixedUpdateTime = dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Print timing statistics.
|
|
||||||
* Only show data if jitter exceeds minJitter or
|
|
||||||
* maximum time exceeds minMaxTime.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
SGSubsystemGroup::Member::printTimingStatistics(double minMaxTime,double minJitter)
|
|
||||||
{
|
|
||||||
if (collectTimeStats) {
|
|
||||||
double minTime = timeStat.min() / 1000;
|
|
||||||
double maxTime = timeStat.max() / 1000;
|
|
||||||
double meanTime = timeStat.mean() / 1000;
|
|
||||||
double stddev = timeStat.stdDev() / 1000;
|
|
||||||
|
|
||||||
if ((maxTime - minTime >= minJitter)||
|
|
||||||
(maxTime >= minMaxTime))
|
|
||||||
{
|
|
||||||
char buffer[256];
|
|
||||||
snprintf(buffer, 256, "Timing summary for %20s.\n"
|
|
||||||
"- mean time: %04.2f ms.\n"
|
|
||||||
"- min time : %04.2f ms.\n"
|
|
||||||
"- max time : %04.2f ms.\n"
|
|
||||||
"- stddev : %04.2f ms.\n", name.c_str(), meanTime, minTime, maxTime, stddev);
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SGSubsystemGroup::has_subsystem (const string &name) const
|
SGSubsystemGroup::has_subsystem (const string &name) const
|
||||||
{
|
{
|
||||||
@@ -364,7 +331,6 @@ SGSubsystemGroup::Member::Member ()
|
|||||||
subsystem(0),
|
subsystem(0),
|
||||||
min_step_sec(0),
|
min_step_sec(0),
|
||||||
elapsed_sec(0),
|
elapsed_sec(0),
|
||||||
collectTimeStats(false),
|
|
||||||
exceptionCount(0)
|
exceptionCount(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -407,31 +373,6 @@ SGSubsystemGroup::Member::update (double delta_time_sec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SGSubsystemGroup::Member::printTimingInformation(double time)
|
|
||||||
{
|
|
||||||
if (collectTimeStats) {
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Subsystem Timing Alert, subsystem \"" << name << "\": " << time/1000.0 << "ms");
|
|
||||||
subsystem->printTimingInformation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double SGSubsystemGroup::Member::getTimeWarningThreshold()
|
|
||||||
{
|
|
||||||
return (timeStat.mean() + 3 * timeStat.stdDev());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SGSubsystemGroup::Member::updateExecutionTime(double time)
|
|
||||||
{
|
|
||||||
if (collectTimeStats) {
|
|
||||||
timeStat += time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of SGSubsystemMgr.
|
// Implementation of SGSubsystemMgr.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
@@ -508,14 +449,6 @@ SGSubsystemMgr::update (double delta_time_sec)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
SGSubsystemMgr::collectDebugTiming(bool collect)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < MAX_GROUPS; i++) {
|
|
||||||
_groups[i]->collectDebugTiming(collect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SGSubsystemMgr::suspend ()
|
SGSubsystemMgr::suspend ()
|
||||||
{
|
{
|
||||||
@@ -590,11 +523,12 @@ SGSubsystemMgr::get_subsystem (const string &name) const
|
|||||||
return s->second;
|
return s->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Trigger the timing callback to report data for all subsystems. */
|
||||||
void
|
void
|
||||||
SGSubsystemMgr::printTimingStatistics(double minMaxTime,double minJitter)
|
SGSubsystemMgr::reportTiming()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_GROUPS; i++) {
|
for (int i = 0; i < MAX_GROUPS; i++) {
|
||||||
_groups[i]->printTimingStatistics(minMaxTime, minJitter);
|
_groups[i]->reportTiming();
|
||||||
} // of groups iteration
|
} // of groups iteration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
// Written by David Megginson, started 2000-12
|
// Written by David Megginson, started 2000-12
|
||||||
//
|
//
|
||||||
// Copyright (C) 2000 David Megginson, david@megginson.com
|
// Copyright (C) 2000 David Megginson, david@megginson.com
|
||||||
@@ -31,7 +32,6 @@
|
|||||||
|
|
||||||
#include <simgear/timing/timestamp.hxx>
|
#include <simgear/timing/timestamp.hxx>
|
||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
#include "SGSmplstat.hxx"
|
|
||||||
|
|
||||||
|
|
||||||
class TimingInfo
|
class TimingInfo
|
||||||
@@ -48,9 +48,12 @@ public:
|
|||||||
const SGTimeStamp& getTime() const { return time; }
|
const SGTimeStamp& getTime() const { return time; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SampleStatistic;
|
||||||
|
|
||||||
typedef std::vector<TimingInfo> eventTimeVec;
|
typedef std::vector<TimingInfo> eventTimeVec;
|
||||||
typedef std::vector<TimingInfo>::iterator eventTimeVecIterator;
|
typedef std::vector<TimingInfo>::iterator eventTimeVecIterator;
|
||||||
|
|
||||||
|
typedef void (*SGSubsystemTimingCb)(void* userData, const std::string& name, SampleStatistic* pStatistic);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -227,7 +230,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Suspend or resum operation of this subsystem.
|
* Suspend or resume operation of this subsystem.
|
||||||
*
|
*
|
||||||
* @param suspended true if the subsystem should be suspended, false
|
* @param suspended true if the subsystem should be suspended, false
|
||||||
* otherwise.
|
* otherwise.
|
||||||
@@ -253,43 +256,25 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool is_suspended () const;
|
virtual bool is_suspended () const;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keep track of execution time.
|
* Trigger the callback to report timing information for all subsystems.
|
||||||
*
|
|
||||||
* <p>This method keeps track of timing statistics for each subsystem.</p>
|
|
||||||
*
|
|
||||||
* @param time execution time in ms of last call.
|
|
||||||
*/
|
*/
|
||||||
void updateExecutionTime(double time);
|
void reportTiming(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* Print details of execution time.
|
|
||||||
*
|
|
||||||
* <p>For debugging purposes, developers can place stamp() calls
|
|
||||||
* at strategic points in the update() function of each subsystem, which
|
|
||||||
* record the time between the successive calls to stamp. This method,
|
|
||||||
* printExecutionTime() is called after exectution of the subsystem
|
|
||||||
* update function itself to conduct a post-hoc analysis of excecution
|
|
||||||
* time</p>
|
|
||||||
*/
|
|
||||||
void printTimingInformation();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Place time stamps at strategic points in the execution of subsystems
|
* Place time stamps at strategic points in the execution of subsystems
|
||||||
* update() member functions. Predominantly for debugging purposes.
|
* update() member functions. Predominantly for debugging purposes.
|
||||||
*/
|
*/
|
||||||
void stamp(const std::string& name);
|
void stamp(const std::string& name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool _suspended;
|
bool _suspended;
|
||||||
|
|
||||||
eventTimeVec timingInfo;
|
eventTimeVec timingInfo;
|
||||||
//int test;
|
|
||||||
|
|
||||||
|
static SGSubsystemTimingCb reportTimingCb;
|
||||||
|
static void* reportTimingUserData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -322,40 +307,16 @@ public:
|
|||||||
virtual void remove_subsystem (const std::string &name);
|
virtual void remove_subsystem (const std::string &name);
|
||||||
virtual bool has_subsystem (const std::string &name) const;
|
virtual bool has_subsystem (const std::string &name) const;
|
||||||
|
|
||||||
void collectDebugTiming(bool collect);
|
void reportTiming(void);
|
||||||
void printTimingStatistics(double minMaxTime=0.0,double minJitter=0.0);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void set_fixed_update_time(double fixed_dt);
|
void set_fixed_update_time(double fixed_dt);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
class Member {
|
class Member;
|
||||||
|
Member* get_member (const std::string &name, bool create = false);
|
||||||
private:
|
|
||||||
Member (const Member &member);
|
|
||||||
public:
|
|
||||||
Member ();
|
|
||||||
virtual ~Member ();
|
|
||||||
|
|
||||||
virtual void update (double delta_time_sec);
|
|
||||||
void printTimingInformation(double time);
|
|
||||||
void printTimingStatistics(double minMaxTime=0.0,double minJitter=0.0);
|
|
||||||
void updateExecutionTime(double time);
|
|
||||||
double getTimeWarningThreshold();
|
|
||||||
void collectDebugTiming (bool collect) { collectTimeStats = collect; };
|
|
||||||
|
|
||||||
SampleStatistic timeStat;
|
|
||||||
std::string name;
|
|
||||||
SGSubsystem * subsystem;
|
|
||||||
double min_step_sec;
|
|
||||||
double elapsed_sec;
|
|
||||||
bool collectTimeStats;
|
|
||||||
int exceptionCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
Member * get_member (const std::string &name, bool create = false);
|
|
||||||
|
|
||||||
std::vector<Member *> _members;
|
std::vector<Member *> _members;
|
||||||
|
|
||||||
@@ -427,16 +388,15 @@ public:
|
|||||||
|
|
||||||
virtual SGSubsystem * get_subsystem(const std::string &name) const;
|
virtual SGSubsystem * get_subsystem(const std::string &name) const;
|
||||||
|
|
||||||
void collectDebugTiming(bool collect);
|
void reportTiming();
|
||||||
void printTimingStatistics(double minMaxTime=0.0,double minJitter=0.0);
|
void setReportTimingCb(void* userData,SGSubsystemTimingCb cb) {reportTimingCb = cb;reportTimingUserData = userData;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
SGSubsystemGroup* _groups[MAX_GROUPS];
|
SGSubsystemGroup* _groups[MAX_GROUPS];
|
||||||
|
|
||||||
typedef std::map<std::string, SGSubsystem*> SubsystemDict;
|
typedef std::map<std::string, SGSubsystem*> SubsystemDict;
|
||||||
SubsystemDict _subsystem_map;
|
SubsystemDict _subsystem_map;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user