コード例 #1
0
ファイル: MainScene.cpp プロジェクト: aababy/Tool
void MainScene::error(CCObject *sender)
{
    m_lError->setVisible(true);
    
    string text = xSkill->m_sError + xStr("error_no_attack_frame");
    
    m_lError->setText(text);
    
    scheduleOnce(schedule_selector(MainScene::errorDisable), 5.f);
}
コード例 #2
0
ファイル: MainScene.cpp プロジェクト: aababy/Tool
void MainScene::updateProperty(CCObject *sender)
{
    if (xCurAtk == NULL || xCurAtk->getPartsCount() == 0) {
        return;
    }
    
    char buffer[20];
    const CCPoint po = xCurAtk->getCurPosition();
    sprintf(buffer, "%.1f", po.x);
    m_ebPosition[0]->setText(string(buffer));
    sprintf(buffer, "%.1f", po.y);
    m_ebPosition[1]->setText(string(buffer));
    
    const CCPoint point = xCurAtk->getCurAnchorPoint();
    sprintf(buffer, "%.1f", point.x);
    m_ebAnchor[0]->setText(string(buffer));
    sprintf(buffer, "%.1f", point.y);
    m_ebAnchor[1]->setText(string(buffer));
    
    sprintf(buffer, "%.1f", xCurAtk->getCurRotate());
    m_ebRotate->setText(string(buffer));
    
    sprintf(buffer, "%.1f", xCurAtk->getCurScale());
    m_ebScale->setText(string(buffer));
    
    sprintf(buffer, "%.2f", xCurAtk->getDelay(xSkill->m_iCurIndex));
    m_ebDelay->setText(string(buffer));
    
    sprintf(buffer, "%.2f", xCurAtk->getDegree());
    m_ebDegree->setText(string(buffer));
    
    sprintf(buffer, "%.2f", xCurAtk->getSpeed());
    m_ebSpeed->setText(string(buffer));    
    
    sprintf(buffer, "%.2f", xCurAtk->getDuration());
    m_ebAttackDuration->setText(string(buffer));
    
    sprintf(buffer, "%.2f", xCurAtk->getInterval());
    m_ebAttackInterval->setText(string(buffer));

    sprintf(buffer, "%d", xCurAtk->getFlags(FI_BULLET_TYPE));
    m_ebBulletType->setText(string(buffer));
    
    //音效文件
    string audio = xCurAtk->getAudio(xSkill->m_iCurIndex);
    if (!audio.empty()) {
        _btnAddAudio->setTitleText(audio);
    }
    else
    {
        _btnAddAudio->setTitleText(xStr("add_audio"));
    }
}
コード例 #3
0
ファイル: lspMap.C プロジェクト: srharris91/Katz_Work
void StrandBlockSolver::lspMap()
{
  int mm,nn,jj,ii,j1,j2,jm,jmax,nmax,info,ldu,ldvt,rows,cols,lwork;
  double dsm,dx,dy,ds,w,r1,r2,rs,cond,rcond,xn,yn,ax,ay,xu,xl,bu,bl,xcn,ycn;
  double b[4];
  double* sv;
  double* work1;
  double* uu;
  double* vt;
  double* dr;
  double** lspT;
  char u='U',jobu='n',jobvt='a';
  cond = 0.;
  ldu  = 1;
  ldvt = 2;
  cols = 2;

  for (int n=0; n<nNodes-nGnodes; n++){
    mm    = ncsp(n);
    rows  = mm;
    ii    = cols;
    if (rows < ii) ii = rows;
    jj    = cols;
    if (rows > jj) jj = rows;
    lwork = 1;
    if (3*ii+jj > lwork) lwork = 3*ii+jj;
    if (5*ii    > lwork) lwork = 5*ii;
    uu    = new double[ldu*ldu];
    sv    = new double[cols];
    vt    = new double[ldvt*cols];
    work1 = new double[lwork];
    dr    = new double[rows*2];
    lspT  = new double*[nPstr+1];
    for (int j=0; j<nPstr+1; j++) lspT[j] = new double[rows];
    rcond = 0.;
    info  = 0;
    for (int m=0; m<ldu*ldu;   m++) uu   [m] = 0.;
    for (int m=0; m<cols;      m++) sv   [m] = 0.;
    for (int m=0; m<ldvt*cols; m++) vt   [m] = 0.;
    for (int m=0; m<lwork;     m++) work1[m] = 0.;
    double work [2] = {0.,0.};
    double work2[4] = {0.,0.,0.,0.};
    int    iwork[2] = {0,0};
    int    ipiv [2] = {0,0};

  for (int j=1; j<nPstr+1; j++){ //mid strand nodes

    // coordinates of the mid-strand location in question
    jm = j-1;
    xn = .5*(x(0,j,n)+x(0,jm,n));
    yn = .5*(x(1,j,n)+x(1,jm,n));

    // find data centroid
    xcn = 0.;
    ycn = 0.;
    for (int m=0; m<mm; m++){
      nn  = csp[n][m];
      xcn = xcn+xc(0,j,nn);
      ycn = ycn+xc(1,j,nn);
    }
    xcn = xcn/double(mm);
    ycn = ycn/double(mm);

    // find plane which most closely fits surrounding cell centers
    for (int m=0; m<mm; m++){
      nn       = csp[n][m];
      dr[m   ] = xc(0,j,nn)-xcn;
      dr[m+mm] = xc(1,j,nn)-ycn;
    }
    sgesvd_(jobu,jobvt,rows,cols,dr,rows,sv,uu,ldu,vt,ldvt,work1,lwork,info);
    if (info != 0){
      cout << "\n*** svd procedure failure in lspMap ***" << endl;
      exit(0);
    }
    ax = vt[0];
    ay = vt[2];
    ds = 1./sqrt(ax*ax+ay*ay);
    ax = ax*ds;
    ay = ay*ds;

    // compute 2d least squares problem with projected distances
    // largest distance in stencil
    dsm = 0.;
    for (int m=0; m<mm; m++){
      nn  = csp[n][m];
      dx  = xc(0,j,nn)-xn;
      dy  = xc(1,j,nn)-yn;
      ds  = dx*ax+dy*ay;
      ds  = ds*ds;
      if (ds > dsm) dsm = ds;
    }
    dsm = 1./sqrt(dsm);

    // form least squares matrix
    jj  = jm;
    for (int m=0; m<4; m++) b[m] = 0.;
    for (int m=0; m<mm; m++){
      nn   = csp[n][m];
      dx  = xc(0,j,nn)-xn;
      dy  = xc(1,j,nn)-yn;
      ds   =(dx*ax+dy*ay)*dsm;
      w    = 1./(ds*ds);
      b[0] = b[0]+w;
      b[2] = b[2]+w*ds;
      b[3] = b[3]+w*ds*ds;
    }

    // find max abs row sum for condition number computation
    r1 = fabs(b[0])+fabs(b[2]);
    r2 = fabs(b[1])+fabs(b[3]);
                 rs = r1;
    if (r2 > rs) rs = r2;

    // invert matrix and determine condition number
    ii = 2;
    ssytrf_(u,ii,b,ii,ipiv,work,ii,info);
    ssycon_(u,ii,b,ii,ipiv,rs,rcond,work2,iwork,info);
    ssytri_(u,ii,b,ii,ipiv,work,info);
    rcond = 1./rcond;
    if (rcond > cond){
      nmax = n;
      jmax = j;
      cond = rcond;
    }
    
    // form and store least squares coefficient
    for (int m=0; m<mm; m++){
      nn         = csp[n][m];
      dx         = xc(0,j,nn)-xn;
      dy         = xc(1,j,nn)-yn;
      ds         =(dx*ax+dy*ay)*dsm;
      w          = 1./(ds*ds);
      lspT[j][m] =(b[0]*w    +
                   b[2]*w*ds);
    }
  }

  // interpolate projected coefficients to the nodal positions along each strand
  for (int j=0; j<nPstr+1; j++){
    if      (j == 0    ){
      j1 = 1;
      j2 = 2;
    }
    else if (j == nPstr){
      j1 = nPstr-1;
      j2 = nPstr;
    }
    else{
      j1 = j;
      j2 = j+1;
    }
    xn = xStr(j);
    jm = j1-1;
    xl = .5*(xStr(jm)+xStr(j1));
    jm = j2-1;
    xu = .5*(xStr(jm)+xStr(j2));
    bl =(xu-xn)/(xu-xl);
    bu =(xn-xl)/(xu-xl);
    indlsp(0,j,n,ii);
    for (int m=0; m<mm; m++){
      lsp[ii  ][m] = bl*lspT[j1][m];
      lsp[ii+1][m] = bu*lspT[j2][m];
    }
  }

  delete [] sv;
  delete [] uu;
  delete [] vt;
  delete [] work1;
  delete [] dr;
  for (int j=0; j<nPstr+1; j++) delete [] lspT[j];
  delete [] lspT;
  }

  // output condition information
  xn = x(0,jmax,nmax);
  yn = x(1,jmax,nmax);
  cout << "\nMaximum condition number for LS procedure: "
       << cond << endl
       << "Index of maximum condition number: "
       << nmax << "\t" << jmax << endl
       << "Coordinates of maximum condition number: "
       << xn << "\t" << yn << "\n" << endl;



  /*
  // try using volume averaging on outer boundary nodes
  for (int n=0; n<nNodes-nGnodes; n++){
    mm = ncsp(n);
  for (int j=nPstr; j<nPstr+1; j++){
    if      (j == 0    ) jj = 1;
    else if (j == nPstr) jj = nPstr-1;
    else                 jj = j;

    w  = 0.;
    for (int k=0; k<2; k++){
      indlsp(k,j,n,ii);
    for (int m=0; m<mm; m++){
      nn = csp[n][m];
      lsp[ii][m] = v(jj,nn);
      w         += v(jj,nn);
    }
    jj++;
    }

    w = 1./w;
    for (int k=0; k<2; k++){
      indlsp(k,j,n,ii);
    for (int m=0; m<mm; m++){
      lsp[ii][m] = lsp[ii][m]*w;
    }}}}
  */
}
コード例 #4
0
ファイル: MainScene.cpp プロジェクト: aababy/Tool
bool MainScene::init(CCScene* pScene)
{
    iBGIndex = 1;
    m_scene = pScene;
    
    if (CCLayer::init())
    {      
        m_rootNode = (NodeReader::getInstance()->createNode("R/MainScene_1.json"));
        addChild(m_rootNode);
        
        Layout *root = static_cast<Layout*>(m_rootNode->getChildren()->objectAtIndex(0));
        m_root = root;
        
        btnImport = initButton(BUTTON_IMPORT, root, this, toucheventselector(MainScene::touchEvent));
		btnImport->setTitleText(xStr("start"));
        initButton(BUTTON_PRV, root, this, toucheventselector(MainScene::touchEvent));
        initButton(BUTTON_NEXT, root, this, toucheventselector(MainScene::touchEvent));
        initButton(BUTTON_PREVIEW, root, this, toucheventselector(MainScene::touchEvent));
        initButton(BUTTON_REMOVE, root, this, toucheventselector(MainScene::touchEvent));
        initButton(BUTTON_CLEAN, root, this, toucheventselector(MainScene::touchEvent));
        initButton(BUTTON_SAVE, root, this, toucheventselector(MainScene::touchEvent));
        initButton(BUTTON_PREVIEW_ALL, root, this, toucheventselector(MainScene::touchEvent));
        initButton(CHANGE_BG, root, this, toucheventselector(MainScene::touchEvent));
        initButton(MOTION_PREVIEW, root, this, toucheventselector(MainScene::touchEvent));
        Button * btn = initButton(APPLY_TO_ALL, root, this, toucheventselector(MainScene::touchEvent));
        btn->setScale(0.5f);

        btn2x = initButton(BUTTON_2X, root, this, toucheventselector(MainScene::touchEvent));
        btn2x->setScale(0.3f, 0.5f);
        btnAddMotion = initButton(BUTTON_ADD_MOTION, root, this, toucheventselector(MainScene::touchEvent));
        btnAddMotion->setEnabled(false);
        btnDelMotion = initButton(BUTTON_DEL_MOTION, root, this, toucheventselector(MainScene::touchEvent));
        
        btnPre5 = initButton(BUTTON_PRV_5, root, this, toucheventselector(MainScene::touchEvent));
        btnNext5 = initButton(BUTTON_NEXT_5, root, this, toucheventselector(MainScene::touchEvent));
        
        //输入区
        m_ebAnchor[0] = InputBox::create(ANCHOR_X, root, this, m_rootNode);
        m_ebAnchor[1] = InputBox::create(ANCHOR_Y, root, this, m_rootNode);
        m_ebPosition[0] = InputBox::create(POSITION_X, root, this, m_rootNode);
        m_ebPosition[1] = InputBox::create(POSITION_Y, root, this, m_rootNode);
        m_ebRotate = InputBox::create(ROTATE, root, this, m_rootNode);
        m_ebScale = InputBox::create(SCALE, root, this, m_rootNode);
        m_ebDelay = InputBox::create(DELAY, root, this, m_rootNode);
        m_ebName = InputBox::create(SKILL_PART_NAME, root, this, m_rootNode);
        m_ebDegree = InputBox::create(DEGREE, root, this, m_rootNode);
        m_ebSpeed = InputBox::create(SPEED, root, this, m_rootNode);
        m_ebAttackDuration = InputBox::create(ATTACK_DURATION, root, this, m_rootNode);
        m_ebAttackInterval = InputBox::create(ATTACK_INTERVAL, root, this, m_rootNode);
        m_ebBulletType = InputBox::create(BULLET_TYPE, root, this, m_rootNode);
        m_ebBulletType->setText("0");

        m_pHolder = static_cast<CCSprite*>(m_rootNode->getChildByTag(SPRITE_HOLDER));
        m_pHolder->initWithFile("R/cross.png");
        m_iFrameBG = (ImageView*)UIHelper::seekWidgetByTag(root, FRAME_BG);
        m_iFrameBG->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));

        m_iPreviewBG = (ImageView*)UIHelper::seekWidgetByTag(root, PREVIEW_BG);
        m_iPreviewBG->loadTexture("R/bg_1.jpg");
        m_iPreviewBG->setPosition(ccp(m_iPreviewBG->getPositionX() - 240, m_iPreviewBG->getPositionY()));
        m_iPreviewBG1 = ImageView::create();
        m_iPreviewBG1->loadTexture("R/bg_1.jpg");
        m_iPreviewBG1->setPosition(ccp(1440, 0));
        m_iPreviewBG->addChild(m_iPreviewBG1);
        
        m_lFrameCount = (Label*)UIHelper::seekWidgetByTag(root, LABEL_FRAME_COUNT);
        m_preview = static_cast<CCSprite*>(m_rootNode->getChildByTag(PREVIEW));
        m_preview->initWithFile("R/cross.png");
        m_preview->setVisible(false);
        
        xSkill->init(m_pHolder->getPosition(), m_preview->getPosition(), m_rootNode);
        
        //checkbox
        m_cbFlags[0] = initCheckBox(177, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));
        m_cbFlags[1] = initCheckBox(179, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));
        m_cbFlags[2] = initCheckBox(183, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));
        m_cbFlags[3] = initCheckBox(185, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));
        m_cbFlags[4] = initCheckBox(187, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));
        m_cbFlags[5] = initCheckBox(ISOLATE, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));
        m_cbFlags[6] = NULL;    //FI_BULLET_TYPE
        m_cbFlags[7] = initCheckBox(HIGH_LIGHT, root, this, checkboxselectedeventselector(MainScene::selectedStateEvent));

        m_cbNormal = initCheckBox(NORMAL_ATTACK, root, this, checkboxselectedeventselector(MainScene::selectedNormal));
        CCUserDefault::sharedUserDefault()->setBoolForKey(NORMAL, false);
        
        m_cbAttack = initCheckBox(ATTACK_FRAME, root, this, checkboxselectedeventselector(MainScene::selectedAttackFrame));
        
        m_lError = (Label*)(UIHelper::seekWidgetByTag(root, LABEL_ERROR));
        m_lError->setVisible(false);
        
        //列表
        listView = (UIListView*)UIHelper::seekWidgetByTag(root, PARTS_LIST);
        CCNode *node = (NodeReader::getInstance()->createNode("R/FolderBrowser_2.ExportJson"));
        listroot = static_cast<Layout*>(node->getChildren()->objectAtIndex(0));
        Layout* defaultItem = (Layout*)UIHelper::seekWidgetByTag(listroot, 32);         //还有转一层, 一来至少加2个Panel
        listView->setItemModel(defaultItem);
        
        _listAudio = (UIListView*)UIHelper::seekWidgetByTag(root, T_LIST_AUDIO);
        _listAudio->setItemModel(defaultItem);
        initButton(T_AUDIO_BACK, root, this, toucheventselector(MainScene::touchEvent));
        
        motionlist = (UIListView*)UIHelper::seekWidgetByTag(root, MOTION_LIST);
        motionlist->setItemModel(defaultItem);
        
        _layoutAudio = (Layout*)UIHelper::seekWidgetByTag(root, T_SELECT_AUDIO);
        _layoutAudio->setVisible(false);
        _btnAddAudio = initButton(T_ADD_AUDIO, root, this, toucheventselector(MainScene::touchEvent));
        
        xNotify->addObserver(this, callfuncO_selector(MainScene::updateProperty), UPDATE_PROPERTY, NULL);
        xNotify->addObserver(this, callfuncO_selector(MainScene::updateList), UPDATE_EFFECT_LIST, NULL);
        xNotify->addObserver(this, callfuncO_selector(MainScene::updateMotionList), UPDATE_MOTION_LIST, NULL);
        xNotify->addObserver(this, callfuncO_selector(MainScene::setFrameCount), UPDATE_ALL_INDEX, NULL);
        xNotify->addObserver(this, callfuncO_selector(MainScene::error), UPDATE_ERROR, NULL);
        
        setTouchEnabled(true);
        
        return true;
    }
    
    return true;
}