Ejemplo n.º 1
0
///////////////////////////////////////////////////////////////////////////////
// Descripcion:
// - Activa el cuadro de dialogo.
// Parametros:
// - szText. Texto a establecer en el cuadro de dialogo.
// - pClient. Cliente asociado al cuadro de dialogo que deseamos reciba la
//   notificacion cuando se pulse la opcion que proceda. Ver clases derivadas
//   de esta.
// Devuelve:
// - Si todo ha ido bien true. En caso contrario false.
// Notas:
//////////////////////////////////////////////////////////////////////////////
void 
CGUIWDialog::Active(const std::string& szText,
					iCGUIWindowClient* const pClient)
{
  // SOLO si parametros correctos
  ASSERT(szText.size());

  // Activa si procede
  if (!Inherited::IsActive()) {
	// Se activan componentes.
	m_BackImg.BackImg.SetActive(true);
	m_TextInfo.Text.SetActive(true);
  
	// Se asocia el texto recibido y se justifica al centro siempre
	m_TextInfo.Text.ChangeText(szText);
	m_TextInfo.Text.DrawJustifyTo(CGUICSingleText::JUSTIFY_CENTER);
  
	// Se inicializa el FXBack
	const sPosition FXBackDrawPos(m_TextInfo.Text.GetXPos() - 4,
								  m_TextInfo.Text.GetYPos() - 2);
	const word uwFXBackHeight = FontDefs::CHAR_PIXEL_HEIGHT * m_TextInfo.Text.GetVisibleTextLines();
	m_TextInfo.FXBack.Init(FXBackDrawPos, 
						   2, 
						   m_TextInfo.Text.GetWidthJustify() + 4,
						   uwFXBackHeight,
						   m_TextInfo.FXBackColor,
						   m_TextInfo.FXBackAlpha);
	ASSERT(m_TextInfo.FXBack.IsInitOk());

	// Se establece la posicion del FXBack
	m_TextInfo.FXBack.SetPosition(sPosition(m_TextInfo.Text.GetXPos() - 4,
											m_TextInfo.Text.GetYPos() - 2));

	// En teoria el cursor deberia de interfaz deberia de estar activo, pero
	// se volvera activar para que no existan efectos laterales
	SYSEngine::GetGUIManager()->SetGUICursor(GUIManagerDefs::WINDOWINTERFAZ_CURSOR);

	// Se propaga inicializacion
	Inherited::Active(pClient);
  }  
}
Ejemplo n.º 2
0
void CScreensaverCyclone::Sphere(GLfloat radius, GLint slices, GLint stacks)
{
/* Make it not a power of two to avoid cache thrashing on the chip */
#define CACHE_SIZE 240

  sLight light;
  GLint i,j;
  GLfloat sinCache1a[CACHE_SIZE];
  GLfloat cosCache1a[CACHE_SIZE];
  GLfloat sinCache2a[CACHE_SIZE];
  GLfloat cosCache2a[CACHE_SIZE];
  GLfloat sinCache1b[CACHE_SIZE];
  GLfloat cosCache1b[CACHE_SIZE];
  GLfloat sinCache2b[CACHE_SIZE];
  GLfloat cosCache2b[CACHE_SIZE];
  GLfloat angle;
  GLfloat zHigh;
  GLfloat sintemp1 = 0.0, sintemp2 = 0.0;
  GLfloat costemp3 = 0.0;

  for (i = 0; i < slices; i++)
  {
    angle = 2 * M_PI * i / slices;
    sinCache1a[i] = sinf(angle);
    cosCache1a[i] = cosf(angle);
    sinCache2a[i] = sinCache1a[i];
    cosCache2a[i] = cosCache1a[i];
  }

  for (j = 0; j <= stacks; j++)
  {
    angle = M_PI * j / stacks;
    sinCache2b[j] = sinf(angle);
    cosCache2b[j] = cosf(angle);
    sinCache1b[j] = radius * sinf(angle);
    cosCache1b[j] = radius * cosf(angle);
  }
  /* Make sure it comes to a point */
  sinCache1b[0] = 0;
  sinCache1b[stacks] = 0;

  sinCache1a[slices] = sinCache1a[0];
  cosCache1a[slices] = cosCache1a[0];
  sinCache2a[slices] = sinCache2a[0];
  cosCache2a[slices] = cosCache2a[0];

  /* Low end first (j == 0 iteration) */
  sintemp1 = sinCache1b[1];
  zHigh = cosCache1b[1];
  sintemp2 = sinCache2b[1];
  costemp3 = cosCache2b[1];

  light.normal = sPosition(sinCache2a[0] * sinCache2b[0], cosCache2a[0] * sinCache2b[0], cosCache2b[0]);
  light.vertex = sPosition(0.0, 0.0, radius);
  m_sphereTriangleFan1.push_back(light);
  for (i = slices; i >= 0; i--)
  {
    light.normal = sPosition(sinCache2a[i] * sintemp2, cosCache2a[i] * sintemp2, costemp3);
    light.vertex = sPosition(sintemp1 * sinCache1a[i], sintemp1 * cosCache1a[i], zHigh);
    m_sphereTriangleFan1.push_back(light);
  }

  /* High end next (j == stacks-1 iteration) */
  sintemp1 = sinCache1b[stacks-1];
  zHigh = cosCache1b[stacks-1];
  sintemp2 = sinCache2b[stacks-1];
  costemp3 = cosCache2b[stacks-1];

  light.normal = sPosition(sinCache2a[stacks] * sinCache2b[stacks], cosCache2a[stacks] * sinCache2b[stacks], cosCache2b[stacks]);
  light.vertex = sPosition(0.0, 0.0, -radius);
  m_sphereTriangleFan2.push_back(light);
  for (i = 0; i <= slices; i++)
  {
    light.normal = sPosition(sinCache2a[i] * sintemp2, cosCache2a[i] * sintemp2, costemp3);
    light.vertex = sPosition(sintemp1 * sinCache1a[i], sintemp1 * cosCache1a[i], zHigh);
    m_sphereTriangleFan2.push_back(light);
  }
}
Ejemplo n.º 3
0
void CCyclone::Update(CScreensaverCyclone* base)
{
  int i;
  int temp;
  float between;
  float diff;
  int direction;
  float point[3];
  float step;
  float blend;

  // update cyclone's path
  temp = gCycloneSettings.dComplexity + 2;
  if (m_xyzChange[temp][0] >= m_xyzChange[temp][1])
  {
    m_oldxyz[temp][0] = m_xyz[temp][0];
    m_oldxyz[temp][1] = m_xyz[temp][1];
    m_oldxyz[temp][2] = m_xyz[temp][2];
    m_targetxyz[temp][0] = rsRandf(float(WIDTH*2)) - float(WIDTH);
    m_targetxyz[temp][1] = float(HIGHT);
    m_targetxyz[temp][2] = rsRandf(float(WIDTH*2)) - float(WIDTH);
    m_xyzChange[temp][0] = 0.0f;
    m_xyzChange[temp][1] = rsRandf(150.0f / float(gCycloneSettings.dSpeed)) + 75.0f / float(gCycloneSettings.dSpeed);
  }
  temp = gCycloneSettings.dComplexity + 1;
  if (m_xyzChange[temp][0] >= m_xyzChange[temp][1])
  {
    m_oldxyz[temp][0] = m_xyz[temp][0];
    m_oldxyz[temp][1] = m_xyz[temp][1];
    m_oldxyz[temp][2] = m_xyz[temp][2];
    m_targetxyz[temp][0] = m_xyz[temp+1][0];
    m_targetxyz[temp][1] = rsRandf(float(HIGHT / 3)) + float(HIGHT / 4);
    m_targetxyz[temp][2] = m_xyz[temp+1][2];
    m_xyzChange[temp][0] = 0.0f;
    m_xyzChange[temp][1] = rsRandf(100.0f / float(gCycloneSettings.dSpeed)) + 75.0f / float(gCycloneSettings.dSpeed);
  }
  for (i = gCycloneSettings.dComplexity; i > 1; i--)
  {
    if (m_xyzChange[i][0] >= m_xyzChange[i][1])
    {
      m_oldxyz[i][0] = m_xyz[i][0];
      m_oldxyz[i][1] = m_xyz[i][1];
      m_oldxyz[i][2] = m_xyz[i][2];
      m_targetxyz[i][0] = m_targetxyz[i+1][0] + (m_targetxyz[i+1][0] - m_targetxyz[i+2][0]) / 2.0f + rsRandf(float(WIDTH / 2)) - float(WIDTH / 4);
      m_targetxyz[i][1] = (m_targetxyz[i+1][1] + m_targetxyz[i-1][1]) / 2.0f + rsRandf(float(HIGHT / 8)) - float(HIGHT / 16);
      m_targetxyz[i][2] = m_targetxyz[i+1][2] + (m_targetxyz[i+1][2] - m_targetxyz[i+2][2]) / 2.0f + rsRandf(float(WIDTH / 2)) - float(WIDTH / 4);
      if (m_targetxyz[i][1] > HIGHT)
        m_targetxyz[i][1] = HIGHT;
      if (m_targetxyz[i][1] < -HIGHT)
        m_targetxyz[i][1] = -HIGHT;
      m_xyzChange[i][0] = 0.0f;
      m_xyzChange[i][1] = rsRandf(75.0f / float(gCycloneSettings.dSpeed)) + 50.0f / float(gCycloneSettings.dSpeed);
    }
  }
  if (m_xyzChange[1][0] >= m_xyzChange[1][1])
  {
    m_oldxyz[1][0] = m_xyz[1][0];
    m_oldxyz[1][1] = m_xyz[1][1];
    m_oldxyz[1][2] = m_xyz[1][2];
    m_targetxyz[1][0] = m_targetxyz[2][0] + rsRandf(float(WIDTH / 2)) - float(WIDTH / 4);
    m_targetxyz[1][1] = -rsRandf(float(HIGHT / 2)) - float(HIGHT / 4);
    m_targetxyz[1][2] = m_targetxyz[2][2] + rsRandf(float(WIDTH / 2)) - float(WIDTH / 4);
    m_xyzChange[1][0] = 0.0f;
    m_xyzChange[1][1] = rsRandf(50.0f / float(gCycloneSettings.dSpeed)) + 30.0f / float(gCycloneSettings.dSpeed);
  }
  if (m_xyzChange[0][0] >= m_xyzChange[0][1])
  {
    m_oldxyz[0][0] = m_xyz[0][0];
    m_oldxyz[0][1] = m_xyz[0][1];
    m_oldxyz[0][2] = m_xyz[0][2];
    m_targetxyz[0][0] = m_xyz[1][0] + rsRandf(float(WIDTH / 8)) - float(WIDTH / 16);
    m_targetxyz[0][1] = float(-HIGHT);
    m_targetxyz[0][2] = m_xyz[1][2] + rsRandf(float(WIDTH / 8)) - float(WIDTH / 16);
    m_xyzChange[0][0] = 0.0f;
    m_xyzChange[0][1] = rsRandf(100.0f / float(gCycloneSettings.dSpeed)) + 75.0f / float(gCycloneSettings.dSpeed);
  }
  for (i = 0; i < (gCycloneSettings.dComplexity+3); i++)
  {
    between = m_xyzChange[i][0] / m_xyzChange[i][1] * (2 * M_PI);
    between = (1.0f - float(cos(between))) / 2.0f;
    m_xyz[i][0] = ((m_targetxyz[i][0] - m_oldxyz[i][0]) * between) + m_oldxyz[i][0];
    m_xyz[i][1] = ((m_targetxyz[i][1] - m_oldxyz[i][1]) * between) + m_oldxyz[i][1];
    m_xyz[i][2] = ((m_targetxyz[i][2] - m_oldxyz[i][2]) * between) + m_oldxyz[i][2];
    m_xyzChange[i][0] += base->FrameTime();
  }

  // Update cyclone's widths
  temp = gCycloneSettings.dComplexity + 2;
  if (m_widthChange[temp][0] >= m_widthChange[temp][1])
  {
    m_oldWidth[temp] = m_width[temp];
    m_targetWidth[temp] = rsRandf(225.0f) + 75.0f;
    m_widthChange[temp][0] = 0.0f;
    m_widthChange[temp][1] = rsRandf(50.0f / float(gCycloneSettings.dSpeed)) + 50.0f / float(gCycloneSettings.dSpeed);
  }
  temp = gCycloneSettings.dComplexity + 1;
  if (m_widthChange[temp][0] >= m_widthChange[temp][1])
  {
    m_oldWidth[temp] = m_width[temp];
    m_targetWidth[temp] = rsRandf(100.0f) + 15.0f;
    m_widthChange[temp][0] = 0.0f;
    m_widthChange[temp][1] = rsRandf(50.0f / float(gCycloneSettings.dSpeed)) + 50.0f / float(gCycloneSettings.dSpeed);
  }
  for (i = gCycloneSettings.dComplexity; i > 1; i--)
  {
    if (m_widthChange[i][0] >= m_widthChange[i][1])
    {
      m_oldWidth[i] = m_width[i];
      m_targetWidth[i] = rsRandf(50.0f) + 15.0f;
      m_widthChange[i][0] = 0.0f;
      m_widthChange[i][1] = rsRandf(50.0f / float(gCycloneSettings.dSpeed)) + 40.0f / float(gCycloneSettings.dSpeed);
    }
  }
  if (m_widthChange[1][0] >= m_widthChange[1][1])
  {
    m_oldWidth[1] = m_width[1];
    m_targetWidth[1] = rsRandf(40.0f) + 5.0f;
    m_widthChange[1][0] = 0.0f;
    m_widthChange[1][1] = rsRandf(50.0f / float(gCycloneSettings.dSpeed)) + 30.0f / float(gCycloneSettings.dSpeed);
  }
  if (m_widthChange[0][0] >= m_widthChange[0][1])
  {
    m_oldWidth[0] = m_width[0];
    m_targetWidth[0] = rsRandf(30.0f) + 5.0f;
    m_widthChange[0][0] = 0.0f;
    m_widthChange[0][1] = rsRandf(50.0f / float(gCycloneSettings.dSpeed)) + 20.0f / float(gCycloneSettings.dSpeed);
  }
  for (i = 0; i < (gCycloneSettings.dComplexity+3); i++)
  {
    between = m_widthChange[i][0] / m_widthChange[i][1];
    m_width[i] = ((m_targetWidth[i] - m_oldWidth[i]) * between) + m_oldWidth[i];
    m_widthChange[i][0] += base->FrameTime();
  }

  // Update cyclones color
  if (m_hslChange[0] >= m_hslChange[1])
  {
    m_oldhsl[0] = m_hsl[0];
    m_oldhsl[1] = m_hsl[1];
    m_oldhsl[2] = m_hsl[2];
    m_targethsl[0] = rsRandf(1.0f);
    m_targethsl[1] = rsRandf(1.0f);
    m_targethsl[2] = rsRandf(1.0f) + 0.5f;
    if (m_targethsl[2] > 1.0f)
      m_targethsl[2] = 1.0f;
    m_hslChange[0] = 0.0f;
    m_hslChange[1] = rsRandf(30.0f) + 2.0f;
  }
  between = m_hslChange[0] / m_hslChange[1];
  diff = m_targethsl[0] - m_oldhsl[0];
  direction = 0;
  if ((m_targethsl[0] > m_oldhsl[0] && diff > 0.5f) || (m_targethsl[0] < m_oldhsl[0] && diff < -0.5f))
    if (diff > 0.5f)
      direction = 1;
  hslTween(m_oldhsl[0], m_oldhsl[1], m_oldhsl[2],
           m_targethsl[0], m_targethsl[1], m_targethsl[2], between, direction,
           m_hsl[0], m_hsl[1], m_hsl[2]);
  m_hslChange[0] += base->FrameTime();

  if (gCycloneSettings.dShowCurves)
  {
    unsigned int ptr = 0;
    sLight curves[std::max(gCycloneSettings.dComplexity+3, 50)];
    base->m_lightingEnabled = 0;
    for (step=0.0; step<1.0; step+=0.02f)
    {
      point[0] = point[1] = point[2] = 0.0f;
      for (i = 0; i < (gCycloneSettings.dComplexity+3); i++)
      {
        blend = base->m_fact[gCycloneSettings.dComplexity+2] / (base->m_fact[i]
              * base->m_fact[gCycloneSettings.dComplexity+2-i]) * powf(step, float(i))
              * powf((1.0f - step), float(gCycloneSettings.dComplexity+2-i));
        point[0] += m_xyz[i][0] * blend;
        point[1] += m_xyz[i][1] * blend;
        point[2] += m_xyz[i][2] * blend;
      }
      curves[ptr  ].color = sColor(0.0f, 1.0f, 0.0f);
      curves[ptr++].vertex = sPosition(point);
    }
    base->DrawEntry(GL_LINE_STRIP, curves, ptr);
    ptr = 0;

    for (i = 0; i < (gCycloneSettings.dComplexity+3); i++)
    {
      curves[ptr  ].color = sColor(1.0f, 0.0f, 0.0f);
      curves[ptr++].vertex = sPosition(&m_xyz[i][0]);
    }
    base->DrawEntry(GL_LINE_STRIP, curves, ptr);
    base->m_lightingEnabled = 1;
  }
}
Ejemplo n.º 4
0
ret_ CXMLLoaderActions::LoadWhile(CProgram &Program,
								  const DOMElement *pElement,
								  const CPDUInfo *pPDU)
{
#ifdef _DEBUG_
	if (!pElement)
		return (PARAMETER_NULL | PARAMETER_3);
#endif

	auto_xerces_str	wsPosition	("position");
	auto_xerces_str	sPosition	(pElement->getAttribute(wsPosition));
	bool_			b = true_v;

	if (0 == strcmp(sPosition, "head"))
		b = true_v;
	else if (0 == strcmp(sPosition, "foot"))
		b = false_v;

	//
	DOMElement *pSub = (DOMElement *)pElement->getFirstChild();

	if (!pSub)
		return XML_LOADER_ERROR;

	auto_xerces_str wsDataBlock			("data_block");
	auto_xerces_str wsExpressionUnitary	("expression_unitary");
	auto_xerces_str wsExpressionDuality	("expression_duality");
	auto_xerces_str wsConditionUnitary	("condition_unitary");
	auto_xerces_str wsConditionDuality	("condition_duality");
	auto_xerces_str wsProcessBlock		("process_block");

	CData Data;
	CExpression *pExpression = null_v;
	CProgramWhile *pPW = null_v;

	Data.SetParent(&Program.Data());

	while (pSub)
	{
		if (0 == XMLString::compareString(pSub->getNodeName(),
										  wsDataBlock))
		{
			if (SUCCESS != (LoadDataBlock(Data, pSub)))
				return XML_LOADER_ERROR;
		}
		else if (0 == XMLString::compareString(pSub->getNodeName(),
											   wsExpressionUnitary)
				 || 0 == XMLString::compareString(pSub->getNodeName(),
												  wsExpressionDuality)
				 || 0 == XMLString::compareString(pSub->getNodeName(),
												  wsConditionUnitary)
				 || 0 == XMLString::compareString(pSub->getNodeName(),
												  wsConditionDuality))
		{
			if (SUCCESS != LoadExpression(Data, pSub, pExpression, pPDU))
				return XML_LOADER_ERROR;
			
			pPW = new CProgramWhile(b, pExpression, &Data);
			pPW->Data().SetParent(&Program.Data());
		}
		else if (0 == XMLString::compareString(pSub->getNodeName(),
											   wsProcessBlock))
		{
			if (!pPW)
				return XML_LOADER_ERROR;
			
			if (SUCCESS != LoadProcessBlock(*pPW, pSub, pPDU))
				return XML_LOADER_ERROR;
		}

		pSub = (DOMElement *)pSub->getNextSibling();
	}

	if (false_v == Program.AddOperator(pPW))
		return XML_LOADER_ERROR;

	return SUCCESS;
}
Ejemplo n.º 5
0
sPosition cGameObject::getScreenPosition()
{
	return sPosition( m_position.x - s_pMap->GetRoad(), m_position.y );
}