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

📄 ogrepaginglandscapeindexbuffer.cpp

📁 使用stl技术,(还没看,是听说的)
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	pIdx[ 28 ] = 7; pIdx[ 29 ] = 7; pIdx[ 30 ] = 7; pIdx[ 31 ] = 7;
	pIdx[ 32 ] = 12; pIdx[ 33 ] = 6; pIdx[ 34 ] = 11; pIdx[ 35 ] = 5;
	pIdx[ 36 ] = 10; pIdx[ 37 ] = 10; pIdx[ 38 ] = 12; pIdx[ 39 ] = 12;
	pIdx[ 40 ] = 17; pIdx[ 41 ] = 11; pIdx[ 42 ] = 16; pIdx[ 43 ] = 10;
	pIdx[ 44 ] = 15;
	// Free the buffer
	mIndexes[ 7 ] -> indexBuffer -> unlock();

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

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

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

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

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

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

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

	mIndexes[ 15 ] = new IndexData(); // 15
	mIndexes[ 15 ] -> indexStart = 0;
	mIndexes[ 15 ] -> indexCount = 44;
	mIndexes[ 15 ] -> indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer( HardwareIndexBuffer::IT_16BIT, 44, HardwareBuffer::HBU_WRITE_ONLY );
	// Block the buffer
	pIdx = static_cast<ushort*>( mIndexes[ 15 ]->indexBuffer->lock(	0, 	mIndexes[ 15 ]->indexBuffer->getSizeInBytes(), HardwareBuffer::HBL_DISCARD ) );
	//Construc a triangle Strip of 44
	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 ] = 10; pIdx[ 11 ] = 10;
	pIdx[ 12 ] = 14; pIdx[ 13 ] = 14; pIdx[ 14 ] = 14; pIdx[ 15 ] = 4; pIdx[ 16 ] = 8; pIdx[ 17 ] = 2;
	pIdx[ 18 ] = 2; pIdx[ 19 ] = 10; pIdx[ 20 ] = 10; 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 ] = 16; pIdx[ 31 ] = 16; pIdx[ 32 ] = 10; pIdx[ 33 ] = 11; pIdx[ 34 ] = 6; pIdx[ 35 ] = 12;
	pIdx[ 36 ] = 7; pIdx[ 37 ] = 7; pIdx[ 38 ] = 16; pIdx[ 39 ] = 16; pIdx[ 40 ] = 16; pIdx[ 41 ] = 17;
	pIdx[ 42 ] = 11; pIdx[ 43 ] = 12;
	// Free the buffer
	mIndexes[ 15 ] -> indexBuffer -> unlock();
}

//-----------------------------------------------------------------------
PagingLandScapeIndexBuffer::~PagingLandScapeIndexBuffer()
{
	for ( int i = 0; i < 16; i++ )
	{
		if ( mIndexes[ i ] != 0 )
		{
			//HardwareBufferManager::getSingleton().destroyIndexBuffer( mIndexes[ i ] );
			delete mIndexes[ i ];
			mIndexes[ i ] = 0;
		}
	}
}

//-----------------------------------------------------------------------
IndexData *PagingLandScapeIndexBuffer::getIndex( bool Top, bool Right, bool Down, bool Left )
{
	int a = (int)Top * 8 + (int)Right * 4 + (int) Down * 2 + (int)Left;
	return mIndexes[ a ];
}

//-----------------------------------------------------------------------
PagingLandScapeIndexBuffer& PagingLandScapeIndexBuffer::getSingleton(void)
{
	return Singleton<PagingLandScapeIndexBuffer>::getSingleton();
}

} //namespace

⌨️ 快捷键说明

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