Ejemplo n.º 1
0
void BuildDoorsX2(vec3_t min, vec3_t max,
                  bool bSclMainHor, bool bSclMainVert,
                  bool bSclTrimHor, bool bSclTrimVert,
                  const char* mainTexture, const char* trimTexture,
                  int direction)
{
    int xy;
    if(direction == 0)
        xy = 0;
    else
        xy = 1;

    //----- Build Outer Bounds ---------

    vec3_t v1, v2, v3, v5, v6, v7, ve_1, ve_2, ve_3;
    VectorCopy(min, v1);
    VectorCopy(min, v2);
    VectorCopy(min, v3);
    VectorCopy(max, v5);
    VectorCopy(max, v6);
    VectorCopy(max, v7);

    v2[0] = max[0];
    v3[1] = max[1];

    v6[0] = min[0];
    v7[1] = min[1];

    float width = (max[xy] - min[xy])/2;

    if(direction == 0)
    {
        VectorCopy(v1, ve_1);
        VectorCopy(v3, ve_2);
        VectorCopy(v6, ve_3);
    }
    else
    {
        VectorCopy(v7, ve_1);
        VectorCopy(v1, ve_2);
        VectorCopy(v2, ve_3);
    }

    ve_1[xy] += width;
    ve_2[xy] += width;
    ve_3[xy] += width;

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

    scene::Node* newBrush1 = Brush_AllocNode();
    scene::Node* newBrush2 = Brush_AllocNode();

    AddFaceWithTexture(newBrush1, v1, v2, v3, "textures/common/caulk", FALSE);
    AddFaceWithTexture(newBrush1, v5, v7, v6, "textures/common/caulk", FALSE);

    AddFaceWithTexture(newBrush2, v1, v2, v3, "textures/common/caulk", FALSE);
    AddFaceWithTexture(newBrush2, v5, v7, v6, "textures/common/caulk", FALSE);

    if(direction == 0)
    {
        AddFaceWithTexture(newBrush1, v1, v3, v6, "textures/common/caulk", FALSE);
        AddFaceWithTexture(newBrush2, v5, v2, v7, "textures/common/caulk", FALSE);
    }
    else
    {
        AddFaceWithTexture(newBrush1, v1, v7, v2, "textures/common/caulk", FALSE);
        AddFaceWithTexture(newBrush2, v5, v6, v3, "textures/common/caulk", FALSE);
    }

    if(direction == 0)
    {
        AddFaceWithTextureScaled(newBrush1, v1, v7, v2, mainTexture, bSclMainVert, bSclMainHor,
                                 min[0], min[2], max[0], max[2]);
        AddFaceWithTextureScaled(newBrush1, v5, v6, v3, mainTexture, bSclMainVert, bSclMainHor,
                                 max[0], min[2], min[0], max[2]);


        AddFaceWithTextureScaled(newBrush2, v1, v7, v2, mainTexture, bSclMainVert, bSclMainHor,
                                 min[0], min[2], max[0], max[2]);
        AddFaceWithTextureScaled(newBrush2, v5, v6, v3, mainTexture, bSclMainVert, bSclMainHor,
                                 max[0], min[2], min[0], max[2]);	// flip max/min to reverse tex dir



        AddFaceWithTextureScaled(newBrush1, ve_3, ve_2, ve_1, trimTexture, bSclTrimVert, bSclTrimHor,
                                 min[1], min[2], max[1], max[2]);

        AddFaceWithTextureScaled(newBrush2, ve_1, ve_2, ve_3, trimTexture, bSclTrimVert, bSclTrimHor,
                                 max[1], min[2], min[1], max[2]);
    }
    else
    {
        AddFaceWithTextureScaled(newBrush1, v1, v3, v6, mainTexture, bSclMainVert, bSclMainHor,
                                 min[1], min[2], max[1], max[2]);
        AddFaceWithTextureScaled(newBrush1, v5, v2, v7, mainTexture, bSclMainVert, bSclMainHor,
                                 max[1], min[2], min[1], max[2]);


        AddFaceWithTextureScaled(newBrush2, v1, v3, v6, mainTexture, bSclMainVert, bSclMainHor,
                                 min[1], min[2], max[1], max[2]);
        AddFaceWithTextureScaled(newBrush2, v5, v2, v7, mainTexture, bSclMainVert, bSclMainHor,
                                 max[1], min[2], min[1], max[2]);	// flip max/min to reverse tex dir


        AddFaceWithTextureScaled(newBrush1, ve_1, ve_2, ve_3, trimTexture, bSclTrimVert, bSclTrimHor,
                                 min[0], min[2], max[0], max[2]);

        AddFaceWithTextureScaled(newBrush2, ve_3, ve_2, ve_1, trimTexture, bSclTrimVert, bSclTrimHor,
                                 max[0], min[2], min[0], max[2]);
    }

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


    scene::Node* pEDoor1 = GlobalEntityCreator().createEntity("func_door");
    scene::Node* pEDoor2 = GlobalEntityCreator().createEntity("func_door");

    if(direction == 0)
    {
        pEDoor1->m_entity->setkeyvalue("angle", "180");
        pEDoor2->m_entity->setkeyvalue("angle", "360");
    }
    else
    {
        pEDoor1->m_entity->setkeyvalue("angle", "270");
        pEDoor2->m_entity->setkeyvalue("angle", "90");
    }

    srand((unsigned)time(NULL));

    char teamname[256];
    sprintf(teamname, "t%i", rand());
    pEDoor1->m_entity->setkeyvalue("team", teamname);
    pEDoor2->m_entity->setkeyvalue("team", teamname);

    pEDoor1->m_traverse->insert(newBrush1);
    pEDoor2->m_traverse->insert(newBrush2);

    GlobalSceneGraph().root()->m_traverse->insert(pEDoor1);
    GlobalSceneGraph().root()->m_traverse->insert(pEDoor2);

//	ResetCurrentTexture();
}
Ejemplo n.º 2
0
void BuildDoorsX2( vec3_t min, vec3_t max,
				   bool bSclMainHor, bool bSclMainVert,
				   bool bSclTrimHor, bool bSclTrimVert,
				   const char* mainTexture, const char* trimTexture,
				   int direction ){
	int xy;
	if ( direction == 0 ) {
		xy = 0;
	}
	else{
		xy = 1;
	}

	//----- Build Outer Bounds ---------

	vec3_t v1, v2, v3, v5, v6, v7, ve_1, ve_2, ve_3;
	VectorCopy( min, v1 );
	VectorCopy( min, v2 );
	VectorCopy( min, v3 );
	VectorCopy( max, v5 );
	VectorCopy( max, v6 );
	VectorCopy( max, v7 );

	v2[0] = max[0];
	v3[1] = max[1];

	v6[0] = min[0];
	v7[1] = min[1];

	float width = ( max[xy] - min[xy] ) / 2;

	if ( direction == 0 ) {
		VectorCopy( v1, ve_1 );
		VectorCopy( v3, ve_2 );
		VectorCopy( v6, ve_3 );
	}
	else
	{
		VectorCopy( v7, ve_1 );
		VectorCopy( v1, ve_2 );
		VectorCopy( v2, ve_3 );
	}

	ve_1[xy] += width;
	ve_2[xy] += width;
	ve_3[xy] += width;

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

	brush_t* newBrush1 = (brush_t*)g_FuncTable.m_pfnCreateBrushHandle();
	brush_t* newBrush2 = (brush_t*)g_FuncTable.m_pfnCreateBrushHandle();

	AddFaceWithTexture( newBrush1, v1, v2, v3, "textures/common/caulk", FALSE );
	AddFaceWithTexture( newBrush1, v5, v7, v6, "textures/common/caulk", FALSE );

	AddFaceWithTexture( newBrush2, v1, v2, v3, "textures/common/caulk", FALSE );
	AddFaceWithTexture( newBrush2, v5, v7, v6, "textures/common/caulk", FALSE );

	if ( direction == 0 ) {
		AddFaceWithTexture( newBrush1, v1, v3, v6, "textures/common/caulk", FALSE );
		AddFaceWithTexture( newBrush2, v5, v2, v7, "textures/common/caulk", FALSE );
	}
	else
	{
		AddFaceWithTexture( newBrush1, v1, v7, v2, "textures/common/caulk", FALSE );
		AddFaceWithTexture( newBrush2, v5, v6, v3, "textures/common/caulk", FALSE );
	}

	if ( direction == 0 ) {
		AddFaceWithTextureScaled( newBrush1, v1, v7, v2, mainTexture, bSclMainVert, bSclMainHor,
								  min[0], min[2], max[0], max[2] );
		AddFaceWithTextureScaled( newBrush1, v5, v6, v3, mainTexture, bSclMainVert, bSclMainHor,
								  max[0], min[2], min[0], max[2] );


		AddFaceWithTextureScaled( newBrush2, v1, v7, v2, mainTexture, bSclMainVert, bSclMainHor,
								  min[0], min[2], max[0], max[2] );
		AddFaceWithTextureScaled( newBrush2, v5, v6, v3, mainTexture, bSclMainVert, bSclMainHor,
								  max[0], min[2], min[0], max[2] ); // flip max/min to reverse tex dir



		AddFaceWithTextureScaled( newBrush1, ve_3, ve_2, ve_1, trimTexture, bSclTrimVert, bSclTrimHor,
								  min[1], min[2], max[1], max[2] );

		AddFaceWithTextureScaled( newBrush2, ve_1, ve_2, ve_3, trimTexture, bSclTrimVert, bSclTrimHor,
								  max[1], min[2], min[1], max[2] );
	}
	else
	{
		AddFaceWithTextureScaled( newBrush1, v1, v3, v6, mainTexture, bSclMainVert, bSclMainHor,
								  min[1], min[2], max[1], max[2] );
		AddFaceWithTextureScaled( newBrush1, v5, v2, v7, mainTexture, bSclMainVert, bSclMainHor,
								  max[1], min[2], min[1], max[2] );


		AddFaceWithTextureScaled( newBrush2, v1, v3, v6, mainTexture, bSclMainVert, bSclMainHor,
								  min[1], min[2], max[1], max[2] );
		AddFaceWithTextureScaled( newBrush2, v5, v2, v7, mainTexture, bSclMainVert, bSclMainHor,
								  max[1], min[2], min[1], max[2] ); // flip max/min to reverse tex dir


		AddFaceWithTextureScaled( newBrush1, ve_1, ve_2, ve_3, trimTexture, bSclTrimVert, bSclTrimHor,
								  min[0], min[2], max[0], max[2] );

		AddFaceWithTextureScaled( newBrush2, ve_3, ve_2, ve_1, trimTexture, bSclTrimVert, bSclTrimHor,
								  max[0], min[2], min[0], max[2] );
	}

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


	entity_t* pEDoor1 = (entity_t*)g_FuncTable.m_pfnCreateEntityHandle();
	entity_t* pEDoor2 = (entity_t*)g_FuncTable.m_pfnCreateEntityHandle();

	epair_t* epDoor11 = GetNextChainItem( NULL, "classname", "func_door" );
	epair_t* epDoor21 = GetNextChainItem( NULL, "classname", "func_door" );

	epair_t* epDoor12;
	epair_t* epDoor22;

	if ( direction == 0 ) {
		epDoor12 = GetNextChainItem( epDoor11, "angle", "180" );
		epDoor22 = GetNextChainItem( epDoor21, "angle", "360" );
	}
	else
	{
		epDoor12 = GetNextChainItem( epDoor11, "angle", "270" );
		epDoor22 = GetNextChainItem( epDoor21, "angle", "90" );
	}

	srand( (unsigned)time( NULL ) );

	char teamname[256];
	sprintf( teamname, "t%i", rand() );
	/*epair_t* epDoor13 = */ GetNextChainItem( epDoor12, "team", teamname );
	/*epair_t* epDoor23 = */ GetNextChainItem( epDoor22, "team", teamname );

	g_FuncTable.m_pfnCommitBrushHandleToEntity( newBrush1, pEDoor1 );
	g_FuncTable.m_pfnCommitBrushHandleToEntity( newBrush2, pEDoor2 );

	g_EntityTable.m_pfnSetEntityKeyValList( pEDoor1, epDoor11 );
	g_EntityTable.m_pfnSetEntityKeyValList( pEDoor2, epDoor21 );

	g_FuncTable.m_pfnCommitEntityHandleToMap( pEDoor1 );
	g_FuncTable.m_pfnCommitEntityHandleToMap( pEDoor2 );

//	ResetCurrentTexture();
}
Ejemplo n.º 3
0
void BuildDoorsX2(vec3_t min, vec3_t max, 
				  bool bSclMainHor, bool bSclMainVert, 
				  bool bSclTrimHor, bool bSclTrimVert,
				  const char* mainTexture, const char* trimTexture,
				  int direction)
{
	int xy;
	if(direction == 0)
		xy = 0;
	else
		xy = 1;

	//----- Build Outer Bounds ---------

	vec3_t v1, v2, v3, v5, v6, v7, ve_1, ve_2, ve_3;
	VectorCopy(min, v1);
	VectorCopy(min, v2);
	VectorCopy(min, v3);
	VectorCopy(max, v5);
	VectorCopy(max, v6);
	VectorCopy(max, v7);

	v2[0] = max[0];
	v3[1] = max[1];

	v6[0] = min[0];
	v7[1] = min[1];

	float width = (max[xy] - min[xy])/2;
	
	if(direction == 0)
	{
		VectorCopy(v1, ve_1);
		VectorCopy(v3, ve_2);
		VectorCopy(v6, ve_3);
	}
	else
	{
		VectorCopy(v7, ve_1);
		VectorCopy(v1, ve_2);
		VectorCopy(v2, ve_3);
	}

	ve_1[xy] += width;
	ve_2[xy] += width;
	ve_3[xy] += width;

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

  NodeSmartReference newBrush1(GlobalBrushCreator().createBrush());
	NodeSmartReference newBrush2(GlobalBrushCreator().createBrush());

	AddFaceWithTexture(newBrush1, v1, v2, v3, "textures/common/caulk", false);
	AddFaceWithTexture(newBrush1, v5, v7, v6, "textures/common/caulk", false);

	AddFaceWithTexture(newBrush2, v1, v2, v3, "textures/common/caulk", false);
	AddFaceWithTexture(newBrush2, v5, v7, v6, "textures/common/caulk", false);

	if(direction == 0)
	{
		AddFaceWithTexture(newBrush1, v1, v3, v6, "textures/common/caulk", false);
		AddFaceWithTexture(newBrush2, v5, v2, v7, "textures/common/caulk", false);
	}
	else
	{
		AddFaceWithTexture(newBrush1, v1, v7, v2, "textures/common/caulk", false);
		AddFaceWithTexture(newBrush2, v5, v6, v3, "textures/common/caulk", false);
	}

	if(direction == 0)
	{
		AddFaceWithTextureScaled(newBrush1, v1, v7, v2, mainTexture, bSclMainVert, bSclMainHor,
			min[0], min[2], max[0], max[2]);
		AddFaceWithTextureScaled(newBrush1, v5, v6, v3, mainTexture, bSclMainVert, bSclMainHor,
			max[0], min[2], min[0], max[2]);

		
		AddFaceWithTextureScaled(newBrush2, v1, v7, v2, mainTexture, bSclMainVert, bSclMainHor,
			min[0], min[2], max[0], max[2]);
		AddFaceWithTextureScaled(newBrush2, v5, v6, v3, mainTexture, bSclMainVert, bSclMainHor,
			max[0], min[2], min[0], max[2]);	// flip max/min to reverse tex dir


	
		AddFaceWithTextureScaled(newBrush1, ve_3, ve_2, ve_1, trimTexture, bSclTrimVert, bSclTrimHor,
			min[1], min[2], max[1], max[2]);

		AddFaceWithTextureScaled(newBrush2, ve_1, ve_2, ve_3, trimTexture, bSclTrimVert, bSclTrimHor,
			max[1], min[2], min[1], max[2]);
	}
	else
	{
		AddFaceWithTextureScaled(newBrush1, v1, v3, v6, mainTexture, bSclMainVert, bSclMainHor,
			min[1], min[2], max[1], max[2]);
		AddFaceWithTextureScaled(newBrush1, v5, v2, v7, mainTexture, bSclMainVert, bSclMainHor,
			max[1], min[2], min[1], max[2]);

		
		AddFaceWithTextureScaled(newBrush2, v1, v3, v6, mainTexture, bSclMainVert, bSclMainHor,
			min[1], min[2], max[1], max[2]);
		AddFaceWithTextureScaled(newBrush2, v5, v2, v7, mainTexture, bSclMainVert, bSclMainHor,
			max[1], min[2], min[1], max[2]);	// flip max/min to reverse tex dir


		AddFaceWithTextureScaled(newBrush1, ve_1, ve_2, ve_3, trimTexture, bSclTrimVert, bSclTrimHor,
			min[0], min[2], max[0], max[2]);

		AddFaceWithTextureScaled(newBrush2, ve_3, ve_2, ve_1, trimTexture, bSclTrimVert, bSclTrimHor,
			max[0], min[2], min[0], max[2]);
	}

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

  EntityClass* doorClass = GlobalEntityClassManager().findOrInsert("func_door", true);
  NodeSmartReference pEDoor1(GlobalEntityCreator().createEntity(doorClass));
	NodeSmartReference pEDoor2(GlobalEntityCreator().createEntity(doorClass));

	if(direction == 0)
	{
    Node_getEntity(pEDoor1)->setKeyValue("angle", "180");
    Node_getEntity(pEDoor2)->setKeyValue("angle", "360");
	}
	else
	{
    Node_getEntity(pEDoor1)->setKeyValue("angle", "270");
    Node_getEntity(pEDoor2)->setKeyValue("angle", "90");
	}

	srand((unsigned)time(NULL));

	char teamname[256];
	sprintf(teamname, "t%i", rand());
  Node_getEntity(pEDoor1)->setKeyValue("team", teamname);
  Node_getEntity(pEDoor2)->setKeyValue("team", teamname);

	Node_getTraversable(pEDoor1)->insert(newBrush1);
	Node_getTraversable(pEDoor2)->insert(newBrush2);

  Node_getTraversable(GlobalSceneGraph().root())->insert(pEDoor1);
  Node_getTraversable(GlobalSceneGraph().root())->insert(pEDoor2);

//	ResetCurrentTexture();
}