示例#1
0
void Box::updateTexture()
{
    if(body->IsActive())
    {
        setTexture(textures[type + "_ground"]);

        switch(team)
        {
            case TEAM_NEUTRAL:
                overlaySprite.setColor(sf::Color(255, 255, 255, 0));
                break;
            case TEAM_ALLY:
                setOverlayTexture(textures["overlay_allied"]);
                overlaySprite.setColor(sf::Color(255, 255, 255, 255));
                break;
            case TEAM_ENEMY:
                setOverlayTexture(textures["overlay_enemy"]);
                overlaySprite.setColor(sf::Color(255, 255, 255, 255));
                break;
        }
    }
    else
    {
        setTexture(textures["box_ground"]);
    }


    if(isActive)
    {
        setOverlayTexture(textures["overlay_selected"]);
        overlaySprite.setColor(sf::Color(255, 255, 255, 255));
    }
}
示例#2
0
void sgct_core::Viewport::configure(tinyxml2::XMLElement * element)
{
	if (element->Attribute("user") != NULL)
		setUserName(element->Attribute("user"));

	if (element->Attribute("name") != NULL)
		setName(element->Attribute("name"));

	if (element->Attribute("overlay") != NULL)
		setOverlayTexture(element->Attribute("overlay"));

	//for backward compability
	if (element->Attribute("mask") != NULL)
		setBlendMaskTexture(element->Attribute("mask"));

	if (element->Attribute("BlendMask") != NULL)
		setBlendMaskTexture(element->Attribute("BlendMask"));

	if (element->Attribute("BlackLevelMask") != NULL)
		setBlackLevelMaskTexture(element->Attribute("BlackLevelMask"));

	if (element->Attribute("mesh") != NULL)
		setCorrectionMesh(element->Attribute("mesh"));

	if (element->Attribute("hint") != NULL)
		mMeshHint.assign(element->Attribute("hint"));

	if (element->Attribute("tracked") != NULL)
		setTracked(strcmp(element->Attribute("tracked"), "true") == 0 ? true : false);

	//get eye if set
	if (element->Attribute("eye") != NULL)
	{
		if (strcmp("center", element->Attribute("eye")) == 0)
		{
			setEye(Frustum::MonoEye);
		}
		else if (strcmp("left", element->Attribute("eye")) == 0)
		{
			setEye(Frustum::StereoLeftEye);
		}
		else if (strcmp("right", element->Attribute("eye")) == 0)
		{
			setEye(Frustum::StereoRightEye);
		}
	}

	const char * val;
	tinyxml2::XMLElement * subElement = element->FirstChildElement();
	while (subElement != NULL)
	{
		val = subElement->Value();
		float fTmp[2];
		fTmp[0] = 0.0f;
		fTmp[1] = 0.0f;

		if (strcmp("Pos", val) == 0)
		{
			if (subElement->QueryFloatAttribute("x", &fTmp[0]) == tinyxml2::XML_NO_ERROR &&
				subElement->QueryFloatAttribute("y", &fTmp[1]) == tinyxml2::XML_NO_ERROR)
				setPos(fTmp[0], fTmp[1]);
			else
				sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_ERROR, "Viewport: Failed to parse position from XML!\n");
		}
		else if (strcmp("Size", val) == 0)
		{
			if (subElement->QueryFloatAttribute("x", &fTmp[0]) == tinyxml2::XML_NO_ERROR &&
				subElement->QueryFloatAttribute("y", &fTmp[1]) == tinyxml2::XML_NO_ERROR)
				setSize(fTmp[0], fTmp[1]);
			else
				sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_ERROR, "Viewport: Failed to parse size from XML!\n");
		}
		else if (strcmp("PlanarProjection", val) == 0)
		{
			parsePlanarProjection(subElement);
		}//end if planar projection
		else if (strcmp("FisheyeProjection", val) == 0)
		{
			parseFisheyeProjection(subElement);
		}
		else if (strcmp("SphericalMirrorProjection", val) == 0)
		{
			parseSphericalMirrorProjection(subElement);
		}
		else if (strcmp("Viewplane", val) == 0 || strcmp("Projectionplane", val) == 0)
		{
			mProjectionPlane.configure(subElement);
		}

		//iterate
		subElement = subElement->NextSiblingElement();
	}
}