Commit 36fc86cd authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[FIX #297] needed to remove several functions which use per-primitive-binding...

[FIX #297] needed to remove several functions which use per-primitive-binding as this kind of binding is no longer supported in OSG. Several function still use this ... to be continued
parent cdd38608
This diff is collapsed.
...@@ -128,18 +128,6 @@ namespace wge ...@@ -128,18 +128,6 @@ namespace wge
bool lighting = false bool lighting = false
); );
/**
* Extract the vertices and triangles from a WTriangleMesh and save them
* into an osg::Geometry. It uses per triangle normals.
*
* \param mesh the WTriangleMesh used as input
* \param color This color is used for all vertices
* \return an osg::Geometry containing the mesh
* \note mesh cannot be const since osg::Geometry needs non-const pointers to the contained arrays
*/
osg::ref_ptr< osg::Geometry > convertMeshToOsgGeometryFlat( WTriangleMesh::SPtr mesh,
const WColor& color = WColor( 1.0, 1.0, 1.0, 1.0 ) );
/** /**
* Convert triangle mesh to lines representing it. Draws lines twice (ATM). * Convert triangle mesh to lines representing it. Draws lines twice (ATM).
* *
...@@ -153,20 +141,6 @@ namespace wge ...@@ -153,20 +141,6 @@ namespace wge
const WColor& defaultColor = WColor( 1.0, 1.0, 1.0, 1.0 ), const WColor& defaultColor = WColor( 1.0, 1.0, 1.0, 1.0 ),
bool useMeshColor = true ); bool useMeshColor = true );
/**
* Generates a line geode with thickness and color as parameters.
*
* \param line sequence of points
* \param thickness How thick the line strip should be
* \param color If present this color is used for the whole line, otherwise local coloring is used
*
* \return The new assembled geode for this line
*/
osg::ref_ptr< osg::Geode > generateLineStripGeode( const WLine& line,
const float thickness = 3.0f,
const WColor& color = WColor( 0, 0, 0, 0 ) );
/** /**
* helper function to add a label somewhere * helper function to add a label somewhere
* *
...@@ -229,72 +203,6 @@ namespace wge ...@@ -229,72 +203,6 @@ namespace wge
* \return the geode * \return the geode
*/ */
osg::ref_ptr< osg::Geode > genFinitePlane( osg::Vec3 const& base, osg::Vec3 const& a, osg::Vec3 const& b ); osg::ref_ptr< osg::Geode > genFinitePlane( osg::Vec3 const& base, osg::Vec3 const& a, osg::Vec3 const& b );
/**
* Generates a plane subdivided into quads.
*
* \param resX How many quads in x-direction
* \param resY How many quads in y-direction
* \param spacing Not implement yet
*
* \return The new uncolored plane geode
*/
osg::ref_ptr< WGESubdividedPlane > genUnitSubdividedPlane( size_t resX, size_t resY, double spacing = 0.01 );
/**
* For each points in the STL container generate small cubes.
*
* \param points Center point of the cubes
* \param size The size of the cubes
* \param color The color of the cubes
* \tparam An STL container with WPositions as elements ( don't try it with different than vector, set, list or queue )
*
* \return Geode with as many cubes as points in the container where each cube is around a certain position.
*/
template< class Container > osg::ref_ptr< osg::Geode > genPointBlobs( boost::shared_ptr< Container > points,
double size,
const WColor& color = WColor( 1.0, 0.0, 0.0, 1.0 ) );
} // end of namespace wge } // end of namespace wge
template< class Container > inline osg::ref_ptr< osg::Geode > wge::genPointBlobs( boost::shared_ptr< Container > points,
double size,
const WColor& color )
{
osg::ref_ptr< osg::Vec3Array > vertices = osg::ref_ptr< osg::Vec3Array >( new osg::Vec3Array );
osg::ref_ptr< osg::Vec4Array > colors = osg::ref_ptr< osg::Vec4Array >( new osg::Vec4Array );
osg::ref_ptr< osg::Geometry > geometry = osg::ref_ptr< osg::Geometry >( new osg::Geometry );
osg::ref_ptr< osg::Vec3Array > normals = osg::ref_ptr< osg::Vec3Array >( new osg::Vec3Array );
for( typename Container::const_iterator point = points->begin(); point != points->end(); ++point )
{
const WPosition& pos = *point;
std::vector< WPosition > corners;
corners.reserve( 8 );
double halfSize = size / 2.0;
corners.push_back( WPosition( pos[0] - halfSize, pos[1] - halfSize, pos[2] - halfSize ) );
corners.push_back( WPosition( pos[0] + halfSize, pos[1] - halfSize, pos[2] - halfSize ) );
corners.push_back( WPosition( pos[0] + halfSize, pos[1] - halfSize, pos[2] + halfSize ) );
corners.push_back( WPosition( pos[0] - halfSize, pos[1] - halfSize, pos[2] + halfSize ) );
corners.push_back( WPosition( pos[0] - halfSize, pos[1] + halfSize, pos[2] - halfSize ) );
corners.push_back( WPosition( pos[0] + halfSize, pos[1] + halfSize, pos[2] - halfSize ) );
corners.push_back( WPosition( pos[0] + halfSize, pos[1] + halfSize, pos[2] + halfSize ) );
corners.push_back( WPosition( pos[0] - halfSize, pos[1] + halfSize, pos[2] + halfSize ) );
osg::ref_ptr< osg::Vec3Array > ver = generateCuboidQuads( corners );
vertices->insert( vertices->end(), ver->begin(), ver->end() );
osg::ref_ptr< osg::Vec3Array > nor = generateCuboidQuadNormals( corners );
normals->insert( normals->end(), nor->begin(), nor->end() );
geometry->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::QUADS, vertices->size() - ver->size(), ver->size() ) );
}
geometry->setVertexArray( vertices );
colors->push_back( color );
geometry->setColorArray( colors );
geometry->setColorBinding( osg::Geometry::BIND_OVERALL );
geometry->setNormalArray( normals );
geometry->setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE );
osg::ref_ptr< osg::Geode > geode = osg::ref_ptr< osg::Geode >( new osg::Geode );
geode->addDrawable( geometry );
return geode;
}
#endif // WGEGEODEUTILS_H #endif // WGEGEODEUTILS_H
...@@ -163,7 +163,7 @@ void WROIArbitrary::updateGFX() ...@@ -163,7 +163,7 @@ void WROIArbitrary::updateGFX()
// ------------------------------------------------ // ------------------------------------------------
// normals // normals
surfaceGeometry->setNormalArray( m_triMesh->getTriangleNormalArray() ); surfaceGeometry->setNormalArray( m_triMesh->getTriangleNormalArray() );
surfaceGeometry->setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE ); // surfaceGeometry->setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE );
// ------------------------------------------------ // ------------------------------------------------
// colors // colors
......
...@@ -199,7 +199,7 @@ WROIBox::WROIBox( WPosition minPos, WPosition maxPos ) : ...@@ -199,7 +199,7 @@ WROIBox::WROIBox( WPosition minPos, WPosition maxPos ) :
osg::ref_ptr<osg::Vec3Array> normals = osg::ref_ptr<osg::Vec3Array>( new osg::Vec3Array ); osg::ref_ptr<osg::Vec3Array> normals = osg::ref_ptr<osg::Vec3Array>( new osg::Vec3Array );
setNormals( normals ); setNormals( normals );
m_surfaceGeometry->setNormalArray( normals ); m_surfaceGeometry->setNormalArray( normals );
m_surfaceGeometry->setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE ); // m_surfaceGeometry->setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE );
m_not->set( false ); m_not->set( false );
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WGEGEODEUTILS_TEST_H
#define WGEGEODEUTILS_TEST_H
#include <cxxtest/ValueTraits.h>
#include <cxxtest/TestSuite.h>
#include <osg/io_utils>
#include "../../common/WStringUtils.h"
#include "WVec3Traits.h"
#include "../WGEGeodeUtils.h"
/**
* Testsuite for the WGEGeode utils.
*/
class WGEGeodeUtilsTest : public CxxTest::TestSuite
{
public:
/**
* A unit subdivided plane with resolution width_x_height has width*height many quads.
*/
void testNumQuadsAndTheirVerticesWithoutSpacing( void )
{
double spacing = 0.0;
osg::ref_ptr< WGESubdividedPlane > g = wge::genUnitSubdividedPlane( 2, 2, spacing );
osg::Geometry *geo = dynamic_cast< osg::Geometry* >( g->getDrawable( 0 ) );
if( !geo )
{
TS_FAIL( "The drawable inside the WGESubdividedPlane geode is not a geometry" );
}
TS_ASSERT( geo );
osg::Vec3Array* verts = dynamic_cast< osg::Vec3Array* >( geo->getVertexArray() );
if( !verts )
{
TS_FAIL( "The vertex array inside is not a osg::Vec3Array" );
}
osg::ref_ptr< osg::Vec3Array > expected = osg::ref_ptr< osg::Vec3Array >( new osg::Vec3Array );
expected->push_back( osg::Vec3( 0.0, 0.0, 0.0 ) );
expected->push_back( osg::Vec3( 1.0, 0.0, 0.0 ) );
expected->push_back( osg::Vec3( 1.0, 1.0, 0.0 ) );
expected->push_back( osg::Vec3( 0.0, 1.0, 0.0 ) );
expected->push_back( osg::Vec3( 1.0, 0.0, 0.0 ) );
expected->push_back( osg::Vec3( 2.0, 0.0, 0.0 ) );
expected->push_back( osg::Vec3( 2.0, 1.0, 0.0 ) );
expected->push_back( osg::Vec3( 1.0, 1.0, 0.0 ) );
expected->push_back( osg::Vec3( 0.0, 1.0, 0.0 ) );
expected->push_back( osg::Vec3( 1.0, 1.0, 0.0 ) );
expected->push_back( osg::Vec3( 1.0, 2.0, 0.0 ) );
expected->push_back( osg::Vec3( 0.0, 2.0, 0.0 ) );
expected->push_back( osg::Vec3( 1.0, 1.0, 0.0 ) );
expected->push_back( osg::Vec3( 2.0, 1.0, 0.0 ) );
expected->push_back( osg::Vec3( 2.0, 2.0, 0.0 ) );
expected->push_back( osg::Vec3( 1.0, 2.0, 0.0 ) );
TS_ASSERT_EQUALS( verts->asVector(), expected->asVector() );
}
/**
* For each quad there is a center point defined in the center point array.
*/
void testCenterPoints( void )
{
osg::ref_ptr< WGESubdividedPlane > g = wge::genUnitSubdividedPlane( 2, 2 );
osg::ref_ptr< osg::Vec3Array > expected = osg::ref_ptr< osg::Vec3Array >( new osg::Vec3Array );
expected->push_back( osg::Vec3( 0.5, 0.5, 0.0 ) );
expected->push_back( osg::Vec3( 1.5, 0.5, 0.0 ) );
expected->push_back( osg::Vec3( 0.5, 1.5, 0.0 ) );
expected->push_back( osg::Vec3( 1.5, 1.5, 0.0 ) );
TS_ASSERT_EQUALS( g->getCenterArray()->asVector(), expected->asVector() );
}
};
#endif // WGEGEODEUTILS_TEST_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment