Example #1
0
    Emitter* PugiXMLLoader::LoadEmitter( pugi::xml_node& node, const std::list<AnimImage*>& sprites, Effect *parent )
    {
        Emitter* e = new Emitter;

        e->SetHandleX           (node.attribute("HANDLE_X").as_int());
        e->SetHandleY           (node.attribute("HANDLE_Y").as_int());
        e->SetBlendMode         (node.attribute("BLENDMODE").as_int());
        e->SetParticlesRelative (node.attribute("RELATIVE").as_bool());
        e->SetRandomColor       (node.attribute("RANDOM_COLOR").as_bool());
        e->SetZLayer            (node.attribute("LAYER").as_int());
        e->SetSingleParticle    (node.attribute("SINGLE_PARTICLE").as_bool());
        e->SetName              (node.attribute("NAME").as_string());
        e->SetAnimate           (node.attribute("ANIMATE").as_bool());
        e->SetOnce              (node.attribute("ANIMATE_ONCE").as_bool());
        e->SetCurrentFrame      (node.attribute("FRAME").as_float());
        e->SetRandomStartFrame  (node.attribute("RANDOM_START_FRAME").as_bool());
        e->SetAnimationDirection(node.attribute("ANIMATION_DIRECTION").as_int());
        e->SetUniform           (node.attribute("UNIFORM").as_bool());
        e->SetAngleType         (node.attribute("ANGLE_TYPE").as_int());
        e->SetAngleOffset       (node.attribute("ANGLE_OFFSET").as_int());
        e->SetLockAngle         (node.attribute("LOCK_ANGLE").as_bool());
        e->SetAngleRelative     (node.attribute("ANGLE_RELATIVE").as_bool());
        e->SetUseEffectEmission (node.attribute("USE_EFFECT_EMISSION").as_bool());
        e->SetColorRepeat       (node.attribute("COLOR_REPEAT").as_int());
        e->SetAlphaRepeat       (node.attribute("ALPHA_REPEAT").as_int());
        e->SetOneShot           (node.attribute("ONE_SHOT").as_bool());
        e->SetHandleCenter      (node.attribute("HANDLE_CENTERED").as_bool());
        e->SetGroupParticles    (node.attribute("GROUP_PARTICLES").as_bool());

        if (e->GetAnimationDirection() == 0)
            e->SetAnimationDirection(1);

        e->SetParentEffect(parent);
        std::string path = parent->GetPath();
        path = path + "/" + e->GetName();
        e->SetPath(path.c_str());

        pugi::xml_node sub;

        sub = node.child("SHAPE_INDEX");
        if (sub)
            e->SetImage(GetSpriteInList(sprites, atoi(sub.child_value())));

        sub = node.child("ANGLE_TYPE");
        if (sub)
            e->SetAngleType(sub.attribute("VALUE").as_int());

        sub = node.child("ANGLE_OFFSET");
        if (sub)
            e->SetAngleOffset(sub.attribute("VALUE").as_int());

        sub = node.child("LOCKED_ANGLE");
        if (sub)
            e->SetLockAngle(sub.attribute("VALUE").as_bool());

        sub = node.child("ANGLE_RELATIVE");
        if (sub)
            e->SetAngleRelative(sub.attribute("VALUE").as_bool());

        sub = node.child("USE_EFFECT_EMISSION");
        if (sub)
            e->SetUseEffectEmission(sub.attribute("VALUE").as_bool());

        sub = node.child("COLOR_REPEAT");
        if (sub)
            e->SetColorRepeat(sub.attribute("VALUE").as_int());

        sub = node.child("ALPHA_REPEAT");
        if (sub)
            e->SetAlphaRepeat(sub.attribute("VALUE").as_int());

        sub = node.child("ONE_SHOT");
        if (sub)
            e->SetOneShot(sub.attribute("VALUE").as_bool());

        sub = node.child("HANDLE_CENTERED");
        if (sub)
            e->SetHandleCenter(sub.attribute("VALUE").as_bool());

        AttributeNode* attr = NULL;
        pugi::xml_node attrnode;

        for (attrnode = node.child("LIFE"); attrnode; attrnode = attrnode.next_sibling("LIFE"))
        {
            attr = e->AddLife(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("AMOUNT"); attrnode; attrnode = attrnode.next_sibling("AMOUNT"))
        {
            attr = e->AddAmount(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("BASE_SPEED"); attrnode; attrnode = attrnode.next_sibling("BASE_SPEED"))
        {
            attr = e->AddBaseSpeed(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("BASE_WEIGHT"); attrnode; attrnode = attrnode.next_sibling("BASE_WEIGHT"))
        {
            attr = e->AddBaseWeight(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("BASE_SIZE_X"); attrnode; attrnode = attrnode.next_sibling("BASE_SIZE_X"))
        {
            attr = e->AddSizeX(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("BASE_SIZE_Y"); attrnode; attrnode = attrnode.next_sibling("BASE_SIZE_Y"))
        {
            attr = e->AddSizeY(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("BASE_SPIN"); attrnode; attrnode = attrnode.next_sibling("BASE_SPIN"))
        {
            attr = e->AddBaseSpin(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("SPLATTER"); attrnode; attrnode = attrnode.next_sibling("SPLATTER"))
        {
            attr = e->AddSplatter(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("LIFE_VARIATION"); attrnode; attrnode = attrnode.next_sibling("LIFE_VARIATION"))
        {
            attr = e->AddLifeVariation(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("AMOUNT_VARIATION"); attrnode; attrnode = attrnode.next_sibling("AMOUNT_VARIATION"))
        {
            attr = e->AddAmountVariation(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("VELOCITY_VARIATION"); attrnode; attrnode = attrnode.next_sibling("VELOCITY_VARIATION"))
        {
            attr = e->AddVelVariation(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("WEIGHT_VARIATION"); attrnode; attrnode = attrnode.next_sibling("WEIGHT_VARIATION"))
        {
            attr = e->AddWeightVariation(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("SIZE_X_VARIATION"); attrnode; attrnode = attrnode.next_sibling("SIZE_X_VARIATION"))
        {
            attr = e->AddSizeXVariation(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("SIZE_Y_VARIATION"); attrnode; attrnode = attrnode.next_sibling("SIZE_Y_VARIATION"))
        {
            attr = e->AddSizeYVariation(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("SPIN_VARIATION"); attrnode; attrnode = attrnode.next_sibling("SPIN_VARIATION"))
        {
            attr = e->AddSpinVariation(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("DIRECTION_VARIATION"); attrnode; attrnode = attrnode.next_sibling("DIRECTION_VARIATION"))
        {
            attr = e->AddDirectionVariation(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("ALPHA_OVERTIME"); attrnode; attrnode = attrnode.next_sibling("ALPHA_OVERTIME"))
        {
            attr = e->AddAlpha(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("VELOCITY_OVERTIME"); attrnode; attrnode = attrnode.next_sibling("VELOCITY_OVERTIME"))
        {
            attr = e->AddVelocity(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("WEIGHT_OVERTIME"); attrnode; attrnode = attrnode.next_sibling("WEIGHT_OVERTIME"))
        {
            attr = e->AddWeight(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("SCALE_X_OVERTIME"); attrnode; attrnode = attrnode.next_sibling("SCALE_X_OVERTIME"))
        {
            attr = e->AddScaleX(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("SCALE_Y_OVERTIME"); attrnode; attrnode = attrnode.next_sibling("SCALE_Y_OVERTIME"))
        {
            attr = e->AddScaleY(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("SPIN_OVERTIME"); attrnode; attrnode = attrnode.next_sibling("SPIN_OVERTIME"))
        {
            attr = e->AddSpin(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("DIRECTION"); attrnode; attrnode = attrnode.next_sibling("DIRECTION"))
        {
            attr = e->AddDirection(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("DIRECTION_VARIATIONOT"); attrnode; attrnode = attrnode.next_sibling("DIRECTION_VARIATIONOT"))
        {
            attr = e->AddDirectionVariationOT(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("FRAMERATE_OVERTIME"); attrnode; attrnode = attrnode.next_sibling("FRAMERATE_OVERTIME"))
        {
            attr = e->AddFramerate(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("STRETCH_OVERTIME"); attrnode; attrnode = attrnode.next_sibling("STRETCH_OVERTIME"))
        {
            attr = e->AddStretch(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("RED_OVERTIME"); attrnode; attrnode = attrnode.next_sibling("RED_OVERTIME"))
        {
            attr = e->AddR(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            //LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("GREEN_OVERTIME"); attrnode; attrnode = attrnode.next_sibling("GREEN_OVERTIME"))
        {
            attr = e->AddG(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            //LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("BLUE_OVERTIME"); attrnode; attrnode = attrnode.next_sibling("BLUE_OVERTIME"))
        {
            attr = e->AddB(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            //LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("GLOBAL_VELOCITY"); attrnode; attrnode = attrnode.next_sibling("GLOBAL_VELOCITY"))
        {
            attr = e->AddGlobalVelocity(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("EMISSION_ANGLE"); attrnode; attrnode = attrnode.next_sibling("EMISSION_ANGLE"))
        {
            attr = e->AddEmissionAngle(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        for (attrnode = node.child("EMISSION_RANGE"); attrnode; attrnode = attrnode.next_sibling("EMISSION_RANGE"))
        {
            attr = e->AddEmissionRange(attrnode.attribute("FRAME").as_float(), attrnode.attribute("VALUE").as_float());
            LoadAttributeNode(attrnode, attr);
        }

        sub = node.child("EFFECT");
        if (sub)
            e->AddEffect(LoadEffect(sub, sprites, e));

        return e;
    }
Example #2
0
bool CEffect::Reload(LPD3DXEFFECTPOOL _pEffectPool)
{
  Release();
  return LoadEffect(_pEffectPool);
}
Example #3
0
void E_HandleCommand(HWND dialog, WORD id, WORD code, HWND control)
{
	/* Most of them use this */
	class EditEffect *data = (EditEffect*)GetWindowLongPtr(dialog, DWLP_USER);

	switch (code)
	{
	case BN_CLICKED:
		switch (id)
		{
		case IDC_E_AREA_ALL:
			{
				SetDlgItemInt(dialog, IDC_E_AREAX1, -1, TRUE);
				SetDlgItemInt(dialog, IDC_E_AREAY1, -1, TRUE);
				SetDlgItemInt(dialog, IDC_E_AREAX2, -1, TRUE);
				SetDlgItemInt(dialog, IDC_E_AREAY2, -1, TRUE);
			}
			break;

		case IDC_E_CLEAR:
			{
			    data->e = Effect();
			    LoadEffect(dialog, data);
			}
			break;

		case IDOK:
			{
				bool valid;
				int ret = IDOK;

				SaveEffect(dialog, data);
				valid = data->e.check();

				if (!valid)
					ret = MessageBox(dialog, warnInvalidE, "Effect Editor", MB_OKCANCEL);

				if (ret == IDOK)
				{
					SendMessage(data->parent, EC_Closing,
						MAKELONG(1, valid), reinterpret_cast<LPARAM>(data));
					DestroyWindow(dialog);
				}
			}
			break;

		case IDCANCEL:
			SendMessage(data->parent, EC_Closing,
				0, reinterpret_cast<LPARAM>(data));
			DestroyWindow(dialog);
			break;

		case IDC_E_OPENSEL:
			OnOpenSel(dialog, data);
			break;

		case IDC_E_OPENSEL2:
			if (SingleUnitSelDialogBox(dialog, data->players,
				data->e.uid_loc, (data->e.uid_loc != -1)))
			{
				SetDlgItemInt(dialog, IDC_E_LOCUID, data->e.uid_loc, FALSE);
			}
			break;

		}
		break;

	case CBN_SELCHANGE:
		switch (id)
		{
			case IDC_E_TYPE:
				E_HandleChangeType(dialog, data);
				break;

			case IDC_E_VTYPE:
				E_HandleChangeVType(dialog, data);
				break;

			case IDC_E_RESTYPE:
				if (SendMessage(control, CB_GETCURSEL, 0, 0) >= NUM_STYPES &&
					setts.warnbits & WARN_WEIRDRESOURCE)
					MessageBox(dialog, warnWeirdResource, "Warning", MB_ICONWARNING);
				break;

			case IDC_E_TRIG:
				SetDlgItemInt(dialog, IDC_E_TRIGID, data->e.trig_index, TRUE);
				break;
		}
		break;

	case EN_SETFOCUS:
		E_HandleSetFocus(dialog, id);
		break;

	case EN_KILLFOCUS:
		E_HandleKillFocus(dialog, id);
		break;
	}
}
/*!****************************************************************************
 @Function		InitView
 @Return		bool		true if no error occurred
 @Description	Code in InitView() will be called by PVRShell upon
				initialization or after a change in the rendering context.
				Used to initialize variables that are dependent on the rendering
				context (e.g. textures, vertex buffers, etc.)
******************************************************************************/
bool OGLES2Skybox2::InitView()
{
	// Sets the clear colour
	glClearColor(0.6f, 0.8f, 1.0f, 1.0f);

	// Enables depth test using the z-buffer
	glEnable(GL_DEPTH_TEST);

	CPVRTString ErrorStr;

	/*
		Load textures
	*/
	if(!LoadTextures(&ErrorStr))
	{
		PVRShellSet(prefExitMessage, ErrorStr.c_str());
		return false;
	}

	/*********************/
	/* Create the Skybox */
	/*********************/
	float* skyboxVertices;
	float* skyboxUVs;

	PVRTCreateSkybox( 500.0f, true, 512, &skyboxVertices, &skyboxUVs );

	glGenBuffers(1, &m_iSkyVboID);
	glBindBuffer(GL_ARRAY_BUFFER, m_iSkyVboID);
	glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * 24, &skyboxVertices[0], GL_STATIC_DRAW);
	glBindBuffer(GL_ARRAY_BUFFER, 0);

	PVRTDestroySkybox(skyboxVertices, skyboxUVs);

	/**********************/
	/* Create the Effects */
	/**********************/

	{
		// Parse the file
		m_pEffectParser = new CPVRTPFXParser();

		if(m_pEffectParser->ParseFromFile(g_pszEffectFileName, &ErrorStr) != PVR_SUCCESS)
		{
			delete m_pEffectParser;
			PVRShellSet(prefExitMessage, ErrorStr.c_str());
			return false;
		}

		m_ppEffects = new CPVRTPFXEffect*[g_ui32NoOfEffects];
		memset(m_ppEffects, 0, sizeof(CPVRTPFXEffect*) * g_ui32NoOfEffects);

		// Skybox shader
		if(!LoadEffect(&m_ppEffects[0], "skybox_effect", g_pszEffectFileName))
		{
			delete m_pEffectParser;
			delete[] m_ppEffects;
			return false;
		}

		// The Balloon Shaders
		if(!LoadEffect(&m_ppEffects[1], "balloon_effect1", g_pszEffectFileName) ||
			!LoadEffect(&m_ppEffects[2], "balloon_effect2", g_pszEffectFileName) ||
			!LoadEffect(&m_ppEffects[3], "balloon_effect3", g_pszEffectFileName) ||
			!LoadEffect(&m_ppEffects[4], "balloon_effect4", g_pszEffectFileName) ||
			!LoadEffect(&m_ppEffects[5], "balloon_effect5", g_pszEffectFileName) ||
			!LoadEffect(&m_ppEffects[6], "balloon_effect6", g_pszEffectFileName) ||
			!LoadEffect(&m_ppEffects[7], "balloon_effect7", g_pszEffectFileName))
		{
			delete m_pEffectParser;
			delete[] m_ppEffects;
			return false;
		}
	}

	// Create Geometry Buffer Objects.
	m_aiVboID = new GLuint[m_Scene.nNumMeshNode];
	glGenBuffers(m_Scene.nNumMeshNode, m_aiVboID);

	for(unsigned int i = 0; i < m_Scene.nNumMeshNode ; ++i)
	{
		SPODNode* pNode = &m_Scene.pNode[i];

		// Gets pMesh referenced by the pNode
		SPODMesh* pMesh = &m_Scene.pMesh[pNode->nIdx];

		// Genereta a vertex buffer and set the interleaved vertex datas.
		glBindBuffer(GL_ARRAY_BUFFER, m_aiVboID[i]);
		glBufferData(GL_ARRAY_BUFFER, pMesh->sVertex.nStride*pMesh->nNumVertex, pMesh->pInterleaved, GL_STATIC_DRAW);
		glBindBuffer(GL_ARRAY_BUFFER, 0);

	}

	/**********************
	** Projection Matrix **
	**********************/
	/* Projection */
	bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
	m_mProjection = PVRTMat4::PerspectiveFovRH(PVRT_PI / 6, (float) PVRShellGet(prefWidth) / (float) PVRShellGet(prefHeight), 4.0f, 1000.0f, PVRTMat4::OGL, bRotate);

	// Calculate the model view matrix turning around the balloon
	ComputeViewMatrix();

	/* Init Values */
	bPause = false;
	fDemoFrame = 0.0;
	fBurnAnim = 0.0f;

	m_i32Effect = 1;

	// Initialise Print3D
	if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), bRotate) != PVR_SUCCESS)
	{
		PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n");
		return false;
	}

	// Initialise variables used for the animation
	m_iTimePrev = PVRShellGetTime();

	return true;
}
Example #5
0
void CPaletteManager::SaveEffectAndReset (void)
{
SaveEffect ();
ResetEffect ();
LoadEffect ();
}