void GoaliePen::doClear()
{
	cout << "[GoaliePen] i'm clearing" << endl;
	Clear myClear(pWorldData,pBasicPlayer);
	myClear.clearNow();
}
Exemplo n.º 2
0
void GuiPanel::setSelection(const QModelIndexList &newsel, int k){
  int sel=-1;
  int nsel = (int)newsel.size();
  if (newsel.size()!=0) sel = newsel[0].row();

  //bool vertexani=false;
  //bool skinned=false;
  //bool vertexcolor=false;
  /*bool manyMaterials=false;
  int flags=-1;
  char materialSt[255]="";
  bool differentAni = false;

  int nv=0, nf=0, nfr=0, np=0;
  int last = -1;

  for (QModelIndexList::ConstIterator i=newsel.constBegin(); i!=newsel.constEnd(); i++){
    sel = i->row();
    if (k==MESH && sel<(int)data->mesh.size() ) {
      BrfMesh *m = &(data->mesh[sel]);
      skinned |= m->IsSkinned();
      vertexani |= m->frame.size()>1;
      vertexcolor |= m->hasVertexColor;
      np += m->frame[0].pos.size();
      nv += m->vert.size();
      int k = m->frame.size();
      if (nfr>k || !nfr) nfr=k;

      if (!differentAni) {

        if (last!=-1) {
          if (data->mesh[sel].frame.size()!=data->mesh[last].frame.size()) differentAni=true;
          else for (unsigned int fi=0; fi < data->mesh[sel].frame.size(); fi++)
            if (data->mesh[sel].frame[fi].time!=data->mesh[last].frame[fi].time) differentAni=true;
        } else {
          for (unsigned int fi=0; fi < data->mesh[sel].frame.size(); fi++)
            _frameTime[fi]=data->mesh[sel].frame[fi].time;
        }
        last = sel;
      }

      nf += m->face.size();
      if (!materialSt[0]) sprintf(materialSt,"%s",m->material);
      else if (strcmp(materialSt,m->material)) {
        sprintf(materialSt,"%s","<various>");
        manyMaterials=true;
      }
      if (flags==-1) flags=m->flags; else {
        if (flags!=(int)m->flags) flags=-2;
      }
    }


  }
  if (k==-1) k=NONE;

  BrfMesh *m = NULL;
  BrfTexture *tex = NULL;
  BrfAnimation *ani = NULL;
*/
_selectedIndex = sel;
//_nsel =
switch (TokenEnum(k)){
  case MATERIAL:{
    myClear(ui->leMatBump);
    myClear(ui->leMatDifA);
    myClear(ui->leMatDifB);
    myClear(ui->leMatEnv);
    myClear(ui->leMatShader);
    myClear(ui->leMatSpec);

    myClear(ui->leMatFlags);
    //myClear(ui->leMatRendOrd);
    myClear(ui->leMatCoeff);
    myClear(ui->leMatR);
    myClear(ui->leMatG);
    myClear(ui->leMatB);

    for (QModelIndexList::ConstIterator i=newsel.constBegin(); i!=newsel.constEnd(); i++){
      int sel = i->row();
      if (sel<0 || sel>=(int)data->material.size())  break;
      BrfMaterial &m(data->material[sel]);

      mySetText(ui->leMatBump,  m.bump );
      mySetText(ui->leMatDifA,  m.diffuseA );
      mySetText(ui->leMatDifB,  m.diffuseB );
      mySetText(ui->leMatEnv,   m.enviro);
      mySetText(ui->leMatShader,m.shader );
      mySetText(ui->leMatSpec,  m.spec );

      mySetText(ui->leMatFlags, StringH(m.flags) );
      //mySetText(ui->leMatRendOrd, m.RenderOrder() );
      mySetText(ui->leMatCoeff, StringF(m.specular,3) );
      mySetText(ui->leMatR, StringF( m.r ,3));
      mySetText(ui->leMatG, StringF( m.g ,3));
      mySetText(ui->leMatB, StringF( m.b ,3));
    }
    break;
    }

  case MESH: {
    myClear(ui->boxFlags);
    myClear(ui->boxMaterial);
    myClear(ui->boxTexture);
    myClear(ui->boxNVerts);
    myClear(ui->boxNFaces);
    myClear(ui->boxNPos);
    myClear(ui->boxNVerts);
    myClear(ui->boxNFrames);
    ui->meshDataAni->setVisible(false);
    ui->rbRiggingcolor->setEnabled(false);
    ui->rbVertexcolor->setEnabled(false);
    ui->viewRefAni->setVisible( false );

    int hasAni=-1,hasCol=-1,hasTan=-1,hasRig=-1;
    bool hasBump=false, hasSpec=false, hasTran = false;

    for (QModelIndexList::ConstIterator i=newsel.constBegin(); i!=newsel.constEnd(); i++){
      int sel = i->row();
      if (sel<0 || sel>=(int)data->mesh.size()) continue;
      BrfMesh *m=&(data->mesh[sel]);

      mySetText(ui->boxFlags, StringH(m->flags & ~(3<<16) ));
      mySetText( ui->boxMaterial ,  m->material );

      mySetValueAdd( ui->boxNVerts , (int)m->vert.size());
      mySetValueAdd( ui->boxNFaces , (int)m->face.size());
      mySetValueAdd( ui->boxNPos   , (int)m->frame[0].pos.size());
      mySetValueMax( ui->boxNFrames, (int)m->frame.size());

      mySetCompositeVal(hasAni, m->HasVertexAni());
      mySetCompositeVal(hasCol, m->hasVertexColor);
      mySetCompositeVal(hasTan, m->StoresTangentField());
      mySetCompositeVal(hasRig, m->IsSkinned());

      bool ta,tb,tc;
      QString s = inidata.mat2tex(m->material,&ta,&tb,&tc);
      if (s.isEmpty()) s = tr("<not found>");
      hasBump |= ta;
      hasSpec |= tb;
      hasTran |= tc;

      mySetText( ui->boxTexture, s );

      for (unsigned int fi=0; fi < m->frame.size(); fi++)
         frameTime[fi]=m->frame[fi].time;
    }

    if (hasRig>0)  {
      ui->rbRiggingcolor->setEnabled( true );
      ui->viewRefAni->setVisible( true );
    }
    if (hasCol>0) ui->rbVertexcolor->setEnabled(true);
    if (hasAni>0) ui->meshDataAni->setVisible(true);
    ui->cbMeshHasAni->setCheckState(myCheckState(hasAni));
    ui->cbMeshHasCol->setCheckState(myCheckState(hasCol));
    ui->cbMeshHasTan->setCheckState(myCheckState(hasTan));
    ui->cbMeshHasRig->setCheckState(myCheckState(hasRig));

    ui->cbTransp->setEnabled( hasTran );
    ui->cbNormalmap->setEnabled( hasBump );
    ui->cbSpecularmap->setEnabled( hasSpec );


    ui->timeOfFrame->setEnabled( newsel.size()==1 );

    int nfr = (int)ui->boxNFrames->value();
    if (nfr>0)
    ui->frameNumber->setMaximum(nfr -1 );
    ui->frameNumber->setMinimum( 0 );
    ui->frameNumber->setWrapping(true);

    break;
    }

  case TEXTURE:
    myClear(ui->boxTextureFlags);

    for (QModelIndexList::ConstIterator i=newsel.constBegin(); i!=newsel.constEnd(); i++){
      int j=i->row();
      if (j>=0 && j<(int)data->texture.size())
        mySetText(ui->boxTextureFlags,StringH(data->texture[j].flags));
      int nf = data->texture[j].NFrames();
      if (nf==0)
        ui->labNFrames->setHidden(true);
      else {
        ui->labNFrames->setHidden(false);
        ui->labNFrames->setText(QString("x %1").arg(nf));
      }

    }
    break;
  case SKELETON: {
    {
        int hasHb=-1;
        myClear(ui->boxSkelNBones);
        for (QModelIndexList::ConstIterator i=newsel.constBegin(); i!=newsel.constEnd(); i++){
          int sel = i->row();
          if (sel<0 || sel>=(int)data->skeleton.size()) continue;
          BrfSkeleton *s=&(data->skeleton[sel]);
          int bi=-1;
          if (hitBoxes) bi = hitBoxes->Find(s->name,BODY);
          mySetCompositeVal(hasHb,bi>=0);
          mySetValue(ui->boxSkelNBones,(int)s->bone.size());
        }
        ui->cbSkelHasHitbox->setCheckState(myCheckState(hasHb));

    }

    ui->cbTransp->setEnabled( true );
    ui->cbNormalmap->setEnabled( true );
    ui->cbSpecularmap->setEnabled( true );

    BodyPartModel* bmp = ((BodyPartModel*)(ui->lvBones->model()));
    if (sel>=0 && nsel==1 && sel<(int)data->skeleton.size()) {
      BrfSkeleton &s(data->skeleton[sel]);
      bmp->setSkel(s);      
    } else  bmp->clear();

    emit selectedSubPiece(-1); // unselect all
    ui->lvBones->selectionModel()->clearSelection();
    ui->hitboxEdit->setVisible(false); // until a piece is not selected

    break; }
  case ANIMATION:
    {

    myClear(ui->boxAniNBones);
    myClear(ui->boxAniNFrames);
    myClear(ui->boxAniMinFrame);
    myClear(ui->boxAniMaxFrame);

    for (QModelIndexList::ConstIterator i=newsel.constBegin(); i!=newsel.constEnd(); i++){
      int sel = i->row();
      if (sel<0 || sel>=(int)data->animation.size()) continue;
      BrfAnimation *a=&(data->animation[sel]);

      mySetValue(ui->boxAniNBones,a->nbones);
      mySetValue(ui->boxAniNFrames,a->frame.size());
      mySetValue(ui->boxAniMinFrame,a->FirstIndex());
      mySetValue(ui->boxAniMaxFrame,a->LastIndex() );
    }


    BrfAnimation *ani =NULL;
    if (sel>=0 && nsel==1 && sel<(int)data->animation.size()) ani=&(data->animation[sel]);
    if (ani) {
      for (unsigned int fi=0; fi < ani->frame.size(); fi++)
       frameTime[fi]=ani->frame[fi].index;
      ui->frameNumberAni->setMaximum(ani->frame.size());
      ui->frameNumberAni->setMinimum(1);
      updateFrameNumber( ui->frameNumberAni->value() );
    }

    ui->cbTransp->setEnabled( true );
    ui->cbNormalmap->setEnabled( true );
    ui->cbSpecularmap->setEnabled( true );

    ui->rbRiggingcolor->setEnabled( true ); // quick: use "true": just let user edit them
    ui->rbVertexcolor->setEnabled( true );
    ui->viewRefSkel->setVisible( true );
    if (ani) setAnimation(ani);
    }
    break;
  case SHADER:
      {
      if (!newsel.size()) break;
      int sel = newsel[0].row();
      if (sel<0 || sel>=(int)data->shader.size())  break;
      BrfShader &s(data->shader[sel]);
      ui->leShaderTechnique->setText( s.technique );
      ui->leShaderFallback->setText( s.fallback );
      ui->leShaderFlags->setText( StringH(s.flags) );
      ui->leShaderRequires->setText( StringH(s.requires) );
      updateShaderTextaccSize();
      }
      break;
    case BODY:

      bool collisionBodyHasMesh;
      if (nsel==1) {
          char* bodyname = data->body[sel].name;
          int si = data->Find(bodyname,SKELETON);

          collisionBodyHasSkel= (si>=0);
          if (si>=0) skel = &(data->skeleton[si]); else skel = NULL;
          collisionBodyHasMesh = false;
          for (int i=0; i<(int)data->mesh.size(); i++) {
              if (data->mesh[i].IsNamedAsBody(bodyname)) collisionBodyHasMesh = true;
          }
      } else {
          collisionBodyHasMesh = true;
          collisionBodyHasSkel = false;
      }
      ui->cbComparisonMesh->setEnabled( collisionBodyHasMesh || collisionBodyHasSkel );
      updateBodyPartData();
      break;
    default:

      break;
  }

  ui->animationData->setVisible(k == ANIMATION);
  ui->textureData->setVisible(k == TEXTURE);
  ui->meshData->setVisible(k == MESH);
  ui->materialData->setVisible( k==MATERIAL );
  ui->skeletonData->setVisible( k==SKELETON );
  ui->shaderData->setVisible( k==SHADER );
  ui->bodyData->setVisible( k==BODY );
  ui->generalView->setVisible( k!=SHADER && k!=NONE );

  QRect rect = ui->generalView->geometry();
  if (k==MATERIAL)
    rect.setTop( ui->materialData->geometry().bottom() + 40 );
  else
    rect.setTop( ui->meshData->geometry().bottom() + 40 );
  ui->generalView->setGeometry(rect);

  displaying=k;
  updateVisibility();
  updateFrameNumber( ui->frameNumber->value() );

}
Exemplo n.º 3
0
void display( void ) {
	
     /* 
	* Set clear color to gray 
     */
    myClearColor ( 0.8, 0.8, 0.8, 0.0 );
	
    /* 
	* Clear screen window 
     */
    myClear( GL_COLOR_BUFFER_BIT );
		
	myLoadIdentity();
	myPushMatrix();
	
	/* 
	 * plain old polygon test
	 */
	if ( (displayNumber % 4) == 1) {
		
		/* default clipping */
		myOrtho2D( -100.0, 100.0, -100.0, 100.0 );
		
		/* default viewport */
		myViewport( 0, 0, screenWidth, screenHeight );
	
		myPushMatrix();

		/* draw the polys */
		drawPolys();
	}
	else if ( (displayNumber % 4) == 2) {
		
		/* clipping test */
		myOrtho2D( -65.0, 75.0, -80.0, 65.0 );
		
		/* default viewport */
		myViewport( 0, 0, screenWidth, screenHeight );
		
		/* flip screen around! */
		myScalef(-1.0,1.0);
		myPushMatrix();
		

		/* draw the polys */
		drawPolys();
		
    }
	else if ( (displayNumber % 4) == 3) {
		
		/* default clipping */
		myOrtho2D( -100.0, 100.0, -100.0, 100.0 );
		
		/* default viewport */
		myViewport( 0, 0, screenWidth, screenHeight );

		/* rotate screen */
		myRotatef(15.0);
		myPushMatrix();

		/* draw the tranformed polys */
		drawPolys();
	}
	
	else /* displayNumber == 0 */ {
		
		/* default clipping */
		myOrtho2D( -100.0, 100.0, -100.0, 100.0 );
		
		/* default viewport */
		myViewport( 0, 0, screenWidth, screenHeight );

		myRotatef(-15.0);
		myScalef(.5,.5);
		myPushMatrix();
		myRotatef(15.0);
		myPushMatrix();

		/* draw the tranformed polys */
		drawPolys();
	
		
	}
	
	/* 
     * Flush GL buffers to the display   
     */
    glFlush( );
	
}