ogrepaginglandscapetexture_basetexture2.cpp

来自「使用stl技术,(还没看,是听说的)」· C++ 代码 · 共 84 行

CPP
84
字号
/***************************************************************************
OgrePagingLandScapeTexture_BaseTexture2.cpp  -  description
-------------------
begin                : Mon Apr 26 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_BaseTexture2.h"
#include "OgrePagingLandScapeData2DManager.h"


namespace Ogre
{

PagingLandScapeTexture_BaseTexture2::PagingLandScapeTexture_BaseTexture2() : PagingLandScapeTexture()
{
}

//-----------------------------------------------------------------------
PagingLandScapeTexture_BaseTexture2::~PagingLandScapeTexture_BaseTexture2()
{
}

//-----------------------------------------------------------------------
void PagingLandScapeTexture_BaseTexture2::_loadMaterial()
{
	if ( mMaterial == 0 )
	{
		mMaterial = reinterpret_cast<Material *>(MaterialManager::getSingleton().getByName("BaseMaterial"));

		// Create a new texture using the base image
		const String commonName =  StringConverter::toString(mDataZ) + String(".") + StringConverter::toString(mDataX);

		const String matname = String("SplattingMaterial.") + StringConverter::toString(mDataZ) + String(".") + StringConverter::toString(mDataX);
		mMaterial = mMaterial->clone(matname);

        const String texname = PagingLandScapeOptions::getSingleton().landscape_filename + ".Base." + 
            commonName + "." + PagingLandScapeOptions::getSingleton().landscape_extension;
		// assing this texture to the material
		mMaterial->getTechnique(0)->getPass(0)->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_BaseTexture2::_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 + =
减小字号Ctrl + -
显示快捷键?