root/OpenSceneGraph/trunk/include/osgUtil/TangentSpaceGenerator @ 3526

Revision 3526, 2.9 kB (checked in by robert, 9 years ago)

From Geoff Michel, speeling and typo fixes in osgUtil

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
RevLine 
[2191]1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under 
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGUTIL_TANGENTSPACEGENERATOR_
15#define OSGUTIL_TANGENTSPACEGENERATOR_
16
17#include <osgUtil/Export>
18
19#include <osg/ref_ptr>
20#include <osg/Referenced>
21#include <osg/Array>
22#include <osg/Geometry>
23
24namespace osgUtil
25{
26
[3526]27/**
28 The TangentSpaceGenerator class generates three arrays containing tangent-space basis vectors.
29 It takes a texture-mapped Geometry object as input, traverses its primitive sets and computes
30 Tangent, Normal and Binormal vectors for each vertex, storing them into arrays.
31 The resulting arrays can be used as vertex program varying (per-vertex) parameters,
32 enabling advanced effects like bump-mapping.
33 To use this class, simply call the generate() method specifying the Geometry object
34 you want to process and the texture unit that contains UV mapping for the normal map;
35 then you can retrieve the TBN arrays by calling getTangentArray(), getNormalArray()
36 and getBinormalArray() methods.
37 */
38class OSGUTIL_EXPORT TangentSpaceGenerator: public osg::Referenced {
39public:
40    TangentSpaceGenerator();
41    TangentSpaceGenerator(const TangentSpaceGenerator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
[2191]42
[3526]43    void generate(osg::Geometry *geo, int normal_map_tex_unit = 0);
[2191]44
[3526]45    inline osg::Vec4Array *getTangentArray()               { return T_.get(); }
46    inline const osg::Vec4Array *getTangentArray() const   { return T_.get(); }
47    inline void setTangentArray(osg::Vec4Array *array)     { T_ = array; }
[2191]48
[3526]49    inline osg::Vec4Array *getNormalArray()                { return N_.get(); }
50    inline const osg::Vec4Array *getNormalArray() const    { return N_.get(); }
51    inline void setNormalArray(osg::Vec4Array *array)      { N_ = array; }
[2191]52
[3526]53    inline osg::Vec4Array *getBinormalArray()              { return B_.get(); }
54    inline const osg::Vec4Array *getBinormalArray() const  { return B_.get(); }
55    inline void setBinormalArray(osg::Vec4Array *array)    { B_ = array; }
[2191]56
[3526]57protected:
58    virtual ~TangentSpaceGenerator() {}
59    TangentSpaceGenerator &operator=(const TangentSpaceGenerator &) { return *this; }
[2191]60
[3526]61    void compute_basis_vectors(osg::PrimitiveSet *pset, const osg::Array *vx, const osg::Array *nx, const osg::Array *tx, int iA, int iB, int iC);
[2191]62
[3526]63private:
64    osg::ref_ptr<osg::Vec4Array> T_;
65    osg::ref_ptr<osg::Vec4Array> B_;
66    osg::ref_ptr<osg::Vec4Array> N_;
67};
[2191]68
69}
70
71#endif
Note: See TracBrowser for help on using the browser.