[692] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://www.ogre3d.org/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 | #ifndef __XSIMATERIALEXPORTER_H__
|
---|
| 26 | #define __XSIMATERIALEXPORTER_H__
|
---|
| 27 |
|
---|
| 28 | #include "OgreXSIHelper.h"
|
---|
| 29 | #include "OgreBlendMode.h"
|
---|
| 30 | #include "OgreMaterialSerializer.h"
|
---|
| 31 |
|
---|
| 32 | namespace Ogre {
|
---|
| 33 |
|
---|
| 34 | class XsiMaterialExporter
|
---|
| 35 | {
|
---|
| 36 | public:
|
---|
| 37 | XsiMaterialExporter();
|
---|
| 38 | virtual ~XsiMaterialExporter();
|
---|
| 39 |
|
---|
| 40 | /** Export a set of XSI materials to a material script.
|
---|
| 41 | @param materials List of materials to export
|
---|
| 42 | @param filename Name of the script file to create
|
---|
| 43 | @param copyTextures Whether to copy any textures used into the same
|
---|
| 44 | folder as the material script.
|
---|
| 45 | */
|
---|
| 46 | void exportMaterials(MaterialMap& materials, TextureProjectionMap& texProjMap,
|
---|
| 47 | const String& filename, bool copyTextures);
|
---|
| 48 | protected:
|
---|
| 49 | MaterialSerializer mMatSerializer;
|
---|
| 50 |
|
---|
| 51 | typedef std::multimap<long,TextureUnitState*> TextureUnitTargetMap;
|
---|
| 52 | /// Map of target id -> texture unit to match up tex transforms
|
---|
| 53 | TextureUnitTargetMap mTextureUnitTargetMap;
|
---|
| 54 | /// Pass queue, used to invert ordering
|
---|
| 55 | PassQueue mPassQueue;
|
---|
| 56 | /// Texture projection map
|
---|
| 57 | TextureProjectionMap mTextureProjectionMap;
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | // Export a single material
|
---|
| 61 | void exportMaterial(MaterialEntry* matEntry, bool copyTextures,
|
---|
| 62 | const String& texturePath);
|
---|
| 63 | /// Fill in all the details of a pass
|
---|
| 64 | void populatePass(Pass* pass, XSI::Shader& xsishader);
|
---|
| 65 | /// Fill in the texture units - note this won't pick up transforms yet
|
---|
| 66 | void populatePassTextures(Pass* pass, PassEntry* passEntry,
|
---|
| 67 | bool copyTextures, const String& texturePath);
|
---|
| 68 | /// Find any texture transforms and hook them up via 'target'
|
---|
| 69 | void populatePassTextureTransforms(Pass* pass, XSI::Shader& xsishader);
|
---|
| 70 | /// Populate basic rejection parameters for the pass
|
---|
| 71 | void populatePassDepthCull(Pass* pass, XSI::Shader& xsishader);
|
---|
| 72 | /// Populate lighting parameters for the pass
|
---|
| 73 | void populatePassLighting(Pass* pass, XSI::Shader& xsishader);
|
---|
| 74 | /// Populate scene blending parameters for the pass
|
---|
| 75 | void populatePassSceneBlend(Pass* pass, XSI::Shader& xsishader);
|
---|
| 76 | void populatePassCgPrograms(Pass* pass, XSI::Shader& xsishader);
|
---|
| 77 | void populatePassHLSLPrograms(Pass* pass, XSI::Shader& xsishader);
|
---|
| 78 | void populatePassD3DAssemblerPrograms(Pass* pass, XSI::Shader& xsishader);
|
---|
| 79 | void populateOGLFiltering(TextureUnitState* tex, XSI::Shader& xsishader);
|
---|
| 80 | void populateDXFiltering(TextureUnitState* tex, XSI::Shader& xsishader);
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | // Utility method to get texture coord set from tspace_id name
|
---|
| 84 | unsigned short getTextureCoordIndex(const String& tspace);
|
---|
| 85 |
|
---|
| 86 | /// Add a 2D texture from a shader
|
---|
| 87 | TextureUnitState* add2DTexture(Pass* pass, XSI::Shader& shader,
|
---|
| 88 | bool copyTextures, const String& targetFolder);
|
---|
| 89 | /// Add a cubic texture from a shader
|
---|
| 90 | TextureUnitState* addCubicTexture(Pass* pass, XSI::Shader& shader,
|
---|
| 91 | bool copyTextures, const String& targetFolder);
|
---|
| 92 |
|
---|
| 93 |
|
---|
| 94 | void clearPassQueue(void);
|
---|
| 95 |
|
---|
| 96 | SceneBlendFactor convertSceneBlend(short xsiVal);
|
---|
| 97 | TextureUnitState::TextureAddressingMode convertAddressingMode(short xsiVal);
|
---|
| 98 | void convertTexGenOGL(TextureUnitState* tex, long xsiVal, XSI::Shader& shader);
|
---|
| 99 | void convertTexGenDX(TextureUnitState* tex, long xsiVal, XSI::Shader& shader);
|
---|
| 100 | };
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | #endif
|
---|
| 104 |
|
---|
| 105 |
|
---|