示例#1
0
void mx_LevelGenerator::SetupRoomSector( const Room* room, mx_LevelSector* sector )
{
	sector->planes_count= 6;
	for( unsigned int i= 0; i < 6; i++ )
	{
		for( unsigned int j= 0;j < 3; j++ )
			sector->planes[i].normal[j]= float(c_cube_normals[i][j]);

		unsigned int c= i >> 1;
		sector->planes[i].dist= sector->planes[i].normal[c] * float((i&1) ? room->coord_min[c] : room->coord_max[c]);
	}

	for( unsigned int i= 0; i < 3; i++ )
	{
		sector->bb_min[i]= float(room->coord_min[i]);
		sector->bb_max[i]= float(room->coord_max[i]);
	}

	float relative_light_intancity= mxDistance( sector->bb_min, sector->bb_max );
	sector->light_count= rand_.RandI( 1, 4 );
	for( unsigned int l= 0; l < sector->light_count; l++ )
		for( unsigned int i= 0; i < 3; i++ )
		{
			sector->lights[l].pos[i]= rand_.RandF( sector->bb_min[i] + 1.0f, sector->bb_max[i] - 1.0f );
			sector->lights[l].light_rgb[i]= relative_light_intancity * rand_.RandF( 0.1f, 0.4f );
		}

	sector->ammo_box_count= 1;
	for( unsigned int i= 0; i < 3; i++ )
		sector->ammo_boxes[0].pos[i]= rand_.RandF( sector->bb_min[i] + 1.0f, sector->bb_max[i] - 1.0f );
	sector->ammo_boxes[0].type= BulletType( rand_.Rand() % LastBullet );

	// Central sector is first
	sector->is_central_sector= room == rooms_;
	if( sector->is_central_sector )
	{
		// Setup lights in corners of sector
		sector->light_count= 8;
		const float* mm[2]= { sector->bb_min, sector->bb_max };
		static const float c_shift[2]= { 1.2f, -1.2f };
		for( unsigned int l= 0; l < 8; l++ )
		{
			static const float c_light_intensity= 2.0f;
			for( unsigned int j= 0; j < 3; j++ )
			{
				unsigned int k= ( l >> j ) & 1;
				sector->lights[l].pos[j]= mm[k][j] + c_shift[k];
				sector->lights[l].light_rgb[j]= mx_GameConstants::icosahedron_color[j] * c_light_intensity;
			}
		}
	}
示例#2
0
/*
// CTextStyle::BulletIndent( )
//
// Returns the amount of space to indent after the bullet character.
// Takes into account point size, bullet type and bullet level
*/
CFixed CTextStyle::BulletIndent( ) const
{
	// find the amount of space appropriate for the point size of the font
	int nSpace = 0;
	// only do this if the bullet level is within our fixed range
	if( BulletLevel() >= 0 && BulletLevel() < BULLET_LEVEL_MAX )
	{
		if( BulletType()!= BULLET_none )
		{
			int nSize = FixedInteger( Size() );

			if( nSize < 14 )
				nSpace = 450;				// 1/4 inch
			else if( nSize < 24 )
				nSpace = 900;				// half inch
			else if( nSize < 39 )
				nSpace = 1350;				// 3/4 inch
			else if( nSize < 54 )
				nSpace = 1800;				// one inch
			else if( nSize < 69 )
				nSpace = 2250;				// 1 1/4 inch
			else if( nSize < 89 )
				nSpace = 2700;				// 1 and 1/2 inch
			else if( nSize < 109 )
				nSpace = 3150;				// 1 and 3/4 inch
			else
				nSpace = 3600;				// 2 inches

			int nExtra = 0;
			// a multilevel list may need additional space.
			// this tweek may need to be expanded if we add more list styles.
			if( BulletType() == BULLET_multilevel )
			{
				// in a multilevel mixed list levels 0 and 4 are roman numerals
				if( BulletStyle() == BULLET_roman_mix )
				{
					for( int i = 1; i < BulletLevel(); i++ )
					{
						if( BulletLevel() == 0 || BulletLevel == 4)
							nExtra += nSpace >> 1;
					}
				}
				// as the level increses, need more space for the number (1.1.1 ...)
				else if( BulletStyle() == BULLET_arabic )
				{
					PMGDatabase *pDataBase = Database();
					ASSERT( pDataBase );
					if( pDataBase )
					{
						FontServer* pFontServer = pDataBase->get_font_server();
						CHARACTER str[3] = { '1','.', 0 };
						CTextStyle style = *this;
						PCOORD width = pFontServer->GetAdvanceWidth(&style, 5);
						// need to accumulate the extra space for each level
						for( int i = 1; i <= BulletLevel(); i++ )
						{
							nExtra += width * i;
						}
					}
					else
					{
						// need to accumulate the extra space for each level
						for( int i = 1; i < BulletLevel(); i++ )
						{
							nExtra += MulDiv( nSize, PAGE_RESOLUTION, 72 ) * i;
						}
					}
				}
			}
			TRACE( "bullet level %d\nspace = %d, extra = %d", BulletLevel(), nSpace, nExtra );
			// multiply the space need by the bullet level + 1 to get the total indent
			nSpace *= BulletLevel() + 1;
			TRACE( "space * bulletlevel = %d\n", nSpace );
			nSpace += nExtra;
		}
示例#3
0
 //------------------------------------------------ GET TYPE ------------------------------------------------
 BulletType BulletImpl::getType() const
 {
   return BulletType(self->type);
 }