void buildModel() {
    lightDirection[0]   = -2;
    lightDirection[1]   = 2;
    lightDirection[2]   = 4.5;

    buildShadow();

    color[0].r  = 1;
    color[0].g  = .2;
    color[0].b  = .1;
    color[0].a  = 1;

    color[1].r  = 1;
    color[1].g  = .38;
    color[1].b  = .1;
    color[1].a  = 1;

    color[2].r  = 1;
    color[2].g  = .56;
    color[2].b  = .1;
    color[2].a  = 1;

    color[3].r  = 1;
    color[3].g  = .72;
    color[3].b  = .1;
    color[3].a  = 1;

    color[4].r  = 1;
    color[4].g  = .9;
    color[4].b  = .1;
    color[4].a  = 1;



    for (int i=0; i<PARTNUM; i++) {
        pieVertices[i].Position[0]     = 0;
        pieVertices[i].Position[1]     = 0.6;
        pieVertices[i].Position[2]     = 0;
        pieVertices[i].Color[0]        = color[i].r*.2;
        pieVertices[i].Color[1]        = powf(color[i].g,.4)+.2;
        pieVertices[i].Color[2]        = color[i].b;
        pieVertices[i].Color[3]        = color[i].a;
        pieVertices[i].Normal[0]       = 0.0;
        pieVertices[i].Normal[1]       = 1.0;
        pieVertices[i].Normal[2]       = 0.0;

    }


    float thisDivideValue   = 0;
    float partEndValue      = 0;
    float partStartValue    = 0;

    float divideStep        = 1.0 / SUBDIVIDE;
    float breakStep         = .005f;

    int divideCount         = 0;


    for (int i=0; i<PARTNUM; i++) {
        divideCompletePart  = (float)rand()/RAND_MAX*40;
        partStartValue      = partEndValue;
        partEndValue        += partValue[i];

        thisDivideValue     = partStartValue;

        int isEndDivideBuild    = 0;
        divideCountInPart   = 0;
        while (thisDivideValue<partEndValue) {

            float ang           = PI2*thisDivideValue;
            float sinAng        = sinf(ang);
            float cosAng        = cosf(ang);

            int trianglePoint   = divideCount*7+PARTNUM;
            if(partStartValue==thisDivideValue) {
                makeADivide(trianglePoint,ang,sinAng,cosAng,i,divideCount,1,1);
                divideCount ++;
                trianglePoint   = divideCount*7+PARTNUM;
                thisDivideValue += breakStep;
                ang             = PI2*thisDivideValue;
                sinAng          = sinf(ang);
                cosAng          = cosf(ang);
                makeADivide(trianglePoint,ang,sinAng,cosAng,i,divideCount,0,1);
            } else {
                makeADivide(trianglePoint,ang,sinAng,cosAng,i,divideCount,0,1);
            }


            divideCount ++;
            if(isEndDivideBuild==1 || thisDivideValue+divideStep<partEndValue-breakStep) {
                thisDivideValue += divideStep;
            } else {
                isEndDivideBuild = 1;
                thisDivideValue  = partEndValue-breakStep;
            }
        }
        float ang           = PI2*partEndValue;
        float sinAng        = sinf(ang);
        float cosAng        = cosf(ang);
        int trianglePoint   = divideCount*7+PARTNUM;
        makeADivide(trianglePoint,ang,sinAng,cosAng,i,divideCount,-1,0);
        divideCount ++;
    }


    /*for (int i=0; i<SUBDIVIDE; i++) {
        int partId         = floorf((float)i/SUBDIVIDE*PARTNUM);
        int trianglePoint  = i*3+PARTNUM;
        float ang           = PI2*(float)i/SUBDIVIDE;
        float sinAng        = sinf(ang);
        float cosAng        = cosf(ang);

        makeAVertice(trianglePoint,sinAng,cosAng,partId);
        if(i<SUBDIVIDE-1){
            int id  =i*15;

            pieIndices[id]     =  partId;

            pieIndices[id+1]   = trianglePoint;
            pieIndices[id+2]   = trianglePoint+3;

            pieIndices[id+3]   = trianglePoint;
            pieIndices[id+4]   = trianglePoint+1;
            pieIndices[id+5]   = trianglePoint+3;

            pieIndices[id+6]   = trianglePoint+3;
            pieIndices[id+7]   = trianglePoint+1;
            pieIndices[id+8]   = trianglePoint+4;

            pieIndices[id+9]   = trianglePoint+1;
            pieIndices[id+10]  = trianglePoint+2;
            pieIndices[id+11]  = trianglePoint+4;

            pieIndices[id+12]  = trianglePoint+4;
            pieIndices[id+13]  = trianglePoint+2;
            pieIndices[id+14]  = trianglePoint+5;
        }else{
            int id  =i*15;
            pieIndices[id]     = partId;
            pieIndices[id+1]   = trianglePoint;
            pieIndices[id+2]   = PARTNUM;

            pieIndices[id+3]   = trianglePoint;
            pieIndices[id+4]   = trianglePoint+1;
            pieIndices[id+5]   = PARTNUM;

            pieIndices[id+6]   = PARTNUM;
            pieIndices[id+7]   = trianglePoint+1;
            pieIndices[id+8]   = 1+PARTNUM;

            pieIndices[id+9]   = trianglePoint+1;
            pieIndices[id+10]  = trianglePoint+2;
            pieIndices[id+11]  = 1+PARTNUM;

            pieIndices[id+12]  = 1+PARTNUM;
            pieIndices[id+13]  = trianglePoint+2;
            pieIndices[id+14]  = 2+PARTNUM;
        }
    }*/

}
示例#2
0
void KFileIVIDesktop::drawShadowedText( TQPainter *p, const TQColorGroup &cg )
{
  bool drawRoundedRect = TDEGlobalSettings::iconUseRoundedRect();

  int textX;
  if (drawRoundedRect == true)
    textX = textRect( FALSE ).x() + 4;
  else
    textX = textRect( FALSE ).x() + 2;
  int textY = textRect( FALSE ).y();
  int align = ((TDEIconView *) iconView())->itemTextPos() == TQIconView::Bottom
    ? AlignHCenter : AlignAuto;
  // FIXME
  // Work around incorrect shadow position detailed in Bug 1807
  bool rebuild = true; // shouldUpdateShadow(isSelected());

  KDesktopShadowSettings *settings = (KDesktopShadowSettings *) (m_shadow->shadowSettings());

  unsigned long uid = settings->UID();

  p->setFont(iconView()->font());
  paintFontUpdate(p);
  TQColor shadow;
  TQColor text;
  int spread = shadowThickness();

  if ( isSelected() && settings->selectionType() != KShadowSettings::InverseVideoOnSelection ) {
    text = cg.highlightedText();
    TQRect rect = textRect( false );
    rect.setRight( rect.right() - spread );
    rect.setBottom( rect.bottom() - spread + 1 );
    if (drawRoundedRect == true) {
      p->setBrush( TQBrush( cg.highlight() ) );
      p->setPen( TQPen( cg.highlight() ) );
      p->drawRoundRect( rect,
		      1000 / rect.width(),
		      1000 / rect.height() );
    }
    else {
      p->fillRect( textRect( false ), cg.highlight() );
    }
  }
  else {
    // use shadow
    if ( isSelected() ) {
      // inverse text and shadow colors
      shadow = settings->textColor();
      text = settings->bgColor();
      if ( rebuild ) {
        setSelectedImage( buildShadow( p, align, shadow ) );
        _selectedUID = uid;
      }
    }
    else {
      text = settings->textColor();
      shadow = ( settings->bgColor().isValid() ) ? settings->bgColor() :
               ( tqGray( text.rgb() ) > 127 ) ? black : white;
      if (rebuild) {
        setNormalImage(buildShadow(p, align, shadow));
        _normalUID = uid;
      }
    }

    // draw the shadow
    int shadowX = textX - spread + settings->offsetX();
    int shadowY = textY - spread + settings->offsetY();

    p->drawImage(shadowX, shadowY,
      (isSelected()) ? *selectedImage() : *normalImage(),
      0, 0, -1, -1, DITHER_FLAGS);
  }

  // draw the text
  p->setPen(text);
  wordWrap()->drawText( p, textX, textY, align | KWordWrap::Truncate );
}