示例#1
0
void BuildCornerStairs( vec3_t vMin, vec3_t vMax, int nSteps, const char* mainTexture, const char* riserTex ){
	vec3_t* topPoints = new vec3_t[nSteps + 1];
	vec3_t* botPoints = new vec3_t[nSteps + 1];

	bool bFacesUse[6] = {TRUE, TRUE, FALSE, TRUE, FALSE, FALSE};

	vec3_t centre;
	VectorCopy( vMin, centre );
	centre[0] = vMax[0];

	int height = (int)( vMax[2] - vMin[2] ) / nSteps;

	vec3_t vTop, vBot;
	VectorCopy( vMax, vTop );
	VectorCopy( vMin, vBot );
	vTop[2] = vMin[2] + height;

	int i;
	for ( i = 0; i <= nSteps; i++ )
	{
		VectorCopy( centre, topPoints[i] );
		VectorCopy( centre, botPoints[i] );

		topPoints[i][2] = vMax[2];
		botPoints[i][2] = vMin[2];

		topPoints[i][0] -= 10 * sinf( Q_PI * i / ( 2 * nSteps ) );
		topPoints[i][1] += 10 * cosf( Q_PI * i / ( 2 * nSteps ) );

		botPoints[i][0] = topPoints[i][0];
		botPoints[i][1] = topPoints[i][1];
	}

	vec3_t tp[3];
	for ( int j = 0; j < 3; j++ )
		VectorCopy( topPoints[j], tp[j] );

	for ( i = 0; i < nSteps; i++ )
	{
		brush_t* brush = Build_Get_BoundingCube_Selective( vBot, vTop, "textures/common/caulk", bFacesUse );

		for ( int j = 0; j < 3; j++ )
			tp[j][2] = vTop[2];

		AddFaceWithTexture( brush, tp[2], tp[1], tp[0], mainTexture, FALSE );

		AddFaceWithTexture( brush, centre, botPoints[i + 1], topPoints[i + 1], "textures/common/caulk", FALSE );
		AddFaceWithTexture( brush, centre, topPoints[i], botPoints[i], riserTex, FALSE );

		g_FuncTable.m_pfnCommitBrushHandle( brush );

		vTop[2] += height;
		vBot[2] += height;
	}

	delete[] topPoints;
	delete[] botPoints;

	vMin[2] += height;
	vMax[2] += height;
	MakeBevel( vMin, vMax );
}
示例#2
0
void BuildCornerStairs(vec3_t vMin, vec3_t vMax, int nSteps, const char* mainTexture, const char* riserTex)
{
	vec3_t* topPoints = new vec3_t[nSteps+1];
	vec3_t* botPoints = new vec3_t[nSteps+1];

	//bool bFacesUse[6] = {true, true, false, true, false, false};

	vec3_t centre;
	VectorCopy(vMin, centre);
	centre[0] = vMax[0];

	int height = (int)(vMax[2] - vMin[2]) / nSteps;

	vec3_t vTop, vBot;
	VectorCopy(vMax, vTop);
	VectorCopy(vMin, vBot);
	vTop[2] = vMin[2] + height;

  int i;
	for(i = 0; i <= nSteps; i++)
	{
		VectorCopy(centre, topPoints[i]);
		VectorCopy(centre, botPoints[i]);
		
		topPoints[i][2] = vMax[2];
		botPoints[i][2] = vMin[2];

		topPoints[i][0] -= 10 * sinf( Q_PI * i / ( 2 * nSteps ) );
		topPoints[i][1] += 10 * cosf( Q_PI * i / ( 2 * nSteps ) );

		botPoints[i][0] = topPoints[i][0];
		botPoints[i][1] = topPoints[i][1];
	}

	vec3_t tp[3];
	for(int j = 0; j < 3; j++)
		VectorCopy(topPoints[j], tp[j]);

	for(i = 0; i < nSteps; i++)
	{
		NodeSmartReference brush(GlobalBrushCreator().createBrush());
		vec3_t v1, v2, v3, v5, v6, v7;
		VectorCopy(vBot, v1);
		VectorCopy(vBot, v2);
		VectorCopy(vBot, v3);
		VectorCopy(vTop, v5);
		VectorCopy(vTop, v6);
		VectorCopy(vTop, v7);
		
		v2[0] = vTop[0];
		v3[1] = vTop[1];
		
		v6[0] = vBot[0];
		v7[1] = vBot[1];
		
		AddFaceWithTexture(brush, v1, v2, v3, "textures/common/caulk", false);
		AddFaceWithTexture(brush, v1, v3, v6, "textures/common/caulk", false);
		AddFaceWithTexture(brush, v5, v6, v3, "textures/common/caulk", false);
		
		for(int j = 0; j < 3; j++)
			tp[j][2] = vTop[2];

		AddFaceWithTexture(brush, tp[2], tp[1], tp[0], mainTexture, false);

		AddFaceWithTexture(brush, centre, botPoints[i+1], topPoints[i+1], "textures/common/caulk", false);
		AddFaceWithTexture(brush, centre, topPoints[i], botPoints[i], riserTex, false);

		Node_getTraversable(GlobalRadiant().getMapWorldEntity())->insert(brush);

		vTop[2] += height;
		vBot[2] += height;
	}

	delete[] topPoints;
	delete[] botPoints;

	vMin[2] += height;
	vMax[2] += height;
	MakeBevel(vMin, vMax);
}