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();
|
||||
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);
|
||||
}
|
||||
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 <iostream>
|
||||
|
||||
osg::Geode* createTile(const osg::Vec3& lb, const osg::Vec3& rb,
|
||||
const osg::Vec3& lt, const osg::Vec3& rt,
|
||||
const std::string& imageFile)
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <osg/Matrix>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void testFrustum(double left,double right,double bottom,double top,double zNear,double zFar)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <osg/NodeCallback>
|
||||
|
||||
#include <map>
|
||||
#include <istream>
|
||||
#include <float.h>
|
||||
|
||||
namespace osg {
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
|
||||
namespace osg {
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
|
||||
namespace osg {
|
||||
|
||||
|
@ -16,10 +16,6 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#if defined(__GNUC__) && defined(WIN32)
|
||||
# include <iostream>
|
||||
#endif
|
||||
|
||||
// for OSX users :
|
||||
// comment in if you want backwards compatibility with 10.1.x versions
|
||||
// otherwise you'll have problems with missing floorf and __isnan*()
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <algorithm>
|
||||
|
||||
namespace osg {
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <algorithm>
|
||||
|
||||
namespace osg {
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include <osg/Export>
|
||||
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include <osg/Vec3>
|
||||
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
|
||||
namespace osg {
|
||||
|
||||
|
@ -18,12 +18,13 @@
|
||||
#include <osg/Referenced>
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Timer>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
|
||||
namespace osgUtx{
|
||||
|
||||
@ -39,19 +40,19 @@ class SG_EXPORT Test: public osg::Referenced
|
||||
{
|
||||
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:
|
||||
|
||||
virtual ~Test() {}
|
||||
|
||||
std::string _name;
|
||||
std::string _name;
|
||||
};
|
||||
|
||||
|
||||
@ -66,50 +67,50 @@ class SG_EXPORT TestContext
|
||||
{
|
||||
public:
|
||||
|
||||
TestContext();
|
||||
TestContext();
|
||||
|
||||
bool shouldStop() { return false; }
|
||||
bool isVerbose() { return true; }
|
||||
bool shouldStop() { return false; }
|
||||
bool isVerbose() { return true; }
|
||||
|
||||
enum TraceLevel{
|
||||
Off, ///< All tracing turned off
|
||||
Results, ///< Output results only
|
||||
Full ///< Full test diagnostic output
|
||||
};
|
||||
enum TraceLevel{
|
||||
Off, ///< All tracing turned off
|
||||
Results, ///< Output results only
|
||||
Full ///< Full test diagnostic output
|
||||
};
|
||||
|
||||
void setTraceLevel(TraceLevel tl);
|
||||
TraceLevel getTraceLevel() const;
|
||||
void setTraceLevel(TraceLevel tl);
|
||||
TraceLevel getTraceLevel() const;
|
||||
|
||||
std::ostream& tout(TraceLevel tl=Full) const;
|
||||
std::ostream& tout(TraceLevel tl=Full) const;
|
||||
|
||||
private:
|
||||
|
||||
TestContext(const TestContext&);
|
||||
TestContext operator=(const TestContext&);
|
||||
TestContext(const TestContext&);
|
||||
TestContext operator=(const TestContext&);
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
class SG_EXPORT TraceStream{
|
||||
class SG_EXPORT TraceStream{
|
||||
|
||||
public:
|
||||
TraceStream(std::ostream& o=std::cout, TraceLevel tl=Results);
|
||||
~TraceStream();
|
||||
public:
|
||||
TraceStream(std::ostream& o=osg::notify(osg::NOTICE), TraceLevel tl=Results);
|
||||
~TraceStream();
|
||||
|
||||
void setTraceLevel(TraceLevel tl);
|
||||
TraceLevel getTraceLevel() const;
|
||||
void setTraceLevel(TraceLevel tl);
|
||||
TraceLevel getTraceLevel() const;
|
||||
|
||||
std::ostream& stream(TraceLevel tl);
|
||||
std::ostream& stream(TraceLevel tl);
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
TraceLevel _traceLevel;
|
||||
std::ostream* _outputStreamPtr;
|
||||
std::ofstream _nullStream;
|
||||
};
|
||||
TraceLevel _traceLevel;
|
||||
std::ostream* _outputStreamPtr;
|
||||
std::ofstream _nullStream;
|
||||
};
|
||||
|
||||
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|
||||
|
||||
mutable TraceStream _tout;
|
||||
mutable TraceStream _tout;
|
||||
|
||||
};
|
||||
|
||||
@ -125,20 +126,20 @@ class TestVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
//..Should we enter this node and its children?
|
||||
virtual bool visitEnter( TestSuite* ) { return true; }
|
||||
//..Should we enter this node and its children?
|
||||
virtual bool visitEnter( TestSuite* ) { return true; }
|
||||
|
||||
//..Returns true to continue to next Leaf
|
||||
virtual bool visit( TestCase* ) = 0;
|
||||
//..Returns true to continue to next Leaf
|
||||
virtual bool visit( TestCase* ) = 0;
|
||||
|
||||
//..Returns true to continue to next Composite
|
||||
virtual bool visitLeave( TestSuite* ) { return true; }
|
||||
//..Returns true to continue to next Composite
|
||||
virtual bool visitLeave( TestSuite* ) { return true; }
|
||||
|
||||
protected:
|
||||
|
||||
TestVisitor() {}
|
||||
TestVisitor( const TestVisitor& ) {}
|
||||
virtual ~TestVisitor() {}
|
||||
TestVisitor() {}
|
||||
TestVisitor( const TestVisitor& ) {}
|
||||
virtual ~TestVisitor() {}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -149,13 +150,13 @@ class TestCase : public Test
|
||||
{
|
||||
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:
|
||||
|
||||
@ -170,13 +171,13 @@ class TestX
|
||||
{
|
||||
public:
|
||||
|
||||
TestX(const std::string& s):_what(s) {}
|
||||
virtual ~TestX() {}
|
||||
TestX(const std::string& s):_what(s) {}
|
||||
virtual ~TestX() {}
|
||||
|
||||
const std::string& what() const { return _what; }
|
||||
const std::string& what() const { return _what; }
|
||||
|
||||
private:
|
||||
std::string _what;
|
||||
std::string _what;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -185,7 +186,7 @@ A TestFailureX indicates a failure in the tested component.
|
||||
class TestFailureX: public TestX
|
||||
{
|
||||
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
|
||||
{
|
||||
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 >
|
||||
class TestCase_ : public TestCase
|
||||
{
|
||||
typedef void (FixtureT::*TestMethodPtr)( const Context& );
|
||||
typedef void (FixtureT::*TestMethodPtr)( const Context& );
|
||||
|
||||
public:
|
||||
|
||||
// Constructor adds the TestMethod pointer
|
||||
TestCase_( const std::string& sName, TestMethodPtr pTestMethod ) :
|
||||
TestCase( sName ),
|
||||
_pTestMethod( pTestMethod )
|
||||
{
|
||||
}
|
||||
// Constructor adds the TestMethod pointer
|
||||
TestCase_( const std::string& sName, TestMethodPtr pTestMethod ) :
|
||||
TestCase( sName ),
|
||||
_pTestMethod( pTestMethod )
|
||||
{
|
||||
}
|
||||
|
||||
// Create a TestFixture instance and invoke TestMethod?
|
||||
virtual void run( const Context& ctx )
|
||||
{
|
||||
( FixtureT().*_pTestMethod )( ctx );
|
||||
}
|
||||
// Create a TestFixture instance and invoke TestMethod?
|
||||
virtual void run( const Context& ctx )
|
||||
{
|
||||
( FixtureT().*_pTestMethod )( ctx );
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~TestCase_() {}
|
||||
|
||||
TestMethodPtr _pTestMethod;
|
||||
TestMethodPtr _pTestMethod;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -243,24 +244,24 @@ class SG_EXPORT TestSuite : public Test
|
||||
{
|
||||
public:
|
||||
|
||||
TestSuite( const std::string& name );
|
||||
TestSuite( const std::string& name );
|
||||
|
||||
/** Adds a Test to the suite. */
|
||||
void add( Test* pTest );
|
||||
/** Adds a Test to the suite. */
|
||||
void add( Test* pTest );
|
||||
|
||||
/**
|
||||
@returns The immediate child denoted by name, or 0 if not found.
|
||||
*/
|
||||
Test* findChild(const std::string& name);
|
||||
/**
|
||||
@returns The immediate child denoted by name, or 0 if not found.
|
||||
*/
|
||||
Test* findChild(const std::string& name);
|
||||
|
||||
virtual bool accept( Test::Visitor& v );
|
||||
virtual bool accept( Test::Visitor& v );
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~TestSuite() {}
|
||||
|
||||
typedef std::vector< osg::ref_ptr<Test> > Tests;
|
||||
Tests _tests; // Collection of Suites and/or Cases
|
||||
typedef std::vector< osg::ref_ptr<Test> > Tests;
|
||||
Tests _tests; // Collection of Suites and/or Cases
|
||||
};
|
||||
|
||||
/**
|
||||
@ -272,54 +273,54 @@ class SG_EXPORT TestGraph
|
||||
|
||||
public:
|
||||
|
||||
static TestGraph& instance();
|
||||
static TestGraph& instance();
|
||||
|
||||
/**
|
||||
@return a pointer to the root TestSuite.
|
||||
*/
|
||||
TestSuite* root();
|
||||
/**
|
||||
@return a pointer to the root TestSuite.
|
||||
*/
|
||||
TestSuite* root();
|
||||
|
||||
/**
|
||||
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 \em TestSuite designated by \em path, if it does not already exist.
|
||||
/**
|
||||
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 \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
|
||||
is 0), or the first component of \em path is not the same as the name of the
|
||||
TestSuite \em tsuite.
|
||||
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
|
||||
TestSuite \em tsuite.
|
||||
|
||||
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
|
||||
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"
|
||||
already exists.
|
||||
|
||||
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
|
||||
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"
|
||||
already exists.
|
||||
|
||||
|
||||
@param path The name of the TestSuite to return.
|
||||
@param tsuite The suite to 'start from'. Path is relative to this
|
||||
suite (defaults to root suite).
|
||||
@param createIfNecessary Optionally create the TestSuite(s) denoted by path if
|
||||
they do not exist.
|
||||
*/
|
||||
TestSuite* suite(const std::string& path, TestSuite* tsuite = 0,bool createIfNecessary = false);
|
||||
@param path The name of the TestSuite to return.
|
||||
@param tsuite The suite to 'start from'. Path is relative to this
|
||||
suite (defaults to root suite).
|
||||
@param createIfNecessary Optionally create the TestSuite(s) denoted by path if
|
||||
they do not exist.
|
||||
*/
|
||||
TestSuite* suite(const std::string& path, TestSuite* tsuite = 0,bool createIfNecessary = false);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
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.
|
||||
*/
|
||||
TestSuite* suite(
|
||||
std::list<std::string>::iterator it,
|
||||
std::list<std::string>::iterator end,
|
||||
TestSuite* tsuite, bool createIfNecessary);
|
||||
/**
|
||||
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.
|
||||
*/
|
||||
TestSuite* suite(
|
||||
std::list<std::string>::iterator it,
|
||||
std::list<std::string>::iterator end,
|
||||
TestSuite* tsuite, bool createIfNecessary);
|
||||
|
||||
TestGraph();
|
||||
TestGraph();
|
||||
|
||||
TestGraph(const TestGraph&);
|
||||
TestGraph& operator=(const TestGraph&);
|
||||
TestGraph(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
|
||||
{
|
||||
enum { SEPCHAR = '.' };
|
||||
enum { SEPCHAR = '.' };
|
||||
|
||||
public:
|
||||
|
||||
// Entering a composite: Push its name on the Path
|
||||
virtual bool visitEnter( TestSuite* pSuite );
|
||||
// Entering a composite: Push its name on the Path
|
||||
virtual bool visitEnter( TestSuite* pSuite );
|
||||
|
||||
// Leaving a composite: Pop its name from the Path
|
||||
virtual bool visitLeave( TestSuite* pSuite );
|
||||
// Leaving a composite: Pop its name from the Path
|
||||
virtual bool visitLeave( TestSuite* pSuite );
|
||||
|
||||
// Provide read-only access to the current qualifier
|
||||
const std::string& currentPath() const;
|
||||
// Provide read-only access to the current qualifier
|
||||
const std::string& currentPath() const;
|
||||
|
||||
private:
|
||||
|
||||
std::string _path; // Current qualifier
|
||||
std::string _path; // Current qualifier
|
||||
};
|
||||
|
||||
/**
|
||||
@ -357,50 +358,50 @@ class SG_EXPORT QualifiedTestPrinter : public TestQualifier
|
||||
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,
|
||||
its result, and a textual description of any problems.
|
||||
|
||||
\todo Consider adding accessor methods if necessary, to get the details
|
||||
stored in the TestRecord.
|
||||
\todo Consider adding accessor methods if necessary, to get the details
|
||||
stored in the TestRecord.
|
||||
*/
|
||||
class SG_EXPORT TestRecord
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
void log(const TestFailureX& e);
|
||||
void log(const TestErrorX& e);
|
||||
void log(const std::exception& e);
|
||||
void log(const std::string& s);
|
||||
void start();
|
||||
void stop();
|
||||
void log(const TestFailureX& e);
|
||||
void log(const TestErrorX& e);
|
||||
void log(const std::exception& e);
|
||||
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
|
||||
friend class TestReport;
|
||||
TestRecord(const std::string& name);
|
||||
// Onlye a TestReport can create a TestRecord
|
||||
friend class TestReport;
|
||||
TestRecord(const std::string& name);
|
||||
|
||||
enum Result{
|
||||
Success,Failure,Error
|
||||
};
|
||||
enum Result{
|
||||
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_;
|
||||
osg::Timer_t start_;
|
||||
osg::Timer_t stop_;
|
||||
Result result_;
|
||||
std::string problem_;
|
||||
std::string name_;
|
||||
osg::Timer_t start_;
|
||||
osg::Timer_t stop_;
|
||||
Result result_;
|
||||
std::string problem_;
|
||||
|
||||
};
|
||||
|
||||
@ -408,20 +409,20 @@ class SG_EXPORT TestRecord
|
||||
A TestReport represents the complete set of results (TestRecords) for a
|
||||
given test run.
|
||||
|
||||
\todo Add support for printing the test report in various formats:
|
||||
e.g. text, XML, CSV
|
||||
\todo Add support for printing the test report in various formats:
|
||||
e.g. text, XML, CSV
|
||||
*/
|
||||
class SG_EXPORT TestReport
|
||||
{
|
||||
public:
|
||||
|
||||
TestRecord& createRecord(const std::string& s){
|
||||
_records.push_back(TestRecord(s));
|
||||
return _records.back();
|
||||
}
|
||||
TestRecord& createRecord(const std::string& s){
|
||||
_records.push_back(TestRecord(s));
|
||||
return _records.back();
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
{
|
||||
public:
|
||||
|
||||
TestRunner( TestContext& ctx );
|
||||
TestRunner( TestContext& ctx );
|
||||
|
||||
/**
|
||||
Tests may be specified by partial names. E.g. specifiying "root"
|
||||
will run all tests below root, i.e. all tests.
|
||||
Specifiying "root.osg" will run all tests below \em root.osg.
|
||||
Specifying "root.osg.de" will run all tests (and suites) below
|
||||
\em root.osg with names beginning with the \em de.
|
||||
*/
|
||||
void specify( const std::string& sQualifiedName );
|
||||
/**
|
||||
Tests may be specified by partial names. E.g. specifiying "root"
|
||||
will run all tests below root, i.e. all tests.
|
||||
Specifiying "root.osg" will run all tests below \em root.osg.
|
||||
Specifying "root.osg.de" will run all tests (and suites) below
|
||||
\em root.osg with names beginning with the \em de.
|
||||
*/
|
||||
void specify( const std::string& sQualifiedName );
|
||||
|
||||
bool visitEnter( TestSuite* pSuite );
|
||||
bool visit( TestCase* pTest );
|
||||
bool visitLeave( TestSuite* pSuite );
|
||||
bool visitEnter( TestSuite* pSuite );
|
||||
bool visit( TestCase* pTest );
|
||||
bool visitLeave( TestSuite* pSuite );
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
void perform( TestCase* pTest );
|
||||
void perform( TestCase* pTest );
|
||||
|
||||
private:
|
||||
|
||||
TestReport _db; // Results
|
||||
TestContext& _ctx; // The Global Testing Context
|
||||
std::vector<std::string> _tests; // Specified Tests
|
||||
TestReport _db; // Results
|
||||
TestContext& _ctx; // The Global Testing Context
|
||||
std::vector<std::string> _tests; // Specified Tests
|
||||
};
|
||||
|
||||
}
|
||||
@ -475,11 +476,11 @@ Starts a TestSuite singleton function
|
||||
@see OSGUTX_ADD_TESTCASE, OSGUTX_END_TESTSUITE
|
||||
*/
|
||||
#define OSGUTX_BEGIN_TESTSUITE( tsuite ) \
|
||||
osgUtx::TestSuite* tsuite##_TestSuite() \
|
||||
{ \
|
||||
static osg::ref_ptr<osgUtx::TestSuite> s_suite = 0; \
|
||||
if ( s_suite == 0 ) { \
|
||||
s_suite = new osgUtx::TestSuite( #tsuite );
|
||||
osgUtx::TestSuite* tsuite##_TestSuite() \
|
||||
{ \
|
||||
static osg::ref_ptr<osgUtx::TestSuite> s_suite = 0; \
|
||||
if ( s_suite == 0 ) { \
|
||||
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
|
||||
*/
|
||||
#define OSGUTX_ADD_TESTCASE( tfixture, tmethod ) \
|
||||
s_suite->add( new osgUtx::TestCase_<tfixture>( \
|
||||
#tmethod, &tfixture::tmethod ) );
|
||||
s_suite->add( new osgUtx::TestCase_<tfixture>( \
|
||||
#tmethod, &tfixture::tmethod ) );
|
||||
|
||||
/**
|
||||
Ends a TestSuite singleton function
|
||||
@see OSGUTX_BEGIN_TESTSUITE, OSGUTX_ADD_TESTCASE
|
||||
*/
|
||||
#define OSGUTX_END_TESTSUITE \
|
||||
} \
|
||||
return s_suite.get(); \
|
||||
}
|
||||
} \
|
||||
return s_suite.get(); \
|
||||
}
|
||||
|
||||
/** Define a TestSuite accessor */
|
||||
#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
|
||||
*/
|
||||
#define OSGUTX_ADD_TESTSUITE( childSuite ) \
|
||||
s_suite->add( childSuite##_TestSuite() );
|
||||
s_suite->add( childSuite##_TestSuite() );
|
||||
|
||||
|
||||
/** Autoregister a testsuite with the root suite at startup */
|
||||
#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 */
|
||||
#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{
|
||||
|
||||
@ -531,21 +532,21 @@ direct use, it should be used via the following macros. (It's a secret agent :-)
|
||||
*/
|
||||
struct TestSuiteAutoRegistrationAgent
|
||||
{
|
||||
TestSuiteAutoRegistrationAgent(TestSuite* tsuite, const char* path = 0)
|
||||
{
|
||||
if( ! path ) path = "root";
|
||||
TestSuiteAutoRegistrationAgent(TestSuite* tsuite, const char* path = 0)
|
||||
{
|
||||
if( ! path ) path = "root";
|
||||
|
||||
// Find the suite named in 'path', create it if necessary
|
||||
TestSuite *regSuite = osgUtx::TestGraph::instance().suite( path, 0, true );
|
||||
// Find the suite named in 'path', create it if necessary
|
||||
TestSuite *regSuite = osgUtx::TestGraph::instance().suite( path, 0, true );
|
||||
|
||||
if(!regSuite){
|
||||
std::cerr<<"Warning, unable to register test suite named \""<<tsuite->name()<<"\" at "
|
||||
<<path<<", falling back to root suite."<<std::endl;
|
||||
regSuite = osgUtx::TestGraph::instance().root();
|
||||
}
|
||||
if(!regSuite){
|
||||
osg::notify(osg::WARN)<<"Warning, unable to register test suite named \""<<tsuite->name()<<"\" at "
|
||||
<<path<<", falling back to root suite."<<std::endl;
|
||||
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.
|
||||
*/
|
||||
#define OSGUTX_TEST_F( expr ) \
|
||||
if( !(expr) ){ \
|
||||
std::stringstream ss; \
|
||||
ss<< #expr <<" failure: "<<__FILE__<<", line "<<__LINE__<<std::ends; \
|
||||
throw osgUtx::TestFailureX(ss.str()); \
|
||||
}
|
||||
if( !(expr) ){ \
|
||||
std::stringstream ss; \
|
||||
ss<< #expr <<" failure: "<<__FILE__<<", line "<<__LINE__<<std::ends; \
|
||||
throw osgUtx::TestFailureX(ss.str()); \
|
||||
}
|
||||
|
||||
/**
|
||||
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.
|
||||
*/
|
||||
#define OSGUTX_TEST_E( expr ) \
|
||||
if( !(expr) ){ \
|
||||
std::stringstream ss; \
|
||||
ss<< #expr <<" error: "<<__FILE__<<", line "<<__LINE__<<std::ends; \
|
||||
throw osgUtx::TestErrorX(ss.str()); \
|
||||
}
|
||||
if( !(expr) ){ \
|
||||
std::stringstream ss; \
|
||||
ss<< #expr <<" error: "<<__FILE__<<", line "<<__LINE__<<std::ends; \
|
||||
throw osgUtx::TestErrorX(ss.str()); \
|
||||
}
|
||||
|
||||
|
||||
#endif // OSG_UNITTESTFRAMEWORK
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include <osg/Math>
|
||||
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
|
||||
namespace osg {
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include <osg/Math>
|
||||
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
|
||||
namespace osg {
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include <osg/Vec3>
|
||||
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
|
||||
namespace osg {
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
|
||||
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)
|
||||
{
|
||||
//std::cout<<" trying to disable occluder ";PrintNodePath(nodePath);std::cout<<std::endl;
|
||||
for(OccluderList::iterator itr=_occluderList.begin();
|
||||
itr!=_occluderList.end();
|
||||
++itr)
|
||||
|
@ -401,8 +401,6 @@ void Image::readImageFromCurrentTexture(unsigned int contextID)
|
||||
|
||||
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);
|
||||
|
||||
_internalTextureFormat = internalformat;
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
#include <osg/Notify>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -64,7 +64,6 @@ void PagedLOD::traverse(NodeVisitor& nv)
|
||||
{
|
||||
if (updateTimeStamp) _perRangeDataList[i]._timeStamp=timeStamp;
|
||||
|
||||
//std::cout<<"PagedLOD::traverse() - Selecting child "<<i<<std::endl;
|
||||
_children[i]->accept(nv);
|
||||
lastChildTraversed = (int)i;
|
||||
}
|
||||
@ -79,11 +78,9 @@ void PagedLOD::traverse(NodeVisitor& nv)
|
||||
{
|
||||
unsigned int numChildren = _children.size();
|
||||
|
||||
//std::cout<<"PagedLOD::traverse() - falling back "<<std::endl;
|
||||
// select the last valid child.
|
||||
if (numChildren>0 && ((int)numChildren-1)!=lastChildTraversed)
|
||||
{
|
||||
//std::cout<<" to child "<<numChildren-1<<std::endl;
|
||||
if (updateTimeStamp) _perRangeDataList[numChildren-1]._timeStamp=timeStamp;
|
||||
_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.
|
||||
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());
|
||||
}
|
||||
|
||||
@ -131,25 +127,21 @@ bool PagedLOD::computeBound() const
|
||||
void PagedLOD::childRemoved(unsigned int pos, unsigned int numChildrenToRemove)
|
||||
{
|
||||
LOD::childRemoved(pos, numChildrenToRemove);
|
||||
//std::cout<<"PagedLOD::childRemoved("<<pos<<","<<numChildrenToRemove<<")"<<std::endl;
|
||||
}
|
||||
|
||||
void PagedLOD::childInserted(unsigned int pos)
|
||||
{
|
||||
LOD::childInserted(pos);
|
||||
//std::cout<<"PagedLOD::childInserted("<<pos<<")"<<std::endl;
|
||||
}
|
||||
|
||||
void PagedLOD::rangeRemoved(unsigned int pos, unsigned int numChildrenToRemove)
|
||||
{
|
||||
LOD::rangeRemoved(pos, numChildrenToRemove);
|
||||
std::cout<<"PagedLOD::rangeRemoved("<<pos<<","<<numChildrenToRemove<<")"<<std::endl;
|
||||
}
|
||||
|
||||
void PagedLOD::rangeInserted(unsigned int pos)
|
||||
{
|
||||
LOD::rangeInserted(pos);
|
||||
std::cout<<"PagedLOD::rangeInserted("<<pos<<")"<<std::endl;
|
||||
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)
|
||||
{
|
||||
//removedChildren.push_back(_children[_children.size()-1].get());
|
||||
Group::removeChild(_children[_children.size()-1].get());
|
||||
}
|
||||
}
|
||||
|
@ -827,9 +827,9 @@ void DrawShapeVisitor::apply(const Capsule& capsule)
|
||||
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)
|
||||
@ -1661,9 +1661,9 @@ void PrimitiveShapeVisitor::apply(const Capsule& /*capsule*/)
|
||||
#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)
|
||||
|
@ -385,7 +385,7 @@ bool TestSuite::accept( Test::Visitor& v )
|
||||
|
||||
bool QualifiedTestPrinter::visit( TestCase* pTest )
|
||||
{
|
||||
std::cout << currentPath() + pTest->name() << std::endl;
|
||||
osg::notify(osg::NOTICE) << currentPath() + pTest->name() << std::endl;
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
int loc = getLocation( ext, progObj );
|
||||
|
@ -45,15 +45,12 @@ class ReaderWriter3DC : public osgDB::ReaderWriter
|
||||
if (line[0]=='#')
|
||||
{
|
||||
// comment line
|
||||
std::cout <<"Comment: "<<line<<std::endl;
|
||||
osg::notify(osg::INFO) <<"Comment: "<<line<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
++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))
|
||||
// const_cast<ac3d::Geode*>(static_cast<const ac3d::Geode*>(&node))->Process(fout);
|
||||
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();
|
||||
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 );
|
||||
if (error)
|
||||
{
|
||||
std::cout << "FT_Load_Char(...) error "<<error<<std::endl;
|
||||
osg::notify(osg::WARN) << "FT_Load_Char(...) error "<<error<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -12,14 +12,14 @@
|
||||
*/
|
||||
|
||||
#include "FreeTypeLibrary.h"
|
||||
|
||||
#include <osg/Notify>
|
||||
|
||||
FreeTypeLibrary::FreeTypeLibrary()
|
||||
{
|
||||
FT_Error error = FT_Init_FreeType( &_ftlibrary );
|
||||
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 );
|
||||
if (error == FT_Err_Unknown_File_Format)
|
||||
{
|
||||
std::cout<<" .... 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)<<" .... the font file could be opened and read, but it appears"<<std::endl;
|
||||
osg::notify(osg::WARN)<<" .... that its font format is unsupported"<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
else if (error)
|
||||
{
|
||||
std::cout<<" .... 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)<<" .... another error code means that the font file could notd"<<std::endl;
|
||||
osg::notify(osg::WARN)<<" .... be opened, read or simply that it is broken..d"<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -181,19 +181,19 @@ public:
|
||||
}
|
||||
bool addFlat( const georecord *gface)
|
||||
{ // 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...
|
||||
int shademodel=gfshade ? gfshade->getInt() : -1;
|
||||
if (shademodel==GEO_POLY_SHADEMODEL_LIT) { // flat shaded - need the index
|
||||
const geoField *gfd=gface->getField(GEO_DB_POLY_NORMAL);
|
||||
if (gfd) {
|
||||
float *normal= (gfd) ? (gfd->getVec3Arr()):NULL;
|
||||
osg::Vec3 nrm(normal[0], normal[1], normal[2]);
|
||||
norms->push_back(nrm);
|
||||
isflat=true;
|
||||
}
|
||||
}
|
||||
return isflat;
|
||||
int shademodel=gfshade ? gfshade->getInt() : -1;
|
||||
if (shademodel==GEO_POLY_SHADEMODEL_LIT) { // flat shaded - need the index
|
||||
const geoField *gfd=gface->getField(GEO_DB_POLY_NORMAL);
|
||||
if (gfd) {
|
||||
float *normal= (gfd) ? (gfd->getVec3Arr()):NULL;
|
||||
osg::Vec3 nrm(normal[0], normal[1], normal[2]);
|
||||
norms->push_back(nrm);
|
||||
isflat=true;
|
||||
}
|
||||
}
|
||||
return isflat;
|
||||
}
|
||||
bool addIndices(georecord *gr, const geoHeaderGeo *ghdr, const float cdef[4], const georecord *gface)
|
||||
{ // 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...
|
||||
int shademodel=gfshade ? gfshade->getInt() : -1;
|
||||
if (shademodel!=GEO_POLY_SHADEMODEL_LIT && shademodel!=GEO_POLY_SHADEMODEL_FLAT) {
|
||||
const geoField *gfd=gr->getField(GEO_DB_VRTX_NORMAL);
|
||||
if (gfd->getType()==DB_UINT) {
|
||||
if (gfd) {
|
||||
const geoField *gfd=gr->getField(GEO_DB_VRTX_NORMAL);
|
||||
if (gfd->getType()==DB_UINT) {
|
||||
if (gfd) {
|
||||
unsigned int idx=gfd->getUInt();
|
||||
normindices->push_back(idx);
|
||||
norms->push_back((*npool)[idx]);
|
||||
} else {
|
||||
osg::notify(osg::WARN) << "No valid vertex index" << std::endl;
|
||||
}
|
||||
} else if (gfd->getType()==DB_VEC3F) {
|
||||
float *p=gfd->getVec3Arr();
|
||||
osg::Vec3 nrm;
|
||||
nrm.set(p[0],p[1],p[2]);
|
||||
norms->push_back(nrm);
|
||||
}
|
||||
}
|
||||
normindices->push_back(idx);
|
||||
norms->push_back((*npool)[idx]);
|
||||
} else {
|
||||
osg::notify(osg::WARN) << "No valid vertex index" << std::endl;
|
||||
}
|
||||
} else if (gfd->getType()==DB_VEC3F) {
|
||||
float *p=gfd->getVec3Arr();
|
||||
osg::Vec3 nrm;
|
||||
nrm.set(p[0],p[1],p[2]);
|
||||
norms->push_back(nrm);
|
||||
}
|
||||
}
|
||||
const geoField *gfd=gr->getField(GEO_DB_VRTX_COORD);
|
||||
osg::Vec3 pos;
|
||||
if (gfd->getType()==DB_INT) {
|
||||
if (gfd) {
|
||||
osg::Vec3 pos;
|
||||
if (gfd->getType()==DB_INT) {
|
||||
if (gfd) {
|
||||
int idx=gfd->getInt();
|
||||
pos=(*cpool)[idx];
|
||||
coords->push_back((*cpool)[idx]); //osg::Vec3(cpool[3*idx],cpool[3*idx+1],cpool[3*idx+2]));
|
||||
coordindices->push_back(coords->size());
|
||||
} else {
|
||||
osg::notify(osg::WARN) << "No valid vertex index" << std::endl;
|
||||
}
|
||||
} else if (gfd->getType()==DB_VEC3F) {
|
||||
float *p=gfd->getVec3Arr();
|
||||
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]));
|
||||
}
|
||||
pos=(*cpool)[idx];
|
||||
coords->push_back((*cpool)[idx]); //osg::Vec3(cpool[3*idx],cpool[3*idx+1],cpool[3*idx+2]));
|
||||
coordindices->push_back(coords->size());
|
||||
} else {
|
||||
osg::notify(osg::WARN) << "No valid vertex index" << std::endl;
|
||||
}
|
||||
} else if (gfd->getType()==DB_VEC3F) {
|
||||
float *p=gfd->getVec3Arr();
|
||||
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]));
|
||||
}
|
||||
std::vector< georecord *>bhv=gr->getBehaviour(); // behaviours for vertices, eg tranlate, colour!
|
||||
if (!bhv.empty()) {
|
||||
int ncoord=coords->size();
|
||||
@ -281,15 +281,15 @@ public:
|
||||
gfd=gr->getField(GEO_DB_VRTX_UV_SET_0);
|
||||
if (gfd) {
|
||||
uvc=(float *)gfd->getstore(0);
|
||||
|
||||
if (uvc) { // then there are tx coords
|
||||
osg::Vec2 uv(uvc[0], uvc[1]);
|
||||
txcoords->push_back(uv);
|
||||
} else {
|
||||
txcoords->push_back(osg::Vec2(0,0));
|
||||
}
|
||||
} else {
|
||||
txcoords->push_back(osg::Vec2(0,0));
|
||||
|
||||
if (uvc) { // then there are tx coords
|
||||
osg::Vec2 uv(uvc[0], uvc[1]);
|
||||
txcoords->push_back(uv);
|
||||
} else {
|
||||
txcoords->push_back(osg::Vec2(0,0));
|
||||
}
|
||||
} else {
|
||||
txcoords->push_back(osg::Vec2(0,0));
|
||||
}
|
||||
gfd=gr->getField(GEO_DB_VRTX_PACKED_COLOR);
|
||||
if (gfd) {
|
||||
@ -365,8 +365,8 @@ public:
|
||||
void setPools(const std::vector<osg::Vec3> *coord_pool, const std::vector<osg::Vec3> *normal_pool) {
|
||||
vinf.setPools(coord_pool,normal_pool);
|
||||
}
|
||||
float getlinewidth(void) const { return linewidth;}
|
||||
void setlineWidth(const int w) { linewidth=w;}
|
||||
float getlinewidth(void) const { return linewidth;}
|
||||
void setlineWidth(const int w) { linewidth=w;}
|
||||
void setGeom(osg::Geometry *nugeom) { geom=nugeom;}
|
||||
osg::Geometry *getGeom() { return geom.get();}
|
||||
uint getStart(uint nv) { uint ns=nstart; nstart+=nv; return ns; }
|
||||
@ -381,10 +381,10 @@ private:
|
||||
int texture; // texture index
|
||||
int bothsides; // none, back,front
|
||||
int shademodel;
|
||||
int linewidth;
|
||||
int linewidth;
|
||||
vertexInfo vinf;
|
||||
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;
|
||||
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) {
|
||||
geoField *gfff=gr.getModField(GEO_DB_NORMAL_POOL_VALUES);
|
||||
gfff->uncompress();// uncompress the normals
|
||||
@ -440,7 +440,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
output(fout,sorted);
|
||||
fout.close();
|
||||
#endif /**/
|
||||
makeHeader(*(sorted.begin()));
|
||||
makeHeader(*(sorted.begin()));
|
||||
|
||||
nodeList=makeosg(sorted); // make a list of osg nodes
|
||||
geotxlist.clear();
|
||||
@ -450,7 +450,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
matlist.clear();/* */
|
||||
coord_pool.clear();
|
||||
normal_pool.clear();
|
||||
osg::Node * groupnode = NULL;
|
||||
osg::Node * groupnode = NULL;
|
||||
if (nodeList.empty())
|
||||
{
|
||||
return ReadResult("No data loaded from "+fileName);
|
||||
@ -461,7 +461,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::Group *group = new Group;
|
||||
osg::Group *group = new Group;
|
||||
group->setName("import group");
|
||||
for(NodeList::iterator itr=nodeList.begin();
|
||||
itr!=nodeList.end();
|
||||
@ -469,12 +469,12 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
{
|
||||
group->addChild(*itr);
|
||||
}
|
||||
groupnode=group;
|
||||
groupnode=group;
|
||||
}
|
||||
(theHeader.get())->addChild(groupnode);
|
||||
groupnode=theHeader.get();
|
||||
(theHeader.get())->addChild(groupnode);
|
||||
groupnode=theHeader.get();
|
||||
#ifdef _DEBUG // output a .osg version
|
||||
osgDB::writeNodeFile(*groupnode,"geoosg.osg");
|
||||
osgDB::writeNodeFile(*groupnode,"geoosg.osg");
|
||||
#endif /**/
|
||||
recs.clear();
|
||||
return groupnode;
|
||||
@ -496,8 +496,8 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
case 101: // old header - not appropriate!
|
||||
curparent= &(*itr);
|
||||
sorted.push_back(&(*itr));
|
||||
osg::notify(osg::WARN) << "Old version 2 header block found - possible error!" << std::endl;
|
||||
break;
|
||||
osg::notify(osg::WARN) << "Old version 2 header block found - possible error!" << std::endl;
|
||||
break;
|
||||
case DB_DSK_PUSH:
|
||||
if (!(curparent->getchildren().empty())) {
|
||||
curparent= curparent->getLastChild(); // itr-1;
|
||||
@ -511,7 +511,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
case DB_DSK_HEADER: // attach to previous
|
||||
curparent= &(*itr);
|
||||
sorted.push_back(&(*itr));
|
||||
cpalrec=NULL;
|
||||
cpalrec=NULL;
|
||||
break;
|
||||
case DB_DSK_INTERNAL_VARS: // attach to parent
|
||||
case DB_DSK_LOCAL_VARS:
|
||||
@ -586,12 +586,12 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
case DB_DSK_IF_THEN_ELSE_ACTION:
|
||||
case DB_DSK_DCS_ACTION:
|
||||
case DB_DSK_SQRT_ACTION: // an action
|
||||
if (curparent->getType()==DB_DSK_HEADER)
|
||||
curparent->addBehaviourRecord(&(*itr));
|
||||
else {
|
||||
class georecord *cp=curparent->getLastChild();
|
||||
if (cp) cp->addBehaviourRecord(&(*itr));
|
||||
}
|
||||
if (curparent->getType()==DB_DSK_HEADER)
|
||||
curparent->addBehaviourRecord(&(*itr));
|
||||
else {
|
||||
class georecord *cp=curparent->getLastChild();
|
||||
if (cp) cp->addBehaviourRecord(&(*itr));
|
||||
}
|
||||
break;
|
||||
case DB_DSK_PERSPECTIVE_GRID_INFO: // Feb 2003 not sure what this is yet!
|
||||
(curparent)->addchild(&(*itr));
|
||||
@ -649,7 +649,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
const vertexInfo *vinf=ginf.getVinf();
|
||||
nug->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
nug->setVertexArray(vinf->getCoords());
|
||||
StateSet *dstate=new StateSet;
|
||||
StateSet *dstate=new StateSet;
|
||||
if (bothsides==0) {
|
||||
osg::CullFace *cf = new osg::CullFace; // to define non-default culling
|
||||
cf->setMode(osg::CullFace::BACK);
|
||||
@ -710,20 +710,20 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
nug->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
}
|
||||
} else {
|
||||
if (shademodel==GEO_POLY_SHADEMODEL_LIT_GOURAUD) {
|
||||
nug->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
} else if (shademodel==GEO_POLY_SHADEMODEL_LIT) {
|
||||
nug->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
}
|
||||
osg::Vec4Array *polycols=vinf->getPolcolours();
|
||||
if (shademodel==GEO_POLY_SHADEMODEL_LIT_GOURAUD) {
|
||||
nug->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
} else if (shademodel==GEO_POLY_SHADEMODEL_LIT) {
|
||||
nug->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
}
|
||||
osg::Vec4Array *polycols=vinf->getPolcolours();
|
||||
nug->setColorArray(polycols);
|
||||
nug->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
osg::LineWidth *lw=new osg::LineWidth;
|
||||
lw->setWidth(ginf.getlinewidth());
|
||||
dstate->setAttributeAndModes(lw,osg::StateAttribute::ON);
|
||||
osg::LineWidth *lw=new osg::LineWidth;
|
||||
lw->setWidth(ginf.getlinewidth());
|
||||
dstate->setAttributeAndModes(lw,osg::StateAttribute::ON);
|
||||
nug->setStateSet( dstate );
|
||||
ginf.setGeom(nug);
|
||||
return nug;
|
||||
@ -754,11 +754,11 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
}
|
||||
|
||||
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();
|
||||
itr!=gr.end();
|
||||
++itr) {
|
||||
vinf->addIndices((*itr), theHeader.get(), defcol, grec);
|
||||
vinf->addIndices((*itr), theHeader.get(), defcol, grec);
|
||||
nv++;
|
||||
}
|
||||
}
|
||||
@ -782,7 +782,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
osg::MatrixTransform *makeText(georecord *gr) { // make transform, geode & text
|
||||
osg::MatrixTransform *numt=NULL;
|
||||
std::string ttfPath("fonts/times.ttf");
|
||||
// unused
|
||||
// unused
|
||||
//int gFontSize1=2;
|
||||
osgText::Text *text= new osgText::Text;
|
||||
text->setFont(ttfPath);
|
||||
@ -823,7 +823,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
textState->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||
geod->setStateSet( textState );
|
||||
numt=new osg::MatrixTransform;
|
||||
numt->setName(name);
|
||||
numt->setName(name);
|
||||
gfd=gr->getField(GEO_DB_TEXT_MATRIX);
|
||||
if (gfd) {
|
||||
float *fmat=gfd->getMat44Arr();
|
||||
@ -899,18 +899,18 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
if ((*itr)->getType()==DB_DSK_VERTEX)
|
||||
{ // light point vertices
|
||||
const geoField *gfd=(*itr)->getField(GEO_DB_VRTX_COORD);
|
||||
osg::Vec3 pos;
|
||||
if (gfd->getType()==DB_INT) {
|
||||
if (gfd) {
|
||||
osg::Vec3 pos;
|
||||
if (gfd->getType()==DB_INT) {
|
||||
if (gfd) {
|
||||
int idx=gfd->getInt();
|
||||
pos=coord_pool[idx];
|
||||
} else {
|
||||
osg::notify(osg::WARN) << "No valid vertex index" << std::endl;
|
||||
}
|
||||
} else if (gfd->getType()==DB_VEC3F) {
|
||||
float *p=gfd->getVec3Arr();
|
||||
pos.set(p[0],p[1],p[2]);
|
||||
}
|
||||
pos=coord_pool[idx];
|
||||
} else {
|
||||
osg::notify(osg::WARN) << "No valid vertex index" << std::endl;
|
||||
}
|
||||
} else if (gfd->getType()==DB_VEC3F) {
|
||||
float *p=gfd->getVec3Arr();
|
||||
pos.set(p[0],p[1],p[2]);
|
||||
}
|
||||
gfd=(*itr)->getField(GEO_DB_VRTX_PACKED_COLOR);
|
||||
if (gfd) {
|
||||
unsigned char *cls=gfd->getUCh4Arr();
|
||||
@ -949,16 +949,16 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
int makeAnimatedGeometry(const georecord grec, const int imat,Group *nug) {
|
||||
// animated polygons - create a matrix & geode & poly & add to group nug
|
||||
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
|
||||
unsigned int bothsides=gfd ? gfd->getUInt() : 0;
|
||||
unsigned int bothsides=gfd ? gfd->getUInt() : 0;
|
||||
// int bothsides =allOneSided(&grec);
|
||||
for (std::vector<georecord *>::const_iterator itr=gr.begin();
|
||||
itr!=gr.end();
|
||||
++itr) {
|
||||
std::vector< georecord *>bhv=(*itr)->getBehaviour(); // behaviours attached to facets, eg colour!
|
||||
if ((*itr)->getType()==DB_DSK_POLYGON && !bhv.empty()) { // animated facets go here
|
||||
nanimations++;
|
||||
nanimations++;
|
||||
if (hasMotionAction(bhv)) { // make matrix if motion needed.
|
||||
const geoField *gfd=(*itr)->getField(GEO_DB_POLY_TEX0);
|
||||
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;
|
||||
geoInfo gi(txidx,shademodel, bothsides);
|
||||
gi.setPools(&coord_pool, &normal_pool);
|
||||
gfd=grec->getField(GEO_DB_POLY_LINE_WIDTH); // integer line width...
|
||||
if (gfd) {
|
||||
int w=gfd->getInt();
|
||||
gi.setlineWidth(w);
|
||||
}
|
||||
gfd=grec->getField(GEO_DB_POLY_LINE_WIDTH); // integer line width...
|
||||
if (gfd) {
|
||||
int w=gfd->getInt();
|
||||
gi.setlineWidth(w);
|
||||
}
|
||||
osg::Geometry *nugeom=makeNewGeometry(grec, gi, imat);
|
||||
nug->addDrawable(nugeom);
|
||||
igeom=ia->size();
|
||||
@ -1083,7 +1083,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
if (gr.size()>0) {
|
||||
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
|
||||
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
|
||||
// bool bothsides=allOneSided(&grec);
|
||||
for (std::vector<georecord *>::const_iterator itr=gr.begin();
|
||||
@ -1121,15 +1121,15 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
}
|
||||
}
|
||||
int nv=getprim((*itr), *gi);
|
||||
{
|
||||
const vertexInfo *vinf=gi->getVinf();
|
||||
if (vinf->getNorms() && vinf->getNorms()->size()>0) {
|
||||
gi->getGeom()->setNormalArray(vinf->getNorms());
|
||||
gi->getGeom()->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
} else {
|
||||
gi->getGeom()->setNormalBinding(osg::Geometry::BIND_OFF);
|
||||
}
|
||||
}
|
||||
{
|
||||
const vertexInfo *vinf=gi->getVinf();
|
||||
if (vinf->getNorms() && vinf->getNorms()->size()>0) {
|
||||
gi->getGeom()->setNormalArray(vinf->getNorms());
|
||||
gi->getGeom()->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
} else {
|
||||
gi->getGeom()->setNormalBinding(osg::Geometry::BIND_OFF);
|
||||
}
|
||||
}
|
||||
if (hasColorAction(bhv)) addPolyActions(bhv, *gi, nv);
|
||||
|
||||
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)
|
||||
{ // 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
|
||||
return NULL; // temporary disable april 2003
|
||||
return NULL; // temporary disable april 2003
|
||||
Group *nug=new Group;
|
||||
const geoField *gfd=gr->getField(GEO_DB_RENDERGROUP_MAT);
|
||||
// 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;
|
||||
gfd=gr.getField(GEO_DB_RENDERGROUP_BILLBOARD);
|
||||
bool isbillb = gfd ? gfd->getBool() : false;
|
||||
osg::Geode *nug;
|
||||
osg::Geode *nug;
|
||||
if (isbillb) {
|
||||
Billboard *bilb= new Billboard ;
|
||||
bilb->setAxis(Vec3(0,0,1));
|
||||
@ -1261,15 +1261,15 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
nug=new Geode;
|
||||
}
|
||||
int nchild=makeGeometry(gr,imat,nug);
|
||||
if (nchild>0) { // complete the geode
|
||||
gfd=gr.getField(GEO_DB_NODE_NAME);
|
||||
if (gfd) {
|
||||
nug->setName(gfd->getChar());
|
||||
}
|
||||
return nug;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
if (nchild>0) { // complete the geode
|
||||
gfd=gr.getField(GEO_DB_NODE_NAME);
|
||||
if (gfd) {
|
||||
nug->setName(gfd->getChar());
|
||||
}
|
||||
return nug;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
osg::Group *makePage(const georecord *gr)
|
||||
{
|
||||
@ -1280,11 +1280,11 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
}
|
||||
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);
|
||||
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_SCALE_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_SCALE_TRANSFORM);
|
||||
if (gfd) {
|
||||
MatrixTransform *tr=new MatrixTransform;
|
||||
osg::Matrix mx;
|
||||
@ -1295,7 +1295,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
osg::Group *makeGroup(const georecord *gr) { // group or Static transform
|
||||
osg::Group *gp=setmatrix(gr);
|
||||
if (!gp) {
|
||||
@ -1359,41 +1359,41 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
}
|
||||
return gp;
|
||||
}
|
||||
osg::Drawable* createClipSurface(float xMin,float xMax,float yMin,float yMax,float z)
|
||||
{ // set up the Geometry that defines the clipped region.
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
|
||||
osg::Vec3Array* coords = new osg::Vec3Array(4);
|
||||
(*coords)[0].set(xMin,yMax,z);
|
||||
(*coords)[1].set(xMin,yMin,z);
|
||||
(*coords)[2].set(xMax,yMin,z);
|
||||
(*coords)[3].set(xMax,yMax,z);
|
||||
geom->setVertexArray(coords);
|
||||
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
|
||||
|
||||
return geom;
|
||||
}
|
||||
osg::Drawable* createClipSurface(float xMin,float xMax,float yMin,float yMax,float z)
|
||||
{ // set up the Geometry that defines the clipped region.
|
||||
osg::Geometry* geom = new osg::Geometry;
|
||||
|
||||
osg::Vec3Array* coords = new osg::Vec3Array(4);
|
||||
(*coords)[0].set(xMin,yMax,z);
|
||||
(*coords)[1].set(xMin,yMin,z);
|
||||
(*coords)[2].set(xMax,yMin,z);
|
||||
(*coords)[3].set(xMax,yMax,z);
|
||||
geom->setVertexArray(coords);
|
||||
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
|
||||
|
||||
return geom;
|
||||
}
|
||||
Group *makeClipRegion(const georecord *gr) {
|
||||
GeoClipRegion *clp=new GeoClipRegion;
|
||||
GeoClipRegion *clp=new GeoClipRegion;
|
||||
const geoField *gfd=gr->getField(GEO_DB_NODE_NAME);
|
||||
if (gfd) {
|
||||
clp->setName(gfd->getChar());
|
||||
}
|
||||
gfd=gr->getField(140);
|
||||
float *lleft = (gfd) ? (gfd->getVec3Arr()):NULL;
|
||||
float *lleft = (gfd) ? (gfd->getVec3Arr()):NULL;
|
||||
gfd=gr->getField(141);
|
||||
float *uright= (gfd) ? (gfd->getVec3Arr()):NULL;
|
||||
if (uright && lleft) {
|
||||
Geode *geod=new Geode;
|
||||
Drawable *drw=createClipSurface(lleft[0],uright[0],lleft[1],uright[1],lleft[2]);
|
||||
geod->addDrawable(drw);
|
||||
clp->addClipNode(geod);
|
||||
}
|
||||
return clp;
|
||||
float *uright= (gfd) ? (gfd->getVec3Arr()):NULL;
|
||||
if (uright && lleft) {
|
||||
Geode *geod=new Geode;
|
||||
Drawable *drw=createClipSurface(lleft[0],uright[0],lleft[1],uright[1],lleft[2]);
|
||||
geod->addDrawable(drw);
|
||||
clp->addClipNode(geod);
|
||||
}
|
||||
return clp;
|
||||
}
|
||||
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
|
||||
const geoField *gfd;
|
||||
if (cpalrec) { // global - attach to geoheader
|
||||
@ -1709,23 +1709,23 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
Group *animatedGeodes= makeAnimatedGeodes(gr);
|
||||
Group *lightptGeodes= makeLightPointGeodes(gr);
|
||||
Group *textgeode=makeTextGeode(gr); // group of matrices & texts
|
||||
const geoField *gfd=gr->getField(GEO_DB_GRP_ZBUFFER);
|
||||
if (gfd) {
|
||||
bool onoff=gfd->getBool();
|
||||
if (!onoff) { // no z buffer - force to use unsorted renderBin
|
||||
StateSet *dstate=new StateSet;
|
||||
osg::Depth* depth = new osg::Depth;
|
||||
depth->setFunction(osg::Depth::ALWAYS);
|
||||
dstate->setAttribute(depth);
|
||||
dstate->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
|
||||
dstate->setRenderBinDetails(osg::StateSet::TRANSPARENT_BIN + 1,"RenderBin");
|
||||
// dstate->setRenderBinDetails(osg::StateSet::TRANSPARENT_BIN + 12, "UnSortedBin");
|
||||
if (geode) geode->setStateSet( dstate );
|
||||
if (animatedGeodes) animatedGeodes->setStateSet( dstate );
|
||||
if (lightptGeodes) lightptGeodes->setStateSet( dstate );
|
||||
if (textgeode) textgeode->setStateSet( dstate );
|
||||
}
|
||||
}
|
||||
const geoField *gfd=gr->getField(GEO_DB_GRP_ZBUFFER);
|
||||
if (gfd) {
|
||||
bool onoff=gfd->getBool();
|
||||
if (!onoff) { // no z buffer - force to use unsorted renderBin
|
||||
StateSet *dstate=new StateSet;
|
||||
osg::Depth* depth = new osg::Depth;
|
||||
depth->setFunction(osg::Depth::ALWAYS);
|
||||
dstate->setAttribute(depth);
|
||||
dstate->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
|
||||
dstate->setRenderBinDetails(osg::StateSet::TRANSPARENT_BIN + 1,"RenderBin");
|
||||
// dstate->setRenderBinDetails(osg::StateSet::TRANSPARENT_BIN + 12, "UnSortedBin");
|
||||
if (geode) geode->setStateSet( dstate );
|
||||
if (animatedGeodes) animatedGeodes->setStateSet( dstate );
|
||||
if (lightptGeodes) lightptGeodes->setStateSet( dstate );
|
||||
if (textgeode) textgeode->setStateSet( dstate );
|
||||
}
|
||||
}
|
||||
|
||||
if (mtr) {
|
||||
if (geode) mtr->addChild(geode);
|
||||
@ -1737,7 +1737,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
} else {
|
||||
if (!geodeholder && (geode || textgeode)) {
|
||||
geodeholder=new osg::Group;
|
||||
geodeholder->setName("geodeHolder");
|
||||
geodeholder->setName("geodeHolder");
|
||||
}
|
||||
if (geode) geodeholder->addChild(geode);
|
||||
if (animatedGeodes) geodeholder->addChild(animatedGeodes);
|
||||
@ -1756,12 +1756,12 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
holder=mtr;
|
||||
}
|
||||
(*itr)->setNode(holder);
|
||||
break;
|
||||
break;
|
||||
/* holder= theHeader.get(); // makeHeader(gr);//
|
||||
(*itr)->setNode(holder);
|
||||
if (mtr) {
|
||||
holder->addChild(mtr);
|
||||
osg::Group *grp=makeGroup(gr);
|
||||
osg::Group *grp=makeGroup(gr);
|
||||
mtr->addChild(grp);
|
||||
holder=mtr;
|
||||
}
|
||||
@ -1770,7 +1770,7 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
makeTexture(gr);
|
||||
break;
|
||||
case DB_DSK_BASE_GROUP: // start of a group plus extra features
|
||||
holder=makeClipRegion(gr);
|
||||
holder=makeClipRegion(gr);
|
||||
if (mtr) {
|
||||
mtr->addChild(holder);
|
||||
holder=mtr;
|
||||
@ -1862,9 +1862,9 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
(*itr)->setNode(holder);
|
||||
break;
|
||||
case DB_DSK_PERSPECTIVE_GRID_INFO:
|
||||
{ // relates to how model is viewed in Geo modeller
|
||||
osg::Group *gp=new Group;
|
||||
holder=gp;
|
||||
{ // relates to how model is viewed in Geo modeller
|
||||
osg::Group *gp=new Group;
|
||||
holder=gp;
|
||||
}
|
||||
break;
|
||||
case DB_DSK_FLOAT_VAR:
|
||||
@ -1892,8 +1892,8 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
case DB_DSK_STRING_CONTENT_ACTION:
|
||||
default: {
|
||||
osg::Group *gp=new Group;
|
||||
std::cout << "Unhandled item " << gr->getType() <<
|
||||
"address " << (*itr) << std::endl;
|
||||
osg::notify(osg::WARN) << "Unhandled item " << gr->getType() <<
|
||||
"address " << (*itr) << std::endl;
|
||||
holder=gp;
|
||||
}
|
||||
break;
|
||||
@ -1901,11 +1901,11 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
if (holder) nodelist.push_back(holder);
|
||||
|
||||
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();
|
||||
itr!=child.end();
|
||||
++itr) {
|
||||
if (clip) clip->addClippedChild(*itr);
|
||||
if (clip) clip->addClippedChild(*itr);
|
||||
else holder->addChild(*itr);
|
||||
}
|
||||
}
|
||||
@ -1998,12 +1998,12 @@ class ReaderWriterGEO : public osgDB::ReaderWriter
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
geoRecordList recs; // the records read from file
|
||||
std::vector<osg::Vec3> coord_pool; // current vertex ooords
|
||||
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 *> geomatlist; // list of geo::materials 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
|
||||
static int nread=0; // debug only
|
||||
// unused
|
||||
//geoExtensionDefRec *geoExt=(geoExtensionDefRec *)storage;
|
||||
for (uint i=0; i<numItems; i++) {
|
||||
geoExtensionDefRec rec;
|
||||
fin.read((char *)&rec,sizeof(rec));
|
||||
geoField ginner; // inside reading
|
||||
ginner.readfile(fin,0);
|
||||
}
|
||||
nread++;
|
||||
static int nread=0; // debug only
|
||||
// unused
|
||||
//geoExtensionDefRec *geoExt=(geoExtensionDefRec *)storage;
|
||||
for (uint i=0; i<numItems; i++) {
|
||||
geoExtensionDefRec rec;
|
||||
fin.read((char *)&rec,sizeof(rec));
|
||||
geoField ginner; // inside reading
|
||||
ginner.readfile(fin,0);
|
||||
}
|
||||
nread++;
|
||||
}
|
||||
void geoField::readfile(std::ifstream &fin, const uint id) { // is part of a record id
|
||||
unsigned char tokid, type;
|
||||
unsigned short nits;
|
||||
if (!fin.eof()) {
|
||||
fin.read((char *)&tokid,1);fin.read((char *)&type,1);
|
||||
fin.read((char *)&nits,sizeof(unsigned short));
|
||||
// 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
|
||||
fin.read((char *)&tokenId,sizeof(tokenId));fin.read((char *)&TypeId,sizeof(TypeId));
|
||||
fin.read((char *)&numItems,sizeof(unsigned int));
|
||||
} else {
|
||||
tokenId=tokid; TypeId=type;
|
||||
numItems=nits;
|
||||
}
|
||||
if (id== 0 && tokenId == GEO_DB_NODE_EXTENDED && numItems==1) { // Feb 2003 parse extension template records
|
||||
if (TypeId == DB_SHORT ||
|
||||
TypeId == DB_USHORT) {
|
||||
short upad;
|
||||
fin.read((char *)&upad,SIZEOF_SHORT); // skip the padding on extension template
|
||||
upad=1;
|
||||
} else if (TypeId == DB_CHAR ||
|
||||
TypeId == DB_UCHAR) {
|
||||
char cpad[4];
|
||||
fin.read(cpad,SIZEOF_CHAR); // skip the padding
|
||||
} else {
|
||||
}
|
||||
}
|
||||
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;
|
||||
parseExt(fin); // multiple structs occur here
|
||||
} else {
|
||||
if (numItems>0) {
|
||||
storageRead(fin); // allocate & fill the storage
|
||||
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_CHAR ||TypeId == DB_UCHAR) fin.ignore(3); // skip padding
|
||||
}
|
||||
if (tokenId == GEO_DB_NODE_EXTENDED) {
|
||||
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_SPHERE || id==DB_DSK_CONE || id==DB_DSK_CYLINDER
|
||||
|| id==DB_DSK_TEXTURE || id==DB_DSK_MATERIAL || id==DB_DSK_VIEW) {
|
||||
if (TypeId == DB_SHORT ||TypeId == DB_USHORT) fin.ignore(2); // skip padding
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unsigned char tokid, type;
|
||||
unsigned short nits;
|
||||
if (!fin.eof()) {
|
||||
fin.read((char *)&tokid,1);fin.read((char *)&type,1);
|
||||
fin.read((char *)&nits,sizeof(unsigned short));
|
||||
// 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
|
||||
fin.read((char *)&tokenId,sizeof(tokenId));fin.read((char *)&TypeId,sizeof(TypeId));
|
||||
fin.read((char *)&numItems,sizeof(unsigned int));
|
||||
} else {
|
||||
tokenId=tokid; TypeId=type;
|
||||
numItems=nits;
|
||||
}
|
||||
if (id== 0 && tokenId == GEO_DB_NODE_EXTENDED && numItems==1) { // Feb 2003 parse extension template records
|
||||
if (TypeId == DB_SHORT ||
|
||||
TypeId == DB_USHORT) {
|
||||
short upad;
|
||||
fin.read((char *)&upad,SIZEOF_SHORT); // skip the padding on extension template
|
||||
upad=1;
|
||||
} else if (TypeId == DB_CHAR ||
|
||||
TypeId == DB_UCHAR) {
|
||||
char cpad[4];
|
||||
fin.read(cpad,SIZEOF_CHAR); // skip the padding
|
||||
} else {
|
||||
}
|
||||
}
|
||||
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;
|
||||
parseExt(fin); // multiple structs occur here
|
||||
} else {
|
||||
if (numItems>0) {
|
||||
storageRead(fin); // allocate & fill the storage
|
||||
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_CHAR ||TypeId == DB_UCHAR) fin.ignore(3); // skip padding
|
||||
}
|
||||
if (tokenId == GEO_DB_NODE_EXTENDED) {
|
||||
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_SPHERE || id==DB_DSK_CONE || id==DB_DSK_CYLINDER
|
||||
|| id==DB_DSK_TEXTURE || id==DB_DSK_MATERIAL || id==DB_DSK_VIEW) {
|
||||
if (TypeId == DB_SHORT ||TypeId == DB_USHORT) fin.ignore(2); // skip padding
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace osg;
|
||||
@ -41,7 +42,9 @@ class PrintVisitor : public NodeVisitor
|
||||
|
||||
public:
|
||||
|
||||
PrintVisitor():NodeVisitor(NodeVisitor::TRAVERSE_ALL_CHILDREN)
|
||||
PrintVisitor(std::ostream& out):
|
||||
NodeVisitor(NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||
_out(out)
|
||||
{
|
||||
_indent = 0;
|
||||
_step = 4;
|
||||
@ -51,29 +54,32 @@ class PrintVisitor : public NodeVisitor
|
||||
inline void moveOut() { _indent -= _step; }
|
||||
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)
|
||||
{
|
||||
moveIn();
|
||||
writeIndent(); std::cout << node.className() << " name=" << node.getName() << std::endl;
|
||||
writeIndent(); _out << node.className() <<std::endl;
|
||||
traverse(node);
|
||||
moveOut();
|
||||
}
|
||||
|
||||
virtual void apply(Geode& node) { apply((Node&)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(Transform& node) { apply((Group&)node); }
|
||||
virtual void apply(Projection& node) { apply((Group&)node); }
|
||||
virtual void apply(Switch& node) { apply((Group&)node); }
|
||||
virtual void apply(LOD& node) { apply((Group&)node); }
|
||||
virtual void apply(Impostor& node) { apply((LOD&)node); }
|
||||
|
||||
protected:
|
||||
|
||||
std::ostream& _out;
|
||||
int _indent;
|
||||
int _step;
|
||||
};
|
||||
@ -124,7 +130,7 @@ ReaderWriter3DS::ReaderWriter3DS()
|
||||
These print methods for 3ds hacking
|
||||
*/
|
||||
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(Lib3dsUserData *user,int level);
|
||||
|
@ -241,7 +241,7 @@ public:
|
||||
unsigned int n;
|
||||
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;
|
||||
}
|
||||
if( screen != n )
|
||||
|
@ -674,7 +674,6 @@ void* lightRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
{
|
||||
for(unsigned int i = 0; i < nvert; i++)
|
||||
{
|
||||
std::cout<<"LightPoint node"<<std::endl;
|
||||
trpg3dPoint pt;
|
||||
light.GetVertex(i, pt);
|
||||
osg::Matrix matrix;
|
||||
@ -770,30 +769,30 @@ void* labelRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
osg::ref_ptr< osgText::Text > text = new osgText::Text;
|
||||
|
||||
// Text
|
||||
std::ostringstream os;
|
||||
int nl;
|
||||
std::string lb = *labelText;
|
||||
while ( (nl=lb.find_first_of('\\')) != std::string::npos)
|
||||
{
|
||||
std::string sub = lb.substr(0,nl);
|
||||
switch (lb[nl+1])
|
||||
{
|
||||
case 'n':
|
||||
lb.erase(0,nl+2);
|
||||
if (sub.length()) os << sub << std::endl;
|
||||
break;
|
||||
case 't':
|
||||
lb.erase(0,nl+2);
|
||||
os << sub << " ";//'\t';
|
||||
break;
|
||||
default:
|
||||
lb.erase(0,nl+1);
|
||||
os << '\\' << sub;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (lb.length()) os << lb;
|
||||
std::ostringstream os;
|
||||
unsigned int nl;
|
||||
std::string lb = *labelText;
|
||||
while ( (nl=lb.find_first_of('\\')) != std::string::npos)
|
||||
{
|
||||
std::string sub = lb.substr(0,nl);
|
||||
switch (lb[nl+1])
|
||||
{
|
||||
case 'n':
|
||||
lb.erase(0,nl+2);
|
||||
if (sub.length()) os << sub << std::endl;
|
||||
break;
|
||||
case 't':
|
||||
lb.erase(0,nl+2);
|
||||
os << sub << " ";//'\t';
|
||||
break;
|
||||
default:
|
||||
lb.erase(0,nl+1);
|
||||
os << '\\' << sub;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (lb.length()) os << lb;
|
||||
text->setText(os.str());
|
||||
|
||||
// Position
|
||||
@ -811,13 +810,13 @@ void* labelRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
text->setAlignment(osgText::Text::CENTER_BOTTOM);
|
||||
}
|
||||
// Axis alignment
|
||||
text->setAxisAlignment(osgText::Text::XZ_PLANE);
|
||||
text->setAxisAlignment(osgText::Text::XZ_PLANE);
|
||||
|
||||
const trpgLabelPropertyTable *labelPropertyTable = _parse->getArchive()->GetLabelPropertyTable();
|
||||
const trpgLabelProperty *labelProperty = labelPropertyTable ?
|
||||
labelPropertyTable->GetPropertyRef(label.GetProperty()) : 0;
|
||||
|
||||
bool addTextGeodeIntoSceneGraph = true;
|
||||
bool addTextGeodeIntoSceneGraph = true;
|
||||
if (labelProperty)
|
||||
{
|
||||
const trpgTextStyleTable *textStyleTable = _parse->getArchive()->GetTextStyleTable();
|
||||
@ -833,213 +832,213 @@ void* labelRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
// Font
|
||||
text->setFont(_parse->getArchive()->getStyles()[labelProperty->GetFontStyle()].get());
|
||||
|
||||
// Color
|
||||
text->setColor(_parse->getArchive()->getTextColors()[labelProperty->GetFontStyle()]);
|
||||
// Color
|
||||
text->setColor(_parse->getArchive()->getTextColors()[labelProperty->GetFontStyle()]);
|
||||
|
||||
// Cube
|
||||
osg::ref_ptr<osg::ShapeDrawable> cube = 0;
|
||||
// Cube
|
||||
osg::ref_ptr<osg::ShapeDrawable> cube = 0;
|
||||
|
||||
// Type
|
||||
switch (labelProperty->GetType())
|
||||
{
|
||||
case trpgLabelProperty::Billboard:
|
||||
text->setAxisAlignment(osgText::Text::XY_PLANE);
|
||||
text->setAxisAlignment(osgText::Text::XY_PLANE);
|
||||
text->setAutoRotateToScreen(true);
|
||||
break;
|
||||
case trpgLabelProperty::VertBillboard:
|
||||
addTextGeodeIntoSceneGraph = false;
|
||||
{
|
||||
osg::ref_ptr< osg::Billboard > billboard = new osg::Billboard;
|
||||
text->setPosition(osg::Vec3(0.f,0.f,0.f));
|
||||
billboard->addDrawable(text.get());
|
||||
billboard->setAxis(osg::Vec3(0.0f,0.0,1.0f) );
|
||||
billboard->setNormal(osg::Vec3(0.0f,-1.0,0.0f));
|
||||
billboard->setMode(osg::Billboard::AXIAL_ROT);
|
||||
billboard->setPos(0,pos);
|
||||
addTextGeodeIntoSceneGraph = false;
|
||||
{
|
||||
osg::ref_ptr< osg::Billboard > billboard = new osg::Billboard;
|
||||
text->setPosition(osg::Vec3(0.f,0.f,0.f));
|
||||
billboard->addDrawable(text.get());
|
||||
billboard->setAxis(osg::Vec3(0.0f,0.0,1.0f) );
|
||||
billboard->setNormal(osg::Vec3(0.0f,-1.0,0.0f));
|
||||
billboard->setMode(osg::Billboard::AXIAL_ROT);
|
||||
billboard->setPos(0,pos);
|
||||
|
||||
_parse->getCurrTop()->addChild(billboard.get());
|
||||
}
|
||||
_parse->getCurrTop()->addChild(billboard.get());
|
||||
}
|
||||
break;
|
||||
case trpgLabelProperty::Cube:
|
||||
addTextGeodeIntoSceneGraph = false;
|
||||
{
|
||||
osg::Group* group = new osg::Group;
|
||||
addTextGeodeIntoSceneGraph = false;
|
||||
{
|
||||
osg::Group* group = new osg::Group;
|
||||
|
||||
osg::BoundingBox box = text->getBound();
|
||||
float shift = box.radius()+1.f;
|
||||
osg::BoundingBox box = text->getBound();
|
||||
float shift = box.radius()+1.f;
|
||||
|
||||
// front
|
||||
text->setAlignment(osgText::Text::CENTER_CENTER);
|
||||
// front
|
||||
text->setAlignment(osgText::Text::CENTER_CENTER);
|
||||
|
||||
// back
|
||||
osg::ref_ptr<osgText::Text> backText = new osgText::Text(*text);
|
||||
backText->setPosition(osg::Vec3(pos.x(),pos.y()+shift,pos.z()));
|
||||
backText->setAxisAlignment(osgText::Text::REVERSED_XZ_PLANE);
|
||||
// back
|
||||
osg::ref_ptr<osgText::Text> backText = new osgText::Text(*text);
|
||||
backText->setPosition(osg::Vec3(pos.x(),pos.y()+shift,pos.z()));
|
||||
backText->setAxisAlignment(osgText::Text::REVERSED_XZ_PLANE);
|
||||
|
||||
// top
|
||||
osg::ref_ptr<osgText::Text> topText = new osgText::Text(*text);
|
||||
topText->setPosition(osg::Vec3(pos.x(),pos.y(),pos.z()+shift));
|
||||
topText->setAxisAlignment(osgText::Text::XY_PLANE);
|
||||
// top
|
||||
osg::ref_ptr<osgText::Text> topText = new osgText::Text(*text);
|
||||
topText->setPosition(osg::Vec3(pos.x(),pos.y(),pos.z()+shift));
|
||||
topText->setAxisAlignment(osgText::Text::XY_PLANE);
|
||||
|
||||
// bottom
|
||||
osg::ref_ptr<osgText::Text> bottomText = new osgText::Text(*text);
|
||||
bottomText->setPosition(osg::Vec3(pos.x(),pos.y(),pos.z()-shift));
|
||||
bottomText->setAxisAlignment(osgText::Text::REVERSED_XY_PLANE);
|
||||
// bottom
|
||||
osg::ref_ptr<osgText::Text> bottomText = new osgText::Text(*text);
|
||||
bottomText->setPosition(osg::Vec3(pos.x(),pos.y(),pos.z()-shift));
|
||||
bottomText->setAxisAlignment(osgText::Text::REVERSED_XY_PLANE);
|
||||
|
||||
// left
|
||||
osg::ref_ptr<osgText::Text> leftText = new osgText::Text(*text);
|
||||
leftText->setPosition(osg::Vec3(pos.x()-shift,pos.y(),pos.z()));
|
||||
leftText->setAxisAlignment(osgText::Text::REVERSED_YZ_PLANE);
|
||||
// left
|
||||
osg::ref_ptr<osgText::Text> leftText = new osgText::Text(*text);
|
||||
leftText->setPosition(osg::Vec3(pos.x()-shift,pos.y(),pos.z()));
|
||||
leftText->setAxisAlignment(osgText::Text::REVERSED_YZ_PLANE);
|
||||
|
||||
// right
|
||||
osg::ref_ptr<osgText::Text> rightText = new osgText::Text(*text);
|
||||
rightText->setPosition(osg::Vec3(pos.x()+shift,pos.y(),pos.z()));
|
||||
rightText->setAxisAlignment(osgText::Text::YZ_PLANE);
|
||||
// right
|
||||
osg::ref_ptr<osgText::Text> rightText = new osgText::Text(*text);
|
||||
rightText->setPosition(osg::Vec3(pos.x()+shift,pos.y(),pos.z()));
|
||||
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;
|
||||
hints->setDetailRatio(0.5f);
|
||||
cube = new osg::ShapeDrawable(new osg::Box(pos,2*shift),hints);
|
||||
osg::TessellationHints* hints = new osg::TessellationHints;
|
||||
hints->setDetailRatio(0.5f);
|
||||
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->setUnits(10.0f);
|
||||
osg::ref_ptr<osg::StateSet> ss = cube->getOrCreateStateSet();
|
||||
ss->setAttributeAndModes(polyoffset.get(),osg::StateAttribute::ON);
|
||||
cube->setStateSet(ss.get());
|
||||
osg::ref_ptr<osg::StateSet> ss = cube->getOrCreateStateSet();
|
||||
ss->setAttributeAndModes(polyoffset.get(),osg::StateAttribute::ON);
|
||||
cube->setStateSet(ss.get());
|
||||
|
||||
textGeode->addDrawable(cube.get());
|
||||
textGeode->addDrawable(text.get());
|
||||
textGeode->addDrawable(backText.get());
|
||||
textGeode->addDrawable(topText.get());
|
||||
textGeode->addDrawable(bottomText.get());
|
||||
textGeode->addDrawable(leftText.get());
|
||||
textGeode->addDrawable(rightText.get());
|
||||
textGeode->addDrawable(cube.get());
|
||||
textGeode->addDrawable(text.get());
|
||||
textGeode->addDrawable(backText.get());
|
||||
textGeode->addDrawable(topText.get());
|
||||
textGeode->addDrawable(bottomText.get());
|
||||
textGeode->addDrawable(leftText.get());
|
||||
textGeode->addDrawable(rightText.get());
|
||||
|
||||
group->addChild(textGeode.get());
|
||||
group->addChild(textGeode.get());
|
||||
|
||||
_parse->getCurrTop()->addChild(group);
|
||||
}
|
||||
_parse->getCurrTop()->addChild(group);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
const std::vector<trpg3dPoint> *supports = label.GetSupports();
|
||||
if (supports && supports->size())
|
||||
{
|
||||
osg::ref_ptr<osg::Geode> supGeode = new osg::Geode;
|
||||
const std::vector<trpg3dPoint> *supports = label.GetSupports();
|
||||
if (supports && supports->size())
|
||||
{
|
||||
osg::ref_ptr<osg::Geode> supGeode = new osg::Geode;
|
||||
|
||||
int supId = labelProperty->GetSupport();
|
||||
const trpgSupportStyleTable *supTable = _parse->getArchive()->GetSupportStyleTable();
|
||||
const trpgSupportStyle *supStyle = supTable ? supTable->GetStyleRef(supId) : 0;
|
||||
if (supStyle)
|
||||
{
|
||||
int matId = supStyle->GetMaterial();
|
||||
int supId = labelProperty->GetSupport();
|
||||
const trpgSupportStyleTable *supTable = _parse->getArchive()->GetSupportStyleTable();
|
||||
const trpgSupportStyle *supStyle = supTable ? supTable->GetStyleRef(supId) : 0;
|
||||
if (supStyle)
|
||||
{
|
||||
int matId = supStyle->GetMaterial();
|
||||
|
||||
osg::Vec4 supLineColor(1.f,1.f,1.f,1.f);
|
||||
_parse->loadMaterial(matId);
|
||||
osg::ref_ptr<osg::StateSet> sset = (*_parse->getMaterials())[matId];
|
||||
osg::Vec4 supLineColor(1.f,1.f,1.f,1.f);
|
||||
_parse->loadMaterial(matId);
|
||||
osg::ref_ptr<osg::StateSet> sset = (*_parse->getMaterials())[matId];
|
||||
|
||||
if (cube.get())
|
||||
{
|
||||
osg::StateSet* ss = cube->getOrCreateStateSet();
|
||||
ss->merge(*sset);
|
||||
}
|
||||
if (cube.get())
|
||||
{
|
||||
osg::StateSet* ss = cube->getOrCreateStateSet();
|
||||
ss->merge(*sset);
|
||||
}
|
||||
|
||||
const trpgMatTable* matTable = _parse->getArchive()->GetMaterialTable();
|
||||
if (matTable)
|
||||
{
|
||||
const trpgMaterial* mat = matTable->GetMaterialRef(0,matId);
|
||||
if (mat)
|
||||
{
|
||||
trpgColor faceColor;
|
||||
mat->GetColor(faceColor);
|
||||
const trpgMatTable* matTable = _parse->getArchive()->GetMaterialTable();
|
||||
if (matTable)
|
||||
{
|
||||
const trpgMaterial* mat = matTable->GetMaterialRef(0,matId);
|
||||
if (mat)
|
||||
{
|
||||
trpgColor faceColor;
|
||||
mat->GetColor(faceColor);
|
||||
|
||||
float64 alpha;
|
||||
mat->GetAlpha(alpha);
|
||||
float64 alpha;
|
||||
mat->GetAlpha(alpha);
|
||||
|
||||
supLineColor = osg::Vec4(faceColor.red, faceColor.green, faceColor.blue, alpha );
|
||||
}
|
||||
}
|
||||
|
||||
switch (supStyle->GetType())
|
||||
{
|
||||
case trpgSupportStyle::Line:
|
||||
{
|
||||
osg::Geometry* linesGeom = new osg::Geometry();
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array(supports->size()*2);
|
||||
supLineColor = osg::Vec4(faceColor.red, faceColor.green, faceColor.blue, alpha );
|
||||
}
|
||||
}
|
||||
|
||||
switch (supStyle->GetType())
|
||||
{
|
||||
case trpgSupportStyle::Line:
|
||||
{
|
||||
osg::Geometry* linesGeom = new osg::Geometry();
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array(supports->size()*2);
|
||||
|
||||
int cnt = 0;
|
||||
for (unsigned int i = 0; i < supports->size(); i++)
|
||||
{
|
||||
const trpg3dPoint& supPt = (*supports)[i];
|
||||
(*vertices)[cnt++].set(pos);
|
||||
(*vertices)[cnt++].set(osg::Vec3(supPt.x,supPt.y,supPt.z));
|
||||
}
|
||||
int cnt = 0;
|
||||
for (unsigned int i = 0; i < supports->size(); i++)
|
||||
{
|
||||
const trpg3dPoint& supPt = (*supports)[i];
|
||||
(*vertices)[cnt++].set(pos);
|
||||
(*vertices)[cnt++].set(osg::Vec3(supPt.x,supPt.y,supPt.z));
|
||||
}
|
||||
|
||||
linesGeom->setVertexArray(vertices);
|
||||
linesGeom->setVertexArray(vertices);
|
||||
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
colors->push_back(supLineColor);
|
||||
linesGeom->setColorArray(colors);
|
||||
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||
linesGeom->setNormalArray(normals);
|
||||
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||
colors->push_back(supLineColor);
|
||||
linesGeom->setColorArray(colors);
|
||||
linesGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
osg::Vec3Array* normals = new osg::Vec3Array;
|
||||
normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
|
||||
linesGeom->setNormalArray(normals);
|
||||
linesGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
|
||||
|
||||
|
||||
linesGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,supports->size()*2));
|
||||
supGeode->addDrawable(linesGeom);
|
||||
}
|
||||
linesGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,supports->size()*2));
|
||||
supGeode->addDrawable(linesGeom);
|
||||
}
|
||||
|
||||
_parse->getCurrTop()->addChild(supGeode.get());
|
||||
break;
|
||||
case trpgSupportStyle::Cylinder:
|
||||
{
|
||||
osg::ref_ptr<osg::TessellationHints> hints = new osg::TessellationHints;
|
||||
hints->setDetailRatio(0.5f);
|
||||
_parse->getCurrTop()->addChild(supGeode.get());
|
||||
break;
|
||||
case trpgSupportStyle::Cylinder:
|
||||
{
|
||||
osg::ref_ptr<osg::TessellationHints> hints = new osg::TessellationHints;
|
||||
hints->setDetailRatio(0.5f);
|
||||
|
||||
for (unsigned int i = 0; i < supports->size(); i++)
|
||||
{
|
||||
const trpg3dPoint& supPt = (*supports)[i];
|
||||
|
||||
osg::Vec3 supPos(supPt.x,supPt.y,supPt.z);
|
||||
osg::Vec3 supCenter = (supPos+pos)/2.f;
|
||||
float supHeight = (supPos-pos).length();
|
||||
for (unsigned int i = 0; i < supports->size(); i++)
|
||||
{
|
||||
const trpg3dPoint& supPt = (*supports)[i];
|
||||
|
||||
osg::Vec3 supPos(supPt.x,supPt.y,supPt.z);
|
||||
osg::Vec3 supCenter = (supPos+pos)/2.f;
|
||||
float supHeight = (supPos-pos).length();
|
||||
|
||||
osg::Vec3 d = pos-supPos;
|
||||
d.normalize();
|
||||
osg::Quat r;
|
||||
osg::Vec3 d = pos-supPos;
|
||||
d.normalize();
|
||||
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);
|
||||
cylinder->setRotation(r);
|
||||
osg::Cylinder* cylinder = new osg::Cylinder(supCenter,10.f,supHeight);
|
||||
cylinder->setRotation(r);
|
||||
|
||||
osg::ShapeDrawable* cylinderDrawable = new osg::ShapeDrawable(cylinder,hints.get());
|
||||
osg::StateSet* ss = cylinderDrawable->getOrCreateStateSet();
|
||||
ss->merge(*sset);
|
||||
osg::ShapeDrawable* cylinderDrawable = new osg::ShapeDrawable(cylinder,hints.get());
|
||||
osg::StateSet* ss = cylinderDrawable->getOrCreateStateSet();
|
||||
ss->merge(*sset);
|
||||
|
||||
supGeode->addDrawable(cylinderDrawable);
|
||||
supGeode->addDrawable(cylinderDrawable);
|
||||
|
||||
}
|
||||
|
||||
_parse->getCurrTop()->addChild(supGeode.get());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_parse->getCurrTop()->addChild(supGeode.get());
|
||||
}
|
||||
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;
|
||||
}
|
||||
@ -1388,7 +1387,7 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
|
||||
}
|
||||
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
|
||||
if(num_mipmaps <= 1)
|
||||
{
|
||||
int32 size = tex->CalcTotalSize();
|
||||
int32 size = tex->CalcTotalSize();
|
||||
data = new char [size];
|
||||
image_helper.GetLocalGL(tex,data,size);
|
||||
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
|
||||
if(num_mipmaps <= 1)
|
||||
{
|
||||
int32 size = tex->CalcTotalSize();
|
||||
int32 size = tex->CalcTotalSize();
|
||||
data = new char [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;
|
||||
std::cout << "\tglTexSubImage2D(0x"<<hex<<GL_TEXTURE_2D<<dec<<" ,"<<0<<"\t"<<std::endl<<
|
||||
"\t "<<_texturePosX<<" ,"<<_texturePosY<<std::endl<<
|
||||
"\t "<<s()<<" ,"<<t()<<std::endl<<hex<<
|
||||
"\t 0x"<<(GLenum)getPixelFormat()<<std::endl<<
|
||||
"\t 0x"<<(GLenum)getDataType()<<std::endl<<
|
||||
"\t 0x"<<(unsigned long)data()<<");"<<dec<<std::endl;
|
||||
osg::notify(osg::WARN)<< "\tglTexSubImage2D(0x"<<hex<<GL_TEXTURE_2D<<dec<<" ,"<<0<<"\t"<<std::endl<<
|
||||
"\t "<<_texturePosX<<" ,"<<_texturePosY<<std::endl<<
|
||||
"\t "<<s()<<" ,"<<t()<<std::endl<<hex<<
|
||||
"\t 0x"<<(GLenum)getPixelFormat()<<std::endl<<
|
||||
"\t 0x"<<(GLenum)getDataType()<<std::endl<<
|
||||
"\t 0x"<<(unsigned long)data()<<");"<<dec<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,9 @@ class PrintVisitor : public NodeVisitor
|
||||
|
||||
public:
|
||||
|
||||
PrintVisitor():NodeVisitor(NodeVisitor::TRAVERSE_ALL_CHILDREN)
|
||||
PrintVisitor(std::ostream& out):
|
||||
NodeVisitor(NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||
_out(out)
|
||||
{
|
||||
_indent = 0;
|
||||
_step = 4;
|
||||
@ -57,13 +59,13 @@ class PrintVisitor : public NodeVisitor
|
||||
inline void moveOut() { _indent -= _step; }
|
||||
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)
|
||||
{
|
||||
moveIn();
|
||||
writeIndent(); std::cout << node.className() <<std::endl;
|
||||
writeIndent(); _out << node.className() <<std::endl;
|
||||
traverse(node);
|
||||
moveOut();
|
||||
}
|
||||
@ -82,6 +84,7 @@ class PrintVisitor : public NodeVisitor
|
||||
|
||||
protected:
|
||||
|
||||
std::ostream& _out;
|
||||
int _indent;
|
||||
int _step;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user