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

📄 ogrepaginglandscapeindexbuffer.cpp

📁 使用stl技术,(还没看,是听说的)
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************
  OgrePagingLandScapeIndexBuffer.cpp  -  description
  -------------------
  begin                : Fri Feb 28 2003
  copyright            : (C) 2003 by Jose A Milan
  email                : spoke2@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 "OgrePagingLandScapeIndexBuffer.h"
#include <OgreHardwareBufferManager.h>

namespace Ogre
{
//-----------------------------------------------------------------------
template<> PagingLandScapeIndexBuffer* Singleton<PagingLandScapeIndexBuffer>::ms_Singleton = 0;

//-----------------------------------------------------------------------
PagingLandScapeIndexBuffer::PagingLandScapeIndexBuffer( )
{
	ushort* pIdx;
	ushort i;

	mIndexes[ 0 ] = new IndexData();	//  0 = neighbors same lod
	mIndexes[ 0 ] -> indexStart = 0;
	mIndexes[ 0 ] -> indexCount = 46;
	mIndexes[ 0 ] -> indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer( HardwareIndexBuffer::IT_16BIT, mIndexes[ 0 ] -> indexCount, HardwareBuffer::HBU_WRITE_ONLY );
	// Block the buffer
	pIdx = static_cast<ushort*>( mIndexes[ 0 ]->indexBuffer->lock(	0, 	mIndexes[ 0 ]->indexBuffer->getSizeInBytes(), HardwareBuffer::HBL_DISCARD ) );
	//Construc a triangle Strip of 46
	i = 0;
	pIdx[i++] = 23; pIdx[i++] = 24; pIdx[i++] = 18; pIdx[i++] = 19; pIdx[i++] = 13;
	pIdx[i++] = 14; pIdx[i++] =  8; pIdx[i++] =  9; pIdx[i++] =  3; pIdx[i++] =  4;
	pIdx[i++] =  4; pIdx[i++] = 22; pIdx[i++] = 22; pIdx[i++] = 23; pIdx[i++] = 17;
	pIdx[i++] = 18; pIdx[i++] = 12; pIdx[i++] = 13; pIdx[i++] =  7; pIdx[i++] =  8;
	pIdx[i++] =  2; pIdx[i++] =  3; pIdx[i++] =  3; pIdx[i++] = 21; pIdx[i++] = 21;
	pIdx[i++] = 22; pIdx[i++] = 16; pIdx[i++] = 17; pIdx[i++] = 11; pIdx[i++] = 12;
	pIdx[i++] =  6; pIdx[i++] =  7; pIdx[i++] =  1; pIdx[i++] =  2; pIdx[i++] =  2;
	pIdx[i++] = 20; pIdx[i++] = 20; pIdx[i++] = 21; pIdx[i++] = 15; pIdx[i++] = 16;
	pIdx[i++] = 10; pIdx[i++] = 11; pIdx[i++] =  5; pIdx[i++] =  6; pIdx[i++] =  0;
	pIdx[i++] =  1;
	// Free the buffer
	mIndexes[ 0 ] -> indexBuffer -> unlock();

	mIndexes[ 1 ] = new IndexData(); //  1 = upper lod lower
	mIndexes[ 1 ] -> indexStart = 0;
	mIndexes[ 1 ] -> indexCount = 44;
	mIndexes[ 1 ] -> indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer( HardwareIndexBuffer::IT_16BIT, mIndexes[ 1 ] -> indexCount, HardwareBuffer::HBU_WRITE_ONLY );
	// Block the buffer
	pIdx = static_cast<ushort*>( mIndexes[ 1 ]->indexBuffer->lock(	0, 	mIndexes[ 1 ]->indexBuffer->getSizeInBytes(), HardwareBuffer::HBL_DISCARD ) );
	//Construc a triangle Strip of 44
	i = 0;
	pIdx[i++] = 20; pIdx[i++] = 21; pIdx[i++] = 15; pIdx[i++] = 16; pIdx[i++] = 10;
	pIdx[i++] = 11; pIdx[i++] =  5; pIdx[i++] =  6; pIdx[i++] =  0; pIdx[i++] =  2;
	pIdx[i++] =  2; pIdx[i++] = 22; pIdx[i++] = 22; pIdx[i++] = 23; pIdx[i++] = 17;
	pIdx[i++] = 18; pIdx[i++] = 12; pIdx[i++] = 13; pIdx[i++] =  7; pIdx[i++] =  8;
	pIdx[i++] =  2; pIdx[i++] =  4; pIdx[i++] =  4; pIdx[i++] = 21; pIdx[i++] = 21;
	pIdx[i++] = 22; pIdx[i++] = 16; pIdx[i++] = 17; pIdx[i++] = 11; pIdx[i++] = 12;
	pIdx[i++] =  6; pIdx[i++] =  7; pIdx[i++] =  2; pIdx[i++] =  2; pIdx[i++] =  4;
	pIdx[i++] =  4; pIdx[i++] =  9; pIdx[i++] =  8; pIdx[i++] = 14; pIdx[i++] = 13;
	pIdx[i++] = 19; pIdx[i++] = 18; pIdx[i++] = 24; pIdx[i++] = 23;
	// Free the buffer
	mIndexes[ 1 ] -> indexBuffer -> unlock();

	mIndexes[ 2 ] = new IndexData(); //  2 = right lower lod
	mIndexes[ 2 ] -> indexStart = 0;
	mIndexes[ 2 ] -> indexCount = 44;
	mIndexes[ 2 ] -> indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer( HardwareIndexBuffer::IT_16BIT, mIndexes[ 2 ] -> indexCount, HardwareBuffer::HBU_WRITE_ONLY );
	// Block the buffer
	pIdx = static_cast<ushort*>( mIndexes[ 2 ]->indexBuffer->lock(	0, 	mIndexes[ 2 ]->indexBuffer->getSizeInBytes(), HardwareBuffer::HBL_DISCARD ) );
	//Construc a triangle Strip of 44
	i = 0;
	pIdx[i++] =  4; pIdx[i++] =  8; pIdx[i++] = 14; pIdx[i++] = 13; pIdx[i++] = 18;
	pIdx[i++] = 12; pIdx[i++] = 17; pIdx[i++] = 11; pIdx[i++] = 16; pIdx[i++] = 10;
	pIdx[i++] = 15; pIdx[i++] = 15; pIdx[i++] = 20; pIdx[i++] = 20; pIdx[i++] = 15;
	pIdx[i++] = 21; pIdx[i++] = 16; pIdx[i++] = 22; pIdx[i++] = 17; pIdx[i++] = 23;
	pIdx[i++] = 18; pIdx[i++] = 24; pIdx[i++] = 14; pIdx[i++] = 14; pIdx[i++] = 10;
	pIdx[i++] = 10; pIdx[i++] =  5; pIdx[i++] = 11; pIdx[i++] =  6; pIdx[i++] = 12;
	pIdx[i++] =  7; pIdx[i++] = 13; pIdx[i++] =  8; pIdx[i++] =  8; pIdx[i++] =  5;
	pIdx[i++] =  5; pIdx[i++] =  0; pIdx[i++] =  6; pIdx[i++] =  1; pIdx[i++] =  7;
	pIdx[i++] =  2; pIdx[i++] =  8; pIdx[i++] =  3; pIdx[i++] =  4;
	// Free the buffer
	mIndexes[ 2 ] -> indexBuffer -> unlock();

	mIndexes[ 3 ] = new IndexData(); //  3 = upper right lower LOD
	mIndexes[ 3 ] -> indexStart = 0;
	mIndexes[ 3 ] -> indexCount = 46;
	mIndexes[ 3 ] -> indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer( HardwareIndexBuffer::IT_16BIT, mIndexes[ 3 ] -> indexCount, HardwareBuffer::HBU_WRITE_ONLY );
	// Block the buffer
	pIdx = static_cast<ushort*>( mIndexes[ 3 ]->indexBuffer->lock(	0, 	mIndexes[ 3 ]->indexBuffer->getSizeInBytes(), HardwareBuffer::HBL_DISCARD ) );
	//Construc a triangle Strip of 46
	i = 0;
	pIdx[i++] = 23; pIdx[i++] = 24; pIdx[i++] = 18; pIdx[i++] = 14; pIdx[i++] = 13;
	pIdx[i++] =  8; pIdx[i++] =  7; pIdx[i++] =  2; pIdx[i++] =  6; pIdx[i++] =  0;
	pIdx[i++] =  5; pIdx[i++] =  5; pIdx[i++] =  7; pIdx[i++] =  7; pIdx[i++] = 13;
	pIdx[i++] = 12; pIdx[i++] = 18; pIdx[i++] = 17; pIdx[i++] = 23; pIdx[i++] = 22;
	pIdx[i++] = 22; pIdx[i++] = 21; pIdx[i++] = 21; pIdx[i++] = 22; pIdx[i++] = 16;
	pIdx[i++] = 17; pIdx[i++] = 11; pIdx[i++] = 12; pIdx[i++] =  6; pIdx[i++] =  7;
	pIdx[i++] =  7; pIdx[i++] = 20; pIdx[i++] = 20; pIdx[i++] = 21; pIdx[i++] = 15;
	pIdx[i++] = 16; pIdx[i++] = 10; pIdx[i++] = 11; pIdx[i++] =  5; pIdx[i++] =  6;
	pIdx[i++] =  6; pIdx[i++] = 14; pIdx[i++] = 14; pIdx[i++] =  4; pIdx[i++] =  8;
	pIdx[i++] =  2;
	// Free the buffer
	mIndexes[ 3 ] -> indexBuffer -> unlock();

	mIndexes[ 4 ] = new IndexData(); //  4  = lower LOD lower
	mIndexes[ 4 ] -> indexStart = 0;
	mIndexes[ 4 ] -> indexCount = 44;
	mIndexes[ 4 ] -> indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer( HardwareIndexBuffer::IT_16BIT, mIndexes[ 4 ] -> indexCount, HardwareBuffer::HBU_WRITE_ONLY );
	// Block the buffer
	pIdx = static_cast<ushort*>( mIndexes[ 4 ]->indexBuffer->lock(	0, 	mIndexes[ 4 ]->indexBuffer->getSizeInBytes(), HardwareBuffer::HBL_DISCARD ) );
	//Construc a triangle Strip of 51
	i = 0;
	pIdx[i++] = 22; pIdx[i++] = 24; pIdx[i++] = 18; pIdx[i++] = 19; pIdx[i++] = 13;
	pIdx[i++] = 14; pIdx[i++] =  8; pIdx[i++] =  9; pIdx[i++] =  3; pIdx[i++] =  4;
	pIdx[i++] =  4; pIdx[i++] = 20; pIdx[i++] = 20; pIdx[i++] = 22; pIdx[i++] = 16;
	pIdx[i++] = 17; pIdx[i++] = 11; pIdx[i++] = 12; pIdx[i++] =  6; pIdx[i++] =  7;
	pIdx[i++] =  1; pIdx[i++] =  2; pIdx[i++] =  2; pIdx[i++] =  1; pIdx[i++] =  1;
	pIdx[i++] =  0; pIdx[i++] =  6; pIdx[i++] =  5; pIdx[i++] = 11; pIdx[i++] = 10;
	pIdx[i++] = 16; pIdx[i++] = 15; pIdx[i++] = 20; pIdx[i++] = 20; pIdx[i++] = 22;
	pIdx[i++] = 22; pIdx[i++] = 17; pIdx[i++] = 18; pIdx[i++] = 12;
	pIdx[i++] = 13; pIdx[i++] =  7; pIdx[i++] =  8; pIdx[i++] =  2; pIdx[i++] =  3;
	// Free the buffer
	mIndexes[ 4 ] -> indexBuffer -> unlock();

	mIndexes[ 5 ] = new IndexData(); //  5
	mIndexes[ 5 ] -> indexStart = 0;
	mIndexes[ 5 ] -> indexCount = 53;
	mIndexes[ 5 ] -> indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer( HardwareIndexBuffer::IT_16BIT, 53, HardwareBuffer::HBU_WRITE_ONLY );
	// Block the buffer
	pIdx = static_cast<ushort*>( mIndexes[ 5 ]->indexBuffer->lock(	0, 	mIndexes[ 5 ]->indexBuffer->getSizeInBytes(), HardwareBuffer::HBL_DISCARD ) );
	//Construc a triangle Strip of 53
	pIdx[ 0 ] = 19; pIdx[ 1 ] = 14; pIdx[ 2 ] = 13; pIdx[ 3 ] = 8; pIdx[ 4 ] = 7;
	pIdx[ 5 ] = 2; pIdx[ 6 ] = 6; pIdx[ 7 ] = 0; pIdx[ 8 ] = 5; pIdx[ 9 ] = 5;
	pIdx[ 10 ] = 14; pIdx[ 11 ] = 14; pIdx[ 12 ] = 14; pIdx[ 13 ] = 9; pIdx[ 14 ] = 8;
	pIdx[ 15 ] = 4; pIdx[ 16 ] = 2; pIdx[ 17 ] = 2; pIdx[ 18 ] = 15; pIdx[ 19 ] = 15;
	pIdx[ 20 ] = 15; pIdx[ 21 ] = 20; pIdx[ 22 ] = 16; pIdx[ 23 ] = 22; pIdx[ 24 ] = 17;
	pIdx[ 25 ] = 18; pIdx[ 26 ] = 12; pIdx[ 27 ] = 13; pIdx[ 28 ] = 7; pIdx[ 29 ] = 7;
	pIdx[ 30 ] = 22; pIdx[ 31 ] = 22; pIdx[ 32 ] = 22; pIdx[ 33 ] = 24; pIdx[ 34 ] = 18;
	pIdx[ 35 ] = 19; pIdx[ 36 ] = 13; pIdx[ 37 ] = 13; pIdx[ 38 ] = 7; pIdx[ 39 ] = 7;
	pIdx[ 40 ] = 12; pIdx[ 41 ] = 6; pIdx[ 42 ] = 11; pIdx[ 43 ] = 5; pIdx[ 44 ] = 10;
	pIdx[ 45 ] = 10; pIdx[ 46 ] = 12; pIdx[ 47 ] = 12; pIdx[ 48 ] = 17; pIdx[ 49 ] = 11;
	pIdx[ 50 ] = 16; pIdx[ 51 ] = 10; pIdx[ 52 ] = 15; 
	// Free the buffer
	mIndexes[ 5 ] -> indexBuffer -> unlock();

	mIndexes[ 6 ] = new IndexData(); //  6
	mIndexes[ 6 ] -> indexStart = 0;
	mIndexes[ 6 ] -> indexCount = 49;
	mIndexes[ 6 ] -> indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer( HardwareIndexBuffer::IT_16BIT, 49, HardwareBuffer::HBU_WRITE_ONLY );
	// Block the buffer
	pIdx = static_cast<ushort*>( mIndexes[ 6 ]->indexBuffer->lock(	0, 	mIndexes[ 6 ]->indexBuffer->getSizeInBytes(), HardwareBuffer::HBL_DISCARD ) );
	//Construc a triangle Strip of 49
	pIdx[ 0 ] = 15; pIdx[ 1 ] = 15; pIdx[ 2 ] = 10; pIdx[ 3 ] = 16; pIdx[ 4 ] = 11; 
	pIdx[ 5 ] = 17; pIdx[ 6 ] = 12; pIdx[ 7 ] = 18; pIdx[ 8 ] = 13; pIdx[ 9 ] = 14;
	pIdx[ 10 ] = 8; pIdx[ 11 ] = 4; pIdx[ 12 ] = 3; pIdx[ 13 ] = 3; pIdx[ 14 ] = 16;
	pIdx[ 15 ] = 16; pIdx[ 16 ] = 17; pIdx[ 17 ] = 22; pIdx[ 18 ] = 18; pIdx[ 19 ] = 24;
	pIdx[ 20 ] = 14; pIdx[ 21 ] = 14; pIdx[ 22 ] = 22; pIdx[ 23 ] = 22; pIdx[ 24 ] = 22;
	pIdx[ 25 ] = 16; pIdx[ 26 ] = 20; pIdx[ 27 ] = 15; pIdx[ 28 ] = 15; pIdx[ 29 ] = 3;
	pIdx[ 30 ] = 3; pIdx[ 31 ] = 3; pIdx[ 32 ] = 8; pIdx[ 33 ] = 2; pIdx[ 34 ] = 7;
	pIdx[ 35 ] = 1; pIdx[ 36 ] = 6; pIdx[ 37 ] = 0; pIdx[ 38 ] = 5; pIdx[ 39 ] = 5;
	pIdx[ 40 ] = 8; pIdx[ 41 ] = 8; pIdx[ 42 ] = 13; pIdx[ 43 ] = 7; pIdx[ 44 ] = 12;
	pIdx[ 45 ] = 6; pIdx[ 46 ] = 11; pIdx[ 47 ] = 5; pIdx[ 48 ] = 10;
	// Free the buffer
	mIndexes[ 6 ] -> indexBuffer -> unlock();

	mIndexes[ 7 ] = new IndexData(); //  7
	mIndexes[ 7 ] -> indexStart = 0;
	mIndexes[ 7 ] -> indexCount = 45;
	mIndexes[ 7 ] -> indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer( HardwareIndexBuffer::IT_16BIT, 45, HardwareBuffer::HBU_WRITE_ONLY );
	// Block the buffer
	pIdx = static_cast<ushort*>( mIndexes[ 7 ]->indexBuffer->lock(	0, 	mIndexes[ 7 ]->indexBuffer->getSizeInBytes(), HardwareBuffer::HBL_DISCARD ) );
	//Construc a triangle Strip of 45
	pIdx[ 0 ] = 22; pIdx[ 1 ] = 24; pIdx[ 2 ] = 18; pIdx[ 3 ] = 14;
	pIdx[ 4 ] = 13; pIdx[ 5 ] = 8; pIdx[ 6 ] = 7; pIdx[ 7 ] = 2;
	pIdx[ 8 ] = 6; pIdx[ 9 ] = 0; pIdx[ 10 ] = 5; pIdx[ 11 ] = 5;
	pIdx[ 12 ] = 14; pIdx[ 13 ] = 14; pIdx[ 14 ] = 14; pIdx[ 15 ] = 4;
	pIdx[ 16 ] = 8; pIdx[ 17 ] = 2; pIdx[ 18 ] = 2; pIdx[ 19 ] = 15;
	pIdx[ 20 ] = 15; pIdx[ 21 ] = 20; pIdx[ 22 ] = 16; pIdx[ 23 ] = 22;
	pIdx[ 24 ] = 17; pIdx[ 25 ] = 18; pIdx[ 26 ] = 12; pIdx[ 27 ] = 13;

⌨️ 快捷键说明

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