home *** CD-ROM | disk | FTP | other *** search
/ Action Ware 10: Quake / ACWARE10.iso / acware10 / editors / mdlv14 / mdl.cc < prev    next >
C/C++ Source or Header  |  1996-08-07  |  16KB  |  619 lines

  1. //
  2. // this file by brian martin 1996
  3. // brian@phyast.pitt.edu
  4. //
  5. // this is part of the source for the MedDLe quake model viewer/editor
  6. //
  7. //
  8. #include "mdl.h"
  9.  
  10. int mdl_keys(MDL_model *);
  11. void load_model(char *, MDL_model *);
  12. void vline (unsigned char *, int *, int *,MDL_model );
  13. MDL_window win2d, win3d;
  14. // use this stuff for command line options
  15. #define NUM_CFG_OPTIONS 3
  16. char *cfg_option[NUM_CFG_OPTIONS] = {"mode","driver","progspath"};
  17. char driver[128], progspath[128];
  18. unsigned char pal[256*3];
  19. unsigned char cmap[256*32];
  20. //GrContext *BitMapContext;
  21. void OpenColorMap(char *,unsigned char *);
  22.  
  23. //----------------------------------------------------------------------
  24.  
  25. int main (int argc, char *argv[])
  26. {
  27.     FILE *in, *out, *qpal;
  28.     unsigned char bmppal[256*3];
  29.     unsigned bmpw, bmph;
  30.     struct MDL_model model;
  31.     char *in_filename,*out_filename,*filename;
  32.     char str[256];
  33.     char ch;
  34.     short cur_key;
  35.     short draw_3d=1;
  36.     short draw_triangles=0;
  37.     short draw_vertices=0;
  38.     short import_bmpfile=0;
  39.     short export_bmpfile=0;
  40.     short show_info=0;
  41.     unsigned i,j,k,l;
  42.     unsigned p1,p2,p3,p4;
  43.     int video_mode=0;
  44.     int update=0;
  45.     int refresh=0;
  46.     int oldx,oldy,oldr,oldl,oldm;
  47.     int selected=0;
  48.     int ontopof=0;
  49.     int selectedx, selectedy, selectedindex;
  50.     int madechanges=0;
  51.     int loop;
  52.     int goto_3d=0;
  53.     int skin;
  54.     float zoom_factor=2;
  55.  
  56.     // set default values
  57.     driver[0]=NULL;
  58.     progspath[0]=NULL;
  59.  
  60.     clrscr();
  61.     printf("MedDLe by Brian Martin version %2.1f\n\n",VERSION);
  62.  
  63.     // get config file settings
  64.     if((in=fopen("mdl.cfg","rt"))==NULL)
  65.     {
  66.         fprintf(stderr,"Can't open mdl.cfg, using defaults... \n");
  67.         fprintf(stderr,"Things probably won't work. Hit a key. \n");
  68.         getch();
  69.     }
  70.     else
  71.     {
  72.         fprintf(stderr,"Reading mdl.cfg ...\n");
  73.         ch=0;
  74.         do
  75.         {
  76.             fscanf(in,"%s", str);
  77.             if(feof(in)) break;
  78.             if(str[0]=='#') {while(fgetc(in)!=0x0A);}
  79.             else
  80.             {
  81.                 k=0;
  82.                 for(i=0; i<NUM_CFG_OPTIONS; i++)
  83.                 {
  84.                     j=0;
  85.                     while(*(cfg_option[i]+j)!=NULL)
  86.                     {
  87.                         k=i+1;
  88.                         if(str[j]!=*(cfg_option[i]+j)) {k=0;break;}
  89.                         j++;
  90.                     }
  91.                     if(k!=0) break;
  92.                 }
  93.                 if(k==0) fprintf(stderr,"Don't understand option \"%s\" in config file. \n",str);
  94.                 else
  95.                 {
  96.                     fscanf(in,"%s", str);
  97.                     switch (k)
  98.                     {
  99.                         case 1: video_mode=atoi(str); fprintf(stderr," - setting video mode = %d\n",video_mode); break;
  100.                         case 2: strcpy(driver,str); fprintf(stderr," - setting driver = %s\n",driver);break;
  101.                         case 3: strcpy(progspath,str); fprintf(stderr," - setting progspath = %s\n",progspath);break;
  102.                     }
  103.                 }
  104.             }
  105.         }while(!feof(in));
  106.         fclose(in);
  107.     }
  108.  
  109.  
  110.     // get command line options
  111.     for (argv++, argc--; argc && **argv == '-'; argv++, argc--)
  112.     {
  113.         if ((*argv)[1] == 'e' && argc-- > 1)
  114.         {
  115.             out_filename = *++argv;
  116.             export_bmpfile=1;
  117.             skin = atoi( *(++argv));
  118.  
  119.         }
  120.         else if ((*argv)[1] == 'i' && argc-- > 1)
  121.         {
  122.             in_filename = *++argv;
  123.             import_bmpfile=1;
  124.             skin = atoi( *(++argv));
  125.         }
  126.  
  127.         else if ((*argv)[1] == 'm' && argc-- > 1)
  128.             video_mode= atoi( *(++argv));
  129.  
  130.         else if ((*argv)[1] == '2')
  131.             draw_3d = 0;
  132.  
  133.         else if ((*argv)[1] == 's')
  134.             show_info = 1;
  135.  
  136.         else if ((*argv)[1] == 'h')
  137.         {
  138.             fprintf(stderr, "Usage: mdl [-h] [-2] [-s] [-e <file.bmp> #] [-i <file.bmp> #] [-m #] file.mdl \n");
  139.             fprintf(stderr, "       -h  -- help screen\n");
  140.             fprintf(stderr, "       -2  -- start in 2d view\n");
  141. //            fprintf(stderr, "       -s  -- show header information\n");
  142.             fprintf(stderr, "       -e  -- extract BMP file, skin #\n");
  143.             fprintf(stderr, "       -i  -- insert BMP file, skin #\n");
  144.             fprintf(stderr, "       -m  -- video mode\n");
  145.             fprintf(stderr, "              0 = 320x200 (default)\n");
  146.             fprintf(stderr, "              1-4 hi res modes\n");
  147.             exit(1);
  148.         }
  149.         else
  150.         {
  151.             fprintf(stderr, "What is %s?  mdl -h will help you", *argv);
  152.             exit(1);
  153.         }
  154.     }
  155.  
  156.     if (argc > 0)
  157.         filename = *argv;
  158.     else
  159.     {
  160.         fprintf(stderr, "mdl -h will help you", *argv);
  161.         exit(1);
  162.     }
  163.  
  164.     // read in quake colors
  165.     BG_OpenPalette("mdl.pal",pal);
  166.     //read color map
  167.     OpenColorMap("mdl.map",cmap);
  168.     // read in mdl file
  169.     // and set up data
  170.     load_model(filename, &model);
  171.  
  172.     // export bitmap of skin
  173.     if(export_bmpfile==1)
  174.     {
  175.         if((skin<=model.num_skins)&&(skin>0))
  176.         {
  177.             out=fopen(out_filename,"wb");
  178.             BG_WriteBMP(out, pal, model.skin[skin-1].bitmap, model.skinw, model.skinh);
  179.             fclose(out);
  180.         }
  181.         // new skin (polygon pic)
  182.         if(skin<=0)
  183.         {
  184.             int x1,x2,x3;
  185.             unsigned p1,p2,p3,p4;
  186.             unsigned char *pic;
  187.             pic= new(unsigned char)[model.skinw*model.skinh];
  188.  
  189.             for(j=0; j<model.skinh; j++)
  190.             {
  191.                 for(i=0; i<model.skinw; i++)
  192.                 {
  193.                     pic[i+model.skinw*j]=0;
  194.                 }
  195.             }
  196.  
  197.             int v1[2], v2[2];
  198.             for(i=0;i<model.num_triangles;i++)
  199.             {
  200.                 p1=model.triangle[i*4+1];
  201.                 p2=model.triangle[i*4+2];
  202.                 p3=model.triangle[i*4+3];
  203.                 p4=model.triangle[i*4];
  204.                 x1=x2=x3=0;
  205.                 if((model.vertex[3*p1]==32)&&(p4==0)) x1=model.skinw/2;
  206.                 if((model.vertex[3*p2]==32)&&(p4==0)) x2=model.skinw/2;
  207.                 if((model.vertex[3*p3]==32)&&(p4==0)) x3=model.skinw/2;
  208.                 v1[0]=model.vertex[p2*3+1]+x2;
  209.                 v1[1]=model.vertex[p2*3+2];
  210.                 v2[0]=model.vertex[p3*3+1]+x3;
  211.                 v2[1]=model.vertex[p3*3+2];
  212.                 vline(pic,v1,v2,model);
  213.                 v1[0]=model.vertex[p3*3+1]+x3;
  214.                 v1[1]=model.vertex[p3*3+2];
  215.                 v2[0]=model.vertex[p1*3+1]+x1;
  216.                 v2[1]=model.vertex[p1*3+2];
  217.                 vline(pic,v1,v2,model );
  218.                 v1[0]=model.vertex[p1*3+1]+x1;
  219.                 v1[1]=model.vertex[p1*3+2];
  220.                 v2[0]=model.vertex[p2*3+1]+x2;
  221.                 v2[1]=model.vertex[p2*3+2];
  222.                 vline(pic,v1,v2,model);
  223.  
  224.             }
  225.             out=fopen(out_filename,"wb");
  226.             BG_WriteBMP(out, pal, pic, model.skinw, model.skinh);
  227.             fclose(out);
  228.             delete [] pic;
  229.         }
  230.         goto the_end;
  231.     }
  232.  
  233.     // import skin bmp
  234.     if((skin>0)&&(import_bmpfile==1))
  235.     {
  236.         unsigned char *pic;
  237.  
  238.         in=fopen(in_filename,"rb");
  239.         rewind(in);
  240.         fseek(in,18,SEEK_SET);
  241.         fread(&bmpw,4,1,in);
  242.         fread(&bmph,4,1,in);
  243.         fseek(in,28,SEEK_CUR);
  244.  
  245.         for (i = 0; i < 256; i++)
  246.         {
  247.             fread(bmppal+i*3 + 2,1,1,in);
  248.             fread(bmppal+i*3 + 1,1,1,in);
  249.             fread(bmppal+i*3 + 0,1,1,in);
  250.             fseek(in,1,SEEK_CUR);
  251.         }
  252.  
  253.         //read new pic
  254.         pic=new (unsigned char)[(bmpw*bmph)];
  255.         int ali;
  256.         unsigned char junk[4];
  257.         if(bmpw<4) ali=4-bmpw;
  258.         else ali=bmpw%4;
  259.  
  260.         for(j=bmph;j>0;j--)
  261.         {
  262.             for(i=0;i<bmpw;i++)
  263.             {
  264.                 fread(&pic[i+bmpw*(j-1)],1,1,in);
  265.             }
  266.             if(ali!=0) fread(&junk[0],ali,1,in);
  267.         }
  268.         fclose(in);
  269.  
  270.         // now stick the info in the model...
  271.         // match colors up
  272.         printf("matching colors\n");
  273.         char close_color[256];
  274.         for(i=0; i<256; i++)
  275.         {
  276.             close_color[i]=i;
  277.             float error, error0=1.566e5;
  278.             float e1,e2,e3;
  279.             for(j=0; j<256; j++)
  280.             {
  281.                 e1= (float)(pal[j*3]-bmppal[i*3]);
  282.                 e2= (float)(pal[j*3+1]-bmppal[i*3+1]);
  283.                 e3= (float)(pal[j*3+2]-bmppal[i*3+2]);
  284.                 error=e1*e1+e2*e2+e3*e3;
  285.                 if(error<=error0)
  286.                 {
  287.                     error0=error;
  288.                     close_color[i]=j;
  289.                 }
  290.             }
  291.  
  292.         }
  293.  
  294.         //if adding a skin (not replacing)
  295.         if(skin>model.num_skins)
  296.         {
  297.             model.num_skins++; skin=model.num_skins;
  298.             // make room for more skin!
  299.             struct MDL_model_skin *tempskin;
  300.             tempskin=new(MDL_model_skin)[model.num_skins-1];
  301.             memcpy (tempskin, model.skin,sizeof(MDL_model_skin)*(model.num_skins-1));
  302.             delete [] model.skin;
  303.             model.skin = new (MDL_model_skin)[model.num_skins];
  304.             memcpy (model.skin,tempskin,sizeof(MDL_model_skin)*(model.num_skins-1));
  305.             delete [] tempskin;
  306.             model.skin[skin-1].bitmap=new (unsigned char)[model.skinw*model.skinh];
  307.         }
  308.  
  309.         // resize pic if needed and add to model
  310.         printf("resizing pic\n");
  311.         double scalew, scaleh;
  312.         scalew=(double)(bmpw)/(double)(model.skinw);
  313.         scaleh=(double)(bmph)/(double)(model.skinh);
  314.  
  315.         for(j=0; j<model.skinh;j++)
  316.         {
  317.             for(i=0;i<model.skinw;i++)
  318.             {
  319.                 unsigned pic_index;
  320.                 double di, dj;
  321.                 di=(double)i;
  322.                 dj=(double)j;
  323.                 pic_index=(unsigned)(scalew*di)+(unsigned)(scaleh*dj)*(bmpw);
  324.                 model.skin[skin-1].bitmap[i+j*model.skinw]=close_color[pic[pic_index]];
  325.             }
  326.         }
  327.  
  328.         delete [] pic;
  329.  
  330.     }
  331.  
  332.  
  333.  
  334.     // intiate graphics mode
  335.     BG_GraphicsMode(driver,video_mode);
  336.     // change the screen colors to the quake palette
  337.     BG_SetPalette(pal);
  338.     // initiate mouse
  339.     BG_InitMouse();
  340.     BG_MouseStatus();
  341.     oldx=BG_MouseX;
  342.     oldy=BG_MouseY;
  343.     // intiate math tables
  344.     BG_InitMath();
  345.  
  346.     BG_ClearScreen(0);
  347.     // loop through the 3 modes (3d,2d,help)
  348.     while(1)
  349.     {
  350.         if(draw_3d==1)
  351.         {
  352.             if((i=mdl_3d(&model,&win3d))==0) break;
  353.             if(i==2) draw_3d=2;
  354.             else draw_3d=0;
  355.         }
  356.         if(draw_3d==2)
  357.         {
  358.             if((i=mdl_keys(&model))==0) break;
  359.             if(i==1) draw_3d=0;
  360.             else draw_3d=1;
  361.         }
  362.         else
  363.         {
  364.             if((i=mdl_2d(&model,&win2d))==0) break;
  365.             if(i==2) draw_3d=2;
  366.             else draw_3d=1;
  367.         }
  368.  
  369.  
  370.     }
  371.     // go back to text mode
  372.     GrSetModeRestore(0);
  373.     BG_TextMode();
  374.  
  375.     the_end:
  376.     clrscr();
  377.  
  378.  
  379.  
  380. //    delete [] mdl.bitmap;
  381.     delete[] model.vertex;
  382.     delete [] model.triangle;
  383. //    for(j=0; j<mdl.num_frames;  j++)
  384. //    {
  385. //        if(mdl.frame[j].atype!=0) delete [] mdl.frame[j].n3;
  386. //        delete [] mdl.frame[j].v;
  387. //    }
  388. //    delete [] mdl.frame;
  389. //    delete_3d_data(&mdl);
  390.  
  391.     fprintf(stderr,"\nMedDLe v%2.1f 1996\n  by Brian Martin\n  brian@phyast.pitt.edu\n  irc: ZombyWoof\n",VERSION);
  392.     return(0);
  393. }
  394.  
  395. // read in the color map needed for shading
  396. void OpenColorMap(char *mapfile,unsigned char *cm)
  397. {
  398.     FILE *in;
  399.     in=fopen(mapfile,"rb");
  400.  
  401.     fread(cm,1,256*32,in);
  402.     fclose(in);
  403.  
  404. }
  405. // help file
  406. int mdl_keys(MDL_model *m)
  407. {
  408.      int loop=1;
  409.      int draw_3d=2;
  410.      int cur_key;
  411.      static int page=0;
  412.      int MAXPAGE=5;
  413.      int update =1;
  414.      BG_ClearScreen(0);
  415.  
  416.  
  417.         while(loop)
  418.         {
  419.  
  420.             if(kbhit())
  421.             {
  422.                 if((cur_key=getch())==0x0) cur_key=getch();
  423.              //    cur_key=getch();
  424.                 switch(cur_key)
  425.                 {
  426.                 case 27:               loop=0; draw_3d=2; break;
  427.                 case '3':            loop=0; draw_3d=1; break;
  428.                 case '2':            loop=0; draw_3d=0; break;
  429.  
  430.                 case ARROW_RIGHT: case ARROW_DOWN:    if(page<MAXPAGE) page+=1;
  431.                                                         else page=0;
  432.                                                         break;
  433.                 case ARROW_LEFT: case ARROW_UP:        if(page>0) page-=1;
  434.                                                         else page=MAXPAGE;
  435.                                                         break;
  436.  
  437.                 }
  438.                 update=1;
  439.             }
  440.  
  441.          if(update==1)
  442.          {
  443.                  BG_ClearScreen(0);
  444.                 update=0;
  445.  
  446.             if(page==0)
  447.             {
  448.                 // page 0
  449.                 BG_Text("..About MedDLe..",BG_ScreenWidth/2-60,2,250,0);
  450.  
  451.                 BG_Text("MedDLe was written by Brian Martin",5,30,253,0);
  452.                 BG_Text("   (on quake/irc I am the ZombyWoof!)",5,45,253,0);
  453.                 BG_Text("",5,60,253,0);
  454.                 BG_Text("It is free-ware and the source is included.",5,75,253,0);
  455.                 BG_Text("This is NOT an id software product! ",5,90,253,0);
  456.                 BG_Text("Questions or whatever go to:",5,105,253,0);
  457.                 BG_Text("brian@phayst.pitt.edu ",5,120,253,0);
  458.                 BG_Text("http://www.phyast.pitt.edu/~brian",5,135,253,0);
  459.                 BG_Text("",5,150,253,0);
  460.                 BG_Text("I will program for food. (i.e. hire me)",5,155,253,0);
  461.  
  462.                 BG_Text("Use arrow keys (up/down) to see more.",5,170,250,0);
  463.             }
  464.  
  465.             else if(page==1)
  466.             {
  467.                         // page 1
  468.                 BG_Text("..MedDLe Useful Keys..",BG_ScreenWidth/2-70,2,250,0);
  469.                 BG_Text("Key  Action",5,15,250,0);
  470.                 BG_Text("1    Brings up Help",5,30,253,0);
  471.                 BG_Text("2    Brings up (2D) Skin Editor",5,45,253,0);
  472.                 BG_Text("3    Brings up (3D) Frame Editor",5,60,253,0);
  473.                 BG_Text("Esc  Exits",5,75,253,0);
  474.                 BG_Text("These keys always work. For specifics, read on.",5,90,253,0);
  475.  
  476.                 BG_Text("Use arrow keys (up/down) to see more.",5,170,250,0);
  477.             }
  478.             else if(page==2)
  479.             {
  480.                 // page 2
  481.                 BG_Text("..MedDLe Useful Keys..",BG_ScreenWidth/2-70,2,250,0);
  482.                 BG_Text("Keys for 2D Mode",5,15,250,0);
  483.                 BG_Text("1,3,Esc  Help, 3d mode, exit",5,30,253,0);
  484.                 BG_Text("<,>  move through skins",5,45,253,0);
  485.                 BG_Text("t    Show wireframe (triangles)",5,60,253,0);
  486.                 BG_Text("v    Show vertices",5,75,253,0);
  487.                 BG_Text("s    Saves changes",5,90,253,0);
  488.                 BG_Text(";,'  change pants",5,105,253,0);
  489.                 BG_Text("[,]  change shirt",5,120,253,0);
  490.                 BG_Text("Mouse and arrow keys move cursor",5,135,253,0);
  491.                 BG_Text("Mouse Left Button grabs vertex",5,150,253,0);
  492.  
  493.                 BG_Text("Use arrow keys (up/down) to see more.",5,170,250,0);
  494.             }
  495.             else if(page==3)
  496.             {
  497.                 // page 3
  498.                 BG_Text("..MedDLe Useful Keys..",BG_ScreenWidth/2-70,2,250,0);
  499.                 BG_Text("Keys for 3D Mode",5,15,250,0);
  500.                 BG_Text("1,2,Esc    Help,Skin Editor,Exit",5,30,253,0);
  501.                 BG_Text("r    Reset View",5,45,253,0);
  502.                 BG_Text("s    Save View to file 'pic#.bmp'",5,60,253,0);
  503.                 BG_Text("TAB  change render mode",5,75,253,0);
  504.                 BG_Text(";,'  change pants",5,90,253,0);
  505.                 BG_Text("[,]  change shirt",5,105,253,0);
  506.                 BG_Text("Use arrow keys (up/down) to see more.",5,170,250,0);
  507.             }
  508.  
  509.             else if(page==4)
  510.             {
  511.                 // page 4
  512.                 BG_Text("..MedDLe Useful Keys..",BG_ScreenWidth/2-70,2,250,0);
  513.                 BG_Text("..MORE Keys for 3D Mode",5,15,250,0);
  514.  
  515.                 BG_Text("h    Show Frame Header Info",5,30,253,0);
  516.                 BG_Text("c    Cycle Through Frames",5,45,253,0);
  517.                 BG_Text("b    Change Background Color",5,60,253,0);
  518.                 BG_Text("Up/Down    Move View Up or Down",5,75,253,0);
  519.                 BG_Text("Left/Right    Cycle Frames Forward/Backward",5,90,253,0);
  520.                 BG_Text("Move Mouse moves light source",5,105,253,0);
  521.                 BG_Text("Move Mouse front/back + Right Button Zooms in/out",5,120,253,0);
  522.                 BG_Text("Move Mouse + Left Button Rotates Object",5,135,253,0);
  523.  
  524.                 BG_Text("Use arrow keys (up/down) to see more.",5,170,250,0);
  525.             }
  526.  
  527.             else if(page==5)
  528.             {
  529.                 // page 5
  530.                 BG_Text("..MedDLe Other Info..",BG_ScreenWidth/2-70,2,250,0);
  531.  
  532.                 BG_Text("Import bitmap by command line:",5,30,253,0);
  533.                 BG_Text("mdl -i player.bmp [# skin] player.mdl",5,45,253,0);
  534.                 BG_Text("  if # is bigger than num skins, adds a skin",5,60,253,0);
  535.                 BG_Text("Export bitmaps by command line:",5,60,253,0);
  536.                 BG_Text("mdl -e player.bmp [# skin] player.mdl",5,75,253,0);
  537.                 BG_Text(" if # is 0, creats a blank skin",5,90,253,0);
  538.  
  539.                 BG_Text("Use arrow keys (up/down) to see more.",5,170,250,0);
  540.             }
  541.  
  542.  
  543.          }
  544.  
  545.  
  546.         }
  547.  
  548.  
  549.     if(draw_3d==2) return 0;
  550.     else if(draw_3d==1) return 2;
  551.     else return 1;
  552.  
  553. }
  554.  
  555. void load_model(char *filename, MDL_model *model)
  556. {
  557.     FILE *in;
  558.     char str[256];
  559.  
  560.     strcpy(str,progspath);
  561.     strcat(str,filename);
  562.  
  563.     if((in=fopen(str,"rb"))==NULL)
  564.     {
  565.         printf("can't open mdl file \"%s\" ...exiting\n",str);
  566.         exit(1);
  567.     }
  568.     read_mdl(in, model);
  569.     fclose(in);
  570.  
  571.     strcpy(model->filename,filename);
  572.  
  573.     // setup 3d stuff
  574.     printf("wait... setting up 3d data.\n");
  575.      setup_3d_data(model);
  576.  
  577. }
  578.  
  579.  
  580.  
  581. void vline(unsigned char *pic, int *v1, int *v2, MDL_model model)
  582. {
  583.  
  584.             int i;
  585.             register int inc_ah,inc_al;
  586.             int dx,dy,long_d,short_d;
  587.             int d,add_dh,add_dl;
  588.             int inc_xh,inc_yh,inc_xl,inc_yl;
  589.  
  590.             dx=v2[0]-v1[0]; dy=v2[1]-v1[1];
  591.  
  592.             if(dx<0){dx=-dx; inc_xh=-1; inc_xl=-1;}
  593.             else    {        inc_xh=1;  inc_xl=1; }
  594.  
  595.             if(dy<0){dy=-dy;inc_yh=-model.skinw;
  596.                    inc_yl=-model.skinw;
  597.                    }
  598.             else    {       inc_yh= model.skinw;
  599.                    inc_yl= model.skinw;
  600.             }
  601.            if(dx>dy){long_d=dx;short_d=dy;inc_yl=0;}
  602.             else     {long_d=dy;short_d=dx;inc_xl=0;}
  603.  
  604.             inc_ah=inc_xh+inc_yh;
  605.             inc_al=inc_xl+inc_yl;
  606.             pic+=v1[1]*model.skinw+v1[0];
  607.  
  608.             d=2*short_d-long_d;
  609.             add_dl=2*short_d;
  610.             add_dh=2*short_d-2*long_d;
  611.  
  612.             for(i=0;i<=long_d;i++)
  613.             {
  614.                 *pic=11;
  615.                 if(d>=0){pic+=inc_ah; d+=add_dh;}
  616.                 else    {pic+=inc_al; d+=add_dl;}
  617.             }
  618.  
  619. }