1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
23
//---------------------------------------------------------------------------
31
#include <boost/lexical_cast.hpp>
38
#include "../common/WColor.h"
39
#include "../common/WAssert.h"
40
#include "../common/math/linearAlgebra/WLinearAlgebra.h"
42
#include "WExportWGE.h"
47
* Transforms a direction given via two points into a RGB color.
49
* \param pos1 First point
50
* \param pos2 Second point
52
* \return converts a vector to a color
54
WColor getRGBAColorFromDirection( const WPosition &pos1, const WPosition &pos2 );
57
* Converts a whole vector of WPositions into an osg::Vec3Array.
59
* \param posArray The given positions vector
61
* \return Refernce to the same vector but as osg::Vec3Array.
63
osg::ref_ptr< osg::Vec3Array > WGE_EXPORT osgVec3Array( const std::vector< WPosition >& posArray );
66
* Converts screen coordinates into Camera coordinates.
68
* \param screen the screen coordinates
69
* \param camera The matrices of this camera will used for unprojecting.
71
* \return un-projects a screen coordinate back to world space
73
osg::Vec3 WGE_EXPORT unprojectFromScreen( const osg::Vec3 screen, osg::ref_ptr< osg::Camera > camera );
76
* creates the same color as the atlas colormap shader from the index
78
* \param index unsigned char that indexes the color
81
WColor WGE_EXPORT createColorFromIndex( int index );
84
* creates a rgb WColor from a HSV value
90
WColor WGE_EXPORT createColorFromHSV( int h, float s = 1.0, float v = 1.0 );
93
* creates the nth color of a partition of the hsv color circle
95
* \param n number of the color
98
WColor WGE_EXPORT getNthHSVColor( int n );
101
inline WColor wge::getRGBAColorFromDirection( const WPosition &pos1, const WPosition &pos2 )
103
WPosition direction( normalize( pos2 - pos1 ) );
104
return WColor( std::abs( direction[0] ), std::abs( direction[1] ), std::abs( direction[2] ), 1.0f );