⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maputil.h

📁 使用stl技术,(还没看,是听说的)
💻 H
字号:
/***************************************************************************
*                                                                         *
*   This program 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 2 of the    *
*   License, or (at your option) any later version.                       *
*                                                                         *
***************************************************************************/
/**
@file 
MapUtil.h
@brief
Utility that split big map in tiles, pre-calculate splatting by
pre-calculating coverage map and pre-calculate normals.
*/
#ifndef MapUtil_H
#define MapUtil_H

#ifdef _DEBUG
#define DEBUG_PROGRESS_OUTPUT(A) {std::cout << A;}
#else
#define DEBUG_PROGRESS_OUTPUT(A) 
#endif 

#include "Ogre.h"
#include "OgreRoot.h"
#include "OgreImage.h"
#include "OgreString.h"
#include "OgreSingleton.h"
#include "OgreDefaultHardwareBufferManager.h"
#include "OgreMaterialManager.h"

#include "OgrePagingLandScapeOptions.h"
#include "OgrePagingLandScapeData2D.h"

#include "MapNormaler.h"

namespace Ogre
{

/**
 * \ingroup Tool_MapSplitter
 *
 *
 * \par untested on linux
 *
 * \version 0.2
 * second version
 *
 * \date 06-07-2004
 *
 * \author tuan.kuranes@free.fr
 *
 * \todo 
 * Add New methods, faster, smaller. 
 * Add DXT5 compression to maps.
 * Add Real-time methods to modify part of a map
 *     (SubNormalCalc, SubCoverageCalc, subPvs, sublight)
 * adds unlimited number of splat maps ?
 * Zip all maps at the end 
 * 
 *
 * \bug 
 */
    class MapUtil : public Singleton<MapUtil>
    {
    public :
        static MapUtil& getSingleton(void);
        /** Override standard Singleton retrieval.
            @remarks
            Why do we do this? Well, it's because the Singleton
            implementation is in a .h file, which means it gets compiled
            into anybody who includes it. This is needed for the
            Singleton template to work, but we actually only want it
                compiled into the implementation of the class based on the
                Singleton, not all of them. If we don't change this, we get
                link errors when trying to use the Singleton-based class from
                an outside dll.
                @par
                This method just delegates to the template version anyway,
                but the implementation stays in this single compilation unit,
                preventing link errors.
        */
        static MapUtil* getSingletonPtr(void);
        

        MapUtil();
        ~MapUtil();
        /**
        *  @remarks 
        * Does what it should. (depending on option file)
        */
        void process();

        /**
         *  @remarks 
         * no scaling here.
         * \param x position in width
         * \param z position in height
         * \return height at this point
         */
        const Real getHeight (const float x, const float z);
        /**
        *  @remarks 
        * no scaling here. Value comes from the pre-calculated map.
        * \param x position in width
        * \param z position in height
        * \return Normal at this point
        */
        const Vector3 getNormalAt(const float x, const float z);
        /**
        *  @remarks 
        * \return big heightmap image
        */
        uchar *getHeightMapData();       
        /**
        *
        * \return Max height
        */
        uint getMaxHeight () {return mMax;}
        /**
        *
        * \return Memory size of HeightMap
        */
        uint getSize () {return mSize;}
        /**
        *
        * \return total Width of HeightMap
        */
        uint getMapWidth () {return mWidth;}
        /**
        *
        * \return total Height of HeightMap
        */
        uint getMapHeight () {return mHeight;}
        /**
        *
        * \param Filename of image to load as Map 
        * \param *ImageMap Where to load image
        * \return 
        */
        void load (String filename, Image *ImageMap);
     
        /**
        * save and split maps
        * \param extension of filename name under which file must be saved
        */
        void saveAndSplitHeightMap (String filename);
        /**
        * save and split Normal maps
        * \param extension of filename name under which file must be saved
        */
        void saveAndSplitNormalMap (String filename);
        /**
        * save and split Base maps
        * \param extension of filename name under which file must be saved
        */
        void saveAndSplitBaseMap (String filename);
        /**
        * save and split Color maps
        * \param extension of filename name under which file must be saved
        */
        void saveAndSplitColorMap (String filename);
        /**
        * save and split Coverage maps
        * \param extension of filename name under which file must be saved
        */
        void saveAndSplitCoverageMap (String filename);
        /**
        * save and split Alpha maps
        * \param extension of filename name under which file must be saved
        */
        void saveAndSplitAlphaMaps (String filename, int i);
        /**
        * save and split Light maps
        * \param extension of filename name under which file must be saved
        */
        void saveAndSplitLightMap (String filename);
        /**
        * save and split Shadow maps
        * \param extension of filename name under which file must be saved
        */
        void saveAndSplitShadowMap (String filename);
        /**
        * get theorical maximum height (depend on source data type, not on data)
        */
        const Real getMaxTheoHeight ();
private :
 
        /**
         * Loads the Big heightMap to split and pre-calculate
         *
         */
        void loadHeightMap();

        String mFileName;

        bool b_SaveAsRaw;
        bool b_SaveAsPng;
        bool b_SaveBigFile;

        uint mTileSize;
        uint mTileSpacing;

        uint mSize;
        uint mHeight;
        uint mWidth;
        uint mMax;

        PagingLandScapeData2D *mHeightdata;

        Image *mHeightMap;

        Image *mNormalMap;
        Image *mAlphaMap[4];
        uint  mNormalMapBpp;
        uint  mNormalMapDataSize;
        uchar *mNormalMapData;

         MapNormaler NormalMapper; // best (fast sobel)

         Vector3 mSun;
         Real    mAmb;
         Real    mDiff;
         int     mBlur;


         PagingLandScapeOptions *mPagingLandScapeOptions;

         Root *mRoot;      
         
         Real maxHeight;

};
}
#endif //MapUtil_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -