示例#1
0
/* renders the Research IMDs into the surface - used by message display in
Intelligence Map */
void renderResearchToBuffer(RESEARCH *psResearch, UDWORD OriginX, UDWORD OriginY)
{
    UDWORD   angle = 0;

    BASE_STATS      *psResGraphic;
    UDWORD          compID, IMDType;
    Vector3i Rotation,Position;
    UDWORD          basePlateSize, Radius;
    SDWORD          scale = 0;

    // Set identity (present) context
    pie_MatBegin();

    pie_SetGeometricOffset(OriginX+10, OriginY+10);

    // Pitch down a bit
    //pie_MatRotX(-65536/12);

    // Rotate round
    // full rotation once every 2 seconds..
    angle = (realTime % ROTATE_TIME) * 360 / ROTATE_TIME;

    Position.x = 0;
    Position.y = 0;
    Position.z = BUTTON_DEPTH;

    // Rotate round
    Rotation.x = -30;
    Rotation.y = angle;
    Rotation.z = 0;

    //draw the IMD for the research
    if (psResearch->psStat)
    {
        //we have a Stat associated with this research topic
        if  (StatIsStructure(psResearch->psStat))
        {
            //this defines how the button is drawn
            IMDType = IMDTYPE_STRUCTURESTAT;
            psResGraphic = psResearch->psStat;
            //set up the scale
            basePlateSize= getStructureStatSizeMax((STRUCTURE_STATS*)psResearch->psStat);
            if(basePlateSize == 1)
            {
                scale = RESEARCH_COMPONENT_SCALE / 2;
                /*HACK HACK HACK!
                if its a 'tall thin (ie tower)' structure stat with something on
                the top - offset the position to show the object on top*/
                if (((STRUCTURE_STATS*)psResearch->psStat)->pIMD[0]->nconnectors &&
                        getStructureStatHeight((STRUCTURE_STATS*)psResearch->psStat) > TOWER_HEIGHT)
                {
                    Position.y -= 30;
                }
            }
            else if(basePlateSize == 2)
            {
                scale = RESEARCH_COMPONENT_SCALE / 4;
            }
            else
            {
                scale = RESEARCH_COMPONENT_SCALE / 5;
            }
        }
        else
        {
            compID = StatIsComponent(psResearch->psStat);
            if (compID != COMP_UNKNOWN)
            {
                //this defines how the button is drawn
                IMDType = IMDTYPE_COMPONENT;
                psResGraphic = psResearch->psStat;
                // NOTE: Another kludge to deal with the superTransport to make it "fit" the display.
                // Using pName, should be safe to compare, pName doesn't get translated.
                if (!strcmp("SuperTransport", psResearch->pName))
                {
                    scale = RESEARCH_COMPONENT_SCALE / 3;
                }
                else
                {
                    scale = RESEARCH_COMPONENT_SCALE;
                }
            }
            else
            {
                ASSERT( false, "intDisplayMessageButton: invalid stat" );
                IMDType = IMDTYPE_RESEARCH;
                psResGraphic = (BASE_STATS *)psResearch;
            }
        }
    }
    else
    {
        //no Stat for this research topic so use the research topic to define what is drawn
        psResGraphic = (BASE_STATS *)psResearch;
        IMDType = IMDTYPE_RESEARCH;
    }

    //scale the research according to size of IMD
    if (IMDType == IMDTYPE_RESEARCH)
    {
        Radius = getResearchRadius((BASE_STATS*)psResGraphic);
        if(Radius <= 100)
        {
            scale = RESEARCH_COMPONENT_SCALE / 2;
        }
        else if(Radius <= 128)
        {
            scale = RESEARCH_COMPONENT_SCALE / 3;
        }
        else if(Radius <= 256)
        {
            scale = RESEARCH_COMPONENT_SCALE / 4;
        }
        else
        {
            scale = RESEARCH_COMPONENT_SCALE / 5;
        }
    }

    /* display the IMDs */
    if(IMDType == IMDTYPE_COMPONENT)
    {
        displayComponentButton(psResGraphic, &Rotation, &Position, true, scale);
    }
    else if(IMDType == IMDTYPE_RESEARCH)
    {
        displayResearchButton(psResGraphic, &Rotation, &Position, true, scale);
    }
    else if(IMDType == IMDTYPE_STRUCTURESTAT)
    {
        displayStructureStatButton((STRUCTURE_STATS *)psResGraphic, &Rotation, &Position, true, scale);
    }
    else
    {
        ASSERT( false, "Unknown PIEType" );
    }

    // close matrix context
    pie_MatEnd();
}
示例#2
0
static void sharedStructureButton(STRUCTURE_STATS *Stats, iIMDShape *strImd, const Vector3i *Rotation, const Vector3i *Position, int scale)
{
	iIMDShape *baseImd, *mountImd[STRUCT_MAXWEAPS], *weaponImd[STRUCT_MAXWEAPS];
	Vector3i pos = *Position;

	/* HACK HACK HACK!
	if its a 'tall thin (ie tower)' structure stat with something on the top - offset the position to show the object on top */
	if (strImd->nconnectors && scale == SMALL_STRUCT_SCALE && getStructureStatHeight(Stats) > TOWER_HEIGHT)
	{
		pos.y -= 20;
	}

	setMatrix(&pos, Rotation, scale);

	/* Draw the building's base first */
	baseImd = Stats->pBaseIMD;

	if (baseImd != NULL)
	{
		pie_Draw3DShape(baseImd, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, pie_BUTTON, 0);
	}
	pie_Draw3DShape(strImd, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, pie_BUTTON, 0);

	//and draw the turret
	if (strImd->nconnectors)
	{
		weaponImd[0] = NULL;
		mountImd[0] = NULL;
		for (int i = 0; i < Stats->numWeaps; i++)
		{
			weaponImd[i] = NULL;//weapon is gun ecm or sensor
			mountImd[i] = NULL;
		}
		//get an imd to draw on the connector priority is weapon, ECM, sensor
		//check for weapon
		//can only have the STRUCT_MAXWEAPS
		for (int i = 0; i < MAX(1, Stats->numWeaps); i++)
		{
			//can only have the one
			if (Stats->psWeapStat[i] != NULL)
			{
				weaponImd[i] = Stats->psWeapStat[i]->pIMD;
				mountImd[i] = Stats->psWeapStat[i]->pMountGraphic;
			}

			if (weaponImd[i] == NULL)
			{
				//check for ECM
				if (Stats->pECM != NULL)
				{
					weaponImd[i] =  Stats->pECM->pIMD;
					mountImd[i] =  Stats->pECM->pMountGraphic;
				}
			}

			if (weaponImd[i] == NULL)
			{
				//check for sensor
				if (Stats->pSensor != NULL)
				{
					weaponImd[i] =  Stats->pSensor->pIMD;
					mountImd[i]  =  Stats->pSensor->pMountGraphic;
				}
			}
		}

		//draw Weapon/ECM/Sensor for structure
		if (weaponImd[0] != NULL)
		{
			for (int i = 0; i < MAX(1, Stats->numWeaps); i++)
			{
				pie_MatBegin();
				pie_TRANSLATE(strImd->connectors[i].x, strImd->connectors[i].z, strImd->connectors[i].y);
				if (mountImd[i] != NULL)
				{
					pie_Draw3DShape(mountImd[i], 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, pie_BUTTON, 0);
					if (mountImd[i]->nconnectors)
					{
						pie_TRANSLATE(mountImd[i]->connectors->x, mountImd[i]->connectors->z, mountImd[i]->connectors->y);
					}
				}
				pie_Draw3DShape(weaponImd[i], 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, pie_BUTTON, 0);
				//we have a droid weapon so do we draw a muzzle flash
				pie_MatEnd();
			}
		}
	}

	unsetMatrix();
}
示例#3
0
static void sharedStructureButton(STRUCTURE_STATS *Stats, iIMDShape *strImd, const Vector3i *Rotation, const Vector3i *Position, int scale)
{
	iIMDShape *baseImd, *mountImd[MAX_WEAPONS], *weaponImd[MAX_WEAPONS];
	Vector3i pos = *Position;

	/* HACK HACK HACK!
	if its a 'tall thin (ie tower)' structure stat with something on the top - offset the position to show the object on top */
	if (strImd->nconnectors && scale == SMALL_STRUCT_SCALE && getStructureStatHeight(Stats) > TOWER_HEIGHT)
	{
		pos.y -= 20;
	}

	const glm::mat4 matrix = setMatrix(&pos, Rotation, scale);

	/* Draw the building's base first */
	baseImd = Stats->pBaseIMD;

	if (baseImd != nullptr)
	{
		pie_Draw3DShape(baseImd, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, pie_BUTTON, 0, matrix);
	}
	pie_Draw3DShape(strImd, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, pie_BUTTON, 0, matrix);

	//and draw the turret
	if (strImd->nconnectors)
	{
		weaponImd[0] = nullptr;
		mountImd[0] = nullptr;
		for (int i = 0; i < Stats->numWeaps; i++)
		{
			weaponImd[i] = nullptr;//weapon is gun ecm or sensor
			mountImd[i] = nullptr;
		}
		//get an imd to draw on the connector priority is weapon, ECM, sensor
		//check for weapon
		//can only have the MAX_WEAPONS
		for (int i = 0; i < MAX(1, Stats->numWeaps); i++)
		{
			//can only have the one
			if (Stats->psWeapStat[i] != nullptr)
			{
				weaponImd[i] = Stats->psWeapStat[i]->pIMD;
				mountImd[i] = Stats->psWeapStat[i]->pMountGraphic;
			}

			if (weaponImd[i] == nullptr)
			{
				//check for ECM
				if (Stats->pECM != nullptr)
				{
					weaponImd[i] =  Stats->pECM->pIMD;
					mountImd[i] =  Stats->pECM->pMountGraphic;
				}
			}

			if (weaponImd[i] == nullptr)
			{
				//check for sensor
				if (Stats->pSensor != nullptr)
				{
					weaponImd[i] =  Stats->pSensor->pIMD;
					mountImd[i]  =  Stats->pSensor->pMountGraphic;
				}
			}
		}

		//draw Weapon/ECM/Sensor for structure
		if (weaponImd[0] != nullptr)
		{
			for (int i = 0; i < MAX(1, Stats->numWeaps); i++)
			{
				glm::mat4 localMatrix = glm::translate(glm::vec3(strImd->connectors[i].xzy()));
				if (mountImd[i] != nullptr)
				{
					pie_Draw3DShape(mountImd[i], 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, pie_BUTTON, 0, matrix * localMatrix);
					if (mountImd[i]->nconnectors)
					{
						localMatrix *= glm::translate(glm::vec3(mountImd[i]->connectors->xzy()));
					}
				}
				pie_Draw3DShape(weaponImd[i], 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, pie_BUTTON, 0, matrix * localMatrix);
				//we have a droid weapon so do we draw a muzzle flash
			}
		}
	}
}
示例#4
0
static UDWORD getStructureHeight(STRUCTURE *psStructure)
{
	return (getStructureStatHeight(psStructure->pStructureType));
}