예제 #1
0
void DoBuildDoors( vec3_t vMin, vec3_t vMax ){
	// ensure we have something selected
	if ( g_FuncTable.m_pfnSelectedBrushCount() != 1 ) {
		DoMessageBox( "Invalid number of brushes selected, chose 1 only", "Error", MB_OK );
		return;
	}

	// tell Radiant we want to access the selected brushes
	g_FuncTable.m_pfnAllocateSelectedBrushHandles();

	// get handle to size definition brush
	brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( 0 );
	// cant release until we delete the brush, if we do...

	DoorRS rs;
	strcpy( rs.mainTexture, GetCurrentTexture() );

	if ( DoDoorsBox( &rs ) == IDOK ) {
		g_FuncTable.m_pfnDeleteBrushHandle( brush );

		BuildDoorsX2( vMin, vMax,
					  rs.bScaleMainH, rs.bScaleMainV,
					  rs.bScaleTrimH, rs.bScaleTrimV,
					  rs.mainTexture, rs.trimTexture,
					  rs.nOrientation ); // shapes.cpp
	}

	g_FuncTable.m_pfnReleaseSelectedBrushHandles();
}
void VImageState::OnPaint(VGraphicsInfo &Graphics, const VItemRenderInfo &parentState)
{
  VTextureObject *pTex = GetCurrentTexture();
  if (!pTex)
    return;

  VASSERT(parentState.m_pWindow);
  VRectanglef rect = parentState.m_pWindow->GetBoundingBox();
  VSimpleRenderState_t state = VGUIManager::DefaultGUIRenderState(m_eTranspType);
  VColorRef iColor = parentState.iFadeColor*m_iColor;
  state.SetFlag(m_iAdditionalStateFlags); // apply filtering for instance

  if (m_eStretchMode==BORDER)
  {
    hkvVec2 v1 = rect.m_vMin;
    hkvVec2 v2 = rect.m_vMax;
    float bx = (float)pTex->GetTextureWidth()*0.5f;
    float by = (float)pTex->GetTextureHeight()*0.5f;
    float hx = 1.f / bx;
    float hy = 1.f / by;
    bx -= 1.f;
    by -= 1.f;
    Overlay2DVertex_t v[(4+4+1)*6]; // 9 quads
    int iVertexCount = 0;

    // corners
    IVRender2DInterface::CreateQuadVertices(v1.x,v1.y, v1.x+bx,v1.y+by, 0,0,0.5f-hx,0.5f-hy, iColor, &v[iVertexCount]); iVertexCount+=6;
    IVRender2DInterface::CreateQuadVertices(v2.x-bx,v1.y, v2.x,v1.y+by, 0.5f+hx,0,1,0.5f-hy, iColor, &v[iVertexCount]); iVertexCount+=6;
    IVRender2DInterface::CreateQuadVertices(v2.x-bx,v2.y-by, v2.x,v2.y, 0.5f+hx,0.5f+hy,1,1, iColor, &v[iVertexCount]); iVertexCount+=6;
    IVRender2DInterface::CreateQuadVertices(v1.x,v2.y-by, v1.x+bx,v2.y, 0,0.5f+hy,0.5f-hx,1, iColor, &v[iVertexCount]); iVertexCount+=6;
  
    // edges
    IVRender2DInterface::CreateQuadVertices(v1.x+bx,v1.y, v2.x-bx,v1.y+by, 0.5f-hx,0,0.5f+hx,0.5f-hy, iColor, &v[iVertexCount]); iVertexCount+=6;
    IVRender2DInterface::CreateQuadVertices(v1.x+bx,v2.y-by, v2.x-bx,v2.y, 0.5f-hx,0.5f+hy,0.5f+hx,1, iColor, &v[iVertexCount]); iVertexCount+=6;
    IVRender2DInterface::CreateQuadVertices(v1.x,v1.y+by, v1.x+bx,v2.y-by, 0,0.5f-hy,0.5f-hx,0.5f+hy, iColor, &v[iVertexCount]); iVertexCount+=6;
    IVRender2DInterface::CreateQuadVertices(v2.x-bx,v1.y+by, v2.x,v2.y-by, 0.5f+hx,0.5f-hy,1,0.5f+hy, iColor, &v[iVertexCount]); iVertexCount+=6;
    
    // inner rect
    IVRender2DInterface::CreateQuadVertices(v1.x+bx,v1.y+by, v2.x-bx,v2.y-by, 0.5f-hx,0.5f-hy,0.5f+hx,0.5f+hy, iColor, &v[iVertexCount]); iVertexCount+=6;

    RENDER_VERTICES(iVertexCount);
  } 
  else if (m_eStretchMode==STRETCHED)
  {
    Overlay2DVertex_t v[6];    
    IVRender2DInterface::CreateQuadVertices(rect.m_vMin.x,rect.m_vMin.y,rect.m_vMax.x,rect.m_vMax.y,texCoord.m_vMin.x,texCoord.m_vMin.y,texCoord.m_vMax.x,texCoord.m_vMax.y,iColor,v);
    RENDER_VERTICES(6);
  }
  else // actual texture size
  {
    Overlay2DVertex_t v[6];
    rect.m_vMax.x = rect.m_vMin.x + (float)pTex->GetTextureWidth();
    rect.m_vMax.y = rect.m_vMin.y + (float)pTex->GetTextureHeight();
    IVRender2DInterface::CreateQuadVertices(rect.m_vMin.x,rect.m_vMin.y,rect.m_vMax.x,rect.m_vMax.y,texCoord.m_vMin.x,texCoord.m_vMin.y,texCoord.m_vMax.x,texCoord.m_vMax.y,iColor,v);
    RENDER_VERTICES(6);
  }
}
예제 #3
0
void DShape::BuildRegularPrism( vec3_t min, vec3_t max, int nSides, bool bAlignTop ){
	vec3_t vc[MAX_POLYGON_FACES + 2], vd[MAX_POLYGON_FACES + 2];

	vec3_t radius;
	vec3_t origin;

	VectorSubtract( max, min, radius );
	VectorScale( radius, 0.5f, radius );
	// calc 3d radius and origin
	VectorAdd( max, min, origin );
	VectorScale( origin, 0.5f, origin );

	float phase = 0.0f;

	if ( bAlignTop ) {
		phase = -( Q_PI / nSides );
		VectorScale( radius, static_cast< float >( 1 / cos( phase ) ), radius );
	}

	//----- Build Polygon Vertices -----

	int i;
	for ( i = 0; i < nSides; i++ )
	{
		VectorCopy( origin, vc[i] );
		VectorCopy( origin, vd[i] );

		vc[i][2] = min[2];
		vd[i][2] = max[2];

		vc[i][0] += radius[0] * sinf( ( 2 * Q_PI * i / nSides ) + phase );
		vc[i][1] += radius[1] * cosf( ( 2 * Q_PI * i / nSides ) + phase );

		vd[i][0] = vc[i][0];
		vd[i][1] = vc[i][1];
	}

	VectorCopy( vc[0], vc[nSides] );
	VectorCopy( vd[0], vd[nSides] );
	VectorCopy( vc[1], vc[nSides + 1] );
	VectorCopy( vd[1], vd[nSides + 1] );

	//----------------------------------

	DBrush* pB = m_Container.GetWorldSpawn()->NewBrush( m_nNextBrush++ );

	for ( i = 1; i <= nSides; i++ )
		pB->AddFace( vc[i - 1], vc[i], vd[i], GetCurrentTexture(), FALSE );

	pB->AddFace( vc[2], vc[1], vc[0], "textures/common/caulk", FALSE );
	pB->AddFace( vd[0], vd[1], vd[2], "textures/common/caulk", FALSE );
}
예제 #4
0
void DoResetTextures(){
	static ResetTextureRS rs;

	const char* texName;
	if ( g_SelectedFaceTable.m_pfnGetSelectedFaceCount() != 1 ) {
		texName = NULL;
	}
	else
	{
		texName = GetCurrentTexture();
		strcpy( rs.textureName, GetCurrentTexture() );
	}

	int ret;
	if ( ( ret = DoResetTextureBox( &rs ) ) == IDCANCEL ) {
		return;
	}

	if ( rs.bResetTextureName ) {
		texName = rs.textureName;
	}

	if ( ret == IDOK ) {
		DEntity world;
		world.LoadSelectedBrushes();
		world.ResetTextures( texName,              rs.fScale,      rs.fShift,      rs.rotation, rs.newTextureName,
							 rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation, TRUE );
	}
	else
	{
		DMap world;
		world.LoadAll( TRUE );
		world.ResetTextures( texName,              rs.fScale,      rs.fShift,      rs.rotation, rs.newTextureName,
							 rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation );
	}
}
예제 #5
0
void DShape::BuildBorderedPrism( vec3_t min, vec3_t max, int nSides, int nBorder, bool bAlignTop ){
	vec3_t va[MAX_POLYGON_FACES + 2], vb[MAX_POLYGON_FACES + 2];
	vec3_t vc[MAX_POLYGON_FACES + 2], vd[MAX_POLYGON_FACES + 2];

	vec3_t radius;
	vec3_t origin;

	VectorSubtract( max, min, radius );
	VectorScale( radius, 0.5f, radius );
	// calc 3d radius and origin
	VectorAdd( max, min, origin );
	VectorScale( origin, 0.5f, origin );

	if ( nBorder >= Min( radius[0], radius[1] ) ) {
//		DoMessageBox("Border is too large", "Error", MB_OK);
		return;
	}

	float phase = 0.0f;

	if ( bAlignTop ) {
		phase = -( Q_PI / nSides );
		VectorScale( radius, static_cast< float >( 1 / cos( phase ) ), radius );
	}

	//----- Build Polygon Vertices -----

	int i;
	for ( i = 0; i < nSides; i++ )
	{
		VectorCopy( origin, va[i] );
		VectorCopy( origin, vb[i] );
		VectorCopy( origin, vc[i] );
		VectorCopy( origin, vd[i] );

		va[i][2] = min[2];
		vb[i][2] = max[2];

		va[i][0] += ( radius[0] - nBorder ) * sinf( ( 2 * Q_PI * i / nSides ) + phase );
		va[i][1] += ( radius[1] - nBorder ) * cosf( ( 2 * Q_PI * i / nSides ) + phase );

		vb[i][0] = va[i][0];
		vb[i][1] = va[i][1];



		vc[i][2] = min[2];
		vd[i][2] = max[2];

		vc[i][0] += radius[0] * sinf( ( 2 * Q_PI * i / nSides ) + phase );
		vc[i][1] += radius[1] * cosf( ( 2 * Q_PI * i / nSides ) + phase );

		vd[i][0] = vc[i][0];
		vd[i][1] = vc[i][1];
	}

	VectorCopy( va[0], va[nSides] );
	VectorCopy( vb[0], vb[nSides] );
	VectorCopy( va[1], va[nSides + 1] );
	VectorCopy( vb[1], vb[nSides + 1] );

	VectorCopy( vc[0], vc[nSides] );
	VectorCopy( vd[0], vd[nSides] );
	VectorCopy( vc[1], vc[nSides + 1] );
	VectorCopy( vd[1], vd[nSides + 1] );

	//----------------------------------

	for ( i = 1; i <= nSides; i++ )
	{
		DBrush* pB = GetBoundingCube( min, max, "textures/common/caulk" );

		pB->AddFace( origin, vc[i - 1], vd[i - 1], "textures/common/caulk", FALSE );
		pB->AddFace( origin, vd[i], vc[i], "textures/common/caulk", FALSE );

		pB->AddFace( vc[i - 1], vc[i], vd[i], GetCurrentTexture(), FALSE );
		pB->AddFace( vb[i], va[i], va[i - 1], GetCurrentTexture(), FALSE );
	}
}
예제 #6
0
void DShape::BuildInversePrism( vec3_t min, vec3_t max, int nSides, bool bAlignTop ){
	vec3_t va[MAX_POLYGON_FACES + 1], vb[MAX_POLYGON_FACES + 1];
	vec3_t radius;
	vec3_t origin;

	VectorSubtract( max, min, radius );
	VectorScale( radius, 0.5f, radius );
	// calc 3d radius and origin
	VectorAdd( max, min, origin );
	VectorScale( origin, 0.5f, origin );

	float phase = 0.0f;

	if ( bAlignTop ) {
		phase = -( Q_PI / nSides );
		VectorScale( radius, static_cast< float >( 1 / cos( phase ) ), radius );
	}

	//----- Build Polygon Vertices -----

	int i;
	for ( i = 0; i < nSides; i++ )
	{
		VectorCopy( origin, va[i] );
		VectorCopy( origin, vb[i] );

		va[i][2] = min[2];
		vb[i][2] = max[2];

		va[i][0] += radius[0] * sinf( ( 2 * Q_PI * i / nSides ) + phase );
		va[i][1] += radius[1] * cosf( ( 2 * Q_PI * i / nSides ) + phase );

		vb[i][0] = va[i][0];
		vb[i][1] = va[i][1];
	}

	VectorCopy( va[0], va[nSides] );
	VectorCopy( vb[0], vb[nSides] );

	//----------------------------------

	for ( i = 1; i <= nSides; i++ )
	{
		DBrush* pB = GetBoundingCube( min, max, "textures/common/caulk" );

		vec3_t top, bottom;
		VectorCopy( va[i - 1], top );
		VectorCopy( va[i], bottom );

		if ( va[i - 1][1] > va[i][1] ) {
			top[0] += 5;
			bottom[0] += 5;
		}
		else    // flip direction of plane on crossover
		{
			top[0] -= 5;
			bottom[0] -= 5;
		}

		if ( top[1] != bottom[1] ) { // internal line is flat already if true
			pB->AddFace( va[i - 1], top, vb[i - 1], "textures/common/caulk", FALSE );
			pB->AddFace( va[i], vb[i], bottom, "textures/common/caulk", FALSE );
		}   // add cut-off planes

		pB->AddFace( va[i - 1], vb[i - 1], vb[i], GetCurrentTexture(), FALSE );
		// add internal polygon plane
	}
}
예제 #7
0
void DoBuildStairs( vec3_t vMin, vec3_t vMax ){
	BuildStairsRS rs;

	strcpy( rs.mainTexture, GetCurrentTexture() );

	// ensure we have something selected
	if ( g_FuncTable.m_pfnSelectedBrushCount() != 1 ) {
		DoMessageBox( "Invalid number of brushes selected, chose 1 only", "Error", MB_OK );
		return;
	}

	// tell Radiant we want to access the selected brushes
	g_FuncTable.m_pfnAllocateSelectedBrushHandles();

	// get handle to size definition brush
	brush_t *brush = (brush_t*)g_FuncTable.m_pfnGetSelectedBrushHandle( 0 );
	// cant release until we delete the brush, if we do...


	// ask user for type, size, etc....
	if ( DoBuildStairsBox( &rs ) == IDOK ) {
		// calc brush size
		vec3_t size;
		VectorSubtract( vMax, vMin, size );

		if ( ( (int)size[2] % rs.stairHeight ) != 0 ) {
			// stairs must fit evenly into brush
			DoMessageBox( "Invalid stair height\nHeight of block must be divisable by stair height", "Error", MB_OK );
		}
		else
		{

			// Remove Size Brush
			g_FuncTable.m_pfnDeleteBrushHandle( brush );


			// Get Step Count
			int numSteps = (int)size[2] / rs.stairHeight;

			if ( rs.style == STYLE_CORNER ) {
				BuildCornerStairs( vMin, vMax, numSteps, rs.mainTexture, rs.riserTexture );
			}
			else
			{

				// Get Step Dimensions
				float stairHeight = (float)rs.stairHeight;
				float stairWidth;
				if ( ( rs.direction == MOVE_EAST ) || ( rs.direction == MOVE_WEST ) ) {
					stairWidth = ( size[0] ) / numSteps;
				}
				else{
					stairWidth = ( size[1] ) / numSteps;
				}


				// Build Base For Stair (bob's style)
				if ( rs.style == STYLE_BOB ) {
					Build_Wedge( rs.direction, vMin, vMax, TRUE );
				}


				// Set First Step Starting Position
				vMax[2] = vMin[2] + stairHeight;
				SetInitialStairPos( rs.direction, vMin, vMax, stairWidth );


				// Build The Steps
				for ( int i = 0; i < numSteps; i++ )
				{
					if ( rs.style == STYLE_BOB ) {
						Build_StairStep_Wedge( rs.direction, vMin, vMax, rs.mainTexture, rs.riserTexture, rs.bUseDetail );
					}
					else if ( rs.style == STYLE_ORIGINAL ) {
						Build_StairStep( vMin, vMax, rs.mainTexture, rs.riserTexture, rs.direction );
					}

					// get step into next position
					MoveBlock( rs.direction, vMin, vMax, stairWidth );
					vMax[2] += stairHeight;
					if ( rs.style == STYLE_BOB ) {
						vMin[2] += stairHeight; // wedge bottom must be raised
					}
				}
			}
		}
	}

	g_FuncTable.m_pfnReleaseSelectedBrushHandles();
}