Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/tools/TextureGenerator.cc @ 9066

Last change on this file since 9066 was 6417, checked in by rgrieder, 15 years ago

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
  • Property svn:eol-style set to native
File size: 2.9 KB
RevLine 
[1609]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
[1614]25 *      ...
[1609]26 *
27 */
28
29/**
30    @file
[1614]31    @brief Implementation of the TextureGenerator.
[1609]32*/
33
34#include "TextureGenerator.h"
[3196]35
[1609]36#include <OgreMaterialManager.h>
37#include <OgreTechnique.h>
38#include "util/Convert.h"
[3196]39#include "util/Math.h"
[1609]40
41namespace std
42{
43    template <>
[3196]44    inline bool less<orxonox::ColourValue>::operator()(const orxonox::ColourValue& __x, const orxonox::ColourValue& __y) const
[1609]45    {
46        if (__x.r == __y.r)
47        {
48            if (__x.g == __y.g)
49            {
50                if (__x.b == __y.b)
51                {
52                    return __x.a < __y.a;
53                }
54                return __x.b < __y.b;
55            }
56            return __x.g < __y.g;
57        }
58        return __x.r < __y.r;
59    }
60}
61
62namespace orxonox
63{
64    std::map<std::string, std::map<ColourValue, std::string> > TextureGenerator::materials_s;
65    unsigned int TextureGenerator::materialCount_s = 0;
66
[3196]67    /*static*/ const std::string& TextureGenerator::getMaterialName(const std::string& textureName, const ColourValue& colour)
[1609]68    {
69        std::map<ColourValue, std::string>& colourMap = materials_s[textureName];
70        std::map<ColourValue, std::string>::const_iterator it = colourMap.find(colour);
71
72        if (it == colourMap.end())
73        {
[6417]74            const std::string& materialName = textureName + "_Material_" + multi_cast<std::string>(materialCount_s++);
[3300]75            Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().create(materialName, "General"));
[1609]76            material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
77            Ogre::TextureUnitState* textureUnitState = material->getTechnique(0)->getPass(0)->createTextureUnitState();
78            textureUnitState->setTextureName(textureName);
79            textureUnitState->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour);
[1613]80            return (colourMap[colour] = materialName);
[1609]81        }
82        else
83        {
[6417]84            return it->second;
[1609]85        }
86    }
87}
Note: See TracBrowser for help on using the repository browser.