当前位置: 首页>>代码示例>>C++>>正文


C++ Split函数代码示例

本文整理汇总了C++中Split函数的典型用法代码示例。如果您正苦于以下问题:C++ Split函数的具体用法?C++ Split怎么用?C++ Split使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Split函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

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
                                    {
//.........这里部分代码省略.........
开发者ID:fastbird,项目名称:fastbirdEngine_NewAPI,代码行数:101,代码来源:ImageBox.cpp

示例2: VG4_GeomLoad

/* Функция загрузки геометрического объекта.
 * АРГУМЕНТЫ:
 *   - геометрический объект:
 *       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] == ' ')
    {
//.........这里部分代码省略.........
开发者ID:svyatoslav777,项目名称:sum2014,代码行数:101,代码来源:GEOMLOAD.C

示例3: SetDuration

//-----------------------------------------------------------------------------
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;
//.........这里部分代码省略.........
开发者ID:OpenSourcedGames,项目名称:Arx-Fatalis,代码行数:101,代码来源:ARX_SpellFX_Lvl05.cpp

示例4: SetDuration

//-----------------------------------------------------------------------------
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;
//.........这里部分代码省略.........
开发者ID:fourks,项目名称:ArxLibertatis,代码行数:101,代码来源:Spells09.cpp

示例5: SetDuration

//-----------------------------------------------------------------------------
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;
//.........这里部分代码省略.........
开发者ID:Eli2,项目名称:ArxLibertatis,代码行数:101,代码来源:Spells05.cpp

示例6: Split

Vector String::Split(const string &delimiter) const
{
    Vector splitted;
    Split(delimiter, splitted);
    return splitted;
}
开发者ID:contactless,项目名称:rfsniffer,代码行数:6,代码来源:strutils.cpp

示例7: TrimBoth

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) {
//.........这里部分代码省略.........
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:101,代码来源:Navigator.cpp

示例8: Split

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;
}
开发者ID:grainrigi,项目名称:jscripts,代码行数:97,代码来源:IniFile.cpp

示例9: SetDuration

//-----------------------------------------------------------------------------
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;
//.........这里部分代码省略.........
开发者ID:Eli2,项目名称:ArxLibertatis,代码行数:101,代码来源:Spells03.cpp

示例10: Split

Vector<String> Split(const char *s, const char *text, bool ignoreempty)
{
    return Split(INT_MAX, s, text, ignoreempty);
}
开发者ID:koz4k,项目名称:soccer,代码行数:4,代码来源:SplitMerge.cpp

示例11: SpellHit

 void SpellHit(Unit* /*caster*/, const SpellInfo* spell)
 {
     if (spell->Id == SPELL_DISPERSE)
         Split();
 }
开发者ID:Matt-One,项目名称:azerothcore-wotlk,代码行数:5,代码来源:boss_ionar.cpp

示例12: Split

// -------------------------------------------------------------------------------------------------
// 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;
    }
}
开发者ID:FriedRice,项目名称:spring,代码行数:70,代码来源:Patch.cpp

示例13: Explore


//.........这里部分代码省略.........
        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;
}
开发者ID:aperloff,项目名称:TAMUWW,代码行数:101,代码来源:Explore.c

示例14: Split

void BaseMesh::Split(Plane &p, BaseMesh &M1, BaseMesh &M2)
{
    BaseMeshPlane = p;
    Split(BaseMeshPlaneFunction, M1, M2);
}
开发者ID:kbinani,项目名称:dxrip,代码行数:5,代码来源:BaseMeshSplitting.cpp

示例15: SetDuration

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);
}
开发者ID:nemyax,项目名称:ArxLibertatis,代码行数:70,代码来源:Spells05.cpp


注:本文中的Split函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。