コード例 #1
0
bool ImageBox::SetProperty(UIProperty::Enum prop, const char* val)
{
	switch (prop)
	{
	case UIProperty::TEXTUREATLAS:
	{
									 mTextureAtlasFile = val;
									 return true;
	}
		break;

	case UIProperty::REGION:
	{
		mStrRegion = val;
		if (mTextureAtlasFile.empty()){
			mTextureAtlasFile = "data/textures/gameui.xml";
		}
		SetTextureAtlasRegion(mTextureAtlasFile.c_str(), val);
		return true;
	}
		break;

	case UIProperty::REGIONS:
	{
		mStrRegions = val;
		if (mTextureAtlasFile.empty()){
			mTextureAtlasFile = "data/textures/gameui.xml";
		}
		mAnimation = true;
		auto useNumberData = Split(val, ":");
		if (useNumberData.size() >= 2)
		{
			auto fromtoData = Split(useNumberData[1], ",");
			fromtoData[0] = StripBoth(fromtoData[0].c_str());
			fromtoData[1] = StripBoth(fromtoData[1].c_str());
			unsigned from = StringConverter::ParseUnsignedInt(fromtoData[0].c_str());
			unsigned to = StringConverter::ParseUnsignedInt(fromtoData[1].c_str());
			assert(to > from);
			std::vector<std::string> data;
			char buf[256];
			for (unsigned i = from; i <= to; i++)
			{
				sprintf_s(buf, "%s%u", useNumberData[0].c_str(), i);
				data.push_back(buf);
			}
			SetTextureAtlasRegions(mTextureAtlasFile.c_str(), data);
		}
		else
		{
			auto data = Split(val, ",");
			for (auto& str : data)
			{
				str = StripBoth(str.c_str());
			}
			SetTextureAtlasRegions(mTextureAtlasFile.c_str(), data);
		}
		if (!mAtlasRegions.empty())
		{
			Vec2 texcoords[4];
			mAtlasRegions[mCurFrame]->GetQuadUV(texcoords);
			mUIObject->SetTexCoord(texcoords, 4);
		}
								
		return true;

	}
		break;

	case UIProperty::FPS:
	{
							mSecPerFrame = 1.0f / StringConverter::ParseReal(val);
							return true;
	}
		break;

	case UIProperty::TEXTURE_FILE:
	{
									 SetTexture(val);
									 return true;
	}

	case UIProperty::KEEP_IMAGE_RATIO:
	{
										 SetKeepImageRatio(StringConverter::ParseBool(val, true));
										 return true;
	}
	case UIProperty::FRAME_IMAGE:
	{
		mStrFrameImage = val;
									if (!mFrameImage)
									{
										mFrameImage = CreateChildImageBox();
									}
									mFrameImage->SetTextureAtlasRegion(mTextureAtlasFile.c_str(), val);
									if (strlen(val) == 0)
									{
										mFrameImage->SetVisible(false);
									}
									else
									{
										mFrameImage->SetVisible(true);
									}
									return true;
	}

	case UIProperty::IMAGE_COLOR_OVERLAY:
	{
		mColorOveraySet = true;
											Color color = Color(val);
											if (mUIObject)
											{
												mUIObject->GetMaterial()->SetDiffuseColor(color.GetVec4());
											}
											return true;

	}

	case UIProperty::IMAGE_FIXED_SIZE:
	{
										 mImageFixedSize = StringConverter::ParseBool(val);										 
										 if (mTexture || mAtlasRegion)
										 {
											 DrawAsFixedSize();
										 }
										 
										 return true;

	}

	case UIProperty::IMAGE_ROTATE:
	{
		SetUVRot(mImageRot);		
		return true;

	}

	case UIProperty::IMAGE_LINEAR_SAMPLER:
	{
		mLinearSampler = StringConverter::ParseBool(val);
		if (mUIObject){
			mUIObject->EnableLinearSampler(mLinearSampler);
		}
		return true;
	}

	}

	return __super::SetProperty(prop, val);
}
コード例 #2
0
ファイル: GEOMLOAD.C プロジェクト: svyatoslav777/sum2014
/* Функция загрузки геометрического объекта.
 * АРГУМЕНТЫ:
 *   - геометрический объект:
 *       vg4GEOM *G;
 *   - имя файла материалов:
 *       CHAR *FileName;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ:
 *   (BOOL) TRUE при успехе.
 */
BOOL VG4_GeomLoad( vg4GEOM *G, CHAR *FileName )
{
  INT vn = 0, vtn = 0, vnn = 0, fn = 0, pn = 0, size, i, p;
  FILE *F;
  /* читаемые данные */
  VEC *ReadV, *ReadN;
  vg4UV *ReadUV;
  INT (*ReadF)[3];
  /* хранение примитивов */
  struct
  {
    INT
      First, Last, /* первый и последний номера вершин примитива */
      Mtl;         /* материал примитива */
  } *PrimInfo;

  memset(G, 0, sizeof(vg4GEOM));
  /* разбиваем имя на части и открываем файл */
  _splitpath(FileName, ModelDrive, ModelDir, ModelFileName, ModelFileExt);
  if ((F = fopen(FileName, "rt")) == NULL)
    return FALSE;

  /* считаем количества */
  while (fgets(Buf, sizeof(Buf), F) != NULL)
    if (Buf[0] == 'v' && Buf[1] == ' ')
      vn++;
    else if (Buf[0] == 'v' && Buf[1] == 't')
      vtn++;
    else if (Buf[0] == 'v' && Buf[1] == 'n')
      vnn++;
    else if (Buf[0] == 'f' && Buf[1] == ' ')
      fn += Split() - 3;
    else if (strncmp(Buf, "usemtl", 6) == 0)
      pn++;

  if (pn == 0)
    pn = 1; /* материалы не использовались */

  /* загружаем:
   *   вершины                        vn
   *   нормали                        vvn
   *   текстурные координаты          vtn
   *   треугольники                   fn
   *   примитивы                      pn
   * дополнительно:
   *   индексы (Vv, Vn, Vt) <- новые номера вершин  ? (vn + vt + vnn) * ???
   *   начальные индексы              vn
   */

  /* выделяем память под вспомогательные данные */
  size = 
    sizeof(VEC) * vn +                        /*   вершины               vn */
    sizeof(VEC) * vnn +                       /*   нормали               vnn */
    sizeof(vg4UV) * vtn +                     /*   текстурные координаты vtn */
    sizeof(INT [3]) * fn +                    /*   треугольники          fn */
    sizeof(PrimInfo[0]) * pn +                /*   примитивы             pn */
    sizeof(VertexRefs[0]) * (vn + vtn + vnn) + /*   индексы (Vv, Vn, Vt)  (vn + vt + vnn) */
    sizeof(INT) * vn;                         /*   начальные индексы     vn */
  if ((ReadV = malloc(size)) == NULL)
  {
    fclose(F);
    return FALSE;
  }
  memset(ReadV, 0, size);

  /* расставляем указатели */
  ReadN = ReadV + vn;
  ReadUV = (vg4UV *)(ReadN + vnn);
  ReadF = (INT (*)[3])(ReadUV + vtn);
  VertexRefsStart = (INT *)(ReadF + fn);
  PrimInfo = (VOID *)(VertexRefsStart + vn);
  VertexRefs = (VOID *)(PrimInfo + pn);
  NumOfAllocedVertexRefs = vn + vtn + vnn;
  NumOfVertexRefs = 0;
  /* начала списка индексов вершин ==> -1 */
  memset(VertexRefsStart, 0xFF, sizeof(INT) * vn);
  memset(VertexRefs, 0xFF, sizeof(VertexRefs[0]) * NumOfAllocedVertexRefs);

  /* второй проход - читаем геометрию */
  rewind(F);
  vn = 0;
  vtn = 0;
  vnn = 0;
  fn = 0;
  pn = 0;
  PrimInfo[0].First = 0;

  /* считаем количества */
  while (fgets(Buf, sizeof(Buf), F) != NULL)
    if (Buf[0] == 'v' && Buf[1] == ' ')
    {
      FLT x = 0, y = 0, z = 0;

      sscanf(Buf + 2, "%f%f%f", &x, &y, &z);
      ReadV[vn++] = VecSet(x, y, z);
    }
    else if (Buf[0] == 'v' && Buf[1] == 't')
    {
      FLT u = 0, v = 0;

      sscanf(Buf + 3, "%f%f", &u, &v);
      ReadUV[vtn++] = VG4_UVSet(u, v);
    }
    else if (Buf[0] == 'v' && Buf[1] == 'n')
    {
      FLT nx = 0, ny = 0, nz = 0;

      sscanf(Buf + 3, "%f%f%f", &nx, &ny, &nz);
      ReadN[vnn++] = VecNormalize(VecSet(nx, ny, nz));
    }
    else if (Buf[0] == 'f' && Buf[1] == ' ')
    {
      INT n0[3], n1[3], n[3], r0, r1, r;

      Split();
      SCANF3(Parts[1], n0);
      r0 = GetVertexNo(n0[0], n0[1], n0[2]);

      SCANF3(Parts[2], n1);
      r1 = GetVertexNo(n1[0], n1[1], n1[2]);

      for (i = 3; i < NumOfParts; i++)
      {
        SCANF3(Parts[i], n);
        r = GetVertexNo(n[0], n[1], n[2]);

        ReadF[fn][0] = r0;
        ReadF[fn][1] = r1;
        ReadF[fn][2] = r;
        r1 = r;
        fn++;
      }
    }
    else if (strncmp(Buf, "usemtl", 6) == 0)
    {
      Split();

      /* запоминаем номер последней грани */
      if (pn != 0)
        PrimInfo[pn - 1].Last = fn - 1;

      /* ищем материал */
      for (i = 0; i < G->NumOfMtls; i++)
        if (strcmp(Parts[1], G->Mtls[i].Name) == 0)
          break;
      if (i == G->NumOfMtls)
        PrimInfo[pn].Mtl = -1;
      else
        PrimInfo[pn].Mtl = i;
      PrimInfo[pn].First = fn;
      pn++;
    }
    else if (strncmp(Buf, "mtllib ", 7) == 0)
    {
      Split();
      LoadMaterials(G, Parts[1]);
    }

  /* у последнего примитива запоминаем номер последней грани */
  if (pn == 0)
  {
    PrimInfo[0].Last = fn - 1;
    PrimInfo[0].Mtl = -1;
  }
  else
    PrimInfo[pn - 1].Last = fn - 1;
  fclose(F);

  /* Формируем примитивы из прочитанных данных */
  VG4_DefaultColor = ColorSet(1, 1, 1);
  for (p = 0; p < pn; p++)
  {
    INT minv, maxv, j;
    vg4PRIM prim;

    minv = maxv = ReadF[PrimInfo[p].First][0];
    for (i = PrimInfo[p].First; i <= PrimInfo[p].Last; i++)
      for (j = 0; j < 3; j++)
      {
        if (minv > ReadF[i][j])
          minv = ReadF[i][j];
        if (maxv < ReadF[i][j])
          maxv = ReadF[i][j];
      }
    vn = maxv - minv + 1;
    fn = PrimInfo[p].Last - PrimInfo[p].First + 1;
    VG4_PrimCreate(&prim, VG4_PRIM_TRIMESH, vn, fn * 3);

    /* копируем вершины */
    for (i = 0; i < vn; i++)
    {
      INT n;

      prim.V[i].P = ReadV[VertexRefs[minv + i].Nv];
      if ((n = VertexRefs[minv + i].Nn) != -1)
        prim.V[i].N = ReadN[n];
      if ((n = VertexRefs[minv + i].Nt) != -1)
        prim.V[i].T = ReadUV[n];
    }
    /* копируем грани */
    for (i = 0; i < fn; i++)
      for (j = 0; j < 3; j++)
        prim.I[i * 3 + j] = ReadF[PrimInfo[p].First + i][j] - minv;
    prim.Mtl = PrimInfo[p].Mtl;
    VG4_GeomAddPrim(G, &prim);
  }
  /* освобождаем память из-под прочитанных данных */
  free(ReadV);
  return TRUE;
} /* End of 'VG4_GeomLoad' function */
コード例 #3
0
//-----------------------------------------------------------------------------
void CPoisonProjectile::Create(EERIE_3D _eSrc, float _fBeta)
{
	int i;

	SetDuration(ulDuration);

	SetAngle(_fBeta);

	eSrc.x = _eSrc.x;
	eSrc.y = _eSrc.y;
	eSrc.z = _eSrc.z;

	fSize = 1;
	bDone = true;
	bOk = false;

	eTarget.x = eSrc.x - fBetaRadSin * 850;
	eTarget.y = eSrc.y;
	eTarget.z = eSrc.z + fBetaRadCos * 850;

	eMove.x = - fBetaRadSin * 2; 
	eMove.y = 0;
	eMove.z = + fBetaRadCos * 2; 

	EERIE_3D s, e, h;
	s.x = eSrc.x;
	s.y = eSrc.y;
	s.z = eSrc.z;
	e.x = eSrc.x;
	e.y = eSrc.y;
	e.z = eSrc.z;

	i = 0;

	while (Visible(&s, &e, NULL, &h) && i < 20)
	{
		e.x -= fBetaRadSin * 50;
		e.z += fBetaRadCos * 50;

		i++;
	}

	e.y += 0.f;

	pathways[0].sx = eSrc.x;
	pathways[0].sy = eSrc.y;
	pathways[0].sz = eSrc.z;
	pathways[9].sx = e.x;
	pathways[9].sy = e.y;
	pathways[9].sz = e.z;
	Split(pathways, 0, 9, 10 * fBetaRadCos, 10, 10, 10, 10 * fBetaRadSin, 10);

	if (0)
		for (i = 0; i < 10; i++)
		{
			if (pathways[i].sy >= eSrc.y + 150)
			{
				pathways[i].sy = eSrc.y + 150;
			}

			if (pathways[i].sy <= eSrc.y + 50)
			{
				pathways[i].sy = eSrc.y + 50;
			}
		}

	fTrail = -1;

	//-------------------------------------------------------------------------
	// système de partoches
	CParticleParams cp;
	cp.iNbMax = 5;
	cp.fLife = 2000;
	cp.fLifeRandom = 1000;
	cp.p3Pos.x = 0;
	cp.p3Pos.y = 0;
	cp.p3Pos.z = 0;
	cp.p3Direction.x = -eMove.x;
	cp.p3Direction.y = -eMove.y;
	cp.p3Direction.z = -eMove.z;
	cp.fAngle = 0;
	cp.fSpeed = 10;
	cp.fSpeedRandom = 10;
	cp.p3Gravity.x = 0;
	cp.p3Gravity.y = 0;
	cp.p3Gravity.z = 0;
	cp.fFlash = 21;
	cp.fRotation = 80;
	cp.bRotationRandomDirection = true;
	cp.bRotationRandomStart = true;

	cp.fStartSize = 5; 
	cp.fStartSizeRandom = 3;
	cp.fStartColor[0] = 0;
	cp.fStartColor[1] = 50;
	cp.fStartColor[2] = 0;
	cp.fStartColor[3] = 40; 
	cp.fStartColorRandom[0] = 0;
	cp.fStartColorRandom[1] = 100;
	cp.fStartColorRandom[2] = 0;
	cp.fStartColorRandom[3] = 50;
	cp.bStartLock = false;

	cp.fEndSize = 8; 
	cp.fEndSizeRandom = 13;
	cp.fEndColor[0] = 0;
	cp.fEndColor[1] = 60;
	cp.fEndColor[2] = 0;
	cp.fEndColor[3] = 40;
	cp.fEndColorRandom[0] = 0;
	cp.fEndColorRandom[1] = 100;
	cp.fEndColorRandom[2] = 0;
	cp.fEndColorRandom[3] = 50;
	cp.bEndLock = false;

	cp.iBlendMode = 5;

	pPS.SetParams(cp);
	pPS.ulParticleSpawn = 0;

	pPS.SetTexture("graph\\particles\\big_greypouf.bmp", 0, 200);

	pPS.fParticleFreq = -1;

	pPS.bParticleFollow = true;

	pPS.SetPos(eSrc);
	pPS.Update(0);
}
コード例 #4
0
ファイル: Spells09.cpp プロジェクト: fourks/ArxLibertatis
//-----------------------------------------------------------------------------
void CIncinerate::Create(Vec3f _eSrc, float _fBeta)
{
    SetDuration(ulDuration);
    SetAngle(_fBeta);

    eSrc.x = _eSrc.x;
    eSrc.y = _eSrc.y - 20;
    eSrc.z = _eSrc.z;

    eTarget.x = eSrc.x - fBetaRadSin * 500;
    eTarget.y = eSrc.y;
    eTarget.z = eSrc.z + fBetaRadCos * 500;

    fSize = 1;

    iMax = iNumber;
    Vec3f s, e, h;

    s.x = eSrc.x;
    s.y = eSrc.y - 20;
    s.z = eSrc.z;
    e.x = eSrc.x;
    e.y = eSrc.y - 20;
    e.z = eSrc.z;

    e.x = s.x - fBetaRadSin * 900;
    e.y = s.y;
    e.z = s.z + fBetaRadCos * 900;

    float fd;

    if (!Visible(&s, &e, NULL, &h))
    {
        e.x = h.x + fBetaRadSin * 20;
        e.y = h.y;
        e.z = h.z - fBetaRadCos * 20;
    }

    fd = fdist(s, e);


    float fDur = ulDuration * (fd / 900.0f);
    SetDuration(checked_range_cast<unsigned long>(fDur));

    float fCalc = (fd / 900.0f) * iMax;

    iNumber = checked_range_cast<int>(fCalc);

    int end = 40;
    tv1a[0].p.x = s.x;
    tv1a[0].p.y = s.y;
    tv1a[0].p.z = s.z;
    tv1a[end].p.x = e.x;
    tv1a[end].p.y = e.y;
    tv1a[end].p.z = e.z;

    Split(tv1a, 0, end, 10, 1, 0, 1, 10, 1);

    ParticleParams cp;
    cp.iNbMax = 250;
    cp.fLife = 1000;
    cp.fLifeRandom = 500;
    cp.p3Pos.x = 0;
    cp.p3Pos.y = 10;
    cp.p3Pos.z = 0;
    cp.p3Direction.x = + fBetaRadSin * 4;
    cp.p3Direction.y = 0;
    cp.p3Direction.z = - fBetaRadCos * 4;
    cp.fAngle = radians(1);
    cp.fSpeed = 0;
    cp.fSpeedRandom = 20;
    cp.p3Gravity.x = 0;
    cp.p3Gravity.y = 0;
    cp.p3Gravity.z = 0;
    cp.fFlash = 0;
    cp.fRotation = 0;
    cp.bRotationRandomDirection = false;
    cp.bRotationRandomStart = false;

    cp.fStartSize = 5;
    cp.fStartSizeRandom = 5;
    cp.fStartColor[0] = 80;
    cp.fStartColor[1] = 80;
    cp.fStartColor[2] = 0;
    cp.fStartColor[3] = 20;
    cp.fStartColorRandom[0] = 81;
    cp.fStartColorRandom[1] = 81;
    cp.fStartColorRandom[2] = 51;
    cp.fStartColorRandom[3] = 51;
    cp.bStartLock = true;

    cp.fEndSize = 1;
    cp.fEndSizeRandom = 5;
    cp.fEndColor[0] = 50;
    cp.fEndColor[1] = 0;
    cp.fEndColor[2] = 0;
    cp.fEndColor[3] = 20;
    cp.fEndColorRandom[0] = 50;
    cp.fEndColorRandom[1] = 50;
    cp.fEndColorRandom[2] = 50;
    cp.fEndColorRandom[3] = 20;
    cp.bEndLock = true;
    cp.bTexLoop = true;

    cp.iBlendMode = 3;

    pPSStream.SetParams(cp);
    pPSStream.ulParticleSpawn = 0;

    pPSStream.SetTexture("graph/particles/smallfire", 4, 10);

    pPSStream.fParticleFreq = 250;
    pPSStream.bParticleFollow = false;
    pPSStream.SetPos(eSrc);
    pPSStream.Update(0);



    // Hit
    cp.iNbMax = 150;
    cp.fLife = 2000;
    cp.fLifeRandom = 1000;
    cp.p3Pos.x = 80;
    cp.p3Pos.y = 10;
    cp.p3Pos.z = 80;
    cp.p3Direction.x = 0;
    cp.p3Direction.y = 2;
    cp.p3Direction.z = 0;
    cp.fAngle = 0;
    cp.fSpeed = 0;
    cp.fSpeedRandom = 0;
    cp.p3Gravity.x = 0;
    cp.p3Gravity.y = 0;
    cp.p3Gravity.z = 0;
    cp.fFlash = 0;
    cp.fRotation = 0;
    cp.bRotationRandomDirection = false;
    cp.bRotationRandomStart = false;

    cp.fStartSize = 10;
    cp.fStartSizeRandom = 3;
    cp.fStartColor[0] = 25;
    cp.fStartColor[1] = 25;
    cp.fStartColor[2] = 25;
    cp.fStartColor[3] = 50;
    cp.fStartColorRandom[0] = 51;
    cp.fStartColorRandom[1] = 51;
    cp.fStartColorRandom[2] = 51;
    cp.fStartColorRandom[3] = 101;
    cp.bStartLock = false;

    cp.fEndSize = 10;
    cp.fEndSizeRandom = 3;
    cp.fEndColor[0] = 25;
    cp.fEndColor[1] = 25;
    cp.fEndColor[2] = 25;
    cp.fEndColor[3] = 50; //0
    cp.fEndColorRandom[0] = 0;
    cp.fEndColorRandom[1] = 0;
    cp.fEndColorRandom[2] = 0;
    cp.fEndColorRandom[3] = 100; //0
    cp.bEndLock = false;
    cp.bTexLoop = true;

    cp.iBlendMode = 0;

    pPSHit.SetParams(cp);
    pPSHit.ulParticleSpawn = 0;

    pPSHit.SetTexture("graph/particles/firebase", 4, 100);

    pPSHit.fParticleFreq = -1;
    pPSHit.SetPos(eSrc);
    pPSHit.Update(0);

}
コード例 #5
0
ファイル: Spells05.cpp プロジェクト: Eli2/ArxLibertatis
//-----------------------------------------------------------------------------
void CPoisonProjectile::Create(Vec3f _eSrc, float _fBeta)
{
	int i;

	SetDuration(ulDuration);

	SetAngle(_fBeta);

	eSrc = _eSrc;

	bOk = false;

	eMove = Vec3f(-fBetaRadSin * 2, 0.f, fBetaRadCos * 2); 

	Vec3f s, e, h;
	s = eSrc;
	e = eSrc;

	i = 0;

	while (Visible(&s, &e, NULL, &h) && i < 20)
	{
		e.x -= fBetaRadSin * 50;
		e.z += fBetaRadCos * 50;

		i++;
	}

	e.y += 0.f;

	pathways[0].p = eSrc;
	pathways[9].p = e;
	Split(pathways, 0, 9, 10 * fBetaRadCos, 10, 10, 10, 10 * fBetaRadSin, 10);

	if (0)
		for (i = 0; i < 10; i++)
		{
			if (pathways[i].p.y >= eSrc.y + 150)
			{
				pathways[i].p.y = eSrc.y + 150;
			}

			if (pathways[i].p.y <= eSrc.y + 50)
			{
				pathways[i].p.y = eSrc.y + 50;
			}
		}

	fTrail = -1;

	//-------------------------------------------------------------------------
	// système de partoches
	ParticleParams cp;
	cp.iNbMax = 5;
	cp.fLife = 2000;
	cp.fLifeRandom = 1000;
	cp.p3Pos = Vec3f::ZERO;
	cp.p3Direction = -eMove;
	cp.fAngle = 0;
	cp.fSpeed = 10;
	cp.fSpeedRandom = 10;
	cp.p3Gravity = Vec3f::ZERO;
	cp.fFlash = 21;
	cp.fRotation = 80;
	cp.bRotationRandomDirection = true;
	cp.bRotationRandomStart = true;

	cp.fStartSize = 5; 
	cp.fStartSizeRandom = 3;
	cp.fStartColor[0] = 0;
	cp.fStartColor[1] = 50;
	cp.fStartColor[2] = 0;
	cp.fStartColor[3] = 40; 
	cp.fStartColorRandom[0] = 0;
	cp.fStartColorRandom[1] = 100;
	cp.fStartColorRandom[2] = 0;
	cp.fStartColorRandom[3] = 50;
	cp.bStartLock = false;

	cp.fEndSize = 8; 
	cp.fEndSizeRandom = 13;
	cp.fEndColor[0] = 0;
	cp.fEndColor[1] = 60;
	cp.fEndColor[2] = 0;
	cp.fEndColor[3] = 40;
	cp.fEndColorRandom[0] = 0;
	cp.fEndColorRandom[1] = 100;
	cp.fEndColorRandom[2] = 0;
	cp.fEndColorRandom[3] = 50;
	cp.bEndLock = false;

	cp.iBlendMode = 5;

	pPS.SetParams(cp);
	pPS.ulParticleSpawn = 0;

	pPS.SetTexture("graph/particles/big_greypouf", 0, 200);

	pPS.fParticleFreq = -1;

	pPS.bParticleFollow = true;

	pPS.SetPos(eSrc);
	pPS.Update(0);
}
コード例 #6
0
ファイル: strutils.cpp プロジェクト: contactless/rfsniffer
Vector String::Split(const string &delimiter) const
{
    Vector splitted;
    Split(delimiter, splitted);
    return splitted;
}
コード例 #7
0
ファイル: Navigator.cpp プロジェクト: AbdelghaniDr/mirror
void Navigator::Search()
{
	sortitems.Check(sorting);
	int sc = scope.GetScroll();
	String key = scope.GetKey();
	String s = TrimBoth(~search);
	String search_name, search_nest;
	bool wholeclass = false;
	bool both = false;
	navigator_global = false;
	if(s.Find('.') >= 0) {
		Vector<String> h = Split((String)~search, '.');
		if(*s.Last() == '.')
			search_nest = Join(h, "::");
		else {
			search_name = h.Pop();
			if(h.GetCount())
				search_nest = Join(h, "::");
		}
		wholeclass = *s == '.' && search_nest.GetCount();
	}
	else {
		search_name = search_nest = ~search;
		both = true;
	}
	s = Join(Split(s, '.'), "::") + (s.EndsWith(".") ? "::" : "");
	int lineno = StrInt(s);
	gitem.Clear();
	nitem.Clear();
	if(IsNull(theide->editfile))
		return;
	int fileii = GetSourceFileIndex(theide->editfile);
	if(!IsNull(lineno)) {
		NavItem& m = nitem.Add();
		m.type = "Go to line " + AsString(lineno);
		m.kind = KIND_LINE;
		m.line = lineno;
		gitem.Add(Null).Add(&m);
	}
	else
	if(IsNull(s) && !sorting) {
		const CppBase& b = CodeBase();
		for(int i = 0; i < b.GetCount(); i++) {
			String nest = b.GetKey(i);
			const Array<CppItem>& ci = b[i];
			for(int j = 0; j < ci.GetCount(); j++) {
				const CppItem& m = ci[j];
				if(m.file == fileii) {
					NavItem& n = nitem.Add();
					n.Set(m);
					n.nest = nest;
					n.decl_line = m.line;
					n.decl_file = m.file;
					n.decl = !m.impl;
					NavLine& l = n.linefo.Add();
					l.impl = m.impl;
					l.file = m.file;
					l.line = m.line;
				}
			}
		}
		Sort(nitem, FieldRelation(&NavItem::line, StdLess<int>()));
		NavGroup(true);
	}
	else {
		navigator_global = true;
		const CppBase& b = CodeBase();
		String usearch_nest = ToUpper(search_nest);
		String usearch_name = ToUpper(search_name);
		ArrayMap<String, NavItem> imap;
		bool local = sorting && IsNull(s);
		VectorMap<String, int> nest_pass;
		for(int pass = -1; pass < 2; pass++) {
			for(int i = 0; i < b.GetCount(); i++) {
				String nest = b.GetKey(i);
				bool foundnest = (wholeclass ? pass < 0 ? false :
				                               pass ? ToUpper(nest) == usearch_nest
				                                    : nest == search_nest
				                             : pass < 0 ? nest == search_nest :
				                               (pass ? ToUpper(nest).Find(usearch_nest) >= 0
				                                     : nest.StartsWith(search_nest)))
				                 && nest.Find('@') < 0;
				if(local || foundnest || both) {
					const Array<CppItem>& ci = b[i];
					for(int j = 0; j < ci.GetCount(); j++) {
						const CppItem& m = ci[j];
						if(local ? m.file == fileii
						         : m.uname.Find('@') < 0 && (pass < 0 ? m.name == search_name :
						                               pass ? m.uname.Find(usearch_name) >= 0
						                                    : m.name.StartsWith(search_name))
						           || both && foundnest) {
							String key = nest + '\1' + m.qitem;
							int q = nest_pass.Find(nest);
							int p = pass;
							if(q < 0) // We do not want classes to be split based on pass
								nest_pass.Add(nest, pass);
							else
								p = nest_pass[q];
							q = imap.Find(key);
							if(q < 0) {
								NavItem& ni = imap.Add(key);
								ni.Set(m);
								ni.nest = nest;
								ni.decl_line = ni.line;
								ni.decl_file = ni.file;
								ni.decl = !ni.impl;
								ni.pass = p;
								NavLine& l = ni.linefo.Add();
								l.impl = m.impl;
								l.file = m.file;
								l.line = m.line;
							}
							else {
								NavItem& mm = imap[q];
								if(!m.impl &&
								  (!mm.decl
								    || CombineCompare(mm.decl_file, m.file)(mm.decl_line, m.line) < 0)) {
										mm.decl = true;
										mm.decl_line = m.line;
										mm.decl_file = m.file;
										mm.natural = m.natural;
								}
								NavLine& l = mm.linefo.Add();
								l.impl = m.impl;
								l.file = m.file;
								l.line = m.line;
							}
						}
					}
				}
			}
		}
		nitem = imap.PickValues();
		NavGroup(false);
		SortByKey(gitem);
		Vector<String> keys = gitem.PickKeys();
		Vector<Vector<NavItem *> > values = gitem.PickValues();
		IndexSort(keys, values);
		for(int i = 0; i < keys.GetCount(); i++)
			keys[i].Remove(0);
		VectorMap<String, Vector<NavItem *> > h(pick(keys), pick(values));
		gitem = pick(h);
		for(int i = 0; i < gitem.GetCount(); i++)
			Sort(gitem[i], sorting ? SortByNames : SortByLines);
	}
	scope.Clear();
	scope.Add(Null);
	Index<String> done;
	for(int i = 0; i < gitem.GetCount(); i++) {
		String s = gitem.GetKey(i);
		if(done.Find(s) < 0) {
			done.Add(s);
			scope.Add(s);
		}
	}
	scope.ScrollTo(sc);
	if(!navigator_global || !scope.FindSetCursor(key))
		scope.GoBegin();
}
コード例 #8
0
ファイル: IniFile.cpp プロジェクト: grainrigi/jscripts
int
CIniFile::SetComPort( LPCTSTR filename, HANDLE file )
{
	CStr port = filename;
	CValue *comData;
	int timeout, rate, bits, parity, stopBit, flow;
	port.MakeUpper();
	if ( Variables.Lookup( L"[Port_" + port + L"]", comData ) )
	{
		CStrArray data;
		CStr dataString;
		dataString = (CStr)*comData;

		Split( dataString, L"\n", data );
		timeout = _wtol( data[0] );
		rate = _wtol( data[1] );
		parity = _wtol( data[2] );
		bits = _wtol( data[3] );
		stopBit = _wtol( data[4] );
		flow = _wtol( data[5] );
		//MessageBox( NULL, comData, L"Debug", MB_OK );
	}
	else
	{
		timeout = 10000;
		rate = 4800;
		parity = NOPARITY;
		bits = 8;
		stopBit = ONESTOPBIT;
		flow = 0;
	}

	DCB PortDCB;
	ZeroMemory (&PortDCB, sizeof(PortDCB));
	PortDCB.DCBlength = sizeof(DCB);
	GetCommState( file, &PortDCB );

	// Change the DCB structure settings.
	PortDCB.BaudRate = rate;              // Current baud 
	PortDCB.fBinary = TRUE;               // ASCII mode
	PortDCB.fParity = TRUE;               // Enable parity checking 
	PortDCB.fOutxCtsFlow = (flow==1);     // CTS output flow control 
	PortDCB.fOutxDsrFlow = FALSE;         // DSR output flow control 
	PortDCB.fDtrControl = DTR_CONTROL_ENABLE; 
	// DTR flow control type 
	PortDCB.fDsrSensitivity = FALSE;      // DSR sensitivity 
	PortDCB.fTXContinueOnXoff = TRUE;     // XOFF continues Tx 
	PortDCB.fOutX = (flow==2);            // XON/XOFF out flow control 
	PortDCB.fInX = (flow==2);             // XON/XOFF in flow control 
	PortDCB.fErrorChar = FALSE;           // Disable error replacement 
	PortDCB.fNull = TRUE;                 // Enable null stripping 
	PortDCB.fRtsControl = (flow==1) ? RTS_CONTROL_HANDSHAKE : RTS_CONTROL_ENABLE; 
	// RTS flow control 
	PortDCB.fAbortOnError = FALSE;        // Do not abort reads/writes on 
	// error
	PortDCB.ByteSize = bits;              // Number of bits/byte, 4-8 
	PortDCB.Parity = parity;              // 0-4=no,odd,even,mark,space 
	PortDCB.StopBits = stopBit;           // 0,1,2 = 1, 1.5, 2 

	//CStr msg;
	//msg.Format( L"BaudRate: %d\nByteSize: %d\nStopBits: %d\nParity: %d\nfOutX: %d\nfInX: %d\nfOutxCtsFlow: %d\nfRtsControl: %d\nfDsrSensitivity: %d", 
	//			     PortDCB.BaudRate,
	//				 PortDCB.ByteSize,
	//				 PortDCB.StopBits,
	//				 PortDCB.Parity,
	//				 PortDCB.fOutX,
	//				 PortDCB.fInX,
 	//				 PortDCB.fOutxCtsFlow,
	//				 PortDCB.fRtsControl,
	//				 PortDCB.fDsrSensitivity );
	//MessageBox( NULL, L"Port-Info: " + msg, L"Port-Info", MB_OK|MB_SETFOREGROUND );

	// Configure the port according to the specifications of the DCB 
	// structure.
	SetCommState( file, &PortDCB );

	// Retrieve the time-out parameters for all read and write operations
	// on the port. 
	COMMTIMEOUTS CommTimeouts;
	GetCommTimeouts( file, &CommTimeouts);

	// Change the COMMTIMEOUTS structure settings.
	CommTimeouts.ReadIntervalTimeout = MAXDWORD;
	CommTimeouts.ReadTotalTimeoutMultiplier = MAXDWORD;  
	CommTimeouts.ReadTotalTimeoutConstant = timeout;
	CommTimeouts.WriteTotalTimeoutMultiplier = 10;
	CommTimeouts.WriteTotalTimeoutConstant = 1000;
	
	// Set the time-out parameters for all read and write operations
	// on the port. 
	SetCommTimeouts( file, &CommTimeouts);

	EscapeCommFunction( file, SETDTR );
	EscapeCommFunction( file, SETRTS );

	return timeout;
}
コード例 #9
0
ファイル: Spells03.cpp プロジェクト: Eli2/ArxLibertatis
//-----------------------------------------------------------------------------
void CIceProjectile::Create(Vec3f aeSrc, float afBeta)
{
	SetDuration(ulDuration);
	SetAngle(afBeta);

	fSize = 1;

	float xmin, ymin, zmin;

	Vec3f s, e, h;

	s.x					= aeSrc.x;
	s.y					= aeSrc.y - 100;
	s.z					= aeSrc.z;
	float fspelldist	= static_cast<float>(iMax * 15);

	fspelldist = min(fspelldist, 200.0f);
	fspelldist = max(fspelldist, 450.0f);
	e.x = aeSrc.x - fBetaRadSin * fspelldist;
	e.y = aeSrc.y - 100;
	e.z = aeSrc.z + fBetaRadCos * fspelldist;

	float fd;

	if (!Visible(&s, &e, NULL, &h))
	{
		e.x = h.x + fBetaRadSin * 20;
		e.y = h.y;
		e.z = h.z - fBetaRadCos * 20;
	}

	fd = fdist(s, e);

	float fCalc = ulDuration * (fd / fspelldist);
	SetDuration(checked_range_cast<unsigned long>(fCalc));

	float fDist = (fd / fspelldist) * iMax ;

	iNumber = checked_range_cast<int>(fDist);

	int end = iNumber / 2;
	tv1a[0].p = s + Vec3f(0.f, 100.f, 0.f);
	tv1a[end].p = e + Vec3f(0.f, 100.f, 0.f);

	Split(tv1a, 0, end, 80, 0.5f, 0, 1, 80, 0.5f);

	for (int i = 0; i < iNumber; i++)
	{
		float t = rnd();

		if (t < 0.5f)
			tType[i] = 0;
		else
			tType[i] = 1;

		tSize[i] = Vec3f::ZERO;
		tSizeMax[i] = randomVec() + Vec3f(0.f, 0.2f, 0.f);

		if (tType[i] == 0)
		{
			xmin = 1.2f;
			ymin = 1;
			zmin = 1.2f;
		}
		else
		{
			xmin = 0.4f;
			ymin = 0.3f;
			zmin = 0.4f;
		}

		if (tSizeMax[i].x < xmin)
			tSizeMax[i].x = xmin;

		if (tSizeMax[i].y < ymin)
			tSizeMax[i].y = ymin;

		if (tSizeMax[i].z < zmin)
			tSizeMax[i].z = zmin;

		int iNum = static_cast<int>(i / 2);

		if (tType[i] == 0)
		{
			tPos[i].x = tv1a[iNum].p.x + frand2() * 80;
			tPos[i].y = tv1a[iNum].p.y;
			tPos[i].z = tv1a[iNum].p.z + frand2() * 80;
		}
		else
		{
			tPos[i].x = tv1a[iNum].p.x + frand2() * 40;
			tPos[i].y = tv1a[iNum].p.y;
			tPos[i].z = tv1a[iNum].p.z + frand2() * 40;
		}

		long ttt = ARX_DAMAGES_GetFree();
		if(ttt != -1) {
			damages[ttt].pos = tPos[i];
			damages[ttt].radius = 60.f;
			damages[ttt].damages = 0.1f * spells[spellinstance].caster_level;
			damages[ttt].area = DAMAGE_FULL;
			damages[ttt].duration = ulDuration;
			damages[ttt].source = spells[spellinstance].caster;
			damages[ttt].flags = DAMAGE_FLAG_DONT_HURT_SOURCE;
			damages[ttt].type = DAMAGE_TYPE_MAGICAL | DAMAGE_TYPE_COLD;
			damages[ttt].exist = true;
		}
	}

	fColor = 1;
}
コード例 #10
0
ファイル: SplitMerge.cpp プロジェクト: koz4k/soccer
Vector<String> Split(const char *s, const char *text, bool ignoreempty)
{
	return Split(INT_MAX, s, text, ignoreempty);
}
コード例 #11
0
 void SpellHit(Unit* /*caster*/, const SpellInfo* spell)
 {
     if (spell->Id == SPELL_DISPERSE)
         Split();
 }
コード例 #12
0
ファイル: SplitMerge.cpp プロジェクト: koz4k/soccer
Vector<String> Split(const char *s, int chr, bool ignoreempty)
{
	return Split(INT_MAX, s, chr, ignoreempty);
}
コード例 #13
0
ファイル: SplitMerge.cpp プロジェクト: koz4k/soccer
Vector<String> Split(const char *s, int (*filter)(int), bool ignoreempty)
{
	return Split(INT_MAX, s, filter, ignoreempty);
}
コード例 #14
0
ファイル: SplitMerge.cpp プロジェクト: koz4k/soccer
Vector<String> Split(const char *s, const char * (*text_filter)(const char *), bool ignoreempty)
{
	return Split(INT_MAX, s, text_filter, ignoreempty);
}
コード例 #15
0
ファイル: Patch.cpp プロジェクト: FriedRice/spring
// -------------------------------------------------------------------------------------------------
// Split a single Triangle and link it into the mesh.
// Will correctly force-split diamonds.
//
void Patch::Split(TriTreeNode* tri)
{
	// We are already split, no need to do it again.
	if (!tri->IsLeaf())
		return;

	// If this triangle is not in a proper diamond, force split our base neighbor
	if (tri->BaseNeighbor && (tri->BaseNeighbor->BaseNeighbor != tri))
		Split(tri->BaseNeighbor);

	// Create children and link into mesh
	CTriNodePool* pool = CTriNodePool::GetPool();
	tri->LeftChild  = pool->AllocateTri();
	tri->RightChild = pool->AllocateTri();

	// If creation failed, just exit.
	if (!tri->IsBranch())
		return;

	// Fill in the information we can get from the parent (neighbor pointers)
	tri->LeftChild->BaseNeighbor = tri->LeftNeighbor;
	tri->LeftChild->LeftNeighbor = tri->RightChild;

	tri->RightChild->BaseNeighbor = tri->RightNeighbor;
	tri->RightChild->RightNeighbor = tri->LeftChild;

	// Link our Left Neighbor to the new children
	if (tri->LeftNeighbor != NULL) {
		if (tri->LeftNeighbor->BaseNeighbor == tri)
			tri->LeftNeighbor->BaseNeighbor = tri->LeftChild;
		else if (tri->LeftNeighbor->LeftNeighbor == tri)
			tri->LeftNeighbor->LeftNeighbor = tri->LeftChild;
		else if (tri->LeftNeighbor->RightNeighbor == tri)
			tri->LeftNeighbor->RightNeighbor = tri->LeftChild;
		else
			;// Illegal Left Neighbor!
	}

	// Link our Right Neighbor to the new children
	if (tri->RightNeighbor != NULL) {
		if (tri->RightNeighbor->BaseNeighbor == tri)
			tri->RightNeighbor->BaseNeighbor = tri->RightChild;
		else if (tri->RightNeighbor->RightNeighbor == tri)
			tri->RightNeighbor->RightNeighbor = tri->RightChild;
		else if (tri->RightNeighbor->LeftNeighbor == tri)
			tri->RightNeighbor->LeftNeighbor = tri->RightChild;
		else
			;// Illegal Right Neighbor!
	}

	// Link our Base Neighbor to the new children
	if (tri->BaseNeighbor != NULL) {
		if (tri->BaseNeighbor->IsBranch()) {
			tri->BaseNeighbor->LeftChild->RightNeighbor = tri->RightChild;
			tri->BaseNeighbor->RightChild->LeftNeighbor = tri->LeftChild;
			tri->LeftChild->RightNeighbor = tri->BaseNeighbor->RightChild;
			tri->RightChild->LeftNeighbor = tri->BaseNeighbor->LeftChild;
		} else {
			Split(tri->BaseNeighbor); // Base Neighbor (in a diamond with us) was not split yet, so do that now.
		}
	} else {
		// An edge triangle, trivial case.
		tri->LeftChild->RightNeighbor = NULL;
		tri->RightChild->LeftNeighbor = NULL;
	}
}
コード例 #16
0
ファイル: Explore.c プロジェクト: aperloff/TAMUWW
static bool Explore(count iregion, cSamples *samples, cint depth, cint flags)
{
#define SPLICE (flags & 1)
#define HAVESAMPLES (flags & 2)

  TYPEDEFREGION;

  count n, dim, comp, maxcomp;
  Extrema extrema[NCOMP];
  Result *r;
  real *x, *f;
  real halfvol, maxerr;
  Region *region;
  Bounds *bounds;
  Result *result;

  /* needed as of gcc 3.3 to make gcc correctly address region #@$&! */
  sizeof(*region);

  if( SPLICE ) {
    if( nregions_ == size_ ) {
      size_ += CHUNKSIZE;
      ReAlloc(voidregion_, size_*sizeof(Region));
    }
    VecCopy(region_[nregions_].bounds, region_[iregion].bounds);
    iregion = nregions_++;
  }
  region = &region_[iregion];
  bounds = region->bounds;
  result = region->result;

  for( comp = 0; comp < ncomp_; ++comp ) {
    Extrema *e = &extrema[comp];
    e->fmin = INFTY;
    e->fmax = -INFTY;
    e->xmin = e->xmax = NULL;
  }

  if( !HAVESAMPLES ) {
    real vol = 1;
    for( dim = 0; dim < ndim_; ++dim ) {
      cBounds *b = &bounds[dim];
      vol *= b->upper - b->lower;
    }
    region->vol = vol;

    for( comp = 0; comp < ncomp_; ++comp ) {
      Result *r = &result[comp];
      r->fmin = INFTY;
      r->fmax = -INFTY;
    }

    x = xgiven_;
    f = fgiven_;
    n = ngiven_;
    if( nextra_ ) n += SampleExtra(bounds);

    for( ; n; --n ) {
      for( dim = 0; dim < ndim_; ++dim ) {
        cBounds *b = &bounds[dim];
        if( x[dim] < b->lower || x[dim] > b->upper ) goto skip;
      }
      for( comp = 0; comp < ncomp_; ++comp ) {
        Extrema *e = &extrema[comp];
        creal y = f[comp];
        if( y < e->fmin ) e->fmin = y, e->xmin = x;
        if( y > e->fmax ) e->fmax = y, e->xmax = x;
      }
skip:
      x += ldxgiven_;
      f += ncomp_;
    }

    samples->sampler(samples, bounds, vol);
  }

  x = samples->x;
  f = samples->f;
  for( n = samples->n; n; --n ) {
    for( comp = 0; comp < ncomp_; ++comp ) {
      Extrema *e = &extrema[comp];
      creal y = *f++;
      if( y < e->fmin ) e->fmin = y, e->xmin = x;
      if( y > e->fmax ) e->fmax = y, e->xmax = x;
    }
    x += ndim_;
  }
  neval_opt_ -= neval_;

  halfvol = .5*region->vol;
  maxerr = -INFTY;
  maxcomp = -1;

  for( comp = 0; comp < ncomp_; ++comp ) {
    Extrema *e = &extrema[comp];
    Result *r = &result[comp];
    real xtmp[NDIM], ftmp, err;

    if( e->xmin ) {	/* not all NaNs */
      selectedcomp_ = comp;

      sign_ = 1;
      VecCopy(xtmp, e->xmin);
      ftmp = FindMinimum(bounds, xtmp, e->fmin);
      if( ftmp < r->fmin ) {
        r->fmin = ftmp;
        VecCopy(r->xmin, xtmp);
      }

      sign_ = -1;
      VecCopy(xtmp, e->xmax);
      ftmp = -FindMinimum(bounds, xtmp, -e->fmax);
      if( ftmp > r->fmax ) {
        r->fmax = ftmp;
        VecCopy(r->xmax, xtmp);
      }
    }

    r->avg = samples->avg[comp];
    r->err = samples->err[comp];
    r->spread = halfvol*(r->fmax - r->fmin);

    err = r->spread/Max(fabs(r->avg), NOTZERO);
    if( err > maxerr ) {
      maxerr = err;
      maxcomp = comp;
    }
  }

  neval_opt_ += neval_;

  if( maxcomp == -1 ) {		/* all NaNs */
    region->depth = 0;
    return false;
  }

  region->cutcomp = maxcomp;
  r = &region->result[maxcomp];
  if( halfvol*(r->fmin + r->fmax) > r->avg ) {
    region->fminor = r->fmin;
    region->fmajor = r->fmax;
    region->xmajor = r->xmax - (real *)region->result;
  }
  else {
    region->fminor = r->fmax;
    region->fmajor = r->fmin;
    region->xmajor = r->xmin - (real *)region->result;
  }

  region->depth = IDim(depth);

  if( !HAVESAMPLES ) {
    if( samples->weight*r->spread < r->err ||
        r->spread < totals_[maxcomp].secondspread ) region->depth = 0;
    if( region->depth == 0 )
      for( comp = 0; comp < ncomp_; ++comp )
        totals_[comp].secondspread =
          Max(totals_[comp].secondspread, result[comp].spread);
  }

  if( region->depth ) Split(iregion, region->depth);
  return true;
}
コード例 #17
0
ファイル: BaseMeshSplitting.cpp プロジェクト: kbinani/dxrip
void BaseMesh::Split(Plane &p, BaseMesh &M1, BaseMesh &M2)
{
    BaseMeshPlane = p;
    Split(BaseMeshPlaneFunction, M1, M2);
}
コード例 #18
0
ファイル: Spells05.cpp プロジェクト: nemyax/ArxLibertatis
void CPoisonProjectile::Create(Vec3f _eSrc, float _fBeta)
{
	SetDuration(ulDuration);
	
	float fBetaRad = glm::radians(_fBeta);
	fBetaRadCos = glm::cos(fBetaRad);
	fBetaRadSin = glm::sin(fBetaRad);

	eSrc = _eSrc;

	bOk = false;

	eMove = Vec3f(-fBetaRadSin * 2, 0.f, fBetaRadCos * 2); 

	Vec3f tempHit;
	Vec3f dest = eSrc;

	int i = 0;
	while(Visible(eSrc, dest, &tempHit) && i < 20) {
		dest.x -= fBetaRadSin * 50;
		dest.z += fBetaRadCos * 50;

		i++;
	}

	dest.y += 0.f;

	pathways[0] = eSrc;
	pathways[9] = dest;
	
	Split(pathways, 0, 9, Vec3f(10 * fBetaRadCos, 10, 10 * fBetaRadSin));
	
	fTrail = -1;

	//-------------------------------------------------------------------------
	// système de partoches
	ParticleParams cp = ParticleParams();
	cp.m_nbMax = 5;
	cp.m_life = 2000;
	cp.m_lifeRandom = 1000;
	cp.m_pos = Vec3f_ZERO;
	cp.m_direction = -eMove * 0.1f;
	cp.m_angle = 0;
	cp.m_speed = 10;
	cp.m_speedRandom = 10;
	cp.m_gravity = Vec3f_ZERO;
	cp.m_flash = 21 * (1.f/100);
	cp.m_rotation = 1.0f / (101 - 80);
	cp.m_rotationRandomDirection = true;
	cp.m_rotationRandomStart = true;

	cp.m_startSegment.m_size = 5;
	cp.m_startSegment.m_sizeRandom = 3;
	cp.m_startSegment.m_color = Color(0, 50, 0, 40).to<float>();
	cp.m_startSegment.m_colorRandom = Color(0, 100, 0, 50).to<float>();

	cp.m_endSegment.m_size = 8;
	cp.m_endSegment.m_sizeRandom = 13;
	cp.m_endSegment.m_color = Color(0, 60, 0, 40).to<float>();
	cp.m_endSegment.m_colorRandom = Color(0, 100, 0, 50).to<float>();

	cp.m_blendMode = RenderMaterial::Screen;
	cp.m_freq = -1;
	cp.m_texture.set("graph/particles/big_greypouf", 0, 200);
	cp.m_spawnFlags = 0;
	
	pPS.SetParams(cp);
	pPS.SetPos(eSrc);
	pPS.Update(0);
}
コード例 #19
0
ファイル: WString.hpp プロジェクト: Barashuk/Moder-Funcs
//
// Specialization of Split that returns the right side of the split
//
WString WString::SplitRight ( const WString& strDelim, WString* pstrLeft, int iIndex ) const
{
    WString strRight;
    Split ( strDelim, pstrLeft, &strRight, iIndex );
    return strRight;
}
コード例 #20
0
ファイル: StdStringTest.cpp プロジェクト: buf1024/lgcbasic
void StdStringTest::testStdString()
{
    //GetAnsiString
    std::string strAnsi = GetAnsiString(L"hello");
    CPPUNIT_ASSERT(strAnsi == "hello");
    strAnsi = GetAnsiString(L"");
    CPPUNIT_ASSERT(strAnsi == "");

    //GetWideString
    std::wstring strWide = GetWideString("hello");
    CPPUNIT_ASSERT(strWide == L"hello");
    strWide = GetWideString(L"");
    CPPUNIT_ASSERT(strWide == L"");

    //GetCStyleAnsiString
    char szBuf[64] = {0};
    const char* pTmp = GetCStyleAnsiString("hello", szBuf);
    CPPUNIT_ASSERT_EQUAL(0, lstrcmpA(pTmp, "hello"));
    pTmp = GetCStyleAnsiString("", szBuf);
    CPPUNIT_ASSERT_EQUAL(0, lstrlenA(pTmp));

    //GetCStyleWideString
    wchar_t szBuf2[64] = {0};
    const wchar_t* pTmp2 = GetCStyleWideString(L"hello", szBuf2);
    CPPUNIT_ASSERT_EQUAL(0, lstrcmpW(pTmp2, L"hello"));
    pTmp2 = GetCStyleWideString(L"", szBuf2);
    CPPUNIT_ASSERT_EQUAL(0, lstrlenW(pTmp2));

    //Split
    std::string strDel = " \t";
    strAnsi = " a\t hello                         world         ";
    std::list<std::string> rgpRet;
    int nVal = Split(strAnsi, strDel, rgpRet);
    CPPUNIT_ASSERT(3 == nVal);
    CPPUNIT_ASSERT(3u == rgpRet.size());

    std::list<std::string>::iterator iter = rgpRet.begin();
    CPPUNIT_ASSERT(*iter == "a");
    iter++;
    CPPUNIT_ASSERT(*iter == "hello");
    iter++;
    CPPUNIT_ASSERT(*iter == "world");
    
    //Trim
    strAnsi = "     \t a evil world                     \t               ";
    strAnsi = TrimLeft(strAnsi, strDel);
    CPPUNIT_ASSERT(strAnsi == "a evil world                     \t               ");
    strAnsi = "     \t a evil world                     \t               ";
    strAnsi = TrimRight(strAnsi, strDel);
    CPPUNIT_ASSERT(strAnsi == "     \t a evil world");
    strAnsi = "     \t a evil world                     \t               ";
    strAnsi = Trim(strAnsi, strDel);
    CPPUNIT_ASSERT(strAnsi == "a evil world");

    //StartsWith
    strAnsi = "this is a world";
    strDel = "this";
    CPPUNIT_ASSERT(StartsWith(strAnsi, strDel));
    strDel = "his";
    CPPUNIT_ASSERT(!StartsWith(strAnsi, strDel));

    //EndsWith
    strDel = "world";
    CPPUNIT_ASSERT(EndsWith(strAnsi, strDel));
    strDel = "his";
    CPPUNIT_ASSERT(!EndsWith(strAnsi, strDel));

    //Contains
    strDel = "is";
    CPPUNIT_ASSERT(Contains(strAnsi, strDel));
    strDel = "his name";
    CPPUNIT_ASSERT(!Contains(strAnsi, strDel));

}
コード例 #21
0
ファイル: Spells09.cpp プロジェクト: fourks/ArxLibertatis
//-----------------------------------------------------------------------------
void CSummonCreature::Create(Vec3f aeSrc, float afBeta)
{
    int i;
    TexturedVertex target;

    SetDuration(ulDurationIntro, ulDurationRender, ulDurationOuttro);

    eSrc.x = aeSrc.x;
    eSrc.y = aeSrc.y - 50;
    eSrc.z = aeSrc.z;

    fBeta = afBeta;
    fBetaRad = radians(fBeta);
    fBetaRadCos = (float) cos(fBetaRad);
    fBetaRadSin = (float) sin(fBetaRad);
    sizeF = 0;
    fSizeIntro = 0.0f;
    fTexWrap = 0;
    fRand = (float) rand();
    end = 40 - 1;
    bIntro = true;

    for (i = 0; i < 40; i++)
    {
        tfRaysa[i] = 0.4f * rnd();
        tfRaysb[i] = 0.4f * rnd();
    }

    target.p.x = eSrc.x - 100;
    target.p.y = eSrc.y;
    target.p.z = eSrc.z;

    v1a[0].p.x = eSrc.x;
    v1a[0].p.y = eSrc.y - 100;
    v1a[0].p.z = eSrc.z;
    v1a[end].p.x = eSrc.x;
    v1a[end].p.y = eSrc.y + 100;
    v1a[end].p.z = eSrc.z;

    v1b[0].p.x = v1a[0].p.x;
    v1b[0].p.y = v1a[0].p.y;
    v1b[0].p.z = v1a[0].p.z;
    v1b[end].p.x = v1a[end].p.x;
    v1b[end].p.y = v1a[end].p.y;
    v1b[end].p.z = v1a[end].p.z;

    sizeF = 200;
    Split(v1a, 0, end, 20);
    Split(v1b, 0, end, -20);

    sizeF = 200;
    Split(v1a, 0, end, 80);
    Split(v1b, 0, end, -80);

    // check de la conformité du split
    // sinon recalc de l'un de l'autre ou des deux
    // espace min
    for (i = 0; i < 40; i++)
    {
        if (v1a[i].p.x > v1b[i].p.x)
        {
            float fTemp = v1a[i].p.x;
            v1a[i].p.x = v1b[i].p.x;
            v1b[i].p.x = fTemp;
        }

        if (v1a[i].p.z > v1b[i].p.z)
        {
            float fTemp = v1a[i].p.z;
            v1a[i].p.z = v1b[i].p.z;
            v1b[i].p.z = fTemp;
        }

        if ((v1b[i].p.x - v1a[i].p.x) > 20)
        {
            v1b[i].p.x = v1a[i].p.x + rnd() * 20.0f;
        }

        if ((v1b[i].p.z - v1a[i].p.z) > 20)
        {
            v1b[i].p.z = v1a[i].p.z + rnd() * 20.0f;
        }
    }

    for (i = 0; i <= end; i++)
    {
        va[i].p.x = eSrc.x;
        va[i].p.y = eSrc.y;
        va[i].p.z = eSrc.z;
        vb[i].p.x = eSrc.x;
        vb[i].p.y = eSrc.y;
        vb[i].p.z = eSrc.z;
    }

    sizeF = 0;
}
コード例 #22
0
ファイル: treesocket2.cpp プロジェクト: Canternet/inspircd
void TreeSocket::ProcessLine(std::string &line)
{
	std::string prefix;
	std::string command;
	parameterlist params;

	ServerInstance->Logs->Log(MODNAME, LOG_RAWIO, "S[%d] I %s", this->GetFd(), line.c_str());

	Split(line, prefix, command, params);

	if (command.empty())
		return;

	switch (this->LinkState)
	{
		case WAIT_AUTH_1:
			/*
			 * State WAIT_AUTH_1:
			 *  Waiting for SERVER command from remote server. Server initiating
			 *  the connection sends the first SERVER command, listening server
			 *  replies with theirs if its happy, then if the initiator is happy,
			 *  it starts to send its net sync, which starts the merge, otherwise
			 *  it sends an ERROR.
			 */
			if (command == "PASS")
			{
				/*
				 * Ignore this silently. Some services packages insist on sending PASS, even
				 * when it is not required (i.e. by us). We have to ignore this here, otherwise
				 * as it's an unknown command (effectively), it will cause the connection to be
				 * closed, which probably isn't what people want. -- w00t
				 */
			}
			else if (command == "SERVER")
			{
				this->Inbound_Server(params);
			}
			else if (command == "ERROR")
			{
				this->Error(params);
			}
			else if (command == "USER")
			{
				this->SendError("Client connections to this port are prohibited.");
			}
			else if (command == "CAPAB")
			{
				this->Capab(params);
			}
			else
			{
				this->SendError("Invalid command in negotiation phase: " + command);
			}
		break;
		case WAIT_AUTH_2:
			/*
			 * State WAIT_AUTH_2:
			 *  We have sent SERVER to the other side of the connection. Now we're waiting for them to start BURST.
			 *  The other option at this stage of things, of course, is for them to close our connection thanks
			 *  to invalid credentials.. -- w
			 */
			if (command == "SERVER")
			{
				/*
				 * Connection is either attempting to re-auth itself (stupid) or sending netburst without sending BURST.
				 * Both of these aren't allowable, so block them here. -- w
				 */
				this->SendError("You may not re-authenticate or commence netburst without sending BURST.");
			}
			else if (command == "BURST")
			{
				if (params.size())
				{
					time_t them = ConvToInt(params[0]);
					time_t delta = them - ServerInstance->Time();
					if ((delta < -600) || (delta > 600))
					{
						ServerInstance->SNO->WriteGlobalSno('l',"\2ERROR\2: Your clocks are out by %ld seconds (this is more than five minutes). Link aborted, \2PLEASE SYNC YOUR CLOCKS!\2",labs((long)delta));
						SendError("Your clocks are out by "+ConvToStr(labs((long)delta))+" seconds (this is more than five minutes). Link aborted, PLEASE SYNC YOUR CLOCKS!");
						return;
					}
					else if ((delta < -30) || (delta > 30))
					{
						ServerInstance->SNO->WriteGlobalSno('l',"\2WARNING\2: Your clocks are out by %ld seconds. Please consider synching your clocks.", labs((long)delta));
					}
				}

				// Check for duplicate server name/sid again, it's possible that a new
				// server was introduced while we were waiting for them to send BURST.
				// (we do not reserve their server name/sid when they send SERVER, we do it now)
				if (!CheckDuplicate(capab->name, capab->sid))
					return;

				FinishAuth(capab->name, capab->sid, capab->description, capab->hidden);
			}
			else if (command == "ERROR")
			{
				this->Error(params);
			}
			else if (command == "CAPAB")
			{
				this->Capab(params);
			}

		break;
		case CONNECTING:
			/*
			 * State CONNECTING:
			 *  We're connecting (OUTGOING) to another server. They are in state WAIT_AUTH_1 until they verify
			 *  our credentials, when they proceed into WAIT_AUTH_2 and send SERVER to us. We then send BURST
			 *  + our netburst, which will put them into CONNECTED state. -- w
			 */
			if (command == "SERVER")
			{
				// Our credentials have been accepted, send netburst. (this puts US into the CONNECTED state)
				this->Outbound_Reply_Server(params);
			}
			else if (command == "ERROR")
			{
				this->Error(params);
			}
			else if (command == "CAPAB")
			{
				this->Capab(params);
			}
		break;
		case CONNECTED:
			/*
			 * State CONNECTED:
			 *  Credentials have been exchanged, we've gotten their 'BURST' (or sent ours).
			 *  Anything from here on should be accepted a little more reasonably.
			 */
			this->ProcessConnectedLine(prefix, command, params);
		break;
		case DYING:
		break;
	}
}
コード例 #23
0
ファイル: Table.cpp プロジェクト: ultimatepp/mirror
void RichEdit::TableProps()
{
	if(IsSelection() || cursorp.table == 0)
		return;
	RichEditTableProperties dlg;
	dlg.Breaker(dlg.destroy, IDNO);
	RichTable::Format fmt = text.GetTableFormat(cursorp.table);
	String ratios;
	for(int i = 0; i < fmt.column.GetCount(); i++) {
		if(i)
			ratios << ':';
		ratios << "1";
	}
	dlg.ratios.SetFilter(CharFilterEqualize);
	dlg.ratios <<= ratios;
	CtrlRetriever r;
	Advn(r, dlg.before.SetUnit(unit), fmt.before);
	Advn(r, dlg.after.SetUnit(unit), fmt.after);
	Advn(r, dlg.lm.SetUnit(unit), fmt.lm);
	Advn(r, dlg.rm.SetUnit(unit), fmt.rm);
	Advn(r, dlg.frame.SetUnit(unit), fmt.frame);
	r(dlg.framecolor, fmt.framecolor);
	Advn(r, dlg.grid.SetUnit(unit), fmt.grid);
	Advn(r, dlg.header, fmt.header);
	Advn(r, dlg.keep, fmt.keep);
	Advn(r, dlg.newpage, fmt.newpage);
	Advn(r, dlg.newhdrftr, fmt.newhdrftr);
	dlg.header_qtf = fmt.header_qtf;
	dlg.footer_qtf = fmt.footer_qtf;
	r(dlg.gridcolor, fmt.gridcolor);
	dlg.SyncHdrFtr();
	dlg.newhdrftr.Enable(cursorp.level == 1);
	dlg.hdrftr.Enable(cursorp.level == 1);
	for(;;) {
		switch(dlg.Run()) {
		case IDCANCEL:
			return;
		case IDNO:
			NextUndo();
			DestroyTable();
			return;
		default:
			r.Retrieve();
			if(dlg.newhdrftr) {
				fmt.header_qtf = dlg.header_qtf;
				fmt.footer_qtf = dlg.footer_qtf;
			}
			else
				fmt.header_qtf = fmt.footer_qtf = Null;
			const RichTable& tbl = text.GetConstTable(cursorp.table);
			bool valid = true;
			Point violator(0, 0);
			int vspan = 0;
			for(int rw = 0; valid && rw < fmt.header && rw < tbl.GetRows(); rw++)
				for(int co = 0; valid && co < tbl.GetColumns(); co++)
					if(tbl(rw, co) && (vspan = tbl[rw][co].vspan) + rw > fmt.header) {
						valid = false;
						violator.x = co;
						violator.y = rw;
						break;
					}
			if(!valid) {
				Exclamation(NFormat(t_("Invalid header row count %d, cell at rw %d, co %d has vspan = %d."),
					fmt.header, violator.y + 1, violator.x + 1, vspan));
				continue;
			}
			NextUndo();
			SaveTableFormat(cursorp.table);
			if(dlg.equalize) {
				Vector<String> r = Split((String)~dlg.ratios, ':');
				for(int i = 0; i < fmt.column.GetCount(); i++)
					fmt.column[i] = i < r.GetCount() ? max(atoi(r[i]), 1) : 1;
			}
			text.SetTableFormat(cursorp.table, fmt);
			Finish();
			return;
		}
	}
}
コード例 #24
0
ファイル: macro.cpp プロジェクト: guowei8412/upp-mirror
String CppMacro::Expand(const Vector<String>& p, const Vector<String>& ep) const
{
	String r;
	const char *s = body;
	String pp = param;
	bool variadic = false;
	if(*pp.Last() == '.') {
		variadic = true;
		pp.Trim(pp.GetCount() - 1);
	}
	Index<String> param(Split(pp, ','));
	static String VA_ARGS("__VA_ARGS__"); // static - Speed optimization
	while(*s) {
		if(IsAlpha(*s) || *s == '_') {
			const char *b = s;
			s++;
			while(IsAlNum(*s) || *s == '_')
				s++;
			String id(b, s);
			const char *ss = b;
			bool cat = false;
			while(ss > ~body && ss[-1] == ' ')
				ss--;
			if(ss >= ~body + 2 && ss[-1] == '#' && ss[-2] == '#')
				cat = true;
			ss = s;
			while(*ss && *ss == ' ')
				ss++;
			if(ss[0] == '#' && ss[1] == '#')
				cat = true;
			if(id == VA_ARGS) {
				bool next = false;
				for(int i = param.GetCount(); i < ep.GetCount(); i++) {
					if(next)
						r.Cat(", ");
					r.Cat((cat ? p : ep)[i]);
					next = true;
				}
			}
			else {
				int q = param.Find(id);
				if(q >= 0) {
					if(q < ep.GetCount())
						r.Cat((cat ? p : ep)[q]);
				}
				else
					r.Cat(id);
			}
			continue;
		}
		if(s[0] == '#' && s[1] == '#') {
			int q = r.GetLength();
			while(q > 0 && IsSpc(r[q - 1]))
				q--;
			r.Trim(q);
			s += 2;
			while((byte)*s <= ' ')
				s++;
			continue;
		}
		if(*s == '#') {
			const char *ss = s + 1;
			while(IsSpc(*ss))
				ss++;
			if(IsAlpha(*ss) || *ss == '_') {
				const char *b = ss;
				ss++;
				while(IsAlNum(*ss) || *ss == '_')
					ss++;
				String id(b, ss);
				int q = param.Find(id);
				if(q >= 0) {
					if(q <= p.GetCount()) {
						if(q < p.GetCount())
							r.Cat(AsCString(p[q]));
						s = ss;
						continue;
					}
				}
				r.Cat(String(s, ss));
				s = ss;
				continue;
			}
		}
		r.Cat(*s++);
	}
	return r;
}
コード例 #25
0
ファイル: String.cpp プロジェクト: chronos38/lupus-framework
		Vector<String> String::Split(const Vector<char>& delimiter, StringSplitOptions splitOptions) const
		{
			return Split(delimiter, _length, splitOptions);
		}
コード例 #26
0
ファイル: MXTree.cpp プロジェクト: jsc0218/MxTree
void MXTree::Split(GiSTnode **node, const GiSTentry& entry)
{
	double radii[2], dist, *dists = new double[(*node)->NumEntries()*2];
	int pageNums[2], cands[2];
	vector<vector<int>> vec(2);
	((MXTnode *)(*node))->TestPromotion(radii, &dist, pageNums, cands, dists, vec);
	if (Trade((*node)->Path().IsRoot(), radii, dist, pageNums, ((MXTnode *)(*node))->GetPageNum()+1, (*node)->NumEntries())) {
		// don't split now
		delete[] dists;
		GiSTpath oldPath = (*node)->Path();

		int startPage = ((*node)->Path().IsRoot() ? rootPage : (*node)->Path().Page());
		int pageNum = ((MXTnode *)(*node))->GetPageNum();
		((MXTfile *)store)->Deallocate(startPage, pageNum);
		startPage = ((MXTfile *)store)->Allocate(++pageNum);
		(*node)->Path().MakeSibling(startPage);
		rootPage = ((*node)->Path().IsRoot() ? startPage : rootPage);
		((MXTnode *)(*node))->SetPageNum(pageNum);
		WriteNode(*node);

		if (!(*node)->Path().IsRoot() && startPage != oldPath.Page()) {
			GiSTpath parentPath = oldPath;
			parentPath.MakeParent();
			GiSTnode *parentNode = ReadNode(parentPath);
			GiSTentry *e = parentNode->SearchPtr(oldPath.Page());
			assert(e != NULL);
			int pos = e->Position();
			e->SetPtr(startPage);
			parentNode->DeleteEntry(pos);
			parentNode->InsertBefore(*e, pos);
			WriteNode(parentNode);
			delete parentNode;
			delete e;
		}
	} else {
		// split now
		bool bLeft = false, bNewRoot = false;

		if ((*node)->Path().IsRoot()) {
			bNewRoot = true;
			(*node)->Path().MakeChild(rootPage);
			rootPage = store->Allocate();
		}

		int oldPageNum = ((MXTnode *)(*node))->GetPageNum();
		GiSTnode *node2 = ((MXTnode *)(*node))->PickSplit(cands, dists, vec);
		delete[] dists;
		int curPageNum = ((MXTnode *)(*node))->GetPageNum();
		assert(oldPageNum >= curPageNum);
		if (oldPageNum > curPageNum) {
			((MXTfile *)store)->Deallocate((*node)->Path().Page()+curPageNum, oldPageNum-curPageNum);
		}
		node2->Path().MakeSibling(((MXTfile *)store)->Allocate(((MXTnode *)node2)->GetPageNum()));

		WriteNode(*node);
		WriteNode(node2);
	
		GiSTentry *e = (*node)->SearchPtr(entry.Ptr());
		if (e != NULL) {
			bLeft = true;
			delete e;
		}
	
		GiSTentry *e1 = (*node)->Union();
		GiSTentry *e2 = node2->Union();
	
		e1->SetPtr((*node)->Path().Page());
		e2->SetPtr(node2->Path().Page());
		// Create new root if root is being split
		if (bNewRoot) {
			GiSTnode *root = NewNode(this);
			root->SetLevel((*node)->Level() + 1);
			root->InsertBefore(*e1, 0);
			root->InsertBefore(*e2, 1);
			root->Path().MakeRoot();
			WriteNode(root);
			delete root;
		} else {
			// Insert entry for N' in parent
			GiSTpath parentPath = (*node)->Path();
			parentPath.MakeParent();
			GiSTnode *parent = ReadNode(parentPath);
			// Find the entry for N in parent
			GiSTentry *e = parent->SearchPtr((*node)->Path().Page());
			assert(e != NULL);
			// Insert the new entry right after it
			int pos = e->Position();
			parent->DeleteEntry(pos);
			parent->InsertBefore(*e1, pos);
			parent->InsertBefore(*e2, pos+1);
			delete e;
			if (!parent->IsOverFull(*store)) {
				WriteNode(parent);
			} else {
				Split(&parent, bLeft? *e1: *e2);  // parent is the node which contains the entry inserted
				GiSTpage page = (*node)->Path().Page();
				(*node)->Path() = parent->Path();  // parent's path may change
				(*node)->Path().MakeChild(page);
				page = node2->Path().Page();
				node2->Path() = (*node)->Path();
				node2->Path().MakeSibling(page);
			}
			delete parent;
		}
		if (!bLeft) {
			delete *node;
			*node = node2;  // return it
		} else {
			delete node2;
		}
		delete e1;
		delete e2;
	}
}
コード例 #27
0
ファイル: GiST.cpp プロジェクト: voidcycles/m3
void 
GiST::Split(GiSTnode **node, const GiSTentry& entry)
{
	int went_left=0, new_root=0;

	if((*node)->Path().IsRoot()) {
		new_root=1;
		(*node)->Path().MakeChild(store->Allocate());
	}

	GiSTnode *node2=(*node)->PickSplit();
	node2->Path().MakeSibling(store->Allocate());
	GiSTentry *e=(*node)->SearchPtr(entry.Ptr());

	if(e!=NULL) {
		went_left=1;
		delete e;
	}
	node2->SetSibling((*node)->Sibling());
	(*node)->SetSibling(node2->Path().Page());
	WriteNode(*node);
	WriteNode(node2);

	GiSTentry *e1=(*node)->Union();
	GiSTentry *e2=node2->Union();

	e1->SetPtr((*node)->Path().Page());
	e2->SetPtr(node2->Path().Page());
	// Create new root if root is being split
	if (new_root) {
		GiSTnode *root=NewNode(this);

		root->SetLevel((*node)->Level()+1);
		root->InsertBefore(*e1, 0);
		root->InsertBefore(*e2, 1);
		root->Path().MakeRoot();
		WriteNode(root);
		delete root;
	}
	else {
		// Insert entry for N' in parent
		GiSTpath parent_path=(*node)->Path();
		parent_path.MakeParent();
		GiSTnode *parent=ReadNode(parent_path);
		// Find the entry for N in parent
		GiSTentry *e=parent->SearchPtr((*node)->Path().Page());
		assert(e!=NULL);
		// Insert the new entry right after it
		int pos=e->Position();

		parent->DeleteEntry(pos);
		parent->InsertBefore(*e1, pos);
		parent->InsertBefore(*e2, pos+1);
		delete e;
		if(!parent->IsOverFull(*store)) WriteNode(parent);
		else {
			Split(&parent, went_left? *e1: *e2);
			GiSTpage page=(*node)->Path().Page();

			(*node)->Path()=parent->Path();
			(*node)->Path().MakeChild(page);
			page=node2->Path().Page();
			node2->Path()=(*node)->Path();
			node2->Path().MakeSibling(page);
		}
		delete parent;
	}
	if(!went_left) {
		delete *node;
		*node=node2;
	}
	else delete node2;
	delete e1;
	delete e2;
}
コード例 #28
0
/*
====================
idSurface_Polytope::SplitPolytope
====================
*/
int idSurface_Polytope::SplitPolytope( const idPlane &plane, const float epsilon, idSurface_Polytope **front, idSurface_Polytope **back ) const {
	int side, i, j, s, v0, v1, v2, edgeNum;
	idSurface *surface[2];
	idSurface_Polytope *polytopeSurfaces[2], *surf;
	int *onPlaneEdges[2];

	onPlaneEdges[0] = (int *) _alloca( indexes.Num() / 3 * sizeof( int ) );
	onPlaneEdges[1] = (int *) _alloca( indexes.Num() / 3 * sizeof( int ) );

	side = Split( plane, epsilon, &surface[0], &surface[1], onPlaneEdges[0], onPlaneEdges[1] );

	*front = polytopeSurfaces[0] = new (TAG_IDLIB_SURFACE) idSurface_Polytope;
	*back = polytopeSurfaces[1] = new (TAG_IDLIB_SURFACE) idSurface_Polytope;

	for ( s = 0; s < 2; s++ ) {
		if ( surface[s] ) {
			polytopeSurfaces[s] = new idSurface_Polytope( *surface[s] );
			delete surface[s];
			surface[s] = NULL;
		}
	}

	*front = polytopeSurfaces[0];
	*back = polytopeSurfaces[1];

	if ( side != SIDE_CROSS ) {
		return side;
	}

	// add triangles to close off the front and back polytope
	for ( s = 0; s < 2; s++ ) {

		surf = polytopeSurfaces[s];

		edgeNum = surf->edgeIndexes[onPlaneEdges[s][0]];
		v0 = surf->edges[abs(edgeNum)].verts[INT32_SIGNBITSET(edgeNum)];
		v1 = surf->edges[abs(edgeNum)].verts[INT32_SIGNBITNOTSET(edgeNum)];

		for ( i = 1; onPlaneEdges[s][i] >= 0; i++ ) {
			for ( j = i+1; onPlaneEdges[s][j] >= 0; j++ ) {
				edgeNum = surf->edgeIndexes[onPlaneEdges[s][j]];
				if ( v1 == surf->edges[abs(edgeNum)].verts[INT32_SIGNBITSET(edgeNum)] ) {
					v1 = surf->edges[abs(edgeNum)].verts[INT32_SIGNBITNOTSET(edgeNum)];
					SwapValues( onPlaneEdges[s][i], onPlaneEdges[s][j] );
					break;
				}
			}
		}

		for ( i = 2; onPlaneEdges[s][i] >= 0; i++ ) {
			edgeNum = surf->edgeIndexes[onPlaneEdges[s][i]];
			v1 = surf->edges[abs(edgeNum)].verts[INT32_SIGNBITNOTSET(edgeNum)];
			v2 = surf->edges[abs(edgeNum)].verts[INT32_SIGNBITSET(edgeNum)];
			surf->indexes.Append( v0 );
			surf->indexes.Append( v1 );
			surf->indexes.Append( v2 );
		}

		surf->GenerateEdgeIndexes();
	}

	return side;
}
コード例 #29
0
ファイル: GEOMLOAD.C プロジェクト: Killaz/SUM2014
/* Функция загрузки материала.
 * АРГУМЕНТЫ:
 *   - геометрический объект:
 *       as4GEOM *G;
 *   - имя файла материалов:
 *       CHAR *FileName;
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
*/
static VOID LoadMaterials( as4GEOM *G, CHAR *FileName )
{
  FILE *F;
  as4MATERIAL DefMat, Mat;
  static CHAR FName[_MAX_PATH];

  _makepath(FName, ModelDrive, ModelDir, FileName, "");
  if ((F = fopen(FName, "r")) == NULL)
    return;

  DefMat.Ka = VecSet(0.1, 0.1, 0.1);
  DefMat.Kd = VecSet(0.9, 0.9, 0.9);
  DefMat.Ks = VecSet(0.0, 0.0, 0.0);
  DefMat.Phong = 30;
  DefMat.TexNo = 0;
  DefMat.Trans = 1;
  strcpy(DefMat.Name, "Default Material SPR 2014");
  DefMat.MapD[0] = 0;
  Mat = DefMat;

  /* считываем все сроки */
  while (fgets(Buf, sizeof(Buf), F) != NULL)
  {
    Split();
    if (NumOfParts > 1)
      if (strcmp(Parts[0], "Ka") == 0)
      {
        sscanf(Parts[1], "%f", &Mat.Ka.x);
        sscanf(Parts[2], "%f", &Mat.Ka.y);
        sscanf(Parts[3], "%f", &Mat.Ka.z);
      }
      else if (strcmp(Parts[0], "Kd") == 0)
      {
        sscanf(Parts[1], "%f", &Mat.Kd.x);
        sscanf(Parts[2], "%f", &Mat.Kd.y);
        sscanf(Parts[3], "%f", &Mat.Kd.z);
      }
      else if (strcmp(Parts[0], "Ks") == 0)
      {
        sscanf(Parts[1], "%f", &Mat.Ks.x);
        sscanf(Parts[2], "%f", &Mat.Ks.y);
        sscanf(Parts[3], "%f", &Mat.Ks.z);
      }
      else if (strcmp(Parts[0], "Ns") == 0)
        sscanf(Parts[1], "%f", &Mat.Phong);
      else if (strcmp(Parts[0], "D") == 0 ||
               strcmp(Parts[0], "d") == 0 ||
               strcmp(Parts[0], "Tr") == 0)
        sscanf(Parts[1], "%f", &Mat.Trans);
      else if (strcmp(Parts[0], "map_Kd") == 0)
      {
        _splitpath(Parts[NumOfParts - 1], TexDrive, TexDir, TexFileName, TexFileExt);
        _makepath(Mat.MapD, ModelDrive, ModelDir, TexFileName, ".bmp");
      }
      else if (strcmp(Parts[0], "newmtl") == 0)
      {
        AS4_GeomAddMaterial(G, &Mat);
        Mat = DefMat;
        strncpy(Mat.Name, Parts[1], sizeof(Mat.Name) - 1);
      }
  }
  AS4_GeomAddMaterial(G, &Mat);
  fclose(F);
} /* End of 'LoadMaterials' function */
コード例 #30
0
ファイル: lpd_secure.c プロジェクト: Distrotech/lprng
/*************************************************************************
 * Receive_secure() - receive a secure transfer
 *************************************************************************/
int Receive_secure( int *sock, char *input )
{
	char *printername;
	char error[SMALLBUFFER];	/* error message */
	char *authtype;
	char *cf, *s;
	char *jobsize = 0;
	char *user = 0;
	int tempfd = -1;
	int ack, status, from_server;
	struct line_list args, header_info, info;
	struct stat statb;
	char *tempfile = 0;
	const struct security *security = 0;

	Name = "RCVSEC";
	memset( error, 0, sizeof(error));
	ack = 0;
	status = 0;

	DEBUGF(DRECV1)("Receive_secure: input line '%s'", input );
	Init_line_list( &args );
	Init_line_list( &header_info );
	Init_line_list( &info );

	Split(&args,input+1,Whitespace,0,0,0,0,0,0);
	DEBUGFC(DRECV1)Dump_line_list("Receive_secure - input", &args);
	if( args.count != 5 && args.count != 4 ){
		plp_snprintf( error+1, sizeof(error)-1,
			_("bad command line '%s'"), input );
		ack = ACK_FAIL;	/* no retry, don't send again */
		status = JFAIL;
		goto error;
	}
	Check_max(&args,1);
	args.list[args.count] = 0;

	/*
     * \REQ_SECUREprintername C/F user authtype jobsize\n - receive a job
     *              0           1   2  3        4
	 */
	printername = args.list[0];
	cf = args.list[1];
	user = args.list[2];	/* user is escape encoded */
	Unescape(user);
	authtype = args.list[3];
	Unescape(authtype);
	jobsize = args.list[4];

	setproctitle( "lpd %s '%s'", Name, printername );

	Perm_check.authtype = authtype;
	from_server = 0;
	if( *cf == 'F' ){
		from_server = 1;
	}

	/* set up the authentication support information */

	if( Is_clean_name( printername ) ){
		plp_snprintf( error+1, sizeof(error)-1,
			_("bad printer name '%s'"), input );
		ack = ACK_FAIL;	/* no retry, don't send again */
		status = JFAIL;
		goto error;
	}

	Set_DYN(&Printer_DYN,printername);

	if( Setup_printer( printername, error+1, sizeof(error)-1, 0 ) ){
		if( jobsize ){
			plp_snprintf( error+1, sizeof(error)-1,
				_("bad printer '%s'"), printername );
			ack = ACK_FAIL;	/* no retry, don't send again */
			status = JFAIL;
			goto error;
		}
	} else {
		int db, dbf;

		db = Debug;
		dbf = DbgFlag;
		s = Find_str_value(&Spool_control,DEBUG);
		if(!s) s = New_debug_DYN;
		Parse_debug( s, 0 );

		if( !(DRECVMASK & DbgFlag) ){
			Debug = db;
			DbgFlag = dbf;
		} else {
			int tdb, tdbf;
			tdb = Debug;
			tdbf = DbgFlag;
			Debug = db;
			DbgFlag = dbf;
			if( Log_file_DYN ){
				tempfd = Checkwrite( Log_file_DYN, &statb,0,0,0);
				if( tempfd > 0 && tempfd != 2 ){
					dup2(tempfd,2);
					close(tempfd);
				}
				tempfd = -1;
			}
			Debug = tdb;
			DbgFlag = tdbf;
			LOGDEBUG("Receive_secure: socket fd %d", *sock);
			Dump_line_list("Receive_secure - input", &args);
		}
		DEBUGF(DRECV1)("Receive_secure: debug '%s', Debug %d, DbgFlag 0x%x",
			s, Debug, DbgFlag );
	}

	if( !(security = Fix_receive_auth(authtype, &info)) ){
		plp_snprintf( error+1, sizeof(error)-1,
			_("unsupported authentication '%s'"), authtype );
		ack = ACK_FAIL;	/* no retry, don't send again */
		status = JFAIL;
		goto error;
	}
	if( !security->server_receive ){
		plp_snprintf( error+1, sizeof(error)-1,
			_("no receive method supported for '%s'"), authtype );
		ack = ACK_FAIL;	/* no retry, don't send again */
		status = JFAIL;
		goto error;
	}


	if( jobsize ){
		double read_len;
		read_len = strtod(jobsize,0);

		DEBUGF(DRECV2)("Receive_secure: spooling_disabled %d",
			Sp_disabled(&Spool_control) );
		if( Sp_disabled(&Spool_control) ){
			plp_snprintf( error+1, sizeof(error)-1,
				_("%s: spooling disabled"), Printer_DYN );
			ack = ACK_RETRY;	/* retry */
			status = JFAIL;
			goto error;
		}
		if( Max_job_size_DYN > 0 && (read_len+1023)/1024 > Max_job_size_DYN ){
			plp_snprintf( error+1, sizeof(error)-1,
				_("%s: job size %0.0f is larger than %d K"),
				Printer_DYN, read_len, Max_job_size_DYN );
			ack = ACK_RETRY;
			status = JFAIL;
			goto error;
		} else if( !Check_space( read_len, Minfree_DYN, Spool_dir_DYN ) ){
			plp_snprintf( error+1, sizeof(error)-1,
				_("%s: insufficient file space"), Printer_DYN );
			ack = ACK_RETRY;
			status = JFAIL;
			goto error;
		}
	}

	tempfd = Make_temp_fd(&tempfile);
	close(tempfd); tempfd = -1;

	DEBUGF(DRECV1)("Receive_secure: sock %d, user '%s', jobsize '%s'",  
		*sock, user, jobsize );

	status = security->server_receive( sock, Send_job_rw_timeout_DYN,
		user, jobsize, from_server, authtype,
		&info,
		error+1, sizeof(error)-1,
		&header_info,
		security, tempfile, Do_secure_work);

 error:
	DEBUGF(DRECV1)("Receive_secure: status %d, ack %d, error '%s'",
		status, ack, error+1 );

	if( status ){
		if( ack == 0 ) ack = ACK_FAIL;
		error[0] = ack;
		DEBUGF(DRECV1)("Receive_secure: sending '%s'", error );
		(void)Link_send( ShortRemote_FQDN, sock,
			Send_query_rw_timeout_DYN, error, safestrlen(error), 0 );
		Errorcode = JFAIL;
	}

	Free_line_list( &args );
	Free_line_list( &header_info );
	Free_line_list( &info );

	close( *sock ); *sock = -1;
	Remove_tempfiles();

	if( status == 0 && jobsize ){
		/* start a new server */
		DEBUGF(DRECV1)("Receive_secure: starting server");
		if( Server_queue_name_DYN ){
			Do_queue_jobs( Server_queue_name_DYN, 0 );
		} else {
			Do_queue_jobs( Printer_DYN, 0 );
		}
	}
	cleanup(0);
}