Removed include <iostream> where possible, replacing with istream or ostream and changing
std::cout/cerr to osg::notify().
This commit is contained in:
parent
f3bee81e7a
commit
4aa7afedf3
@ -39,12 +39,12 @@ public:
|
|||||||
osg::Geometry* geom = geoset->convertToGeometry();
|
osg::Geometry* geom = geoset->convertToGeometry();
|
||||||
if (geom)
|
if (geom)
|
||||||
{
|
{
|
||||||
std::cout<<"Successfully converted GeoSet to Geometry"<<std::endl;
|
osg::notify(osg::NOTICE)<<"Successfully converted GeoSet to Geometry"<<std::endl;
|
||||||
geode.replaceDrawable(geoset,geom);
|
geode.replaceDrawable(geoset,geom);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout<<"*** Failed to convert GeoSet to Geometry"<<std::endl;
|
osg::notify(osg::NOTICE)<<"*** Failed to convert GeoSet to Geometry"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include <osgUtil/Optimizer>
|
#include <osgUtil/Optimizer>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
osg::Geode* createTile(const osg::Vec3& lb, const osg::Vec3& rb,
|
osg::Geode* createTile(const osg::Vec3& lb, const osg::Vec3& rb,
|
||||||
const osg::Vec3& lt, const osg::Vec3& rt,
|
const osg::Vec3& lt, const osg::Vec3& rt,
|
||||||
const std::string& imageFile)
|
const std::string& imageFile)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <osg/Matrix>
|
#include <osg/Matrix>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
void testFrustum(double left,double right,double bottom,double top,double zNear,double zFar)
|
void testFrustum(double left,double right,double bottom,double top,double zNear,double zFar)
|
||||||
{
|
{
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <osg/NodeCallback>
|
#include <osg/NodeCallback>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <istream>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
|
@ -16,10 +16,6 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#if defined(__GNUC__) && defined(WIN32)
|
|
||||||
# include <iostream>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// for OSX users :
|
// for OSX users :
|
||||||
// comment in if you want backwards compatibility with 10.1.x versions
|
// comment in if you want backwards compatibility with 10.1.x versions
|
||||||
// otherwise you'll have problems with missing floorf and __isnan*()
|
// otherwise you'll have problems with missing floorf and __isnan*()
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <ostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <ostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <osg/Export>
|
#include <osg/Export>
|
||||||
|
|
||||||
#include <iostream>
|
#include <ostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <osg/Vec3>
|
#include <osg/Vec3>
|
||||||
|
|
||||||
#include <iostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
|
@ -18,12 +18,13 @@
|
|||||||
#include <osg/Referenced>
|
#include <osg/Referenced>
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
#include <osg/Timer>
|
#include <osg/Timer>
|
||||||
|
#include <osg/Notify>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace osgUtx{
|
namespace osgUtx{
|
||||||
|
|
||||||
@ -39,19 +40,19 @@ class SG_EXPORT Test: public osg::Referenced
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef TestVisitor Visitor; // Test is redundant
|
typedef TestVisitor Visitor; // Test is redundant
|
||||||
|
|
||||||
Test( const std::string& sName ) : _name( sName ) {}
|
Test( const std::string& sName ) : _name( sName ) {}
|
||||||
|
|
||||||
const std::string& name() const { return _name; }
|
const std::string& name() const { return _name; }
|
||||||
|
|
||||||
virtual bool accept( Visitor& ) = 0;
|
virtual bool accept( Visitor& ) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual ~Test() {}
|
virtual ~Test() {}
|
||||||
|
|
||||||
std::string _name;
|
std::string _name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -66,50 +67,50 @@ class SG_EXPORT TestContext
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TestContext();
|
TestContext();
|
||||||
|
|
||||||
bool shouldStop() { return false; }
|
bool shouldStop() { return false; }
|
||||||
bool isVerbose() { return true; }
|
bool isVerbose() { return true; }
|
||||||
|
|
||||||
enum TraceLevel{
|
enum TraceLevel{
|
||||||
Off, ///< All tracing turned off
|
Off, ///< All tracing turned off
|
||||||
Results, ///< Output results only
|
Results, ///< Output results only
|
||||||
Full ///< Full test diagnostic output
|
Full ///< Full test diagnostic output
|
||||||
};
|
};
|
||||||
|
|
||||||
void setTraceLevel(TraceLevel tl);
|
void setTraceLevel(TraceLevel tl);
|
||||||
TraceLevel getTraceLevel() const;
|
TraceLevel getTraceLevel() const;
|
||||||
|
|
||||||
std::ostream& tout(TraceLevel tl=Full) const;
|
std::ostream& tout(TraceLevel tl=Full) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
TestContext(const TestContext&);
|
TestContext(const TestContext&);
|
||||||
TestContext operator=(const TestContext&);
|
TestContext operator=(const TestContext&);
|
||||||
|
|
||||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||||
|
|
||||||
class SG_EXPORT TraceStream{
|
class SG_EXPORT TraceStream{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TraceStream(std::ostream& o=std::cout, TraceLevel tl=Results);
|
TraceStream(std::ostream& o=osg::notify(osg::NOTICE), TraceLevel tl=Results);
|
||||||
~TraceStream();
|
~TraceStream();
|
||||||
|
|
||||||
void setTraceLevel(TraceLevel tl);
|
void setTraceLevel(TraceLevel tl);
|
||||||
TraceLevel getTraceLevel() const;
|
TraceLevel getTraceLevel() const;
|
||||||
|
|
||||||
std::ostream& stream(TraceLevel tl);
|
std::ostream& stream(TraceLevel tl);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
TraceLevel _traceLevel;
|
TraceLevel _traceLevel;
|
||||||
std::ostream* _outputStreamPtr;
|
std::ostream* _outputStreamPtr;
|
||||||
std::ofstream _nullStream;
|
std::ofstream _nullStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||||
|
|
||||||
mutable TraceStream _tout;
|
mutable TraceStream _tout;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -125,20 +126,20 @@ class TestVisitor
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//..Should we enter this node and its children?
|
//..Should we enter this node and its children?
|
||||||
virtual bool visitEnter( TestSuite* ) { return true; }
|
virtual bool visitEnter( TestSuite* ) { return true; }
|
||||||
|
|
||||||
//..Returns true to continue to next Leaf
|
//..Returns true to continue to next Leaf
|
||||||
virtual bool visit( TestCase* ) = 0;
|
virtual bool visit( TestCase* ) = 0;
|
||||||
|
|
||||||
//..Returns true to continue to next Composite
|
//..Returns true to continue to next Composite
|
||||||
virtual bool visitLeave( TestSuite* ) { return true; }
|
virtual bool visitLeave( TestSuite* ) { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
TestVisitor() {}
|
TestVisitor() {}
|
||||||
TestVisitor( const TestVisitor& ) {}
|
TestVisitor( const TestVisitor& ) {}
|
||||||
virtual ~TestVisitor() {}
|
virtual ~TestVisitor() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,13 +150,13 @@ class TestCase : public Test
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef TestContext Context; // Test in TestContext? is redundant
|
typedef TestContext Context; // Test in TestContext? is redundant
|
||||||
|
|
||||||
TestCase( const std::string& sName ) : Test( sName ) {}
|
TestCase( const std::string& sName ) : Test( sName ) {}
|
||||||
|
|
||||||
virtual bool accept( Visitor& v ) { return v.visit( this ); }
|
virtual bool accept( Visitor& v ) { return v.visit( this ); }
|
||||||
|
|
||||||
virtual void run( const Context& ) = 0; // Subclass OSGUTX_EXPORT Responsibility
|
virtual void run( const Context& ) = 0; // Subclass OSGUTX_EXPORT Responsibility
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -170,13 +171,13 @@ class TestX
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TestX(const std::string& s):_what(s) {}
|
TestX(const std::string& s):_what(s) {}
|
||||||
virtual ~TestX() {}
|
virtual ~TestX() {}
|
||||||
|
|
||||||
const std::string& what() const { return _what; }
|
const std::string& what() const { return _what; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _what;
|
std::string _what;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -185,7 +186,7 @@ A TestFailureX indicates a failure in the tested component.
|
|||||||
class TestFailureX: public TestX
|
class TestFailureX: public TestX
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestFailureX(const std::string& s):TestX(s) {}
|
TestFailureX(const std::string& s):TestX(s) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -197,7 +198,7 @@ run which prevents the component from being tested.
|
|||||||
class TestErrorX: public TestX
|
class TestErrorX: public TestX
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestErrorX(const std::string& s):TestX(s) {}
|
TestErrorX(const std::string& s):TestX(s) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -211,28 +212,28 @@ of information from one test case to the next.
|
|||||||
template< typename FixtureT >
|
template< typename FixtureT >
|
||||||
class TestCase_ : public TestCase
|
class TestCase_ : public TestCase
|
||||||
{
|
{
|
||||||
typedef void (FixtureT::*TestMethodPtr)( const Context& );
|
typedef void (FixtureT::*TestMethodPtr)( const Context& );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructor adds the TestMethod pointer
|
// Constructor adds the TestMethod pointer
|
||||||
TestCase_( const std::string& sName, TestMethodPtr pTestMethod ) :
|
TestCase_( const std::string& sName, TestMethodPtr pTestMethod ) :
|
||||||
TestCase( sName ),
|
TestCase( sName ),
|
||||||
_pTestMethod( pTestMethod )
|
_pTestMethod( pTestMethod )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a TestFixture instance and invoke TestMethod?
|
// Create a TestFixture instance and invoke TestMethod?
|
||||||
virtual void run( const Context& ctx )
|
virtual void run( const Context& ctx )
|
||||||
{
|
{
|
||||||
( FixtureT().*_pTestMethod )( ctx );
|
( FixtureT().*_pTestMethod )( ctx );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual ~TestCase_() {}
|
virtual ~TestCase_() {}
|
||||||
|
|
||||||
TestMethodPtr _pTestMethod;
|
TestMethodPtr _pTestMethod;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -243,24 +244,24 @@ class SG_EXPORT TestSuite : public Test
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TestSuite( const std::string& name );
|
TestSuite( const std::string& name );
|
||||||
|
|
||||||
/** Adds a Test to the suite. */
|
/** Adds a Test to the suite. */
|
||||||
void add( Test* pTest );
|
void add( Test* pTest );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@returns The immediate child denoted by name, or 0 if not found.
|
@returns The immediate child denoted by name, or 0 if not found.
|
||||||
*/
|
*/
|
||||||
Test* findChild(const std::string& name);
|
Test* findChild(const std::string& name);
|
||||||
|
|
||||||
virtual bool accept( Test::Visitor& v );
|
virtual bool accept( Test::Visitor& v );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual ~TestSuite() {}
|
virtual ~TestSuite() {}
|
||||||
|
|
||||||
typedef std::vector< osg::ref_ptr<Test> > Tests;
|
typedef std::vector< osg::ref_ptr<Test> > Tests;
|
||||||
Tests _tests; // Collection of Suites and/or Cases
|
Tests _tests; // Collection of Suites and/or Cases
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -272,54 +273,54 @@ class SG_EXPORT TestGraph
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static TestGraph& instance();
|
static TestGraph& instance();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return a pointer to the root TestSuite.
|
@return a pointer to the root TestSuite.
|
||||||
*/
|
*/
|
||||||
TestSuite* root();
|
TestSuite* root();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A utility function for accessing an arbitrary quite by pathname, relative to
|
A utility function for accessing an arbitrary quite by pathname, relative to
|
||||||
the suite 'tsuite' (defaults to root if null), and with the option of creating
|
the suite 'tsuite' (defaults to root if null), and with the option of creating
|
||||||
the \em TestSuite designated by \em path, if it does not already exist.
|
the \em TestSuite designated by \em path, if it does not already exist.
|
||||||
|
|
||||||
This method may return 0 if the suite either cannot be found (and createIfNecssary
|
This method may return 0 if the suite either cannot be found (and createIfNecssary
|
||||||
is 0), or the first component of \em path is not the same as the name of the
|
is 0), or the first component of \em path is not the same as the name of the
|
||||||
TestSuite \em tsuite.
|
TestSuite \em tsuite.
|
||||||
|
|
||||||
This was written to aid the auto-registration of tests at specific points in
|
This was written to aid the auto-registration of tests at specific points in
|
||||||
the test tree, where the tests' AutoRegistrationAgents may be distributed across
|
the test tree, where the tests' AutoRegistrationAgents may be distributed across
|
||||||
several files, and cannot be guaranteed to run in a given order. E.g. You cannot
|
several files, and cannot be guaranteed to run in a given order. E.g. You cannot
|
||||||
register a test "root.osg.MyTest" unless you know that the the suite "root.osg"
|
register a test "root.osg.MyTest" unless you know that the the suite "root.osg"
|
||||||
already exists.
|
already exists.
|
||||||
|
|
||||||
|
|
||||||
@param path The name of the TestSuite to return.
|
@param path The name of the TestSuite to return.
|
||||||
@param tsuite The suite to 'start from'. Path is relative to this
|
@param tsuite The suite to 'start from'. Path is relative to this
|
||||||
suite (defaults to root suite).
|
suite (defaults to root suite).
|
||||||
@param createIfNecessary Optionally create the TestSuite(s) denoted by path if
|
@param createIfNecessary Optionally create the TestSuite(s) denoted by path if
|
||||||
they do not exist.
|
they do not exist.
|
||||||
*/
|
*/
|
||||||
TestSuite* suite(const std::string& path, TestSuite* tsuite = 0,bool createIfNecessary = false);
|
TestSuite* suite(const std::string& path, TestSuite* tsuite = 0,bool createIfNecessary = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Does the same job as the version of suite listed above, but the path
|
Does the same job as the version of suite listed above, but the path
|
||||||
is passed in as components in a list, represented by the iterator parameters.
|
is passed in as components in a list, represented by the iterator parameters.
|
||||||
*/
|
*/
|
||||||
TestSuite* suite(
|
TestSuite* suite(
|
||||||
std::list<std::string>::iterator it,
|
std::list<std::string>::iterator it,
|
||||||
std::list<std::string>::iterator end,
|
std::list<std::string>::iterator end,
|
||||||
TestSuite* tsuite, bool createIfNecessary);
|
TestSuite* tsuite, bool createIfNecessary);
|
||||||
|
|
||||||
TestGraph();
|
TestGraph();
|
||||||
|
|
||||||
TestGraph(const TestGraph&);
|
TestGraph(const TestGraph&);
|
||||||
TestGraph& operator=(const TestGraph&);
|
TestGraph& operator=(const TestGraph&);
|
||||||
|
|
||||||
osg::ref_ptr<TestSuite> root_;
|
osg::ref_ptr<TestSuite> root_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -330,22 +331,22 @@ current qualified TestSuite path.
|
|||||||
*/
|
*/
|
||||||
class SG_EXPORT TestQualifier : public TestVisitor
|
class SG_EXPORT TestQualifier : public TestVisitor
|
||||||
{
|
{
|
||||||
enum { SEPCHAR = '.' };
|
enum { SEPCHAR = '.' };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Entering a composite: Push its name on the Path
|
// Entering a composite: Push its name on the Path
|
||||||
virtual bool visitEnter( TestSuite* pSuite );
|
virtual bool visitEnter( TestSuite* pSuite );
|
||||||
|
|
||||||
// Leaving a composite: Pop its name from the Path
|
// Leaving a composite: Pop its name from the Path
|
||||||
virtual bool visitLeave( TestSuite* pSuite );
|
virtual bool visitLeave( TestSuite* pSuite );
|
||||||
|
|
||||||
// Provide read-only access to the current qualifier
|
// Provide read-only access to the current qualifier
|
||||||
const std::string& currentPath() const;
|
const std::string& currentPath() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string _path; // Current qualifier
|
std::string _path; // Current qualifier
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -357,50 +358,50 @@ class SG_EXPORT QualifiedTestPrinter : public TestQualifier
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
virtual bool visit( TestCase* pTest );
|
virtual bool visit( TestCase* pTest );
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A TestRecord records the output of a given test case, i.e. its start/stop time,
|
A TestRecord records the output of a given test case, i.e. its start/stop time,
|
||||||
its result, and a textual description of any problems.
|
its result, and a textual description of any problems.
|
||||||
|
|
||||||
\todo Consider adding accessor methods if necessary, to get the details
|
\todo Consider adding accessor methods if necessary, to get the details
|
||||||
stored in the TestRecord.
|
stored in the TestRecord.
|
||||||
*/
|
*/
|
||||||
class SG_EXPORT TestRecord
|
class SG_EXPORT TestRecord
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
void log(const TestFailureX& e);
|
void log(const TestFailureX& e);
|
||||||
void log(const TestErrorX& e);
|
void log(const TestErrorX& e);
|
||||||
void log(const std::exception& e);
|
void log(const std::exception& e);
|
||||||
void log(const std::string& s);
|
void log(const std::string& s);
|
||||||
|
|
||||||
// Default copy construction and assignment are OK
|
// Default copy construction and assignment are OK
|
||||||
|
|
||||||
// FIXME: Add accessors?
|
// FIXME: Add accessors?
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Onlye a TestReport can create a TestRecord
|
// Onlye a TestReport can create a TestRecord
|
||||||
friend class TestReport;
|
friend class TestReport;
|
||||||
TestRecord(const std::string& name);
|
TestRecord(const std::string& name);
|
||||||
|
|
||||||
enum Result{
|
enum Result{
|
||||||
Success,Failure,Error
|
Success,Failure,Error
|
||||||
};
|
};
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& o,const TestRecord& tr);
|
friend std::ostream& operator<<(std::ostream& o,const TestRecord& tr);
|
||||||
|
|
||||||
static osg::Timer timer_; // To time tests
|
static osg::Timer timer_; // To time tests
|
||||||
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
osg::Timer_t start_;
|
osg::Timer_t start_;
|
||||||
osg::Timer_t stop_;
|
osg::Timer_t stop_;
|
||||||
Result result_;
|
Result result_;
|
||||||
std::string problem_;
|
std::string problem_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -408,20 +409,20 @@ class SG_EXPORT TestRecord
|
|||||||
A TestReport represents the complete set of results (TestRecords) for a
|
A TestReport represents the complete set of results (TestRecords) for a
|
||||||
given test run.
|
given test run.
|
||||||
|
|
||||||
\todo Add support for printing the test report in various formats:
|
\todo Add support for printing the test report in various formats:
|
||||||
e.g. text, XML, CSV
|
e.g. text, XML, CSV
|
||||||
*/
|
*/
|
||||||
class SG_EXPORT TestReport
|
class SG_EXPORT TestReport
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TestRecord& createRecord(const std::string& s){
|
TestRecord& createRecord(const std::string& s){
|
||||||
_records.push_back(TestRecord(s));
|
_records.push_back(TestRecord(s));
|
||||||
return _records.back();
|
return _records.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<TestRecord> _records;
|
std::list<TestRecord> _records;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -435,37 +436,37 @@ private:
|
|||||||
A TestRunner is a visitor which will run specified tests as it traverses the
|
A TestRunner is a visitor which will run specified tests as it traverses the
|
||||||
test graph.
|
test graph.
|
||||||
|
|
||||||
\todo Consider an accessor method to get at the TestReport if necessary.
|
\todo Consider an accessor method to get at the TestReport if necessary.
|
||||||
*/
|
*/
|
||||||
class SG_EXPORT TestRunner : public TestQualifier
|
class SG_EXPORT TestRunner : public TestQualifier
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TestRunner( TestContext& ctx );
|
TestRunner( TestContext& ctx );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Tests may be specified by partial names. E.g. specifiying "root"
|
Tests may be specified by partial names. E.g. specifiying "root"
|
||||||
will run all tests below root, i.e. all tests.
|
will run all tests below root, i.e. all tests.
|
||||||
Specifiying "root.osg" will run all tests below \em root.osg.
|
Specifiying "root.osg" will run all tests below \em root.osg.
|
||||||
Specifying "root.osg.de" will run all tests (and suites) below
|
Specifying "root.osg.de" will run all tests (and suites) below
|
||||||
\em root.osg with names beginning with the \em de.
|
\em root.osg with names beginning with the \em de.
|
||||||
*/
|
*/
|
||||||
void specify( const std::string& sQualifiedName );
|
void specify( const std::string& sQualifiedName );
|
||||||
|
|
||||||
bool visitEnter( TestSuite* pSuite );
|
bool visitEnter( TestSuite* pSuite );
|
||||||
bool visit( TestCase* pTest );
|
bool visit( TestCase* pTest );
|
||||||
bool visitLeave( TestSuite* pSuite );
|
bool visitLeave( TestSuite* pSuite );
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void perform( TestCase* pTest );
|
void perform( TestCase* pTest );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
TestReport _db; // Results
|
TestReport _db; // Results
|
||||||
TestContext& _ctx; // The Global Testing Context
|
TestContext& _ctx; // The Global Testing Context
|
||||||
std::vector<std::string> _tests; // Specified Tests
|
std::vector<std::string> _tests; // Specified Tests
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -475,11 +476,11 @@ Starts a TestSuite singleton function
|
|||||||
@see OSGUTX_ADD_TESTCASE, OSGUTX_END_TESTSUITE
|
@see OSGUTX_ADD_TESTCASE, OSGUTX_END_TESTSUITE
|
||||||
*/
|
*/
|
||||||
#define OSGUTX_BEGIN_TESTSUITE( tsuite ) \
|
#define OSGUTX_BEGIN_TESTSUITE( tsuite ) \
|
||||||
osgUtx::TestSuite* tsuite##_TestSuite() \
|
osgUtx::TestSuite* tsuite##_TestSuite() \
|
||||||
{ \
|
{ \
|
||||||
static osg::ref_ptr<osgUtx::TestSuite> s_suite = 0; \
|
static osg::ref_ptr<osgUtx::TestSuite> s_suite = 0; \
|
||||||
if ( s_suite == 0 ) { \
|
if ( s_suite == 0 ) { \
|
||||||
s_suite = new osgUtx::TestSuite( #tsuite );
|
s_suite = new osgUtx::TestSuite( #tsuite );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -488,21 +489,21 @@ Adds a test case to a suite object being created in a TestSuite singleton functi
|
|||||||
@see OSGUTX_BEGIN_TESTSUITE, OSGUTX_END_TESTSUITE
|
@see OSGUTX_BEGIN_TESTSUITE, OSGUTX_END_TESTSUITE
|
||||||
*/
|
*/
|
||||||
#define OSGUTX_ADD_TESTCASE( tfixture, tmethod ) \
|
#define OSGUTX_ADD_TESTCASE( tfixture, tmethod ) \
|
||||||
s_suite->add( new osgUtx::TestCase_<tfixture>( \
|
s_suite->add( new osgUtx::TestCase_<tfixture>( \
|
||||||
#tmethod, &tfixture::tmethod ) );
|
#tmethod, &tfixture::tmethod ) );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Ends a TestSuite singleton function
|
Ends a TestSuite singleton function
|
||||||
@see OSGUTX_BEGIN_TESTSUITE, OSGUTX_ADD_TESTCASE
|
@see OSGUTX_BEGIN_TESTSUITE, OSGUTX_ADD_TESTCASE
|
||||||
*/
|
*/
|
||||||
#define OSGUTX_END_TESTSUITE \
|
#define OSGUTX_END_TESTSUITE \
|
||||||
} \
|
} \
|
||||||
return s_suite.get(); \
|
return s_suite.get(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Define a TestSuite accessor */
|
/** Define a TestSuite accessor */
|
||||||
#define OSGUTX_TESTSUITE( tsuite ) \
|
#define OSGUTX_TESTSUITE( tsuite ) \
|
||||||
tsuite##_TestSuite()
|
tsuite##_TestSuite()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -510,16 +511,16 @@ Adds a suite to a suite - allows composition of test suites.
|
|||||||
@see OSGUTX_BEGIN_TESTSUITE, OSGUTX_END_TESTSUITE
|
@see OSGUTX_BEGIN_TESTSUITE, OSGUTX_END_TESTSUITE
|
||||||
*/
|
*/
|
||||||
#define OSGUTX_ADD_TESTSUITE( childSuite ) \
|
#define OSGUTX_ADD_TESTSUITE( childSuite ) \
|
||||||
s_suite->add( childSuite##_TestSuite() );
|
s_suite->add( childSuite##_TestSuite() );
|
||||||
|
|
||||||
|
|
||||||
/** Autoregister a testsuite with the root suite at startup */
|
/** Autoregister a testsuite with the root suite at startup */
|
||||||
#define OSGUTX_AUTOREGISTER_TESTSUITE( tsuite ) \
|
#define OSGUTX_AUTOREGISTER_TESTSUITE( tsuite ) \
|
||||||
static osgUtx::TestSuiteAutoRegistrationAgent tsuite##_autoRegistrationObj__( tsuite##_TestSuite() );
|
static osgUtx::TestSuiteAutoRegistrationAgent tsuite##_autoRegistrationObj__( tsuite##_TestSuite() );
|
||||||
|
|
||||||
/** Auto register a testsuite with at designated point in the suite graph at startup */
|
/** Auto register a testsuite with at designated point in the suite graph at startup */
|
||||||
#define OSGUTX_AUTOREGISTER_TESTSUITE_AT( tsuite , path ) \
|
#define OSGUTX_AUTOREGISTER_TESTSUITE_AT( tsuite , path ) \
|
||||||
static osgUtx::TestSuiteAutoRegistrationAgent tsuite##_autoRegistrationObj__( tsuite##_TestSuite(), #path );
|
static osgUtx::TestSuiteAutoRegistrationAgent tsuite##_autoRegistrationObj__( tsuite##_TestSuite(), #path );
|
||||||
|
|
||||||
namespace osgUtx{
|
namespace osgUtx{
|
||||||
|
|
||||||
@ -531,21 +532,21 @@ direct use, it should be used via the following macros. (It's a secret agent :-)
|
|||||||
*/
|
*/
|
||||||
struct TestSuiteAutoRegistrationAgent
|
struct TestSuiteAutoRegistrationAgent
|
||||||
{
|
{
|
||||||
TestSuiteAutoRegistrationAgent(TestSuite* tsuite, const char* path = 0)
|
TestSuiteAutoRegistrationAgent(TestSuite* tsuite, const char* path = 0)
|
||||||
{
|
{
|
||||||
if( ! path ) path = "root";
|
if( ! path ) path = "root";
|
||||||
|
|
||||||
// Find the suite named in 'path', create it if necessary
|
// Find the suite named in 'path', create it if necessary
|
||||||
TestSuite *regSuite = osgUtx::TestGraph::instance().suite( path, 0, true );
|
TestSuite *regSuite = osgUtx::TestGraph::instance().suite( path, 0, true );
|
||||||
|
|
||||||
if(!regSuite){
|
if(!regSuite){
|
||||||
std::cerr<<"Warning, unable to register test suite named \""<<tsuite->name()<<"\" at "
|
osg::notify(osg::WARN)<<"Warning, unable to register test suite named \""<<tsuite->name()<<"\" at "
|
||||||
<<path<<", falling back to root suite."<<std::endl;
|
<<path<<", falling back to root suite."<<std::endl;
|
||||||
regSuite = osgUtx::TestGraph::instance().root();
|
regSuite = osgUtx::TestGraph::instance().root();
|
||||||
}
|
}
|
||||||
|
|
||||||
regSuite->add(tsuite);
|
regSuite->add(tsuite);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -560,11 +561,11 @@ The exception will indicate the file and line number of the failed expression,
|
|||||||
along with expression itself.
|
along with expression itself.
|
||||||
*/
|
*/
|
||||||
#define OSGUTX_TEST_F( expr ) \
|
#define OSGUTX_TEST_F( expr ) \
|
||||||
if( !(expr) ){ \
|
if( !(expr) ){ \
|
||||||
std::stringstream ss; \
|
std::stringstream ss; \
|
||||||
ss<< #expr <<" failure: "<<__FILE__<<", line "<<__LINE__<<std::ends; \
|
ss<< #expr <<" failure: "<<__FILE__<<", line "<<__LINE__<<std::ends; \
|
||||||
throw osgUtx::TestFailureX(ss.str()); \
|
throw osgUtx::TestFailureX(ss.str()); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
OSGUTX_TEST_E is a convenience macro, analogous to assert(), which will
|
OSGUTX_TEST_E is a convenience macro, analogous to assert(), which will
|
||||||
@ -576,11 +577,11 @@ The exception will indicate the file and line number of the failed expression,
|
|||||||
along with expression itself.
|
along with expression itself.
|
||||||
*/
|
*/
|
||||||
#define OSGUTX_TEST_E( expr ) \
|
#define OSGUTX_TEST_E( expr ) \
|
||||||
if( !(expr) ){ \
|
if( !(expr) ){ \
|
||||||
std::stringstream ss; \
|
std::stringstream ss; \
|
||||||
ss<< #expr <<" error: "<<__FILE__<<", line "<<__LINE__<<std::ends; \
|
ss<< #expr <<" error: "<<__FILE__<<", line "<<__LINE__<<std::ends; \
|
||||||
throw osgUtx::TestErrorX(ss.str()); \
|
throw osgUtx::TestErrorX(ss.str()); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // OSG_UNITTESTFRAMEWORK
|
#endif // OSG_UNITTESTFRAMEWORK
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <osg/Math>
|
#include <osg/Math>
|
||||||
|
|
||||||
#include <iostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <osg/Math>
|
#include <osg/Math>
|
||||||
|
|
||||||
#include <iostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <osg/Vec3>
|
#include <osg/Vec3>
|
||||||
|
|
||||||
#include <iostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <istream>
|
||||||
|
|
||||||
namespace osgDB {
|
namespace osgDB {
|
||||||
|
|
||||||
|
@ -25,20 +25,8 @@ CullingSet::~CullingSet()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintNodePath(const NodePath& nodePath)
|
|
||||||
{
|
|
||||||
for(NodePath::const_iterator itr=nodePath.begin();
|
|
||||||
itr!=nodePath.end();
|
|
||||||
++itr)
|
|
||||||
{
|
|
||||||
std::cout<<*itr<<" ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CullingSet::disableAndPushOccludersCurrentMask(NodePath& nodePath)
|
void CullingSet::disableAndPushOccludersCurrentMask(NodePath& nodePath)
|
||||||
{
|
{
|
||||||
//std::cout<<" trying to disable occluder ";PrintNodePath(nodePath);std::cout<<std::endl;
|
|
||||||
for(OccluderList::iterator itr=_occluderList.begin();
|
for(OccluderList::iterator itr=_occluderList.begin();
|
||||||
itr!=_occluderList.end();
|
itr!=_occluderList.end();
|
||||||
++itr)
|
++itr)
|
||||||
|
@ -401,8 +401,6 @@ void Image::readImageFromCurrentTexture(unsigned int contextID)
|
|||||||
|
|
||||||
allocateImage(width,height,1,internalformat,internalformat);
|
allocateImage(width,height,1,internalformat,internalformat);
|
||||||
|
|
||||||
std::cout << "width="<<width<<" height="<<height<<" internalFormat="<<internalformat<<" _internalFormat="<<_internalTextureFormat<<std::endl;
|
|
||||||
|
|
||||||
extensions->glGetCompressedTexImage(GL_TEXTURE_2D, 0, _data);
|
extensions->glGetCompressedTexImage(GL_TEXTURE_2D, 0, _data);
|
||||||
|
|
||||||
_internalTextureFormat = internalformat;
|
_internalTextureFormat = internalformat;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <osg/Notify>
|
#include <osg/Notify>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -64,7 +64,6 @@ void PagedLOD::traverse(NodeVisitor& nv)
|
|||||||
{
|
{
|
||||||
if (updateTimeStamp) _perRangeDataList[i]._timeStamp=timeStamp;
|
if (updateTimeStamp) _perRangeDataList[i]._timeStamp=timeStamp;
|
||||||
|
|
||||||
//std::cout<<"PagedLOD::traverse() - Selecting child "<<i<<std::endl;
|
|
||||||
_children[i]->accept(nv);
|
_children[i]->accept(nv);
|
||||||
lastChildTraversed = (int)i;
|
lastChildTraversed = (int)i;
|
||||||
}
|
}
|
||||||
@ -79,11 +78,9 @@ void PagedLOD::traverse(NodeVisitor& nv)
|
|||||||
{
|
{
|
||||||
unsigned int numChildren = _children.size();
|
unsigned int numChildren = _children.size();
|
||||||
|
|
||||||
//std::cout<<"PagedLOD::traverse() - falling back "<<std::endl;
|
|
||||||
// select the last valid child.
|
// select the last valid child.
|
||||||
if (numChildren>0 && ((int)numChildren-1)!=lastChildTraversed)
|
if (numChildren>0 && ((int)numChildren-1)!=lastChildTraversed)
|
||||||
{
|
{
|
||||||
//std::cout<<" to child "<<numChildren-1<<std::endl;
|
|
||||||
if (updateTimeStamp) _perRangeDataList[numChildren-1]._timeStamp=timeStamp;
|
if (updateTimeStamp) _perRangeDataList[numChildren-1]._timeStamp=timeStamp;
|
||||||
_children[numChildren-1]->accept(nv);
|
_children[numChildren-1]->accept(nv);
|
||||||
}
|
}
|
||||||
@ -97,7 +94,6 @@ void PagedLOD::traverse(NodeVisitor& nv)
|
|||||||
// modify the priority according to the child's priority offset and scale.
|
// modify the priority according to the child's priority offset and scale.
|
||||||
priority = _perRangeDataList[numChildren]._priorityOffset + priority * _perRangeDataList[numChildren]._priorityScale;
|
priority = _perRangeDataList[numChildren]._priorityOffset + priority * _perRangeDataList[numChildren]._priorityScale;
|
||||||
|
|
||||||
//std::cout<<" requesting child "<<_fileNameList[numChildren]<<" priotity = "<<priority<<std::endl;
|
|
||||||
nv.getDatabaseRequestHandler()->requestNodeFile(_perRangeDataList[numChildren]._filename,this,priority,nv.getFrameStamp());
|
nv.getDatabaseRequestHandler()->requestNodeFile(_perRangeDataList[numChildren]._filename,this,priority,nv.getFrameStamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,25 +127,21 @@ bool PagedLOD::computeBound() const
|
|||||||
void PagedLOD::childRemoved(unsigned int pos, unsigned int numChildrenToRemove)
|
void PagedLOD::childRemoved(unsigned int pos, unsigned int numChildrenToRemove)
|
||||||
{
|
{
|
||||||
LOD::childRemoved(pos, numChildrenToRemove);
|
LOD::childRemoved(pos, numChildrenToRemove);
|
||||||
//std::cout<<"PagedLOD::childRemoved("<<pos<<","<<numChildrenToRemove<<")"<<std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PagedLOD::childInserted(unsigned int pos)
|
void PagedLOD::childInserted(unsigned int pos)
|
||||||
{
|
{
|
||||||
LOD::childInserted(pos);
|
LOD::childInserted(pos);
|
||||||
//std::cout<<"PagedLOD::childInserted("<<pos<<")"<<std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PagedLOD::rangeRemoved(unsigned int pos, unsigned int numChildrenToRemove)
|
void PagedLOD::rangeRemoved(unsigned int pos, unsigned int numChildrenToRemove)
|
||||||
{
|
{
|
||||||
LOD::rangeRemoved(pos, numChildrenToRemove);
|
LOD::rangeRemoved(pos, numChildrenToRemove);
|
||||||
std::cout<<"PagedLOD::rangeRemoved("<<pos<<","<<numChildrenToRemove<<")"<<std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PagedLOD::rangeInserted(unsigned int pos)
|
void PagedLOD::rangeInserted(unsigned int pos)
|
||||||
{
|
{
|
||||||
LOD::rangeInserted(pos);
|
LOD::rangeInserted(pos);
|
||||||
std::cout<<"PagedLOD::rangeInserted("<<pos<<")"<<std::endl;
|
|
||||||
expandPerRangeDataTo(pos);
|
expandPerRangeDataTo(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +201,7 @@ void PagedLOD::removeExpiredChildren(double expiryTime,NodeList& removedChildren
|
|||||||
{
|
{
|
||||||
if (!_perRangeDataList[_children.size()-1]._filename.empty() && _perRangeDataList[_children.size()-1]._timeStamp<expiryTime)
|
if (!_perRangeDataList[_children.size()-1]._filename.empty() && _perRangeDataList[_children.size()-1]._timeStamp<expiryTime)
|
||||||
{
|
{
|
||||||
|
//removedChildren.push_back(_children[_children.size()-1].get());
|
||||||
Group::removeChild(_children[_children.size()-1].get());
|
Group::removeChild(_children[_children.size()-1].get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -827,9 +827,9 @@ void DrawShapeVisitor::apply(const Capsule& capsule)
|
|||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawShapeVisitor::apply(const InfinitePlane& plane)
|
void DrawShapeVisitor::apply(const InfinitePlane&)
|
||||||
{
|
{
|
||||||
std::cout << "draw a Plane ("<<plane<<") "<<std::endl;
|
notify(NOTICE)<<"Warning: DrawShapeVisitor::apply(const InfinitePlane& plane) not yet implementated. "<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawShapeVisitor::apply(const TriangleMesh& mesh)
|
void DrawShapeVisitor::apply(const TriangleMesh& mesh)
|
||||||
@ -1661,9 +1661,9 @@ void PrimitiveShapeVisitor::apply(const Capsule& /*capsule*/)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitiveShapeVisitor::apply(const InfinitePlane& plane)
|
void PrimitiveShapeVisitor::apply(const InfinitePlane&)
|
||||||
{
|
{
|
||||||
std::cout << "Primitive a Plane ("<<plane<<") "<<std::endl;
|
notify(NOTICE)<<"Warning: PrimitiveShapeVisitor::apply(const InfinitePlane& plane) not yet implementated. "<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitiveShapeVisitor::apply(const TriangleMesh& mesh)
|
void PrimitiveShapeVisitor::apply(const TriangleMesh& mesh)
|
||||||
|
@ -385,7 +385,7 @@ bool TestSuite::accept( Test::Visitor& v )
|
|||||||
|
|
||||||
bool QualifiedTestPrinter::visit( TestCase* pTest )
|
bool QualifiedTestPrinter::visit( TestCase* pTest )
|
||||||
{
|
{
|
||||||
std::cout << currentPath() + pTest->name() << std::endl;
|
osg::notify(osg::NOTICE) << currentPath() + pTest->name() << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,9 @@ int UniformValue::getLocation( Extensions *ext, const GLhandleARB progObj ) cons
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef sgi
|
||||||
|
template <>
|
||||||
|
#endif
|
||||||
void UniformValue_int::apply( Extensions *ext, const GLhandleARB progObj ) const
|
void UniformValue_int::apply( Extensions *ext, const GLhandleARB progObj ) const
|
||||||
{
|
{
|
||||||
int loc = getLocation( ext, progObj );
|
int loc = getLocation( ext, progObj );
|
||||||
@ -47,6 +50,9 @@ void UniformValue_int::apply( Extensions *ext, const GLhandleARB progObj ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef sgi
|
||||||
|
template <>
|
||||||
|
#endif
|
||||||
void UniformValue_float::apply( Extensions *ext, const GLhandleARB progObj ) const
|
void UniformValue_float::apply( Extensions *ext, const GLhandleARB progObj ) const
|
||||||
{
|
{
|
||||||
int loc = getLocation( ext, progObj );
|
int loc = getLocation( ext, progObj );
|
||||||
@ -56,6 +62,9 @@ void UniformValue_float::apply( Extensions *ext, const GLhandleARB progObj ) con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef sgi
|
||||||
|
template <>
|
||||||
|
#endif
|
||||||
void UniformValue_Vec2::apply( Extensions *ext, const GLhandleARB progObj ) const
|
void UniformValue_Vec2::apply( Extensions *ext, const GLhandleARB progObj ) const
|
||||||
{
|
{
|
||||||
int loc = getLocation( ext, progObj );
|
int loc = getLocation( ext, progObj );
|
||||||
@ -65,6 +74,9 @@ void UniformValue_Vec2::apply( Extensions *ext, const GLhandleARB progObj ) cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef sgi
|
||||||
|
template <>
|
||||||
|
#endif
|
||||||
void UniformValue_Vec3::apply( Extensions *ext, const GLhandleARB progObj ) const
|
void UniformValue_Vec3::apply( Extensions *ext, const GLhandleARB progObj ) const
|
||||||
{
|
{
|
||||||
int loc = getLocation( ext, progObj );
|
int loc = getLocation( ext, progObj );
|
||||||
@ -74,6 +86,9 @@ void UniformValue_Vec3::apply( Extensions *ext, const GLhandleARB progObj ) cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef sgi
|
||||||
|
template <>
|
||||||
|
#endif
|
||||||
void UniformValue_Vec4::apply( Extensions *ext, const GLhandleARB progObj ) const
|
void UniformValue_Vec4::apply( Extensions *ext, const GLhandleARB progObj ) const
|
||||||
{
|
{
|
||||||
int loc = getLocation( ext, progObj );
|
int loc = getLocation( ext, progObj );
|
||||||
|
@ -45,15 +45,12 @@ class ReaderWriter3DC : public osgDB::ReaderWriter
|
|||||||
if (line[0]=='#')
|
if (line[0]=='#')
|
||||||
{
|
{
|
||||||
// comment line
|
// comment line
|
||||||
std::cout <<"Comment: "<<line<<std::endl;
|
osg::notify(osg::INFO) <<"Comment: "<<line<<std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
++num;
|
++num;
|
||||||
}
|
}
|
||||||
//std::cout << "["<<std::endl;
|
|
||||||
//std::cout <<line<<std::endl;
|
|
||||||
//std::cout <<"]"<<std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ class ReaderWriterAC : public osgDB::ReaderWriter
|
|||||||
// else if(dynamic_cast<const osg::Geode*>(&node))
|
// else if(dynamic_cast<const osg::Geode*>(&node))
|
||||||
// const_cast<ac3d::Geode*>(static_cast<const ac3d::Geode*>(&node))->Process(fout);
|
// const_cast<ac3d::Geode*>(static_cast<const ac3d::Geode*>(&node))->Process(fout);
|
||||||
else
|
else
|
||||||
std::cout<<"File must start with a geode "<<std::endl;
|
osg::notify(osg::WARN)<<"File must start with a geode "<<std::endl;
|
||||||
fout.flush();
|
fout.flush();
|
||||||
return WriteResult::FILE_SAVED;
|
return WriteResult::FILE_SAVED;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ osgText::Font::Glyph* FreeTypeFont::getGlyph(unsigned int charcode)
|
|||||||
FT_Error error = FT_Load_Char( _face, charcode, FT_LOAD_RENDER|FT_LOAD_NO_BITMAP );
|
FT_Error error = FT_Load_Char( _face, charcode, FT_LOAD_RENDER|FT_LOAD_NO_BITMAP );
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
std::cout << "FT_Load_Char(...) error "<<error<<std::endl;
|
osg::notify(osg::WARN) << "FT_Load_Char(...) error "<<error<<std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FreeTypeLibrary.h"
|
#include "FreeTypeLibrary.h"
|
||||||
|
#include <osg/Notify>
|
||||||
|
|
||||||
FreeTypeLibrary::FreeTypeLibrary()
|
FreeTypeLibrary::FreeTypeLibrary()
|
||||||
{
|
{
|
||||||
FT_Error error = FT_Init_FreeType( &_ftlibrary );
|
FT_Error error = FT_Init_FreeType( &_ftlibrary );
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
std::cout<<"Warning: an error occured during FT_Init_FreeType(..) initialisation .. "<<std::endl;
|
osg::notify(osg::WARN)<<"Warning: an error occured during FT_Init_FreeType(..) initialisation .. "<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -58,14 +58,14 @@ osgText::Font* FreeTypeLibrary::getFont(const std::string& fontfile,unsigned int
|
|||||||
FT_Error error = FT_New_Face( _ftlibrary, fontfile.c_str(), index, &face );
|
FT_Error error = FT_New_Face( _ftlibrary, fontfile.c_str(), index, &face );
|
||||||
if (error == FT_Err_Unknown_File_Format)
|
if (error == FT_Err_Unknown_File_Format)
|
||||||
{
|
{
|
||||||
std::cout<<" .... the font file could be opened and read, but it appears"<<std::endl;
|
osg::notify(osg::WARN)<<" .... the font file could be opened and read, but it appears"<<std::endl;
|
||||||
std::cout<<" .... that its font format is unsupported"<<std::endl;
|
osg::notify(osg::WARN)<<" .... that its font format is unsupported"<<std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (error)
|
else if (error)
|
||||||
{
|
{
|
||||||
std::cout<<" .... another error code means that the font file could notd"<<std::endl;
|
osg::notify(osg::WARN)<<" .... another error code means that the font file could notd"<<std::endl;
|
||||||
std::cout<<" .... be opened, read or simply that it is broken..d"<<std::endl;
|
osg::notify(osg::WARN)<<" .... be opened, read or simply that it is broken..d"<<std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,19 +181,19 @@ public:
|
|||||||
}
|
}
|
||||||
bool addFlat( const georecord *gface)
|
bool addFlat( const georecord *gface)
|
||||||
{ // this must only be called with a vertex georecord.
|
{ // this must only be called with a vertex georecord.
|
||||||
bool isflat=false;
|
bool isflat=false;
|
||||||
const geoField *gfshade=gface->getField(GEO_DB_POLY_SHADEMODEL); // shaded gouraud, flat...
|
const geoField *gfshade=gface->getField(GEO_DB_POLY_SHADEMODEL); // shaded gouraud, flat...
|
||||||
int shademodel=gfshade ? gfshade->getInt() : -1;
|
int shademodel=gfshade ? gfshade->getInt() : -1;
|
||||||
if (shademodel==GEO_POLY_SHADEMODEL_LIT) { // flat shaded - need the index
|
if (shademodel==GEO_POLY_SHADEMODEL_LIT) { // flat shaded - need the index
|
||||||
const geoField *gfd=gface->getField(GEO_DB_POLY_NORMAL);
|
const geoField *gfd=gface->getField(GEO_DB_POLY_NORMAL);
|
||||||
if (gfd) {
|
if (gfd) {
|
||||||
float *normal= (gfd) ? (gfd->getVec3Arr()):NULL;
|
float *normal= (gfd) ? (gfd->getVec3Arr()):NULL;
|
||||||
osg::Vec3 nrm(normal[0], normal[1], normal[2]);
|
osg::Vec3 nrm(normal[0], normal[1], normal[2]);
|
||||||
norms->push_back(nrm);
|
norms->push_back(nrm);
|
||||||
isflat=true;
|
isflat=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isflat;
|
return isflat;
|
||||||
}
|
}
|
||||||
bool addIndices(georecord *gr, const geoHeaderGeo *ghdr, const float cdef[4], const georecord *gface)
|
bool addIndices(georecord *gr, const geoHeaderGeo *ghdr, const float cdef[4], const georecord *gface)
|
||||||
{ // this must only be called with a vertex georecord.
|
{ // this must only be called with a vertex georecord.
|
||||||
@ -203,38 +203,38 @@ public:
|
|||||||
const geoField *gfshade=gface->getField(GEO_DB_POLY_SHADEMODEL); // shaded gouraud, flat...
|
const geoField *gfshade=gface->getField(GEO_DB_POLY_SHADEMODEL); // shaded gouraud, flat...
|
||||||
int shademodel=gfshade ? gfshade->getInt() : -1;
|
int shademodel=gfshade ? gfshade->getInt() : -1;
|
||||||
if (shademodel!=GEO_POLY_SHADEMODEL_LIT && shademodel!=GEO_POLY_SHADEMODEL_FLAT) {
|
if (shademodel!=GEO_POLY_SHADEMODEL_LIT && shademodel!=GEO_POLY_SHADEMODEL_FLAT) {
|
||||||
const geoField *gfd=gr->getField(GEO_DB_VRTX_NORMAL);
|
const geoField *gfd=gr->getField(GEO_DB_VRTX_NORMAL);
|
||||||
if (gfd->getType()==DB_UINT) {
|
if (gfd->getType()==DB_UINT) {
|
||||||
if (gfd) {
|
if (gfd) {
|
||||||
unsigned int idx=gfd->getUInt();
|
unsigned int idx=gfd->getUInt();
|
||||||
normindices->push_back(idx);
|
normindices->push_back(idx);
|
||||||
norms->push_back((*npool)[idx]);
|
norms->push_back((*npool)[idx]);
|
||||||
} else {
|
} else {
|
||||||
osg::notify(osg::WARN) << "No valid vertex index" << std::endl;
|
osg::notify(osg::WARN) << "No valid vertex index" << std::endl;
|
||||||
}
|
}
|
||||||
} else if (gfd->getType()==DB_VEC3F) {
|
} else if (gfd->getType()==DB_VEC3F) {
|
||||||
float *p=gfd->getVec3Arr();
|
float *p=gfd->getVec3Arr();
|
||||||
osg::Vec3 nrm;
|
osg::Vec3 nrm;
|
||||||
nrm.set(p[0],p[1],p[2]);
|
nrm.set(p[0],p[1],p[2]);
|
||||||
norms->push_back(nrm);
|
norms->push_back(nrm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const geoField *gfd=gr->getField(GEO_DB_VRTX_COORD);
|
const geoField *gfd=gr->getField(GEO_DB_VRTX_COORD);
|
||||||
osg::Vec3 pos;
|
osg::Vec3 pos;
|
||||||
if (gfd->getType()==DB_INT) {
|
if (gfd->getType()==DB_INT) {
|
||||||
if (gfd) {
|
if (gfd) {
|
||||||
int idx=gfd->getInt();
|
int idx=gfd->getInt();
|
||||||
pos=(*cpool)[idx];
|
pos=(*cpool)[idx];
|
||||||
coords->push_back((*cpool)[idx]); //osg::Vec3(cpool[3*idx],cpool[3*idx+1],cpool[3*idx+2]));
|
coords->push_back((*cpool)[idx]); //osg::Vec3(cpool[3*idx],cpool[3*idx+1],cpool[3*idx+2]));
|
||||||
coordindices->push_back(coords->size());
|
coordindices->push_back(coords->size());
|
||||||
} else {
|
} else {
|
||||||
osg::notify(osg::WARN) << "No valid vertex index" << std::endl;
|
osg::notify(osg::WARN) << "No valid vertex index" << std::endl;
|
||||||
}
|
}
|
||||||
} else if (gfd->getType()==DB_VEC3F) {
|
} else if (gfd->getType()==DB_VEC3F) {
|
||||||
float *p=gfd->getVec3Arr();
|
float *p=gfd->getVec3Arr();
|
||||||
pos.set(p[0],p[1],p[2]);
|
pos.set(p[0],p[1],p[2]);
|
||||||
coords->push_back(pos); //osg::Vec3(cpool[3*idx],cpool[3*idx+1],cpool[3*idx+2]));
|
coords->push_back(pos); //osg::Vec3(cpool[3*idx],cpool[3*idx+1],cpool[3*idx+2]));
|
||||||
}
|
}
|
||||||
std::vector< georecord *>bhv=gr->getBehaviour(); // behaviours for vertices, eg tranlate, colour!
|
std::vector< georecord *>bhv=gr->getBehaviour(); // behaviours for vertices, eg tranlate, colour!
|
||||||
if (!bhv.empty()) {
|
if (!bhv.empty()) {
|
||||||
int ncoord=coords->size();
|
int ncoord=coords->size();
|
||||||
@ -281,15 +281,15 @@ public:
|
|||||||
gfd=gr->getField(GEO_DB_VRTX_UV_SET_0);
|
gfd=gr->getField(GEO_DB_VRTX_UV_SET_0);
|
||||||
if (gfd) {
|
if (gfd) {
|
||||||
uvc=(float *)gfd->getstore(0);
|
uvc=(float *)gfd->getstore(0);
|
||||||
|
|
||||||
if (uvc) { // then there are tx coords
|
if (uvc) { // then there are tx coords
|
||||||
osg::Vec2 uv(uvc[0], uvc[1]);
|
osg::Vec2 uv(uvc[0], uvc[1]);
|
||||||
txcoords->push_back(uv);
|
txcoords->push_back(uv);
|
||||||
} else {
|
} else {
|
||||||
txcoords->push_back(osg::Vec2(0,0));
|
txcoords->push_back(osg::Vec2(0,0));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
txcoords->push_back(osg::Vec2(0,0));
|
txcoords->push_back(osg::Vec2(0,0));
|
||||||
}
|
}
|
||||||
gfd=gr->getField(GEO_DB_VRTX_PACKED_COLOR);
|
gfd=gr->getField(GEO_DB_VRTX_PACKED_COLOR);
|
||||||
if (gfd) {
|
if (gfd) {
|
||||||
@ -365,8 +365,8 @@ public:
|
|||||||
void setPools(const std::vector<osg::Vec3> *coord_pool, const std::vector<osg::Vec3> *normal_pool) {
|
void setPools(const std::vector<osg::Vec3> *coord_pool, const std::vector<osg::Vec3> *normal_pool) {
|
||||||
vinf.setPools(coord_pool,normal_pool);
|
vinf.setPools(coord_pool,normal_pool);
|
||||||
}
|
}
|
||||||
float getlinewidth(void) const { return linewidth;}
|
float getlinewidth(void) const { return linewidth;}
|
||||||
void setlineWidth(const int w) { linewidth=w;}
|
void setlineWidth(const int w) { linewidth=w;}
|
||||||
void setGeom(osg::Geometry *nugeom) { geom=nugeom;}
|
void setGeom(osg::Geometry *nugeom) { geom=nugeom;}
|
||||||
osg::Geometry *getGeom() { return geom.get();}
|
osg::Geometry *getGeom() { return geom.get();}
|
||||||
uint getStart(uint nv) { uint ns=nstart; nstart+=nv; return ns; }
|
uint getStart(uint nv) { uint ns=nstart; nstart+=nv; return ns; }
|
||||||
@ -381,10 +381,10 @@ private:
|
|||||||
int texture; // texture index
|
int texture; // texture index
|
||||||
int bothsides; // none, back,front
|
int bothsides; // none, back,front
|
||||||
int shademodel;
|
int shademodel;
|
||||||
int linewidth;
|
int linewidth;
|
||||||
vertexInfo vinf;
|
vertexInfo vinf;
|
||||||
uint nstart; // start vertex for a primitive
|
uint nstart; // start vertex for a primitive
|
||||||
osg::ref_ptr<osg::Geometry> geom; // the geometry created for this vinf and texture
|
osg::ref_ptr<osg::Geometry> geom; // the geometry created for this vinf and texture
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -422,7 +422,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
{
|
{
|
||||||
georecord gr;
|
georecord gr;
|
||||||
gr.readfile(fin);
|
gr.readfile(fin);
|
||||||
// osg::notify(osg::WARN) << "end of record " << (int)gr.getType() << std::endl;
|
// osg::notify(osg::WARN) << "end of record " << (int)gr.getType() << std::endl;
|
||||||
if (gr.getType() == DB_DSK_NORMAL_POOL) {
|
if (gr.getType() == DB_DSK_NORMAL_POOL) {
|
||||||
geoField *gfff=gr.getModField(GEO_DB_NORMAL_POOL_VALUES);
|
geoField *gfff=gr.getModField(GEO_DB_NORMAL_POOL_VALUES);
|
||||||
gfff->uncompress();// uncompress the normals
|
gfff->uncompress();// uncompress the normals
|
||||||
@ -440,7 +440,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
output(fout,sorted);
|
output(fout,sorted);
|
||||||
fout.close();
|
fout.close();
|
||||||
#endif /**/
|
#endif /**/
|
||||||
makeHeader(*(sorted.begin()));
|
makeHeader(*(sorted.begin()));
|
||||||
|
|
||||||
nodeList=makeosg(sorted); // make a list of osg nodes
|
nodeList=makeosg(sorted); // make a list of osg nodes
|
||||||
geotxlist.clear();
|
geotxlist.clear();
|
||||||
@ -450,7 +450,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
matlist.clear();/* */
|
matlist.clear();/* */
|
||||||
coord_pool.clear();
|
coord_pool.clear();
|
||||||
normal_pool.clear();
|
normal_pool.clear();
|
||||||
osg::Node * groupnode = NULL;
|
osg::Node * groupnode = NULL;
|
||||||
if (nodeList.empty())
|
if (nodeList.empty())
|
||||||
{
|
{
|
||||||
return ReadResult("No data loaded from "+fileName);
|
return ReadResult("No data loaded from "+fileName);
|
||||||
@ -461,7 +461,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osg::Group *group = new Group;
|
osg::Group *group = new Group;
|
||||||
group->setName("import group");
|
group->setName("import group");
|
||||||
for(NodeList::iterator itr=nodeList.begin();
|
for(NodeList::iterator itr=nodeList.begin();
|
||||||
itr!=nodeList.end();
|
itr!=nodeList.end();
|
||||||
@ -469,12 +469,12 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
{
|
{
|
||||||
group->addChild(*itr);
|
group->addChild(*itr);
|
||||||
}
|
}
|
||||||
groupnode=group;
|
groupnode=group;
|
||||||
}
|
}
|
||||||
(theHeader.get())->addChild(groupnode);
|
(theHeader.get())->addChild(groupnode);
|
||||||
groupnode=theHeader.get();
|
groupnode=theHeader.get();
|
||||||
#ifdef _DEBUG // output a .osg version
|
#ifdef _DEBUG // output a .osg version
|
||||||
osgDB::writeNodeFile(*groupnode,"geoosg.osg");
|
osgDB::writeNodeFile(*groupnode,"geoosg.osg");
|
||||||
#endif /**/
|
#endif /**/
|
||||||
recs.clear();
|
recs.clear();
|
||||||
return groupnode;
|
return groupnode;
|
||||||
@ -496,8 +496,8 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
case 101: // old header - not appropriate!
|
case 101: // old header - not appropriate!
|
||||||
curparent= &(*itr);
|
curparent= &(*itr);
|
||||||
sorted.push_back(&(*itr));
|
sorted.push_back(&(*itr));
|
||||||
osg::notify(osg::WARN) << "Old version 2 header block found - possible error!" << std::endl;
|
osg::notify(osg::WARN) << "Old version 2 header block found - possible error!" << std::endl;
|
||||||
break;
|
break;
|
||||||
case DB_DSK_PUSH:
|
case DB_DSK_PUSH:
|
||||||
if (!(curparent->getchildren().empty())) {
|
if (!(curparent->getchildren().empty())) {
|
||||||
curparent= curparent->getLastChild(); // itr-1;
|
curparent= curparent->getLastChild(); // itr-1;
|
||||||
@ -511,7 +511,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
case DB_DSK_HEADER: // attach to previous
|
case DB_DSK_HEADER: // attach to previous
|
||||||
curparent= &(*itr);
|
curparent= &(*itr);
|
||||||
sorted.push_back(&(*itr));
|
sorted.push_back(&(*itr));
|
||||||
cpalrec=NULL;
|
cpalrec=NULL;
|
||||||
break;
|
break;
|
||||||
case DB_DSK_INTERNAL_VARS: // attach to parent
|
case DB_DSK_INTERNAL_VARS: // attach to parent
|
||||||
case DB_DSK_LOCAL_VARS:
|
case DB_DSK_LOCAL_VARS:
|
||||||
@ -586,12 +586,12 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
case DB_DSK_IF_THEN_ELSE_ACTION:
|
case DB_DSK_IF_THEN_ELSE_ACTION:
|
||||||
case DB_DSK_DCS_ACTION:
|
case DB_DSK_DCS_ACTION:
|
||||||
case DB_DSK_SQRT_ACTION: // an action
|
case DB_DSK_SQRT_ACTION: // an action
|
||||||
if (curparent->getType()==DB_DSK_HEADER)
|
if (curparent->getType()==DB_DSK_HEADER)
|
||||||
curparent->addBehaviourRecord(&(*itr));
|
curparent->addBehaviourRecord(&(*itr));
|
||||||
else {
|
else {
|
||||||
class georecord *cp=curparent->getLastChild();
|
class georecord *cp=curparent->getLastChild();
|
||||||
if (cp) cp->addBehaviourRecord(&(*itr));
|
if (cp) cp->addBehaviourRecord(&(*itr));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DB_DSK_PERSPECTIVE_GRID_INFO: // Feb 2003 not sure what this is yet!
|
case DB_DSK_PERSPECTIVE_GRID_INFO: // Feb 2003 not sure what this is yet!
|
||||||
(curparent)->addchild(&(*itr));
|
(curparent)->addchild(&(*itr));
|
||||||
@ -649,7 +649,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
const vertexInfo *vinf=ginf.getVinf();
|
const vertexInfo *vinf=ginf.getVinf();
|
||||||
nug->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
nug->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||||
nug->setVertexArray(vinf->getCoords());
|
nug->setVertexArray(vinf->getCoords());
|
||||||
StateSet *dstate=new StateSet;
|
StateSet *dstate=new StateSet;
|
||||||
if (bothsides==0) {
|
if (bothsides==0) {
|
||||||
osg::CullFace *cf = new osg::CullFace; // to define non-default culling
|
osg::CullFace *cf = new osg::CullFace; // to define non-default culling
|
||||||
cf->setMode(osg::CullFace::BACK);
|
cf->setMode(osg::CullFace::BACK);
|
||||||
@ -710,20 +710,20 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
nug->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
nug->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (shademodel==GEO_POLY_SHADEMODEL_LIT_GOURAUD) {
|
if (shademodel==GEO_POLY_SHADEMODEL_LIT_GOURAUD) {
|
||||||
nug->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
nug->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||||
} else if (shademodel==GEO_POLY_SHADEMODEL_LIT) {
|
} else if (shademodel==GEO_POLY_SHADEMODEL_LIT) {
|
||||||
nug->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
nug->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||||
}
|
}
|
||||||
osg::Vec4Array *polycols=vinf->getPolcolours();
|
osg::Vec4Array *polycols=vinf->getPolcolours();
|
||||||
nug->setColorArray(polycols);
|
nug->setColorArray(polycols);
|
||||||
nug->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
nug->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
osg::LineWidth *lw=new osg::LineWidth;
|
osg::LineWidth *lw=new osg::LineWidth;
|
||||||
lw->setWidth(ginf.getlinewidth());
|
lw->setWidth(ginf.getlinewidth());
|
||||||
dstate->setAttributeAndModes(lw,osg::StateAttribute::ON);
|
dstate->setAttributeAndModes(lw,osg::StateAttribute::ON);
|
||||||
nug->setStateSet( dstate );
|
nug->setStateSet( dstate );
|
||||||
ginf.setGeom(nug);
|
ginf.setGeom(nug);
|
||||||
return nug;
|
return nug;
|
||||||
@ -754,11 +754,11 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gr.size()>0) {
|
if (gr.size()>0) {
|
||||||
vinf->addFlat(grec); // for flat normal shading
|
vinf->addFlat(grec); // for flat normal shading
|
||||||
for (std::vector<georecord *>::const_iterator itr=gr.begin();
|
for (std::vector<georecord *>::const_iterator itr=gr.begin();
|
||||||
itr!=gr.end();
|
itr!=gr.end();
|
||||||
++itr) {
|
++itr) {
|
||||||
vinf->addIndices((*itr), theHeader.get(), defcol, grec);
|
vinf->addIndices((*itr), theHeader.get(), defcol, grec);
|
||||||
nv++;
|
nv++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -782,7 +782,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
osg::MatrixTransform *makeText(georecord *gr) { // make transform, geode & text
|
osg::MatrixTransform *makeText(georecord *gr) { // make transform, geode & text
|
||||||
osg::MatrixTransform *numt=NULL;
|
osg::MatrixTransform *numt=NULL;
|
||||||
std::string ttfPath("fonts/times.ttf");
|
std::string ttfPath("fonts/times.ttf");
|
||||||
// unused
|
// unused
|
||||||
//int gFontSize1=2;
|
//int gFontSize1=2;
|
||||||
osgText::Text *text= new osgText::Text;
|
osgText::Text *text= new osgText::Text;
|
||||||
text->setFont(ttfPath);
|
text->setFont(ttfPath);
|
||||||
@ -823,7 +823,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
textState->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
textState->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||||
geod->setStateSet( textState );
|
geod->setStateSet( textState );
|
||||||
numt=new osg::MatrixTransform;
|
numt=new osg::MatrixTransform;
|
||||||
numt->setName(name);
|
numt->setName(name);
|
||||||
gfd=gr->getField(GEO_DB_TEXT_MATRIX);
|
gfd=gr->getField(GEO_DB_TEXT_MATRIX);
|
||||||
if (gfd) {
|
if (gfd) {
|
||||||
float *fmat=gfd->getMat44Arr();
|
float *fmat=gfd->getMat44Arr();
|
||||||
@ -899,18 +899,18 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
if ((*itr)->getType()==DB_DSK_VERTEX)
|
if ((*itr)->getType()==DB_DSK_VERTEX)
|
||||||
{ // light point vertices
|
{ // light point vertices
|
||||||
const geoField *gfd=(*itr)->getField(GEO_DB_VRTX_COORD);
|
const geoField *gfd=(*itr)->getField(GEO_DB_VRTX_COORD);
|
||||||
osg::Vec3 pos;
|
osg::Vec3 pos;
|
||||||
if (gfd->getType()==DB_INT) {
|
if (gfd->getType()==DB_INT) {
|
||||||
if (gfd) {
|
if (gfd) {
|
||||||
int idx=gfd->getInt();
|
int idx=gfd->getInt();
|
||||||
pos=coord_pool[idx];
|
pos=coord_pool[idx];
|
||||||
} else {
|
} else {
|
||||||
osg::notify(osg::WARN) << "No valid vertex index" << std::endl;
|
osg::notify(osg::WARN) << "No valid vertex index" << std::endl;
|
||||||
}
|
}
|
||||||
} else if (gfd->getType()==DB_VEC3F) {
|
} else if (gfd->getType()==DB_VEC3F) {
|
||||||
float *p=gfd->getVec3Arr();
|
float *p=gfd->getVec3Arr();
|
||||||
pos.set(p[0],p[1],p[2]);
|
pos.set(p[0],p[1],p[2]);
|
||||||
}
|
}
|
||||||
gfd=(*itr)->getField(GEO_DB_VRTX_PACKED_COLOR);
|
gfd=(*itr)->getField(GEO_DB_VRTX_PACKED_COLOR);
|
||||||
if (gfd) {
|
if (gfd) {
|
||||||
unsigned char *cls=gfd->getUCh4Arr();
|
unsigned char *cls=gfd->getUCh4Arr();
|
||||||
@ -949,16 +949,16 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
int makeAnimatedGeometry(const georecord grec, const int imat,Group *nug) {
|
int makeAnimatedGeometry(const georecord grec, const int imat,Group *nug) {
|
||||||
// animated polygons - create a matrix & geode & poly & add to group nug
|
// animated polygons - create a matrix & geode & poly & add to group nug
|
||||||
const std::vector<georecord *> gr=grec.getchildren();
|
const std::vector<georecord *> gr=grec.getchildren();
|
||||||
int nanimations=0;
|
int nanimations=0;
|
||||||
const geoField *gfd=grec.getField(GEO_DB_RENDERGROUP_CULLING); // back, front, none
|
const geoField *gfd=grec.getField(GEO_DB_RENDERGROUP_CULLING); // back, front, none
|
||||||
unsigned int bothsides=gfd ? gfd->getUInt() : 0;
|
unsigned int bothsides=gfd ? gfd->getUInt() : 0;
|
||||||
// int bothsides =allOneSided(&grec);
|
// int bothsides =allOneSided(&grec);
|
||||||
for (std::vector<georecord *>::const_iterator itr=gr.begin();
|
for (std::vector<georecord *>::const_iterator itr=gr.begin();
|
||||||
itr!=gr.end();
|
itr!=gr.end();
|
||||||
++itr) {
|
++itr) {
|
||||||
std::vector< georecord *>bhv=(*itr)->getBehaviour(); // behaviours attached to facets, eg colour!
|
std::vector< georecord *>bhv=(*itr)->getBehaviour(); // behaviours attached to facets, eg colour!
|
||||||
if ((*itr)->getType()==DB_DSK_POLYGON && !bhv.empty()) { // animated facets go here
|
if ((*itr)->getType()==DB_DSK_POLYGON && !bhv.empty()) { // animated facets go here
|
||||||
nanimations++;
|
nanimations++;
|
||||||
if (hasMotionAction(bhv)) { // make matrix if motion needed.
|
if (hasMotionAction(bhv)) { // make matrix if motion needed.
|
||||||
const geoField *gfd=(*itr)->getField(GEO_DB_POLY_TEX0);
|
const geoField *gfd=(*itr)->getField(GEO_DB_POLY_TEX0);
|
||||||
int txidx= gfd ? gfd->getInt() : -1;
|
int txidx= gfd ? gfd->getInt() : -1;
|
||||||
@ -1064,11 +1064,11 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
int shademodel=gfd ? gfd->getInt() : GEO_POLY_SHADEMODEL_LIT_GOURAUD;
|
int shademodel=gfd ? gfd->getInt() : GEO_POLY_SHADEMODEL_LIT_GOURAUD;
|
||||||
geoInfo gi(txidx,shademodel, bothsides);
|
geoInfo gi(txidx,shademodel, bothsides);
|
||||||
gi.setPools(&coord_pool, &normal_pool);
|
gi.setPools(&coord_pool, &normal_pool);
|
||||||
gfd=grec->getField(GEO_DB_POLY_LINE_WIDTH); // integer line width...
|
gfd=grec->getField(GEO_DB_POLY_LINE_WIDTH); // integer line width...
|
||||||
if (gfd) {
|
if (gfd) {
|
||||||
int w=gfd->getInt();
|
int w=gfd->getInt();
|
||||||
gi.setlineWidth(w);
|
gi.setlineWidth(w);
|
||||||
}
|
}
|
||||||
osg::Geometry *nugeom=makeNewGeometry(grec, gi, imat);
|
osg::Geometry *nugeom=makeNewGeometry(grec, gi, imat);
|
||||||
nug->addDrawable(nugeom);
|
nug->addDrawable(nugeom);
|
||||||
igeom=ia->size();
|
igeom=ia->size();
|
||||||
@ -1083,7 +1083,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
if (gr.size()>0) {
|
if (gr.size()>0) {
|
||||||
std::vector<class geoInfo> ia; // list of texture indices & vinfo found in this geode; sort into new
|
std::vector<class geoInfo> ia; // list of texture indices & vinfo found in this geode; sort into new
|
||||||
const geoField *gfd=grec.getField(GEO_DB_RENDERGROUP_CULLING); // back, front, none
|
const geoField *gfd=grec.getField(GEO_DB_RENDERGROUP_CULLING); // back, front, none
|
||||||
unsigned int bothsides=gfd ? gfd->getUInt() : 0;
|
unsigned int bothsides=gfd ? gfd->getUInt() : 0;
|
||||||
// vertexInfo vinf(&coord_pool, &normal_pool); // holds all types of coords, indices etc
|
// vertexInfo vinf(&coord_pool, &normal_pool); // holds all types of coords, indices etc
|
||||||
// bool bothsides=allOneSided(&grec);
|
// bool bothsides=allOneSided(&grec);
|
||||||
for (std::vector<georecord *>::const_iterator itr=gr.begin();
|
for (std::vector<georecord *>::const_iterator itr=gr.begin();
|
||||||
@ -1121,15 +1121,15 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int nv=getprim((*itr), *gi);
|
int nv=getprim((*itr), *gi);
|
||||||
{
|
{
|
||||||
const vertexInfo *vinf=gi->getVinf();
|
const vertexInfo *vinf=gi->getVinf();
|
||||||
if (vinf->getNorms() && vinf->getNorms()->size()>0) {
|
if (vinf->getNorms() && vinf->getNorms()->size()>0) {
|
||||||
gi->getGeom()->setNormalArray(vinf->getNorms());
|
gi->getGeom()->setNormalArray(vinf->getNorms());
|
||||||
gi->getGeom()->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
gi->getGeom()->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||||
} else {
|
} else {
|
||||||
gi->getGeom()->setNormalBinding(osg::Geometry::BIND_OFF);
|
gi->getGeom()->setNormalBinding(osg::Geometry::BIND_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasColorAction(bhv)) addPolyActions(bhv, *gi, nv);
|
if (hasColorAction(bhv)) addPolyActions(bhv, *gi, nv);
|
||||||
|
|
||||||
if (dstyle==GEO_POLY_DSTYLE_SOLID_BOTH_SIDES || dstyle == GEO_POLY_DSTYLE_SOLID) {
|
if (dstyle==GEO_POLY_DSTYLE_SOLID_BOTH_SIDES || dstyle == GEO_POLY_DSTYLE_SOLID) {
|
||||||
@ -1189,7 +1189,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
Group *makeTextGeode(const georecord *gr)
|
Group *makeTextGeode(const georecord *gr)
|
||||||
{ // in geo text is defined with a matrix included in the geo.geode (gr is this geo.geode)
|
{ // in geo text is defined with a matrix included in the geo.geode (gr is this geo.geode)
|
||||||
// - we need to create this tree to render text
|
// - we need to create this tree to render text
|
||||||
return NULL; // temporary disable april 2003
|
return NULL; // temporary disable april 2003
|
||||||
Group *nug=new Group;
|
Group *nug=new Group;
|
||||||
const geoField *gfd=gr->getField(GEO_DB_RENDERGROUP_MAT);
|
const geoField *gfd=gr->getField(GEO_DB_RENDERGROUP_MAT);
|
||||||
// may be used in future const unsigned int imat=gfd ? gfd->getInt():0;
|
// may be used in future const unsigned int imat=gfd ? gfd->getInt():0;
|
||||||
@ -1251,7 +1251,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
const unsigned int imat=gfd ? gfd->getInt():0;
|
const unsigned int imat=gfd ? gfd->getInt():0;
|
||||||
gfd=gr.getField(GEO_DB_RENDERGROUP_BILLBOARD);
|
gfd=gr.getField(GEO_DB_RENDERGROUP_BILLBOARD);
|
||||||
bool isbillb = gfd ? gfd->getBool() : false;
|
bool isbillb = gfd ? gfd->getBool() : false;
|
||||||
osg::Geode *nug;
|
osg::Geode *nug;
|
||||||
if (isbillb) {
|
if (isbillb) {
|
||||||
Billboard *bilb= new Billboard ;
|
Billboard *bilb= new Billboard ;
|
||||||
bilb->setAxis(Vec3(0,0,1));
|
bilb->setAxis(Vec3(0,0,1));
|
||||||
@ -1261,15 +1261,15 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
nug=new Geode;
|
nug=new Geode;
|
||||||
}
|
}
|
||||||
int nchild=makeGeometry(gr,imat,nug);
|
int nchild=makeGeometry(gr,imat,nug);
|
||||||
if (nchild>0) { // complete the geode
|
if (nchild>0) { // complete the geode
|
||||||
gfd=gr.getField(GEO_DB_NODE_NAME);
|
gfd=gr.getField(GEO_DB_NODE_NAME);
|
||||||
if (gfd) {
|
if (gfd) {
|
||||||
nug->setName(gfd->getChar());
|
nug->setName(gfd->getChar());
|
||||||
}
|
}
|
||||||
return nug;
|
return nug;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
osg::Group *makePage(const georecord *gr)
|
osg::Group *makePage(const georecord *gr)
|
||||||
{
|
{
|
||||||
@ -1280,11 +1280,11 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
}
|
}
|
||||||
return gp;
|
return gp;
|
||||||
}
|
}
|
||||||
osg::Group *setmatrix(const georecord *gr) { // find one of the types of matrix supported
|
osg::Group *setmatrix(const georecord *gr) { // find one of the types of matrix supported
|
||||||
const geoField *gfd=gr->getField(GEO_DB_GRP_MATRIX_TRANSFORM);
|
const geoField *gfd=gr->getField(GEO_DB_GRP_MATRIX_TRANSFORM);
|
||||||
if (!gfd) gfd=gr->getField(GEO_DB_GRP_TRANSLATE_TRANSFORM);
|
if (!gfd) gfd=gr->getField(GEO_DB_GRP_TRANSLATE_TRANSFORM);
|
||||||
if (!gfd) gfd=gr->getField(GEO_DB_GRP_ROTATE_TRANSFORM);
|
if (!gfd) gfd=gr->getField(GEO_DB_GRP_ROTATE_TRANSFORM);
|
||||||
if (!gfd) gfd=gr->getField(GEO_DB_GRP_SCALE_TRANSFORM);
|
if (!gfd) gfd=gr->getField(GEO_DB_GRP_SCALE_TRANSFORM);
|
||||||
if (gfd) {
|
if (gfd) {
|
||||||
MatrixTransform *tr=new MatrixTransform;
|
MatrixTransform *tr=new MatrixTransform;
|
||||||
osg::Matrix mx;
|
osg::Matrix mx;
|
||||||
@ -1295,7 +1295,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
osg::Group *makeGroup(const georecord *gr) { // group or Static transform
|
osg::Group *makeGroup(const georecord *gr) { // group or Static transform
|
||||||
osg::Group *gp=setmatrix(gr);
|
osg::Group *gp=setmatrix(gr);
|
||||||
if (!gp) {
|
if (!gp) {
|
||||||
@ -1359,41 +1359,41 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
}
|
}
|
||||||
return gp;
|
return gp;
|
||||||
}
|
}
|
||||||
osg::Drawable* createClipSurface(float xMin,float xMax,float yMin,float yMax,float z)
|
osg::Drawable* createClipSurface(float xMin,float xMax,float yMin,float yMax,float z)
|
||||||
{ // set up the Geometry that defines the clipped region.
|
{ // set up the Geometry that defines the clipped region.
|
||||||
osg::Geometry* geom = new osg::Geometry;
|
osg::Geometry* geom = new osg::Geometry;
|
||||||
|
|
||||||
osg::Vec3Array* coords = new osg::Vec3Array(4);
|
osg::Vec3Array* coords = new osg::Vec3Array(4);
|
||||||
(*coords)[0].set(xMin,yMax,z);
|
(*coords)[0].set(xMin,yMax,z);
|
||||||
(*coords)[1].set(xMin,yMin,z);
|
(*coords)[1].set(xMin,yMin,z);
|
||||||
(*coords)[2].set(xMax,yMin,z);
|
(*coords)[2].set(xMax,yMin,z);
|
||||||
(*coords)[3].set(xMax,yMax,z);
|
(*coords)[3].set(xMax,yMax,z);
|
||||||
geom->setVertexArray(coords);
|
geom->setVertexArray(coords);
|
||||||
|
|
||||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
|
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
|
||||||
|
|
||||||
return geom;
|
return geom;
|
||||||
}
|
}
|
||||||
Group *makeClipRegion(const georecord *gr) {
|
Group *makeClipRegion(const georecord *gr) {
|
||||||
GeoClipRegion *clp=new GeoClipRegion;
|
GeoClipRegion *clp=new GeoClipRegion;
|
||||||
const geoField *gfd=gr->getField(GEO_DB_NODE_NAME);
|
const geoField *gfd=gr->getField(GEO_DB_NODE_NAME);
|
||||||
if (gfd) {
|
if (gfd) {
|
||||||
clp->setName(gfd->getChar());
|
clp->setName(gfd->getChar());
|
||||||
}
|
}
|
||||||
gfd=gr->getField(140);
|
gfd=gr->getField(140);
|
||||||
float *lleft = (gfd) ? (gfd->getVec3Arr()):NULL;
|
float *lleft = (gfd) ? (gfd->getVec3Arr()):NULL;
|
||||||
gfd=gr->getField(141);
|
gfd=gr->getField(141);
|
||||||
float *uright= (gfd) ? (gfd->getVec3Arr()):NULL;
|
float *uright= (gfd) ? (gfd->getVec3Arr()):NULL;
|
||||||
if (uright && lleft) {
|
if (uright && lleft) {
|
||||||
Geode *geod=new Geode;
|
Geode *geod=new Geode;
|
||||||
Drawable *drw=createClipSurface(lleft[0],uright[0],lleft[1],uright[1],lleft[2]);
|
Drawable *drw=createClipSurface(lleft[0],uright[0],lleft[1],uright[1],lleft[2]);
|
||||||
geod->addDrawable(drw);
|
geod->addDrawable(drw);
|
||||||
clp->addClipNode(geod);
|
clp->addClipNode(geod);
|
||||||
}
|
}
|
||||||
return clp;
|
return clp;
|
||||||
}
|
}
|
||||||
geoHeader *makeHeader(const georecord *gr) {
|
geoHeader *makeHeader(const georecord *gr) {
|
||||||
if (!theHeader.valid()) theHeader=new geoHeaderGeo();
|
if (!theHeader.valid()) theHeader=new geoHeaderGeo();
|
||||||
// the header contains variables as well as a transform for the XYZup cases
|
// the header contains variables as well as a transform for the XYZup cases
|
||||||
const geoField *gfd;
|
const geoField *gfd;
|
||||||
if (cpalrec) { // global - attach to geoheader
|
if (cpalrec) { // global - attach to geoheader
|
||||||
@ -1709,23 +1709,23 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
Group *animatedGeodes= makeAnimatedGeodes(gr);
|
Group *animatedGeodes= makeAnimatedGeodes(gr);
|
||||||
Group *lightptGeodes= makeLightPointGeodes(gr);
|
Group *lightptGeodes= makeLightPointGeodes(gr);
|
||||||
Group *textgeode=makeTextGeode(gr); // group of matrices & texts
|
Group *textgeode=makeTextGeode(gr); // group of matrices & texts
|
||||||
const geoField *gfd=gr->getField(GEO_DB_GRP_ZBUFFER);
|
const geoField *gfd=gr->getField(GEO_DB_GRP_ZBUFFER);
|
||||||
if (gfd) {
|
if (gfd) {
|
||||||
bool onoff=gfd->getBool();
|
bool onoff=gfd->getBool();
|
||||||
if (!onoff) { // no z buffer - force to use unsorted renderBin
|
if (!onoff) { // no z buffer - force to use unsorted renderBin
|
||||||
StateSet *dstate=new StateSet;
|
StateSet *dstate=new StateSet;
|
||||||
osg::Depth* depth = new osg::Depth;
|
osg::Depth* depth = new osg::Depth;
|
||||||
depth->setFunction(osg::Depth::ALWAYS);
|
depth->setFunction(osg::Depth::ALWAYS);
|
||||||
dstate->setAttribute(depth);
|
dstate->setAttribute(depth);
|
||||||
dstate->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
|
dstate->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
|
||||||
dstate->setRenderBinDetails(osg::StateSet::TRANSPARENT_BIN + 1,"RenderBin");
|
dstate->setRenderBinDetails(osg::StateSet::TRANSPARENT_BIN + 1,"RenderBin");
|
||||||
// dstate->setRenderBinDetails(osg::StateSet::TRANSPARENT_BIN + 12, "UnSortedBin");
|
// dstate->setRenderBinDetails(osg::StateSet::TRANSPARENT_BIN + 12, "UnSortedBin");
|
||||||
if (geode) geode->setStateSet( dstate );
|
if (geode) geode->setStateSet( dstate );
|
||||||
if (animatedGeodes) animatedGeodes->setStateSet( dstate );
|
if (animatedGeodes) animatedGeodes->setStateSet( dstate );
|
||||||
if (lightptGeodes) lightptGeodes->setStateSet( dstate );
|
if (lightptGeodes) lightptGeodes->setStateSet( dstate );
|
||||||
if (textgeode) textgeode->setStateSet( dstate );
|
if (textgeode) textgeode->setStateSet( dstate );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mtr) {
|
if (mtr) {
|
||||||
if (geode) mtr->addChild(geode);
|
if (geode) mtr->addChild(geode);
|
||||||
@ -1737,7 +1737,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
} else {
|
} else {
|
||||||
if (!geodeholder && (geode || textgeode)) {
|
if (!geodeholder && (geode || textgeode)) {
|
||||||
geodeholder=new osg::Group;
|
geodeholder=new osg::Group;
|
||||||
geodeholder->setName("geodeHolder");
|
geodeholder->setName("geodeHolder");
|
||||||
}
|
}
|
||||||
if (geode) geodeholder->addChild(geode);
|
if (geode) geodeholder->addChild(geode);
|
||||||
if (animatedGeodes) geodeholder->addChild(animatedGeodes);
|
if (animatedGeodes) geodeholder->addChild(animatedGeodes);
|
||||||
@ -1756,12 +1756,12 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
holder=mtr;
|
holder=mtr;
|
||||||
}
|
}
|
||||||
(*itr)->setNode(holder);
|
(*itr)->setNode(holder);
|
||||||
break;
|
break;
|
||||||
/* holder= theHeader.get(); // makeHeader(gr);//
|
/* holder= theHeader.get(); // makeHeader(gr);//
|
||||||
(*itr)->setNode(holder);
|
(*itr)->setNode(holder);
|
||||||
if (mtr) {
|
if (mtr) {
|
||||||
holder->addChild(mtr);
|
holder->addChild(mtr);
|
||||||
osg::Group *grp=makeGroup(gr);
|
osg::Group *grp=makeGroup(gr);
|
||||||
mtr->addChild(grp);
|
mtr->addChild(grp);
|
||||||
holder=mtr;
|
holder=mtr;
|
||||||
}
|
}
|
||||||
@ -1770,7 +1770,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
makeTexture(gr);
|
makeTexture(gr);
|
||||||
break;
|
break;
|
||||||
case DB_DSK_BASE_GROUP: // start of a group plus extra features
|
case DB_DSK_BASE_GROUP: // start of a group plus extra features
|
||||||
holder=makeClipRegion(gr);
|
holder=makeClipRegion(gr);
|
||||||
if (mtr) {
|
if (mtr) {
|
||||||
mtr->addChild(holder);
|
mtr->addChild(holder);
|
||||||
holder=mtr;
|
holder=mtr;
|
||||||
@ -1862,9 +1862,9 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
(*itr)->setNode(holder);
|
(*itr)->setNode(holder);
|
||||||
break;
|
break;
|
||||||
case DB_DSK_PERSPECTIVE_GRID_INFO:
|
case DB_DSK_PERSPECTIVE_GRID_INFO:
|
||||||
{ // relates to how model is viewed in Geo modeller
|
{ // relates to how model is viewed in Geo modeller
|
||||||
osg::Group *gp=new Group;
|
osg::Group *gp=new Group;
|
||||||
holder=gp;
|
holder=gp;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DB_DSK_FLOAT_VAR:
|
case DB_DSK_FLOAT_VAR:
|
||||||
@ -1892,8 +1892,8 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
case DB_DSK_STRING_CONTENT_ACTION:
|
case DB_DSK_STRING_CONTENT_ACTION:
|
||||||
default: {
|
default: {
|
||||||
osg::Group *gp=new Group;
|
osg::Group *gp=new Group;
|
||||||
std::cout << "Unhandled item " << gr->getType() <<
|
osg::notify(osg::WARN) << "Unhandled item " << gr->getType() <<
|
||||||
"address " << (*itr) << std::endl;
|
"address " << (*itr) << std::endl;
|
||||||
holder=gp;
|
holder=gp;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1901,11 +1901,11 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
if (holder) nodelist.push_back(holder);
|
if (holder) nodelist.push_back(holder);
|
||||||
|
|
||||||
std::vector<Node *> child=makeosg((*itr)->getchildren());
|
std::vector<Node *> child=makeosg((*itr)->getchildren());
|
||||||
GeoClipRegion *clip=dynamic_cast<GeoClipRegion *>(holder);
|
GeoClipRegion *clip=dynamic_cast<GeoClipRegion *>(holder);
|
||||||
for (std::vector<Node *>::iterator itr=child.begin();
|
for (std::vector<Node *>::iterator itr=child.begin();
|
||||||
itr!=child.end();
|
itr!=child.end();
|
||||||
++itr) {
|
++itr) {
|
||||||
if (clip) clip->addClippedChild(*itr);
|
if (clip) clip->addClippedChild(*itr);
|
||||||
else holder->addChild(*itr);
|
else holder->addChild(*itr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1998,12 +1998,12 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
geoRecordList recs; // the records read from file
|
geoRecordList recs; // the records read from file
|
||||||
std::vector<osg::Vec3> coord_pool; // current vertex ooords
|
std::vector<osg::Vec3> coord_pool; // current vertex ooords
|
||||||
std::vector<osg::Vec3> normal_pool; // current pool of normal vectors
|
std::vector<osg::Vec3> normal_pool; // current pool of normal vectors
|
||||||
osg::ref_ptr<geoHeaderGeo> theHeader; // an OSG class - has animation vars etc
|
osg::ref_ptr<geoHeaderGeo> theHeader; // an OSG class - has animation vars etc
|
||||||
std::vector<georecord *> geotxlist; // list of geo::textures for this model
|
std::vector<georecord *> geotxlist; // list of geo::textures for this model
|
||||||
std::vector<georecord *> geomatlist; // list of geo::materials for this model
|
std::vector<georecord *> geomatlist; // list of geo::materials for this model
|
||||||
std::vector<osg::Texture2D *> txlist; // list of osg::textures for this model
|
std::vector<osg::Texture2D *> txlist; // list of osg::textures for this model
|
||||||
@ -2135,65 +2135,65 @@ void internalVars::update(const osg::FrameStamp *_frameStamp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void geoField::parseExt(std::ifstream &fin) const { // Feb 2003 parse onme extension fields
|
void geoField::parseExt(std::ifstream &fin) const { // Feb 2003 parse onme extension fields
|
||||||
static int nread=0; // debug only
|
static int nread=0; // debug only
|
||||||
// unused
|
// unused
|
||||||
//geoExtensionDefRec *geoExt=(geoExtensionDefRec *)storage;
|
//geoExtensionDefRec *geoExt=(geoExtensionDefRec *)storage;
|
||||||
for (uint i=0; i<numItems; i++) {
|
for (uint i=0; i<numItems; i++) {
|
||||||
geoExtensionDefRec rec;
|
geoExtensionDefRec rec;
|
||||||
fin.read((char *)&rec,sizeof(rec));
|
fin.read((char *)&rec,sizeof(rec));
|
||||||
geoField ginner; // inside reading
|
geoField ginner; // inside reading
|
||||||
ginner.readfile(fin,0);
|
ginner.readfile(fin,0);
|
||||||
}
|
}
|
||||||
nread++;
|
nread++;
|
||||||
}
|
}
|
||||||
void geoField::readfile(std::ifstream &fin, const uint id) { // is part of a record id
|
void geoField::readfile(std::ifstream &fin, const uint id) { // is part of a record id
|
||||||
unsigned char tokid, type;
|
unsigned char tokid, type;
|
||||||
unsigned short nits;
|
unsigned short nits;
|
||||||
if (!fin.eof()) {
|
if (!fin.eof()) {
|
||||||
fin.read((char *)&tokid,1);fin.read((char *)&type,1);
|
fin.read((char *)&tokid,1);fin.read((char *)&type,1);
|
||||||
fin.read((char *)&nits,sizeof(unsigned short));
|
fin.read((char *)&nits,sizeof(unsigned short));
|
||||||
// osg::notify(osg::WARN) << "geoField " << (int)tokid << " type " << (int)type << " nit " << (int)nits << std::endl;
|
// osg::notify(osg::WARN) << "geoField " << (int)tokid << " type " << (int)type << " nit " << (int)nits << std::endl;
|
||||||
if (type == DB_EXTENDED_FIELD_STRUCT) { // change for true extended type
|
if (type == DB_EXTENDED_FIELD_STRUCT) { // change for true extended type
|
||||||
fin.read((char *)&tokenId,sizeof(tokenId));fin.read((char *)&TypeId,sizeof(TypeId));
|
fin.read((char *)&tokenId,sizeof(tokenId));fin.read((char *)&TypeId,sizeof(TypeId));
|
||||||
fin.read((char *)&numItems,sizeof(unsigned int));
|
fin.read((char *)&numItems,sizeof(unsigned int));
|
||||||
} else {
|
} else {
|
||||||
tokenId=tokid; TypeId=type;
|
tokenId=tokid; TypeId=type;
|
||||||
numItems=nits;
|
numItems=nits;
|
||||||
}
|
}
|
||||||
if (id== 0 && tokenId == GEO_DB_NODE_EXTENDED && numItems==1) { // Feb 2003 parse extension template records
|
if (id== 0 && tokenId == GEO_DB_NODE_EXTENDED && numItems==1) { // Feb 2003 parse extension template records
|
||||||
if (TypeId == DB_SHORT ||
|
if (TypeId == DB_SHORT ||
|
||||||
TypeId == DB_USHORT) {
|
TypeId == DB_USHORT) {
|
||||||
short upad;
|
short upad;
|
||||||
fin.read((char *)&upad,SIZEOF_SHORT); // skip the padding on extension template
|
fin.read((char *)&upad,SIZEOF_SHORT); // skip the padding on extension template
|
||||||
upad=1;
|
upad=1;
|
||||||
} else if (TypeId == DB_CHAR ||
|
} else if (TypeId == DB_CHAR ||
|
||||||
TypeId == DB_UCHAR) {
|
TypeId == DB_UCHAR) {
|
||||||
char cpad[4];
|
char cpad[4];
|
||||||
fin.read(cpad,SIZEOF_CHAR); // skip the padding
|
fin.read(cpad,SIZEOF_CHAR); // skip the padding
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (id== DB_DSK_HEADER && tokenId == GEO_DB_HDR_EXT_TEMPLATE) { // Feb 2003 parse extension records
|
if (id== DB_DSK_HEADER && tokenId == GEO_DB_HDR_EXT_TEMPLATE) { // Feb 2003 parse extension records
|
||||||
// osg::notify(osg::WARN) << "header extension template " << (int)getType() << std::endl;
|
// osg::notify(osg::WARN) << "header extension template " << (int)getType() << std::endl;
|
||||||
parseExt(fin); // multiple structs occur here
|
parseExt(fin); // multiple structs occur here
|
||||||
} else {
|
} else {
|
||||||
if (numItems>0) {
|
if (numItems>0) {
|
||||||
storageRead(fin); // allocate & fill the storage
|
storageRead(fin); // allocate & fill the storage
|
||||||
if (tokenId == GEO_DB_NODE_EXT) { // added Nov 2003 to parse extension nodes
|
if (tokenId == GEO_DB_NODE_EXT) { // added Nov 2003 to parse extension nodes
|
||||||
if (TypeId == DB_SHORT ||TypeId == DB_USHORT) fin.ignore(2); // skip padding
|
if (TypeId == DB_SHORT ||TypeId == DB_USHORT) fin.ignore(2); // skip padding
|
||||||
// if (TypeId == DB_CHAR ||TypeId == DB_UCHAR) fin.ignore(3); // skip padding
|
// if (TypeId == DB_CHAR ||TypeId == DB_UCHAR) fin.ignore(3); // skip padding
|
||||||
}
|
}
|
||||||
if (tokenId == GEO_DB_NODE_EXTENDED) {
|
if (tokenId == GEO_DB_NODE_EXTENDED) {
|
||||||
if (id==DB_DSK_POLYGON || id==DB_DSK_RENDERGROUP || id==DB_DSK_GROUP
|
if (id==DB_DSK_POLYGON || id==DB_DSK_RENDERGROUP || id==DB_DSK_GROUP
|
||||||
|| id==DB_DSK_LOD || id==DB_DSK_MESH || id==DB_DSK_CUBE
|
|| id==DB_DSK_LOD || id==DB_DSK_MESH || id==DB_DSK_CUBE
|
||||||
|| id==DB_DSK_SPHERE || id==DB_DSK_CONE || id==DB_DSK_CYLINDER
|
|| id==DB_DSK_SPHERE || id==DB_DSK_CONE || id==DB_DSK_CYLINDER
|
||||||
|| id==DB_DSK_TEXTURE || id==DB_DSK_MATERIAL || id==DB_DSK_VIEW) {
|
|| id==DB_DSK_TEXTURE || id==DB_DSK_MATERIAL || id==DB_DSK_VIEW) {
|
||||||
if (TypeId == DB_SHORT ||TypeId == DB_USHORT) fin.ignore(2); // skip padding
|
if (TypeId == DB_SHORT ||TypeId == DB_USHORT) fin.ignore(2); // skip padding
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace osg;
|
using namespace osg;
|
||||||
@ -41,7 +42,9 @@ class PrintVisitor : public NodeVisitor
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PrintVisitor():NodeVisitor(NodeVisitor::TRAVERSE_ALL_CHILDREN)
|
PrintVisitor(std::ostream& out):
|
||||||
|
NodeVisitor(NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||||
|
_out(out)
|
||||||
{
|
{
|
||||||
_indent = 0;
|
_indent = 0;
|
||||||
_step = 4;
|
_step = 4;
|
||||||
@ -51,29 +54,32 @@ class PrintVisitor : public NodeVisitor
|
|||||||
inline void moveOut() { _indent -= _step; }
|
inline void moveOut() { _indent -= _step; }
|
||||||
inline void writeIndent()
|
inline void writeIndent()
|
||||||
{
|
{
|
||||||
for(int i=0;i<_indent;++i) std::cout << " ";
|
for(int i=0;i<_indent;++i) _out << " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void apply(Node& node)
|
virtual void apply(Node& node)
|
||||||
{
|
{
|
||||||
moveIn();
|
moveIn();
|
||||||
writeIndent(); std::cout << node.className() << " name=" << node.getName() << std::endl;
|
writeIndent(); _out << node.className() <<std::endl;
|
||||||
traverse(node);
|
traverse(node);
|
||||||
moveOut();
|
moveOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void apply(Geode& node) { apply((Node&)node); }
|
virtual void apply(Geode& node) { apply((Node&)node); }
|
||||||
virtual void apply(Billboard& node) { apply((Geode&)node); }
|
virtual void apply(Billboard& node) { apply((Geode&)node); }
|
||||||
virtual void apply(LightSource& node) { apply((Node&)node); }
|
virtual void apply(LightSource& node) { apply((Group&)node); }
|
||||||
|
virtual void apply(ClipNode& node) { apply((Group&)node); }
|
||||||
|
|
||||||
virtual void apply(Group& node) { apply((Node&)node); }
|
virtual void apply(Group& node) { apply((Node&)node); }
|
||||||
virtual void apply(Transform& node) { apply((Group&)node); }
|
virtual void apply(Transform& node) { apply((Group&)node); }
|
||||||
|
virtual void apply(Projection& node) { apply((Group&)node); }
|
||||||
virtual void apply(Switch& node) { apply((Group&)node); }
|
virtual void apply(Switch& node) { apply((Group&)node); }
|
||||||
virtual void apply(LOD& node) { apply((Group&)node); }
|
virtual void apply(LOD& node) { apply((Group&)node); }
|
||||||
virtual void apply(Impostor& node) { apply((LOD&)node); }
|
virtual void apply(Impostor& node) { apply((LOD&)node); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
std::ostream& _out;
|
||||||
int _indent;
|
int _indent;
|
||||||
int _step;
|
int _step;
|
||||||
};
|
};
|
||||||
@ -124,7 +130,7 @@ ReaderWriter3DS::ReaderWriter3DS()
|
|||||||
These print methods for 3ds hacking
|
These print methods for 3ds hacking
|
||||||
*/
|
*/
|
||||||
void pad(int level) {
|
void pad(int level) {
|
||||||
for(int i=0;i<level;i++) cout<<" ";
|
for(int i=0;i<level;i++) std::cout<<" ";
|
||||||
}
|
}
|
||||||
void print(Lib3dsMesh *mesh,int level);
|
void print(Lib3dsMesh *mesh,int level);
|
||||||
void print(Lib3dsUserData *user,int level);
|
void print(Lib3dsUserData *user,int level);
|
||||||
|
@ -241,7 +241,7 @@ public:
|
|||||||
unsigned int n;
|
unsigned int n;
|
||||||
if( (fscanf( fp, "%d", &n )) != 1 )
|
if( (fscanf( fp, "%d", &n )) != 1 )
|
||||||
{
|
{
|
||||||
std::cerr << "Error... Camera requires an integer argument\n";
|
osg::notify(osg::WARN) << "Error... Camera requires an integer argument\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( screen != n )
|
if( screen != n )
|
||||||
|
@ -674,7 +674,6 @@ void* lightRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
|||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < nvert; i++)
|
for(unsigned int i = 0; i < nvert; i++)
|
||||||
{
|
{
|
||||||
std::cout<<"LightPoint node"<<std::endl;
|
|
||||||
trpg3dPoint pt;
|
trpg3dPoint pt;
|
||||||
light.GetVertex(i, pt);
|
light.GetVertex(i, pt);
|
||||||
osg::Matrix matrix;
|
osg::Matrix matrix;
|
||||||
@ -770,30 +769,30 @@ void* labelRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
|||||||
osg::ref_ptr< osgText::Text > text = new osgText::Text;
|
osg::ref_ptr< osgText::Text > text = new osgText::Text;
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
int nl;
|
unsigned int nl;
|
||||||
std::string lb = *labelText;
|
std::string lb = *labelText;
|
||||||
while ( (nl=lb.find_first_of('\\')) != std::string::npos)
|
while ( (nl=lb.find_first_of('\\')) != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string sub = lb.substr(0,nl);
|
std::string sub = lb.substr(0,nl);
|
||||||
switch (lb[nl+1])
|
switch (lb[nl+1])
|
||||||
{
|
{
|
||||||
case 'n':
|
case 'n':
|
||||||
lb.erase(0,nl+2);
|
lb.erase(0,nl+2);
|
||||||
if (sub.length()) os << sub << std::endl;
|
if (sub.length()) os << sub << std::endl;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
lb.erase(0,nl+2);
|
lb.erase(0,nl+2);
|
||||||
os << sub << " ";//'\t';
|
os << sub << " ";//'\t';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
lb.erase(0,nl+1);
|
lb.erase(0,nl+1);
|
||||||
os << '\\' << sub;
|
os << '\\' << sub;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (lb.length()) os << lb;
|
if (lb.length()) os << lb;
|
||||||
text->setText(os.str());
|
text->setText(os.str());
|
||||||
|
|
||||||
// Position
|
// Position
|
||||||
@ -811,13 +810,13 @@ void* labelRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
|||||||
text->setAlignment(osgText::Text::CENTER_BOTTOM);
|
text->setAlignment(osgText::Text::CENTER_BOTTOM);
|
||||||
}
|
}
|
||||||
// Axis alignment
|
// Axis alignment
|
||||||
text->setAxisAlignment(osgText::Text::XZ_PLANE);
|
text->setAxisAlignment(osgText::Text::XZ_PLANE);
|
||||||
|
|
||||||
const trpgLabelPropertyTable *labelPropertyTable = _parse->getArchive()->GetLabelPropertyTable();
|
const trpgLabelPropertyTable *labelPropertyTable = _parse->getArchive()->GetLabelPropertyTable();
|
||||||
const trpgLabelProperty *labelProperty = labelPropertyTable ?
|
const trpgLabelProperty *labelProperty = labelPropertyTable ?
|
||||||
labelPropertyTable->GetPropertyRef(label.GetProperty()) : 0;
|
labelPropertyTable->GetPropertyRef(label.GetProperty()) : 0;
|
||||||
|
|
||||||
bool addTextGeodeIntoSceneGraph = true;
|
bool addTextGeodeIntoSceneGraph = true;
|
||||||
if (labelProperty)
|
if (labelProperty)
|
||||||
{
|
{
|
||||||
const trpgTextStyleTable *textStyleTable = _parse->getArchive()->GetTextStyleTable();
|
const trpgTextStyleTable *textStyleTable = _parse->getArchive()->GetTextStyleTable();
|
||||||
@ -833,213 +832,213 @@ void* labelRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
|||||||
// Font
|
// Font
|
||||||
text->setFont(_parse->getArchive()->getStyles()[labelProperty->GetFontStyle()].get());
|
text->setFont(_parse->getArchive()->getStyles()[labelProperty->GetFontStyle()].get());
|
||||||
|
|
||||||
// Color
|
// Color
|
||||||
text->setColor(_parse->getArchive()->getTextColors()[labelProperty->GetFontStyle()]);
|
text->setColor(_parse->getArchive()->getTextColors()[labelProperty->GetFontStyle()]);
|
||||||
|
|
||||||
// Cube
|
// Cube
|
||||||
osg::ref_ptr<osg::ShapeDrawable> cube = 0;
|
osg::ref_ptr<osg::ShapeDrawable> cube = 0;
|
||||||
|
|
||||||
// Type
|
// Type
|
||||||
switch (labelProperty->GetType())
|
switch (labelProperty->GetType())
|
||||||
{
|
{
|
||||||
case trpgLabelProperty::Billboard:
|
case trpgLabelProperty::Billboard:
|
||||||
text->setAxisAlignment(osgText::Text::XY_PLANE);
|
text->setAxisAlignment(osgText::Text::XY_PLANE);
|
||||||
text->setAutoRotateToScreen(true);
|
text->setAutoRotateToScreen(true);
|
||||||
break;
|
break;
|
||||||
case trpgLabelProperty::VertBillboard:
|
case trpgLabelProperty::VertBillboard:
|
||||||
addTextGeodeIntoSceneGraph = false;
|
addTextGeodeIntoSceneGraph = false;
|
||||||
{
|
{
|
||||||
osg::ref_ptr< osg::Billboard > billboard = new osg::Billboard;
|
osg::ref_ptr< osg::Billboard > billboard = new osg::Billboard;
|
||||||
text->setPosition(osg::Vec3(0.f,0.f,0.f));
|
text->setPosition(osg::Vec3(0.f,0.f,0.f));
|
||||||
billboard->addDrawable(text.get());
|
billboard->addDrawable(text.get());
|
||||||
billboard->setAxis(osg::Vec3(0.0f,0.0,1.0f) );
|
billboard->setAxis(osg::Vec3(0.0f,0.0,1.0f) );
|
||||||
billboard->setNormal(osg::Vec3(0.0f,-1.0,0.0f));
|
billboard->setNormal(osg::Vec3(0.0f,-1.0,0.0f));
|
||||||
billboard->setMode(osg::Billboard::AXIAL_ROT);
|
billboard->setMode(osg::Billboard::AXIAL_ROT);
|
||||||
billboard->setPos(0,pos);
|
billboard->setPos(0,pos);
|
||||||
|
|
||||||
_parse->getCurrTop()->addChild(billboard.get());
|
_parse->getCurrTop()->addChild(billboard.get());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case trpgLabelProperty::Cube:
|
case trpgLabelProperty::Cube:
|
||||||
addTextGeodeIntoSceneGraph = false;
|
addTextGeodeIntoSceneGraph = false;
|
||||||
{
|
{
|
||||||
osg::Group* group = new osg::Group;
|
osg::Group* group = new osg::Group;
|
||||||
|
|
||||||
osg::BoundingBox box = text->getBound();
|
osg::BoundingBox box = text->getBound();
|
||||||
float shift = box.radius()+1.f;
|
float shift = box.radius()+1.f;
|
||||||
|
|
||||||
// front
|
// front
|
||||||
text->setAlignment(osgText::Text::CENTER_CENTER);
|
text->setAlignment(osgText::Text::CENTER_CENTER);
|
||||||
|
|
||||||
// back
|
// back
|
||||||
osg::ref_ptr<osgText::Text> backText = new osgText::Text(*text);
|
osg::ref_ptr<osgText::Text> backText = new osgText::Text(*text);
|
||||||
backText->setPosition(osg::Vec3(pos.x(),pos.y()+shift,pos.z()));
|
backText->setPosition(osg::Vec3(pos.x(),pos.y()+shift,pos.z()));
|
||||||
backText->setAxisAlignment(osgText::Text::REVERSED_XZ_PLANE);
|
backText->setAxisAlignment(osgText::Text::REVERSED_XZ_PLANE);
|
||||||
|
|
||||||
// top
|
// top
|
||||||
osg::ref_ptr<osgText::Text> topText = new osgText::Text(*text);
|
osg::ref_ptr<osgText::Text> topText = new osgText::Text(*text);
|
||||||
topText->setPosition(osg::Vec3(pos.x(),pos.y(),pos.z()+shift));
|
topText->setPosition(osg::Vec3(pos.x(),pos.y(),pos.z()+shift));
|
||||||
topText->setAxisAlignment(osgText::Text::XY_PLANE);
|
topText->setAxisAlignment(osgText::Text::XY_PLANE);
|
||||||
|
|
||||||
// bottom
|
// bottom
|
||||||
osg::ref_ptr<osgText::Text> bottomText = new osgText::Text(*text);
|
osg::ref_ptr<osgText::Text> bottomText = new osgText::Text(*text);
|
||||||
bottomText->setPosition(osg::Vec3(pos.x(),pos.y(),pos.z()-shift));
|
bottomText->setPosition(osg::Vec3(pos.x(),pos.y(),pos.z()-shift));
|
||||||
bottomText->setAxisAlignment(osgText::Text::REVERSED_XY_PLANE);
|
bottomText->setAxisAlignment(osgText::Text::REVERSED_XY_PLANE);
|
||||||
|
|
||||||
// left
|
// left
|
||||||
osg::ref_ptr<osgText::Text> leftText = new osgText::Text(*text);
|
osg::ref_ptr<osgText::Text> leftText = new osgText::Text(*text);
|
||||||
leftText->setPosition(osg::Vec3(pos.x()-shift,pos.y(),pos.z()));
|
leftText->setPosition(osg::Vec3(pos.x()-shift,pos.y(),pos.z()));
|
||||||
leftText->setAxisAlignment(osgText::Text::REVERSED_YZ_PLANE);
|
leftText->setAxisAlignment(osgText::Text::REVERSED_YZ_PLANE);
|
||||||
|
|
||||||
// right
|
// right
|
||||||
osg::ref_ptr<osgText::Text> rightText = new osgText::Text(*text);
|
osg::ref_ptr<osgText::Text> rightText = new osgText::Text(*text);
|
||||||
rightText->setPosition(osg::Vec3(pos.x()+shift,pos.y(),pos.z()));
|
rightText->setPosition(osg::Vec3(pos.x()+shift,pos.y(),pos.z()));
|
||||||
rightText->setAxisAlignment(osgText::Text::YZ_PLANE);
|
rightText->setAxisAlignment(osgText::Text::YZ_PLANE);
|
||||||
|
|
||||||
text->setPosition(osg::Vec3(pos.x(),pos.y()-shift,pos.z()));
|
text->setPosition(osg::Vec3(pos.x(),pos.y()-shift,pos.z()));
|
||||||
|
|
||||||
osg::TessellationHints* hints = new osg::TessellationHints;
|
osg::TessellationHints* hints = new osg::TessellationHints;
|
||||||
hints->setDetailRatio(0.5f);
|
hints->setDetailRatio(0.5f);
|
||||||
cube = new osg::ShapeDrawable(new osg::Box(pos,2*shift),hints);
|
cube = new osg::ShapeDrawable(new osg::Box(pos,2*shift),hints);
|
||||||
|
|
||||||
osg::ref_ptr<osg::PolygonOffset> polyoffset = new osg::PolygonOffset;
|
osg::ref_ptr<osg::PolygonOffset> polyoffset = new osg::PolygonOffset;
|
||||||
polyoffset->setFactor(10.0f);
|
polyoffset->setFactor(10.0f);
|
||||||
polyoffset->setUnits(10.0f);
|
polyoffset->setUnits(10.0f);
|
||||||
osg::ref_ptr<osg::StateSet> ss = cube->getOrCreateStateSet();
|
osg::ref_ptr<osg::StateSet> ss = cube->getOrCreateStateSet();
|
||||||
ss->setAttributeAndModes(polyoffset.get(),osg::StateAttribute::ON);
|
ss->setAttributeAndModes(polyoffset.get(),osg::StateAttribute::ON);
|
||||||
cube->setStateSet(ss.get());
|
cube->setStateSet(ss.get());
|
||||||
|
|
||||||
textGeode->addDrawable(cube.get());
|
textGeode->addDrawable(cube.get());
|
||||||
textGeode->addDrawable(text.get());
|
textGeode->addDrawable(text.get());
|
||||||
textGeode->addDrawable(backText.get());
|
textGeode->addDrawable(backText.get());
|
||||||
textGeode->addDrawable(topText.get());
|
textGeode->addDrawable(topText.get());
|
||||||
textGeode->addDrawable(bottomText.get());
|
textGeode->addDrawable(bottomText.get());
|
||||||
textGeode->addDrawable(leftText.get());
|
textGeode->addDrawable(leftText.get());
|
||||||
textGeode->addDrawable(rightText.get());
|
textGeode->addDrawable(rightText.get());
|
||||||
|
|
||||||
group->addChild(textGeode.get());
|
group->addChild(textGeode.get());
|
||||||
|
|
||||||
_parse->getCurrTop()->addChild(group);
|
_parse->getCurrTop()->addChild(group);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<trpg3dPoint> *supports = label.GetSupports();
|
const std::vector<trpg3dPoint> *supports = label.GetSupports();
|
||||||
if (supports && supports->size())
|
if (supports && supports->size())
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Geode> supGeode = new osg::Geode;
|
osg::ref_ptr<osg::Geode> supGeode = new osg::Geode;
|
||||||
|
|
||||||
int supId = labelProperty->GetSupport();
|
int supId = labelProperty->GetSupport();
|
||||||
const trpgSupportStyleTable *supTable = _parse->getArchive()->GetSupportStyleTable();
|
const trpgSupportStyleTable *supTable = _parse->getArchive()->GetSupportStyleTable();
|
||||||
const trpgSupportStyle *supStyle = supTable ? supTable->GetStyleRef(supId) : 0;
|
const trpgSupportStyle *supStyle = supTable ? supTable->GetStyleRef(supId) : 0;
|
||||||
if (supStyle)
|
if (supStyle)
|
||||||
{
|
{
|
||||||
int matId = supStyle->GetMaterial();
|
int matId = supStyle->GetMaterial();
|
||||||
|
|
||||||
osg::Vec4 supLineColor(1.f,1.f,1.f,1.f);
|
osg::Vec4 supLineColor(1.f,1.f,1.f,1.f);
|
||||||
_parse->loadMaterial(matId);
|
_parse->loadMaterial(matId);
|
||||||
osg::ref_ptr<osg::StateSet> sset = (*_parse->getMaterials())[matId];
|
osg::ref_ptr<osg::StateSet> sset = (*_parse->getMaterials())[matId];
|
||||||
|
|
||||||
if (cube.get())
|
if (cube.get())
|
||||||
{
|
{
|
||||||
osg::StateSet* ss = cube->getOrCreateStateSet();
|
osg::StateSet* ss = cube->getOrCreateStateSet();
|
||||||
ss->merge(*sset);
|
ss->merge(*sset);
|
||||||
}
|
}
|
||||||
|
|
||||||
const trpgMatTable* matTable = _parse->getArchive()->GetMaterialTable();
|
const trpgMatTable* matTable = _parse->getArchive()->GetMaterialTable();
|
||||||
if (matTable)
|
if (matTable)
|
||||||
{
|
{
|
||||||
const trpgMaterial* mat = matTable->GetMaterialRef(0,matId);
|
const trpgMaterial* mat = matTable->GetMaterialRef(0,matId);
|
||||||
if (mat)
|
if (mat)
|
||||||
{
|
{
|
||||||
trpgColor faceColor;
|
trpgColor faceColor;
|
||||||
mat->GetColor(faceColor);
|
mat->GetColor(faceColor);
|
||||||
|
|
||||||
float64 alpha;
|
float64 alpha;
|
||||||
mat->GetAlpha(alpha);
|
mat->GetAlpha(alpha);
|
||||||
|
|
||||||
supLineColor = osg::Vec4(faceColor.red, faceColor.green, faceColor.blue, alpha );
|
supLineColor = osg::Vec4(faceColor.red, faceColor.green, faceColor.blue, alpha );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (supStyle->GetType())
|
switch (supStyle->GetType())
|
||||||
{
|
{
|
||||||
case trpgSupportStyle::Line:
|
case trpgSupportStyle::Line:
|
||||||
{
|
{
|
||||||
osg::Geometry* linesGeom = new osg::Geometry();
|
osg::Geometry* linesGeom = new osg::Geometry();
|
||||||
osg::Vec3Array* vertices = new osg::Vec3Array(supports->size()*2);
|
osg::Vec3Array* vertices = new osg::Vec3Array(supports->size()*2);
|
||||||
|
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
for (unsigned int i = 0; i < supports->size(); i++)
|
for (unsigned int i = 0; i < supports->size(); i++)
|
||||||
{
|
{
|
||||||
const trpg3dPoint& supPt = (*supports)[i];
|
const trpg3dPoint& supPt = (*supports)[i];
|
||||||
(*vertices)[cnt++].set(pos);
|
(*vertices)[cnt++].set(pos);
|
||||||
(*vertices)[cnt++].set(osg::Vec3(supPt.x,supPt.y,supPt.z));
|
(*vertices)[cnt++].set(osg::Vec3(supPt.x,supPt.y,supPt.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
linesGeom->setVertexArray(vertices);
|
linesGeom->setVertexArray(vertices);
|
||||||
|
|
||||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||||
colors->push_back(supLineColor);
|
colors->push_back(supLineColor);
|
||||||
linesGeom->setColorArray(colors);
|
linesGeom->setColorArray(colors);
|
||||||
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||||
|
|
||||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||||
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||||
linesGeom->setNormalArray(normals);
|
linesGeom->setNormalArray(normals);
|
||||||
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||||
|
|
||||||
|
|
||||||
linesGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,supports->size()*2));
|
linesGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,supports->size()*2));
|
||||||
supGeode->addDrawable(linesGeom);
|
supGeode->addDrawable(linesGeom);
|
||||||
}
|
}
|
||||||
|
|
||||||
_parse->getCurrTop()->addChild(supGeode.get());
|
_parse->getCurrTop()->addChild(supGeode.get());
|
||||||
break;
|
break;
|
||||||
case trpgSupportStyle::Cylinder:
|
case trpgSupportStyle::Cylinder:
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::TessellationHints> hints = new osg::TessellationHints;
|
osg::ref_ptr<osg::TessellationHints> hints = new osg::TessellationHints;
|
||||||
hints->setDetailRatio(0.5f);
|
hints->setDetailRatio(0.5f);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < supports->size(); i++)
|
for (unsigned int i = 0; i < supports->size(); i++)
|
||||||
{
|
{
|
||||||
const trpg3dPoint& supPt = (*supports)[i];
|
const trpg3dPoint& supPt = (*supports)[i];
|
||||||
|
|
||||||
osg::Vec3 supPos(supPt.x,supPt.y,supPt.z);
|
osg::Vec3 supPos(supPt.x,supPt.y,supPt.z);
|
||||||
osg::Vec3 supCenter = (supPos+pos)/2.f;
|
osg::Vec3 supCenter = (supPos+pos)/2.f;
|
||||||
float supHeight = (supPos-pos).length();
|
float supHeight = (supPos-pos).length();
|
||||||
|
|
||||||
osg::Vec3 d = pos-supPos;
|
osg::Vec3 d = pos-supPos;
|
||||||
d.normalize();
|
d.normalize();
|
||||||
osg::Quat r;
|
osg::Quat r;
|
||||||
|
|
||||||
r.makeRotate(osg::Vec3(0.f,0.f,1.f),d);
|
r.makeRotate(osg::Vec3(0.f,0.f,1.f),d);
|
||||||
|
|
||||||
osg::Cylinder* cylinder = new osg::Cylinder(supCenter,10.f,supHeight);
|
osg::Cylinder* cylinder = new osg::Cylinder(supCenter,10.f,supHeight);
|
||||||
cylinder->setRotation(r);
|
cylinder->setRotation(r);
|
||||||
|
|
||||||
osg::ShapeDrawable* cylinderDrawable = new osg::ShapeDrawable(cylinder,hints.get());
|
osg::ShapeDrawable* cylinderDrawable = new osg::ShapeDrawable(cylinder,hints.get());
|
||||||
osg::StateSet* ss = cylinderDrawable->getOrCreateStateSet();
|
osg::StateSet* ss = cylinderDrawable->getOrCreateStateSet();
|
||||||
ss->merge(*sset);
|
ss->merge(*sset);
|
||||||
|
|
||||||
supGeode->addDrawable(cylinderDrawable);
|
supGeode->addDrawable(cylinderDrawable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_parse->getCurrTop()->addChild(supGeode.get());
|
_parse->getCurrTop()->addChild(supGeode.get());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (addTextGeodeIntoSceneGraph)
|
||||||
|
{
|
||||||
|
_parse->getCurrTop()->addChild(textGeode.get());
|
||||||
|
textGeode->addDrawable(text.get());
|
||||||
}
|
}
|
||||||
if (addTextGeodeIntoSceneGraph)
|
|
||||||
{
|
|
||||||
_parse->getCurrTop()->addChild(textGeode.get());
|
|
||||||
textGeode->addDrawable(text.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
return (void*)1;
|
return (void*)1;
|
||||||
}
|
}
|
||||||
@ -1388,7 +1387,7 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout<<"Detected potential memory leak in TXPParerse.cpp"<<std::endl;
|
osg::notify(osg::WARN)<<"Detected potential memory leak in TXPParerse.cpp"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1498,7 +1497,7 @@ osg::Texture2D* txp::getLocalTexture(trpgrImageHelper& image_helper, const trpgT
|
|||||||
// osg::Image do their own mipmaps
|
// osg::Image do their own mipmaps
|
||||||
if(num_mipmaps <= 1)
|
if(num_mipmaps <= 1)
|
||||||
{
|
{
|
||||||
int32 size = tex->CalcTotalSize();
|
int32 size = tex->CalcTotalSize();
|
||||||
data = new char [size];
|
data = new char [size];
|
||||||
image_helper.GetLocalGL(tex,data,size);
|
image_helper.GetLocalGL(tex,data,size);
|
||||||
image->setImage(s.x,s.y,1,internalFormat, pixelFormat, dataType,
|
image->setImage(s.x,s.y,1,internalFormat, pixelFormat, dataType,
|
||||||
@ -1570,7 +1569,7 @@ osg::Texture2D* txp::getTemplateTexture(trpgrImageHelper& image_helper, trpgLoca
|
|||||||
// osg::Image do their own mipmaps
|
// osg::Image do their own mipmaps
|
||||||
if(num_mipmaps <= 1)
|
if(num_mipmaps <= 1)
|
||||||
{
|
{
|
||||||
int32 size = tex->CalcTotalSize();
|
int32 size = tex->CalcTotalSize();
|
||||||
data = new char [size];
|
data = new char [size];
|
||||||
image_helper.GetNthImageForLocalMat(locmat,index, data,size);
|
image_helper.GetNthImageForLocalMat(locmat,index, data,size);
|
||||||
|
|
||||||
|
@ -691,12 +691,12 @@ void Font::Glyph::subload() const
|
|||||||
{
|
{
|
||||||
|
|
||||||
osg::notify(osg::WARN)<<"after Font::Glyph::subload() : detected OpenGL error '"<<gluErrorString(errorNo)<<"'"<<std::endl;
|
osg::notify(osg::WARN)<<"after Font::Glyph::subload() : detected OpenGL error '"<<gluErrorString(errorNo)<<"'"<<std::endl;
|
||||||
std::cout << "\tglTexSubImage2D(0x"<<hex<<GL_TEXTURE_2D<<dec<<" ,"<<0<<"\t"<<std::endl<<
|
osg::notify(osg::WARN)<< "\tglTexSubImage2D(0x"<<hex<<GL_TEXTURE_2D<<dec<<" ,"<<0<<"\t"<<std::endl<<
|
||||||
"\t "<<_texturePosX<<" ,"<<_texturePosY<<std::endl<<
|
"\t "<<_texturePosX<<" ,"<<_texturePosY<<std::endl<<
|
||||||
"\t "<<s()<<" ,"<<t()<<std::endl<<hex<<
|
"\t "<<s()<<" ,"<<t()<<std::endl<<hex<<
|
||||||
"\t 0x"<<(GLenum)getPixelFormat()<<std::endl<<
|
"\t 0x"<<(GLenum)getPixelFormat()<<std::endl<<
|
||||||
"\t 0x"<<(GLenum)getDataType()<<std::endl<<
|
"\t 0x"<<(GLenum)getDataType()<<std::endl<<
|
||||||
"\t 0x"<<(unsigned long)data()<<");"<<dec<<std::endl;
|
"\t 0x"<<(unsigned long)data()<<");"<<dec<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,9 @@ class PrintVisitor : public NodeVisitor
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PrintVisitor():NodeVisitor(NodeVisitor::TRAVERSE_ALL_CHILDREN)
|
PrintVisitor(std::ostream& out):
|
||||||
|
NodeVisitor(NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||||
|
_out(out)
|
||||||
{
|
{
|
||||||
_indent = 0;
|
_indent = 0;
|
||||||
_step = 4;
|
_step = 4;
|
||||||
@ -57,13 +59,13 @@ class PrintVisitor : public NodeVisitor
|
|||||||
inline void moveOut() { _indent -= _step; }
|
inline void moveOut() { _indent -= _step; }
|
||||||
inline void writeIndent()
|
inline void writeIndent()
|
||||||
{
|
{
|
||||||
for(int i=0;i<_indent;++i) std::cout << " ";
|
for(int i=0;i<_indent;++i) _out << " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void apply(Node& node)
|
virtual void apply(Node& node)
|
||||||
{
|
{
|
||||||
moveIn();
|
moveIn();
|
||||||
writeIndent(); std::cout << node.className() <<std::endl;
|
writeIndent(); _out << node.className() <<std::endl;
|
||||||
traverse(node);
|
traverse(node);
|
||||||
moveOut();
|
moveOut();
|
||||||
}
|
}
|
||||||
@ -82,6 +84,7 @@ class PrintVisitor : public NodeVisitor
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
std::ostream& _out;
|
||||||
int _indent;
|
int _indent;
|
||||||
int _step;
|
int _step;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user