Skip to content

Commit

Permalink
Reconstrust Code.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonrong committed May 16, 2016
1 parent c7ddd86 commit 7ca9e66
Show file tree
Hide file tree
Showing 124 changed files with 26,465 additions and 149 deletions.
Binary file added data/dial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,241 changes: 1,241 additions & 0 deletions data/drag_pivot.osg

Large diffs are not rendered by default.

Binary file added data/drag_pivot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/nail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/pivot_cone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
471 changes: 471 additions & 0 deletions data/rotate_pivot.osg

Large diffs are not rendered by default.

1,319 changes: 1,319 additions & 0 deletions data/scale_in_pivot.osg

Large diffs are not rendered by default.

1,319 changes: 1,319 additions & 0 deletions data/scale_out_pivot.osg

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/osg3DViewer/3rdparty/osgWorks/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from http://code.google.com/p/osgworks/
118 changes: 118 additions & 0 deletions src/osg3DViewer/3rdparty/osgWorks/osgwTools/CountStateSets.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*************** <auto-copyright.pl BEGIN do not edit this line> **************
*
* osgWorks is (C) Copyright 2009-2011 by Kenneth Mark Bryden
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*************** <auto-copyright.pl END do not edit this line> ***************/

#include "osgwTools/CountStateSets.h"
#include <osgwTools/StateSetUtils.h>
#include <osg/NodeVisitor>
#include <osg/Geode>
#include <osg/Drawable>
#include <osg/StateSet>
#include <osg/StateAttribute>
#include <osg/Notify>



namespace osgwTools
{


CountStateSets::CountStateSets( bool removeEmptyStateSets, const osg::NodeVisitor::TraversalMode travMode )
: osg::NodeVisitor( travMode ),
_removeEmptyStateSets( removeEmptyStateSets ),
_uniqueStateSets( 0 ),
_sharedStateSets( 0 ),
_emptyStateSets( 0 ),
_removedStateSets( 0 )
{
}
CountStateSets::~CountStateSets()
{
}

void
CountStateSets::reset()
{
_uniqueStateSets = 0;
_sharedStateSets = 0;
_emptyStateSets = 0;
_removedStateSets = 0;
}

void
CountStateSets::setRemoveEmptyStateSets( bool removeEmptyStateSets )
{
_removeEmptyStateSets = removeEmptyStateSets;
}


void
CountStateSets::apply( osg::Node& node )
{
if( !processStateSet( node.getStateSet() ) && _removeEmptyStateSets )
{
node.setStateSet( NULL );
_removedStateSets++;
}
traverse( node );
}
void
CountStateSets::apply( osg::Geode& node )
{
if( !processStateSet( node.getStateSet() ) && _removeEmptyStateSets )
{
node.setStateSet( NULL );
_removedStateSets++;
}

unsigned int idx;
for( idx=0; idx<node.getNumDrawables(); idx++ )
{
osg::Drawable* draw = node.getDrawable( idx );
if( !processStateSet( draw->getStateSet() ) && _removeEmptyStateSets )
{
draw->setStateSet( NULL );
_removedStateSets++;
}
}

traverse( node );
}

bool
CountStateSets::processStateSet( osg::StateSet* ss )
{
if( ss == NULL )
return( true );

if( ss->referenceCount() == 1 )
_uniqueStateSets++;
else
_sharedStateSets++;

bool empty = osgwTools::isEmpty( *ss );
if( empty )
_emptyStateSets++;
return( !empty );
}



// osgwTools
}
84 changes: 84 additions & 0 deletions src/osg3DViewer/3rdparty/osgWorks/osgwTools/CountStateSets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*************** <auto-copyright.pl BEGIN do not edit this line> **************
*
* osgWorks is (C) Copyright 2009-2011 by Kenneth Mark Bryden
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*************** <auto-copyright.pl END do not edit this line> ***************/

#ifndef __OSGWTOOLS_COUNT_STATE_SETS_H__
#define __OSGWTOOLS_COUNT_STATE_SETS_H__ 1


//#include "osgwTools/Export.h"
#include <osg/NodeVisitor>

#include <string>

#define OSGWTOOLS_EXPORT

namespace osgwTools
{


/** \class CountStateSets CountStateSets.h <osgwTools/CountStateSets.h>
\brief Visitor to count \c StateSet objects and optionally removes empty \c StateSet objects.
\deprecated Please use CountsVisitor and RemoveData instead.
*/
//
class OSGWTOOLS_EXPORT CountStateSets : public osg::NodeVisitor
{
public:
/**
@param removeEmptyStateSets The default is true.
@param travMode The traversal mode. The default is \c osg::NodeVisitor::TRAVERSE_ALL_CHILDREN.
*/
CountStateSets( bool removeEmptyStateSets=true, const osg::NodeVisitor::TraversalMode travMode=osg::NodeVisitor::TRAVERSE_ALL_CHILDREN );
~CountStateSets();

/** Sets internal counts to zero. */
void reset();

/** Overrides for base class \c apply() method. */
virtual void apply( osg::Node& node );
/** Overrides for base class \c apply() method. */
virtual void apply( osg::Geode& node );

/** Specifies whether to remove empty \c StateSet objects. The default is true
(remove empty \c StateSet objects).*/
void setRemoveEmptyStateSets( bool removeEmptyStateSets );

/** During traversal, these counters track the total number of programs
and the NodeVisitor removes the uniforms. They are public, so the calling code can access
them directly following the traversal. */
unsigned int _uniqueStateSets, _sharedStateSets, _emptyStateSets, _removedStateSets;

protected:
/** This function examines the \c StateSet and increments the unique and shared counters. It also
increments the empty counter, but doesn't remove it or increment the removed counter.
The calling \c apply() method takes care of this based on the return
value. It returns true if the \c StateSet is NULL or not empty and returns false if the
\c StateSet is non-NULL and empty. */
bool processStateSet( osg::StateSet* ss );

bool _removeEmptyStateSets;
};


// osgwTools
}

// __OSGWTOOLS_COUNT_STATE_SETS_H__
#endif
Loading

0 comments on commit 7ca9e66

Please sign in to comment.