478
faceSizes(rubikstruct * rp, int face, int * sizeOfRow, int * sizeOfColumn)
483
*sizeOfRow = MAXSIZEX;
484
*sizeOfColumn = MAXSIZEZ;
488
*sizeOfRow = MAXSIZEZ;
489
*sizeOfColumn = MAXSIZEY;
493
*sizeOfRow = MAXSIZEX;
494
*sizeOfColumn = MAXSIZEY;
500
checkFaceSquare(rubikstruct * rp, int face)
502
int sizeOfRow, sizeOfColumn;
504
faceSizes(rp, face, &sizeOfRow, &sizeOfColumn);
505
return (sizeOfRow == sizeOfColumn);
506
/* Cubes can be made square with a 4x2 face where 90 degree turns
507
* should be permitted but that is kind of complicated for me.
508
* This can be done in 2 ways where the side of the cubies are
509
* the same size and one where one side (the side with half the
510
* number of cubies) is twice the size of the other. The first is
511
* complicated because faces of cubies can go under other faces.
512
* The second way is similar to "banded cubes" where scotch tape
513
* restricts the moves of some cubes. Here you have to keep track
514
* of the restrictions and show banded cubies graphically as one
520
sizeFace(rubikstruct * rp, int face)
522
int sizeOfRow, sizeOfColumn;
524
faceSizes(rp, face, &sizeOfRow, &sizeOfColumn);
525
return (sizeOfRow * sizeOfColumn);
529
sizeRow(rubikstruct * rp, int face)
531
int sizeOfRow, sizeOfColumn; /* sizeOfColumn not used */
533
faceSizes(rp, face, &sizeOfRow, &sizeOfColumn);
538
draw_stickerless_cubit(rubikstruct *rp)
541
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
542
/* Put sticker here */
543
glNormal3f(0.00, 0.00, 1.00);
544
glVertex3f(-CUBEROUND, -CUBEROUND, CUBELEN);
545
glVertex3f(CUBEROUND, -CUBEROUND, CUBELEN);
546
glVertex3f(CUBEROUND, CUBEROUND, CUBELEN);
547
glVertex3f(-CUBEROUND, CUBEROUND, CUBELEN);
548
glNormal3f(0.00, 0.00, -1.00);
549
glVertex3f(-CUBEROUND, CUBEROUND, -CUBELEN);
550
glVertex3f(CUBEROUND, CUBEROUND, -CUBELEN);
551
glVertex3f(CUBEROUND, -CUBEROUND, -CUBELEN);
552
glVertex3f(-CUBEROUND, -CUBEROUND, -CUBELEN);
553
glNormal3f(-1.00, 0.00, 0.00);
554
glVertex3f(-CUBELEN, -CUBEROUND, CUBEROUND);
555
glVertex3f(-CUBELEN, CUBEROUND, CUBEROUND);
556
glVertex3f(-CUBELEN, CUBEROUND, -CUBEROUND);
557
glVertex3f(-CUBELEN, -CUBEROUND, -CUBEROUND);
558
glNormal3f(1.00, 0.00, 0.00);
559
glVertex3f(CUBELEN, -CUBEROUND, -CUBEROUND);
560
glVertex3f(CUBELEN, CUBEROUND, -CUBEROUND);
561
glVertex3f(CUBELEN, CUBEROUND, CUBEROUND);
562
glVertex3f(CUBELEN, -CUBEROUND, CUBEROUND);
563
glNormal3f(0.00, -1.00, 0.00);
564
glVertex3f(CUBEROUND, -CUBELEN, -CUBEROUND);
565
glVertex3f(CUBEROUND, -CUBELEN, CUBEROUND);
566
glVertex3f(-CUBEROUND, -CUBELEN, CUBEROUND);
567
glVertex3f(-CUBEROUND, -CUBELEN, -CUBEROUND);
568
glNormal3f(0.00, 1.00, 0.00);
569
glVertex3f(-CUBEROUND, CUBELEN, -CUBEROUND);
570
glVertex3f(-CUBEROUND, CUBELEN, CUBEROUND);
571
glVertex3f(CUBEROUND, CUBELEN, CUBEROUND);
572
glVertex3f(CUBEROUND, CUBELEN, -CUBEROUND);
575
glNormal3f(-1.00, -1.00, 0.00);
576
glVertex3f(-CUBEROUND, -CUBELEN, -CUBEROUND);
577
glVertex3f(-CUBEROUND, -CUBELEN, CUBEROUND);
578
glVertex3f(-CUBELEN, -CUBEROUND, CUBEROUND);
579
glVertex3f(-CUBELEN, -CUBEROUND, -CUBEROUND);
580
glNormal3f(1.00, 1.00, 0.00);
581
glVertex3f(CUBEROUND, CUBELEN, -CUBEROUND);
582
glVertex3f(CUBEROUND, CUBELEN, CUBEROUND);
583
glVertex3f(CUBELEN, CUBEROUND, CUBEROUND);
584
glVertex3f(CUBELEN, CUBEROUND, -CUBEROUND);
585
glNormal3f(-1.00, 1.00, 0.00);
586
glVertex3f(-CUBELEN, CUBEROUND, -CUBEROUND);
587
glVertex3f(-CUBELEN, CUBEROUND, CUBEROUND);
588
glVertex3f(-CUBEROUND, CUBELEN, CUBEROUND);
589
glVertex3f(-CUBEROUND, CUBELEN, -CUBEROUND);
590
glNormal3f(1.00, -1.00, 0.00);
591
glVertex3f(CUBELEN, -CUBEROUND, -CUBEROUND);
592
glVertex3f(CUBELEN, -CUBEROUND, CUBEROUND);
593
glVertex3f(CUBEROUND, -CUBELEN, CUBEROUND);
594
glVertex3f(CUBEROUND, -CUBELEN, -CUBEROUND);
595
glNormal3f(0.00, -1.00, -1.00);
596
glVertex3f(-CUBEROUND, -CUBEROUND, -CUBELEN);
597
glVertex3f(CUBEROUND, -CUBEROUND, -CUBELEN);
598
glVertex3f(CUBEROUND, -CUBELEN, -CUBEROUND);
599
glVertex3f(-CUBEROUND, -CUBELEN, -CUBEROUND);
600
glNormal3f(0.00, 1.00, 1.00);
601
glVertex3f(-CUBEROUND, CUBEROUND, CUBELEN);
602
glVertex3f(CUBEROUND, CUBEROUND, CUBELEN);
603
glVertex3f(CUBEROUND, CUBELEN, CUBEROUND);
604
glVertex3f(-CUBEROUND, CUBELEN, CUBEROUND);
605
glNormal3f(0.00, -1.00, 1.00);
606
glVertex3f(-CUBEROUND, -CUBELEN, CUBEROUND);
607
glVertex3f(CUBEROUND, -CUBELEN, CUBEROUND);
608
glVertex3f(CUBEROUND, -CUBEROUND, CUBELEN);
609
glVertex3f(-CUBEROUND, -CUBEROUND, CUBELEN);
610
glNormal3f(0.00, 1.00, -1.00);
611
glVertex3f(-CUBEROUND, CUBELEN, -CUBEROUND);
612
glVertex3f(CUBEROUND, CUBELEN, -CUBEROUND);
613
glVertex3f(CUBEROUND, CUBEROUND, -CUBELEN);
614
glVertex3f(-CUBEROUND, CUBEROUND, -CUBELEN);
615
glNormal3f(-1.00, 0.00, -1.00);
616
glVertex3f(-CUBELEN, -CUBEROUND, -CUBEROUND);
617
glVertex3f(-CUBELEN, CUBEROUND, -CUBEROUND);
618
glVertex3f(-CUBEROUND, CUBEROUND, -CUBELEN);
619
glVertex3f(-CUBEROUND, -CUBEROUND, -CUBELEN);
620
glNormal3f(1.00, 0.00, 1.00);
621
glVertex3f(CUBELEN, -CUBEROUND, CUBEROUND);
622
glVertex3f(CUBELEN, CUBEROUND, CUBEROUND);
623
glVertex3f(CUBEROUND, CUBEROUND, CUBELEN);
624
glVertex3f(CUBEROUND, -CUBEROUND, CUBELEN);
625
glNormal3f(1.00, 0.00, -1.00);
626
glVertex3f(CUBEROUND, -CUBEROUND, -CUBELEN);
627
glVertex3f(CUBEROUND, CUBEROUND, -CUBELEN);
628
glVertex3f(CUBELEN, CUBEROUND, -CUBEROUND);
629
glVertex3f(CUBELEN, -CUBEROUND, -CUBEROUND);
630
glNormal3f(-1.00, 0.00, 1.00);
631
glVertex3f(-CUBEROUND, -CUBEROUND, CUBELEN);
632
glVertex3f(-CUBEROUND, CUBEROUND, CUBELEN);
633
glVertex3f(-CUBELEN, CUBEROUND, CUBEROUND);
634
glVertex3f(-CUBELEN, -CUBEROUND, CUBEROUND);
636
glBegin(GL_TRIANGLES);
637
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
638
/* Corners of cubit */
639
glNormal3f(1.00, 1.00, 1.00);
640
glVertex3f(CUBEROUND, CUBEROUND, CUBELEN);
641
glVertex3f(CUBELEN, CUBEROUND, CUBEROUND);
642
glVertex3f(CUBEROUND, CUBELEN, CUBEROUND);
643
glNormal3f(-1.00, -1.00, -1.00);
644
glVertex3f(-CUBEROUND, -CUBELEN, -CUBEROUND);
645
glVertex3f(-CUBELEN, -CUBEROUND, -CUBEROUND);
646
glVertex3f(-CUBEROUND, -CUBEROUND, -CUBELEN);
647
glNormal3f(-1.00, 1.00, 1.00);
648
glVertex3f(-CUBEROUND, CUBEROUND, CUBELEN);
649
glVertex3f(-CUBEROUND, CUBELEN, CUBEROUND);
650
glVertex3f(-CUBELEN, CUBEROUND, CUBEROUND);
651
glNormal3f(1.00, -1.00, -1.00);
652
glVertex3f(CUBELEN, -CUBEROUND, -CUBEROUND);
653
glVertex3f(CUBEROUND, -CUBELEN, -CUBEROUND);
654
glVertex3f(CUBEROUND, -CUBEROUND, -CUBELEN);
655
glNormal3f(1.00, -1.00, 1.00);
656
glVertex3f(CUBEROUND, -CUBEROUND, CUBELEN);
657
glVertex3f(CUBEROUND, -CUBELEN, CUBEROUND);
658
glVertex3f(CUBELEN, -CUBEROUND, CUBEROUND);
659
glNormal3f(-1.00, 1.00, -1.00);
660
glVertex3f(-CUBELEN, CUBEROUND, -CUBEROUND);
661
glVertex3f(-CUBEROUND, CUBELEN, -CUBEROUND);
662
glVertex3f(-CUBEROUND, CUBEROUND, -CUBELEN);
663
glNormal3f(-1.00, -1.00, 1.00);
664
glVertex3f(-CUBEROUND, -CUBEROUND, CUBELEN);
665
glVertex3f(-CUBELEN, -CUBEROUND, CUBEROUND);
666
glVertex3f(-CUBEROUND, -CUBELEN, CUBEROUND);
667
glNormal3f(1.00, 1.00, -1.00);
668
glVertex3f(CUBELEN, CUBEROUND, -CUBEROUND);
669
glVertex3f(CUBEROUND, CUBEROUND, -CUBELEN);
670
glVertex3f(CUBEROUND, CUBELEN, -CUBEROUND);
493
676
draw_cubit(ModeInfo * mi,
494
677
int back, int front, int left, int right, int bottom, int top)
496
679
rubikstruct *rp = &rubik[MI_SCREEN(mi)];
497
680
int mono = MI_IS_MONO(mi);
499
if (!rp->AreObjectsDefined[ObjCubit]) {
500
glNewList(objects + ObjCubit, GL_COMPILE_AND_EXECUTE);
502
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
503
glNormal3f(0.00, 0.00, 1.00);
504
glVertex3f(-0.45, -0.45, 0.50);
505
glVertex3f(0.45, -0.45, 0.50);
506
glVertex3f(0.45, 0.45, 0.50);
507
glVertex3f(-0.45, 0.45, 0.50);
508
glNormal3f(0.00, 0.00, -1.00);
509
glVertex3f(-0.45, 0.45, -0.50);
510
glVertex3f(0.45, 0.45, -0.50);
511
glVertex3f(0.45, -0.45, -0.50);
512
glVertex3f(-0.45, -0.45, -0.50);
513
glNormal3f(-1.00, 0.00, 0.00);
514
glVertex3f(-0.50, -0.45, 0.45);
515
glVertex3f(-0.50, 0.45, 0.45);
516
glVertex3f(-0.50, 0.45, -0.45);
517
glVertex3f(-0.50, -0.45, -0.45);
518
glNormal3f(1.00, 0.00, 0.00);
519
glVertex3f(0.50, -0.45, -0.45);
520
glVertex3f(0.50, 0.45, -0.45);
521
glVertex3f(0.50, 0.45, 0.45);
522
glVertex3f(0.50, -0.45, 0.45);
523
glNormal3f(0.00, -1.00, 0.00);
524
glVertex3f(0.45, -0.50, -0.45);
525
glVertex3f(0.45, -0.50, 0.45);
526
glVertex3f(-0.45, -0.50, 0.45);
527
glVertex3f(-0.45, -0.50, -0.45);
528
glNormal3f(0.00, 1.00, 0.00);
529
glVertex3f(-0.45, 0.50, -0.45);
530
glVertex3f(-0.45, 0.50, 0.45);
531
glVertex3f(0.45, 0.50, 0.45);
532
glVertex3f(0.45, 0.50, -0.45);
533
glNormal3f(-1.00, -1.00, 0.00);
534
glVertex3f(-0.45, -0.50, -0.45);
535
glVertex3f(-0.45, -0.50, 0.45);
536
glVertex3f(-0.50, -0.45, 0.45);
537
glVertex3f(-0.50, -0.45, -0.45);
538
glNormal3f(1.00, 1.00, 0.00);
539
glVertex3f(0.45, 0.50, -0.45);
540
glVertex3f(0.45, 0.50, 0.45);
541
glVertex3f(0.50, 0.45, 0.45);
542
glVertex3f(0.50, 0.45, -0.45);
543
glNormal3f(-1.00, 1.00, 0.00);
544
glVertex3f(-0.50, 0.45, -0.45);
545
glVertex3f(-0.50, 0.45, 0.45);
546
glVertex3f(-0.45, 0.50, 0.45);
547
glVertex3f(-0.45, 0.50, -0.45);
548
glNormal3f(1.00, -1.00, 0.00);
549
glVertex3f(0.50, -0.45, -0.45);
550
glVertex3f(0.50, -0.45, 0.45);
551
glVertex3f(0.45, -0.50, 0.45);
552
glVertex3f(0.45, -0.50, -0.45);
553
glNormal3f(0.00, -1.00, -1.00);
554
glVertex3f(-0.45, -0.45, -0.50);
555
glVertex3f(0.45, -0.45, -0.50);
556
glVertex3f(0.45, -0.50, -0.45);
557
glVertex3f(-0.45, -0.50, -0.45);
558
glNormal3f(0.00, 1.00, 1.00);
559
glVertex3f(-0.45, 0.45, 0.50);
560
glVertex3f(0.45, 0.45, 0.50);
561
glVertex3f(0.45, 0.50, 0.45);
562
glVertex3f(-0.45, 0.50, 0.45);
563
glNormal3f(0.00, -1.00, 1.00);
564
glVertex3f(-0.45, -0.50, 0.45);
565
glVertex3f(0.45, -0.50, 0.45);
566
glVertex3f(0.45, -0.45, 0.50);
567
glVertex3f(-0.45, -0.45, 0.50);
568
glNormal3f(0.00, 1.00, -1.00);
569
glVertex3f(-0.45, 0.50, -0.45);
570
glVertex3f(0.45, 0.50, -0.45);
571
glVertex3f(0.45, 0.45, -0.50);
572
glVertex3f(-0.45, 0.45, -0.50);
573
glNormal3f(-1.00, 0.00, -1.00);
574
glVertex3f(-0.50, -0.45, -0.45);
575
glVertex3f(-0.50, 0.45, -0.45);
576
glVertex3f(-0.45, 0.45, -0.50);
577
glVertex3f(-0.45, -0.45, -0.50);
578
glNormal3f(1.00, 0.00, 1.00);
579
glVertex3f(0.50, -0.45, 0.45);
580
glVertex3f(0.50, 0.45, 0.45);
581
glVertex3f(0.45, 0.45, 0.50);
582
glVertex3f(0.45, -0.45, 0.50);
583
glNormal3f(1.00, 0.00, -1.00);
584
glVertex3f(0.45, -0.45, -0.50);
585
glVertex3f(0.45, 0.45, -0.50);
586
glVertex3f(0.50, 0.45, -0.45);
587
glVertex3f(0.50, -0.45, -0.45);
588
glNormal3f(-1.00, 0.00, 1.00);
589
glVertex3f(-0.45, -0.45, 0.50);
590
glVertex3f(-0.45, 0.45, 0.50);
591
glVertex3f(-0.50, 0.45, 0.45);
592
glVertex3f(-0.50, -0.45, 0.45);
594
glBegin(GL_TRIANGLES);
595
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray);
596
glNormal3f(1.00, 1.00, 1.00);
597
glVertex3f(0.45, 0.45, 0.50);
598
glVertex3f(0.50, 0.45, 0.45);
599
glVertex3f(0.45, 0.50, 0.45);
600
glNormal3f(-1.00, -1.00, -1.00);
601
glVertex3f(-0.45, -0.50, -0.45);
602
glVertex3f(-0.50, -0.45, -0.45);
603
glVertex3f(-0.45, -0.45, -0.50);
604
glNormal3f(-1.00, 1.00, 1.00);
605
glVertex3f(-0.45, 0.45, 0.50);
606
glVertex3f(-0.45, 0.50, 0.45);
607
glVertex3f(-0.50, 0.45, 0.45);
608
glNormal3f(1.00, -1.00, -1.00);
609
glVertex3f(0.50, -0.45, -0.45);
610
glVertex3f(0.45, -0.50, -0.45);
611
glVertex3f(0.45, -0.45, -0.50);
612
glNormal3f(1.00, -1.00, 1.00);
613
glVertex3f(0.45, -0.45, 0.50);
614
glVertex3f(0.45, -0.50, 0.45);
615
glVertex3f(0.50, -0.45, 0.45);
616
glNormal3f(-1.00, 1.00, -1.00);
617
glVertex3f(-0.50, 0.45, -0.45);
618
glVertex3f(-0.45, 0.50, -0.45);
619
glVertex3f(-0.45, 0.45, -0.50);
620
glNormal3f(-1.00, -1.00, 1.00);
621
glVertex3f(-0.45, -0.45, 0.50);
622
glVertex3f(-0.50, -0.45, 0.45);
623
glVertex3f(-0.45, -0.50, 0.45);
624
glNormal3f(1.00, 1.00, -1.00);
625
glVertex3f(0.50, 0.45, -0.45);
626
glVertex3f(0.45, 0.45, -0.50);
627
glVertex3f(0.45, 0.50, -0.45);
630
rp->AreObjectsDefined[ObjCubit] = 1;
632
(void) printf("Cubit drawn SLOWLY\n");
635
glCallList(objects + ObjCubit);
637
(void) printf("Cubit drawn quickly\n");
682
if (!draw_stickerless_cubit(rp))
641
684
if (back != NO_FACE) {
642
685
glBegin(GL_POLYGON);
643
686
pickcolor(back, mono);
644
687
glNormal3f(0.00, 0.00, -1.00);
645
glVertex3f(-0.35, 0.40, -0.51);
646
glVertex3f(0.35, 0.40, -0.51);
647
glVertex3f(0.40, 0.35, -0.51);
648
glVertex3f(0.40, -0.35, -0.51);
649
glVertex3f(0.35, -0.40, -0.51);
650
glVertex3f(-0.35, -0.40, -0.51);
651
glVertex3f(-0.40, -0.35, -0.51);
652
glVertex3f(-0.40, 0.35, -0.51);
688
glVertex3f(-STICKERSHORT, STICKERLONG, -STICKERDEPTH);
689
glVertex3f(STICKERSHORT, STICKERLONG, -STICKERDEPTH);
690
glVertex3f(STICKERLONG, STICKERSHORT, -STICKERDEPTH);
691
glVertex3f(STICKERLONG, -STICKERSHORT, -STICKERDEPTH);
692
glVertex3f(STICKERSHORT, -STICKERLONG, -STICKERDEPTH);
693
glVertex3f(-STICKERSHORT, -STICKERLONG, -STICKERDEPTH);
694
glVertex3f(-STICKERLONG, -STICKERSHORT, -STICKERDEPTH);
695
glVertex3f(-STICKERLONG, STICKERSHORT, -STICKERDEPTH);
655
698
if (front != NO_FACE) {
656
699
glBegin(GL_POLYGON);
657
700
pickcolor(front, mono);
658
701
glNormal3f(0.00, 0.00, 1.00);
659
glVertex3f(-0.35, -0.40, 0.51);
660
glVertex3f(0.35, -0.40, 0.51);
661
glVertex3f(0.40, -0.35, 0.51);
662
glVertex3f(0.40, 0.35, 0.51);
663
glVertex3f(0.35, 0.40, 0.51);
664
glVertex3f(-0.35, 0.40, 0.51);
665
glVertex3f(-0.40, 0.35, 0.51);
666
glVertex3f(-0.40, -0.35, 0.51);
702
glVertex3f(-STICKERSHORT, -STICKERLONG, STICKERDEPTH);
703
glVertex3f(STICKERSHORT, -STICKERLONG, STICKERDEPTH);
704
glVertex3f(STICKERLONG, -STICKERSHORT, STICKERDEPTH);
705
glVertex3f(STICKERLONG, STICKERSHORT, STICKERDEPTH);
706
glVertex3f(STICKERSHORT, STICKERLONG, STICKERDEPTH);
707
glVertex3f(-STICKERSHORT, STICKERLONG, STICKERDEPTH);
708
glVertex3f(-STICKERLONG, STICKERSHORT, STICKERDEPTH);
709
glVertex3f(-STICKERLONG, -STICKERSHORT, STICKERDEPTH);
669
712
if (left != NO_FACE) {
670
713
glBegin(GL_POLYGON);
671
714
pickcolor(left, mono);
672
715
glNormal3f(-1.00, 0.00, 0.00);
673
glVertex3f(-0.51, -0.35, 0.40);
674
glVertex3f(-0.51, 0.35, 0.40);
675
glVertex3f(-0.51, 0.40, 0.35);
676
glVertex3f(-0.51, 0.40, -0.35);
677
glVertex3f(-0.51, 0.35, -0.40);
678
glVertex3f(-0.51, -0.35, -0.40);
679
glVertex3f(-0.51, -0.40, -0.35);
680
glVertex3f(-0.51, -0.40, 0.35);
716
glVertex3f(-STICKERDEPTH, -STICKERSHORT, STICKERLONG);
717
glVertex3f(-STICKERDEPTH, STICKERSHORT, STICKERLONG);
718
glVertex3f(-STICKERDEPTH, STICKERLONG, STICKERSHORT);
719
glVertex3f(-STICKERDEPTH, STICKERLONG, -STICKERSHORT);
720
glVertex3f(-STICKERDEPTH, STICKERSHORT, -STICKERLONG);
721
glVertex3f(-STICKERDEPTH, -STICKERSHORT, -STICKERLONG);
722
glVertex3f(-STICKERDEPTH, -STICKERLONG, -STICKERSHORT);
723
glVertex3f(-STICKERDEPTH, -STICKERLONG, STICKERSHORT);
683
726
if (right != NO_FACE) {
684
727
glBegin(GL_POLYGON);
685
728
pickcolor(right, mono);
686
729
glNormal3f(1.00, 0.00, 0.00);
687
glVertex3f(0.51, -0.35, -0.40);
688
glVertex3f(0.51, 0.35, -0.40);
689
glVertex3f(0.51, 0.40, -0.35);
690
glVertex3f(0.51, 0.40, 0.35);
691
glVertex3f(0.51, 0.35, 0.40);
692
glVertex3f(0.51, -0.35, 0.40);
693
glVertex3f(0.51, -0.40, 0.35);
694
glVertex3f(0.51, -0.40, -0.35);
730
glVertex3f(STICKERDEPTH, -STICKERSHORT, -STICKERLONG);
731
glVertex3f(STICKERDEPTH, STICKERSHORT, -STICKERLONG);
732
glVertex3f(STICKERDEPTH, STICKERLONG, -STICKERSHORT);
733
glVertex3f(STICKERDEPTH, STICKERLONG, STICKERSHORT);
734
glVertex3f(STICKERDEPTH, STICKERSHORT, STICKERLONG);
735
glVertex3f(STICKERDEPTH, -STICKERSHORT, STICKERLONG);
736
glVertex3f(STICKERDEPTH, -STICKERLONG, STICKERSHORT);
737
glVertex3f(STICKERDEPTH, -STICKERLONG, -STICKERSHORT);
697
740
if (bottom != NO_FACE) {
698
741
glBegin(GL_POLYGON);
699
742
pickcolor(bottom, mono);
700
743
glNormal3f(0.00, -1.00, 0.00);
701
glVertex3f(0.40, -0.51, -0.35);
702
glVertex3f(0.40, -0.51, 0.35);
703
glVertex3f(0.35, -0.51, 0.40);
704
glVertex3f(-0.35, -0.51, 0.40);
705
glVertex3f(-0.40, -0.51, 0.35);
706
glVertex3f(-0.40, -0.51, -0.35);
707
glVertex3f(-0.35, -0.51, -0.40);
708
glVertex3f(0.35, -0.51, -0.40);
744
glVertex3f(STICKERLONG, -STICKERDEPTH, -STICKERSHORT);
745
glVertex3f(STICKERLONG, -STICKERDEPTH, STICKERSHORT);
746
glVertex3f(STICKERSHORT, -STICKERDEPTH, STICKERLONG);
747
glVertex3f(-STICKERSHORT, -STICKERDEPTH, STICKERLONG);
748
glVertex3f(-STICKERLONG, -STICKERDEPTH, STICKERSHORT);
749
glVertex3f(-STICKERLONG, -STICKERDEPTH, -STICKERSHORT);
750
glVertex3f(-STICKERSHORT, -STICKERDEPTH, -STICKERLONG);
751
glVertex3f(STICKERSHORT, -STICKERDEPTH, -STICKERLONG);
711
754
if (top != NO_FACE) {
712
755
glBegin(GL_POLYGON);
713
756
pickcolor(top, mono);
714
757
glNormal3f(0.00, 1.00, 0.00);
715
glVertex3f(-0.40, 0.51, -0.35);
716
glVertex3f(-0.40, 0.51, 0.35);
717
glVertex3f(-0.35, 0.51, 0.40);
718
glVertex3f(0.35, 0.51, 0.40);
719
glVertex3f(0.40, 0.51, 0.35);
720
glVertex3f(0.40, 0.51, -0.35);
721
glVertex3f(0.35, 0.51, -0.40);
722
glVertex3f(-0.35, 0.51, -0.40);
758
glVertex3f(-STICKERLONG, STICKERDEPTH, -STICKERSHORT);
759
glVertex3f(-STICKERLONG, STICKERDEPTH, STICKERSHORT);
760
glVertex3f(-STICKERSHORT, STICKERDEPTH, STICKERLONG);
761
glVertex3f(STICKERSHORT, STICKERDEPTH, STICKERLONG);
762
glVertex3f(STICKERLONG, STICKERDEPTH, STICKERSHORT);
763
glVertex3f(STICKERLONG, STICKERDEPTH, -STICKERSHORT);
764
glVertex3f(STICKERSHORT, STICKERDEPTH, -STICKERLONG);
765
glVertex3f(-STICKERSHORT, STICKERDEPTH, -STICKERLONG);
729
convertMove(rubikstruct * rp, RubikMove move)
771
/* Convert move to weird general notation */
773
convertMove(rubikstruct * rp, RubikMove move, RubikSlice * slice)
776
int sizeOfRow, sizeOfColumn;
734
778
plane = rotateSlice[(int) move.face][move.direction % 2];
735
slice.face = plane.face;
736
slice.rotation = plane.rotation;
737
if (slice.rotation == CW) /* I just know this to be true... */
738
slice.depth = AVSIZESQ - 1 - move.position;
740
slice.depth = move.position;
741
slice.depth = slice.depth / AVSIZE;
742
/* If slice.depth = 0 then face 0, face 1, or face 2 moves */
779
(*slice).face = plane.face;
780
(*slice).rotation = plane.rotation;
782
faceSizes(rp, move.face, &sizeOfRow, &sizeOfColumn);
783
if (plane.face == 1 || /* VERTICAL */
784
(plane.face == 2 && (move.face == 1 || move.face == 3))) {
785
if ((*slice).rotation == CW)
786
(*slice).depth = sizeOfRow - 1 - move.position %
789
(*slice).depth = move.position % sizeOfRow;
790
} else { /* (plane.face == 0 || *//* HORIZONTAL *//*
791
(plane.face == 2 && (move.face == 0 || move.face == 4))) */
792
if ((*slice).rotation == CW)
793
(*slice).depth = sizeOfColumn - 1 - move.position /
796
(*slice).depth = move.position / sizeOfRow;
798
/* If (*slice).depth = 0 then face 0, face 1, or face 2 moves */
743
799
if (move.direction / 2)
744
slice.rotation = (plane.rotation == CW) ? CCW : CW;
800
(*slice).rotation = ((*slice).rotation == CW) ? CCW : CW;
748
/* Assume for the moment that the size is at least 2 */
803
/* Assume the size is at least 2, or its just not challenging... */
750
805
draw_cube(ModeInfo * mi)
1336
1395
writeRC(rubikstruct * rp, int face, int dir, int h, int orient, int size)
1397
int g, position, sizeOfRow;
1399
sizeOfRow = sizeRow(rp, face);
1340
1400
if (dir == TOP || dir == BOTTOM) {
1341
1401
for (g = 0; g < size; g++) {
1342
position = g * size + h;
1402
position = g * sizeOfRow + h;
1343
1403
rp->cubeLoc[face][position] = rp->rowLoc[orient][g];
1344
1404
/* DrawSquare(face, position); */
1346
1406
} else { /* dir == RIGHT || dir == LEFT */
1347
1407
for (g = 0; g < size; g++) {
1348
position = h * size + g;
1408
position = h * sizeOfRow + g;
1349
1409
rp->cubeLoc[face][position] = rp->rowLoc[orient][g];
1350
1410
/* DrawSquare(face, position); */
1356
1416
rotateFace(rubikstruct * rp, int face, int direction)
1359
RubikLoc *faceLoc = NULL;
1418
int position, i, j, sizeOfRow, sizeOfColumn, sizeOnPlane;
1361
if ((faceLoc = (RubikLoc *) malloc(AVSIZESQ * sizeof (RubikLoc))) == NULL)
1362
(void) fprintf(stderr,
1363
"Could not allocate memory for rubik face position info\n");
1421
faceSizes(rp, face, &sizeOfRow, &sizeOfColumn);
1422
sizeOnPlane = sizeOfRow * sizeOfColumn;
1423
if ((faceLoc = (RubikLoc *) malloc(sizeOnPlane *
1424
sizeof (RubikLoc))) == NULL) {
1364
1427
/* Read Face */
1365
for (position = 0; position < AVSIZESQ; position++)
1428
for (position = 0; position < sizeOnPlane; position++)
1366
1429
faceLoc[position] = rp->cubeLoc[face][position];
1367
1430
/* Write Face */
1368
for (position = 0; position < AVSIZESQ; position++) {
1369
i = position % AVSIZE;
1370
j = position / AVSIZE;
1371
rp->cubeLoc[face][position] = (direction == CW) ?
1372
faceLoc[(AVSIZE - i - 1) * AVSIZE + j] :
1373
faceLoc[i * AVSIZE + AVSIZE - j - 1];
1431
for (position = 0; position < sizeOnPlane; position++) {
1432
i = position % sizeOfRow;
1433
j = position / sizeOfRow;
1434
if (direction == CW)
1435
rp->cubeLoc[face][position] =
1436
faceLoc[(sizeOfRow - i - 1) * sizeOfRow + j];
1437
else if (direction == CCW)
1438
rp->cubeLoc[face][position] =
1439
faceLoc[i * sizeOfRow + sizeOfColumn - j - 1];
1440
else /* (direction == HALF) */
1441
rp->cubeLoc[face][position] =
1442
faceLoc[sizeOfRow - i - 1 + (sizeOfColumn - j - 1) * sizeOfRow];
1374
1443
rp->cubeLoc[face][position].rotation =
1375
(rp->cubeLoc[face][position].rotation + direction - MAXORIENT) %
1444
(rp->cubeLoc[face][position].rotation +
1445
direction - MAXORIENT) % MAXORIENT;
1377
1446
/* DrawSquare(face, position); */
1379
1448
if (faceLoc != NULL)
1380
1449
(void) free((void *) faceLoc);
1453
/* Yeah this is big and ugly */
1455
slideRC(int face, int direction, int h, int sizeOnOppAxis,
1456
int *newFace, int *newDirection, int *newH,
1457
int *rotate, Bool *reverse)
1459
*newFace = slideNextRow[face][direction].face;
1460
*rotate = slideNextRow[face][direction].rotation;
1461
*newDirection = (*rotate + direction) % MAXORIENT;
1468
if (*newDirection == TOP || *newDirection == BOTTOM) {
1469
*newH = sizeOnOppAxis - 1 - h;
1471
} else { /* *newDirection == RIGHT || *newDirection == LEFT */
1477
*newH = sizeOnOppAxis - 1 - h;
1481
if (*newDirection == TOP || *newDirection == BOTTOM) {
1484
} else { /* *newDirection == RIGHT || *newDirection == LEFT */
1485
*newH = sizeOnOppAxis - 1 - h;
1490
(void) printf("slideRC: rotate %d\n", *rotate);
1384
1497
moveRubik(rubikstruct * rp, int face, int direction, int position)
1386
int newFace, newDirection, rotate, reverse = False;
1499
int newFace, newDirection, rotate, reverse;
1501
int i, j, sizeOfRow, sizeOfColumn, sizeOnAxis, sizeOnOppAxis;
1503
faceSizes(rp, face, &sizeOfRow, &sizeOfColumn);
1390
1504
if (direction == CW || direction == CCW) {
1391
1505
direction = (direction == CCW) ?
1392
1506
(rotateToRow[face].direction + 2) % MAXORIENT :
1393
1507
rotateToRow[face].direction;
1394
i = j = (rotateToRow[face].sideFace == RIGHT ||
1395
rotateToRow[face].sideFace == BOTTOM) ? AVSIZE - 1 : 0;
1508
if (rotateToRow[face].sideFace == RIGHT) {
1509
i = j = sizeOfColumn - 1;
1510
} else if (rotateToRow[face].sideFace == BOTTOM) {
1511
i = j = sizeOfRow - 1;
1396
1515
face = rotateToRow[face].face;
1397
position = j * AVSIZE + i;
1516
position = j * sizeOfRow + i;
1399
i = position % AVSIZE;
1400
j = position / AVSIZE;
1518
i = position % sizeOfRow;
1519
j = position / sizeOfRow;
1401
1520
h = (direction == TOP || direction == BOTTOM) ? i : j;
1402
/* rotate sides CW or CCW */
1403
if (h == AVSIZE - 1) {
1521
if (direction == TOP || direction == BOTTOM) {
1522
sizeOnAxis = sizeOfColumn;
1523
sizeOnOppAxis = sizeOfRow;
1525
sizeOnAxis = sizeOfRow;
1526
sizeOnOppAxis = sizeOfColumn;
1528
/* rotate sides CW or CCW or HALF) */
1530
if (h == sizeOnOppAxis - 1) {
1404
1531
newDirection = (direction == TOP || direction == BOTTOM) ?
1406
if (direction == TOP || direction == RIGHT)
1407
rotateFace(rp, rowToRotate[face][newDirection], CW);
1408
else /* direction == BOTTOM || direction == LEFT */
1409
rotateFace(rp, rowToRotate[face][newDirection], CCW);
1533
if (rp->degreeTurn == 180) {
1534
if (!rotateFace(rp, rowToRotate[face][newDirection], HALF))
1536
} else if (direction == TOP || direction == RIGHT) {
1537
if (!rotateFace(rp, rowToRotate[face][newDirection], CW))
1539
} else { /* direction == BOTTOM || direction == LEFT */
1540
if (!rotateFace(rp, rowToRotate[face][newDirection], CCW))
1412
1545
newDirection = (direction == TOP || direction == BOTTOM) ?
1414
if (direction == TOP || direction == RIGHT)
1415
rotateFace(rp, rowToRotate[face][newDirection], CCW);
1416
else /* direction == BOTTOM || direction == LEFT */
1417
rotateFace(rp, rowToRotate[face][newDirection], CW);
1547
if (rp->degreeTurn == 180) {
1548
if (!rotateFace(rp, rowToRotate[face][newDirection], HALF))
1550
} else if (direction == TOP || direction == RIGHT) {
1551
if (!rotateFace(rp, rowToRotate[face][newDirection], CCW))
1553
} else { /* direction == BOTTOM || direction == LEFT */
1554
if (!rotateFace(rp, rowToRotate[face][newDirection], CW))
1420
readRC(rp, face, direction, h, 0, AVSIZE);
1421
for (k = 1; k <= MAXORIENT; k++) {
1422
newFace = slideNextRow[face][direction].face;
1423
rotate = slideNextRow[face][direction].rotation;
1424
newDirection = (rotate + direction) % MAXORIENT;
1431
if (newDirection == TOP || newDirection == BOTTOM) {
1432
newH = AVSIZE - 1 - h;
1434
} else { /* newDirection == RIGHT || newDirection == LEFT */
1440
newH = AVSIZE - 1 - h;
1444
if (newDirection == TOP || newDirection == BOTTOM) {
1447
} else { /* newDirection == RIGHT || newDirection == LEFT */
1448
newH = AVSIZE - 1 - h;
1453
(void) printf("moveRubik: rotate %d\n", rotate);
1456
readRC(rp, newFace, newDirection, newH, k, AVSIZE);
1457
rotateRC(rp, rotate, k - 1, AVSIZE);
1558
/* Slide rows or columns */
1559
readRC(rp, face, direction, h, 0, sizeOnAxis);
1560
if (rp->degreeTurn == 180) {
1561
int sizeOnDepthAxis;
1563
slideRC(face, direction, h, sizeOnOppAxis,
1564
&newFace, &newDirection, &newH, &rotate, &reverse);
1565
sizeOnDepthAxis = sizeFace(rp, newFace) / sizeOnOppAxis;
1566
readRC(rp, newFace, newDirection, newH, 1, sizeOnDepthAxis);
1567
rotateRC(rp, rotate, 0, sizeOnAxis);
1458
1568
if (reverse == True)
1459
reverseRC(rp, k - 1, AVSIZE);
1460
writeRC(rp, newFace, newDirection, newH, k - 1, AVSIZE);
1569
reverseRC(rp, 0, sizeOnAxis);
1461
1570
face = newFace;
1462
1571
direction = newDirection;
1573
for (k = 2; k <= MAXORIENT + 1; k++) {
1574
slideRC(face, direction, h, sizeOnOppAxis,
1575
&newFace, &newDirection, &newH, &rotate, &reverse);
1576
if (k != MAXORIENT && k != MAXORIENT + 1)
1577
readRC(rp, newFace, newDirection, newH, k,
1578
(k % 2) ? sizeOnDepthAxis : sizeOnAxis);
1579
rotateRC(rp, rotate, k - 2,
1580
(k % 2) ? sizeOnDepthAxis : sizeOnAxis);
1581
if (k != MAXORIENT + 1)
1582
rotateRC(rp, rotate, k - 1,
1583
(k % 2) ? sizeOnAxis : sizeOnDepthAxis);
1584
if (reverse == True) {
1585
reverseRC(rp, k - 2,
1586
(k % 2) ? sizeOnDepthAxis : sizeOnAxis);
1587
if (k != MAXORIENT + 1)
1588
reverseRC(rp, k - 1,
1589
(k % 2) ? sizeOnAxis : sizeOnDepthAxis);
1591
writeRC(rp, newFace, newDirection, newH, k - 2,
1592
(k % 2) ? sizeOnDepthAxis : sizeOnAxis);
1594
direction = newDirection;
1598
for (k = 1; k <= MAXORIENT; k++) {
1599
slideRC(face, direction, h, sizeOnOppAxis,
1600
&newFace, &newDirection, &newH, &rotate, &reverse);
1602
readRC(rp, newFace, newDirection, newH, k, sizeOnAxis);
1603
rotateRC(rp, rotate, k - 1, sizeOnAxis);
1604
if (reverse == True)
1605
reverseRC(rp, k - 1, sizeOnAxis);
1606
writeRC(rp, newFace, newDirection, newH, k - 1, sizeOnAxis);
1608
direction = newDirection;
1469
1617
printCube(rubikstruct * rp)
1619
int face, position, sizeOfRow, sizeOfColumn;
1473
1621
for (face = 0; face < MAXFACES; face++) {
1474
for (position = 0; position < AVSIZESQ; position++) {
1622
faceSizes(rp, face, &sizeOfRow, &sizeOfColumn);
1623
for (position = 0; position < sizeOfRow * sizeOfColumn; position++) {
1475
1624
(void) printf("%d %d ", rp->cubeLoc[face][position].face,
1476
1625
rp->cubeLoc[face][position].rotation);
1477
if (!((position + 1) % AVSIZE))
1626
if (!((position + 1) % sizeOfRow))
1478
1627
(void) printf("\n");
1480
1629
(void) printf("\n");