root/OpenSceneGraph/trunk/src/osgPlugins/OpenFlight/MaterialPaletteManager.h @ 13041

Revision 13041, 1.8 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/*
2 * This library is open source and may be redistributed and/or modified under
3 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or (at
4 * your option) any later version. The full license is in the LICENSE file
5 * included with this distribution, and on the openscenegraph.org website.
6 *
7 * This library is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * OpenSceneGraph Public License for more details.
11*/
12
13//
14// Copyright(c) 2008 Skew Matrix Software LLC.
15//
16
17#ifndef __FLTEXP_MATERIAL_PALETTE_MANAGER_H__
18#define __FLTEXP_MATERIAL_PALETTE_MANAGER_H__ 1
19
20#include "ExportOptions.h"
21#include <map>
22
23namespace osg {
24    class Material;
25}
26
27
28namespace flt
29{
30
31
32class DataOutputStream;
33
34
35class MaterialPaletteManager
36{
37  public:
38      MaterialPaletteManager( ExportOptions& fltOpt );
39
40    // Add a material to the palette and auto-assign it the next available index
41    int add(osg::Material const* material);
42
43    // Write the material palette records out to a DataOutputStream
44    void write( DataOutputStream& dos ) const;
45
46
47  private:
48    int _currIndex;
49
50    // Helper struct to hold material palette records
51    struct MaterialRecord
52    {
53        MaterialRecord(osg::Material const* m, int i)
54            : Material(m)
55            , Index(i) { }
56
57        osg::Material const* Material;
58        int Index;
59
60    };
61
62    // Map to allow lookups by Material pointer, and permit sorting by index
63    typedef std::map<osg::Material const*, MaterialRecord> MaterialPalette;
64    MaterialPalette _materialPalette;
65
66    ExportOptions& _fltOpt;
67
68protected:
69
70    MaterialPaletteManager& operator = (const MaterialPaletteManager&) { return *this; }
71};
72
73
74// End namespace fltexp
75
76#endif  // !FLTEXP_MATERIAL_PALETTE_MANAGER_H
Note: See TracBrowser for help on using the browser.