📄 ogrepaginglandscapetexture_splatting4.cpp
字号:
/***************************************************************************
OgrePagingLandScapeTexture_Splatting.cpp - description
-------------------
begin : Mon Apr 16 2004
copyright : (C) 2003 by Jose A Milan
email : spoke@supercable.es
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include "OgreVector3.h"
#include "OgreColourValue.h"
#include "OgreStringConverter.h"
#include "OgreMaterialManager.h"
#include "OgreTextureManager.h"
#include "OgreTechnique.h"
#include "OgrePass.h"
#include "OgrePagingLandScapeOptions.h"
#include "OgrePagingLandScapeTexture.h"
#include "OgrePagingLandScapeTexture_Splatting4.h"
namespace Ogre
{
PagingLandScapeTexture_Splatting4::PagingLandScapeTexture_Splatting4() : PagingLandScapeTexture()
{
}
//-----------------------------------------------------------------------
PagingLandScapeTexture_Splatting4::~PagingLandScapeTexture_Splatting4()
{
}
//-----------------------------------------------------------------------
void PagingLandScapeTexture_Splatting4::_loadMaterial()
{
if (mMaterial == 0 )
{
const String commonName = StringConverter::toString(mDataZ) + String(".") + StringConverter::toString(mDataX);
const String filename = PagingLandScapeOptions::getSingleton().landscape_filename;
const String extname = PagingLandScapeOptions::getSingleton().landscape_extension;
mMaterial = reinterpret_cast<Material *>(MaterialManager::getSingleton().getByName("SplattingMaterial4"));
String matname = String("SplattingMaterial4.") + commonName;
mMaterial = mMaterial->clone(matname);
// loads images
const String alphamapname = ".AlphaSplatRGBAMaps.";
String texname;
// Create a new texture using the 1st alpha map
texname = filename + alphamapname + "0." +
commonName + "." + extname;
// assing this texture to the material
mMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(texname);
// Create a new texture using the 2nd alpha map
texname = filename + alphamapname + "1." +
commonName + "." + extname;
// assing this texture to the material
mMaterial->getTechnique(0)->getPass(1)->getTextureUnitState(0)->setTextureName(texname);
// Create a new texture using the 3rd alpha map
texname = filename + alphamapname + "2." +
commonName + "." + extname;
// assing this texture to the material
mMaterial->getTechnique(0)->getPass(2)->getTextureUnitState(0)->setTextureName(texname);
// Create a new texture using the 4th alpha map
texname = filename + alphamapname + "3." +
commonName + "." + extname;
// assing this texture to the material
mMaterial->getTechnique(0)->getPass(3)->getTextureUnitState(0)->setTextureName(texname);
texname = filename + ".Light." +
commonName + "." + extname;
mMaterial->getTechnique(0)->getPass(4)->getTextureUnitState(0)->setTextureName(texname);
mMaterial->getTechnique(1)->getPass(0)->getTextureUnitState(0)->setTextureName(texname);
// Now that we have all the resources in place, we load the material
mMaterial->load();
mMaterial->setLightingEnabled( PagingLandScapeOptions::getSingleton().lit );
}
}
//-----------------------------------------------------------------------
void PagingLandScapeTexture_Splatting4::_unloadMaterial()
{
if ( mMaterial != 0 )
{
mMaterial->unload();
// We can磘 destroy de material here.
//mMaterial -> destroy();
//delete mMaterial;
//mMaterial = 0;
}
}
//-----------------------------------------------------------------------
} //namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -