/[gzz]/gzz/gfx/demo/irregu4.py
ViewVC logotype

Diff of /gzz/gfx/demo/irregu4.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.34 by jvk, Sat Nov 30 21:42:58 2002 UTC revision 1.35 by jvk, Sun Dec 1 06:20:57 2002 UTC
# Line 649  class IrreguScene: Line 649  class IrreguScene:
649    
650    
651  class ShapeScene:  class ShapeScene:
652        def key(self, k):
653            pass
654    
655        def __init__(self, type = 0, outer = 1, alphatest = 1, tex = 1, color = 1, inside = 1, xs = 600, ys = 600):
656            self.type = type
657            self.outer = outer
658            self.alphatest = alphatest
659            self.inside = inside
660            self.tex = tex
661            self.color = color
662            self.xs = xs
663            self.ys = ys
664        
665      def scene(self, vs):      def scene(self, vs):
666          putnoc(vs, background((1.0,1.0,1.0)))          putnoc(vs, background((1.0,1.0,1.0)))
667    
668          xs = 256          shape = 9
669          ys = 256          texscale = 1.3
670            linewidth = 4
671            refsize = 128
672            scale_pow = 0
673            border0 = -.25
674            border1 = .25
675            texslicing = 0.0
676    
677          w = 2          dice = 1.0 / 36 * 16 + 1E-5
         h = 2  
         for y in range(0,h):  
             for x in range(0,w):  
678    
679                            code = stdcode
680                  shape = 10  
681                  texscale = 1          if self.type == 1:
682                  linewidth = 4              texslicing = 1
683                  refsize = 128  
684                  scale_pow = 0          if not self.alphatest:
685                  border0 = -.5 * ripple_scale * texscale              code += "Disable ALPHA_TEST\n"
686                  border1 = .5 * ripple_scale * texscale  
687                  texslicing = 0.0          if not self.tex:
688                                code += "Disable TEXTURE_2D\n"
689                  edge = GLRen.createIrregularEdge(  
690                      shape, texscale, linewidth, refsize, scale_pow,          if self.type == 2:
691                      border0, border1, texslicing,              if not self.outer:
692                      "0 0 0 1 0 0 0 0", "", 0, 0, SLICE_1D + Y_COLOR, # + INSIDE,                  border0,border1=0,0
693                      stdcode, 1.0)              inner = GLRen.createIrregularEdge(
694                                    shape,
695                  cs1 = vs.coords.affineCoordsys(0, 10,                  texscale, linewidth, refsize, scale_pow,
696                                                 (x+1) * xs, (y+1) * ys,                  border0, border1, 1.0,
697                                                 xs/3., 0, 0, ys/3.,                  "", "", 0, 0,
698                                                 )                  65536,
699                    offset_code + parseCombiner("color = 1"), 1.0)
700                outer = GLRen.createIrregularEdge(shape,
701                    texscale, linewidth, refsize, scale_pow,
702                    border0, border1, 1.0,
703                    "", "", 0, 0,
704                    SHIFTS8 + 65536,
705                    offset_code, 1.0)
706            else:
707                inside = self.inside * INSIDE
708    
709                if self.color:
710                    c1 = "1 1 1 1 0 0 0 0"
711                else:
712                    c1 = "0 0 0 0 0 0 0 0"
713    
714                outer = GLRen.createIrregularEdge(
715                    shape, texscale, linewidth, refsize, scale_pow,
716                    border0, border1, texslicing,
717                    c1, "", 0, 0, SLICE_1D + Y_COLOR + SHIFTS8 + inside,
718                    code + """
719                    BlendFunc ZERO ZERO
720                    Enable BLEND
721                    """, dice)
722                if self.outer:
723                    code += parseCombiner("""
724                    SPARE0.alpha = TEX0.alpha + COL0.alpha
725                    alpha = SPARE0.alpha
726                    color = 1
727                    Enable REGISTER_COMBINERS_NV
728                    PolygonMode FRONT_AND_BACK FILL
729                    #PolygonMode FRONT_AND_BACK LINE
730                    """)
731                code += """
732                    Disable BLEND
733                """
734                            
735                  vs.matcher.add(cs1, "1,%s,%s" % (x,y))              inner = GLRen.createIrregularEdge(
736                    shape, texscale, linewidth, refsize, scale_pow,
737                    border0, border1, texslicing,
738                    c1, "", 0, 0, SLICE_1D + Y_COLOR + inside,
739                    code, dice)
740                                    
741                  cs2 = vs.coords.affineCoordsys(0, 0,  0, 0,   1, 0, 0, 1);          cs1 = vs.coords.affineCoordsys(0, 10,
742                  vs.matcher.add(cs1, "2")                                         self.xs*.5, self.ys*.5,
743                                           self.xs * .4, 0, 0, self.ys * .4,
744                                           )
745                
746            vs.matcher.add(cs1, "1")
747                                    
748                  vs.map.put(edge, cs1, cs2)          cs2 = vs.coords.affineCoordsys(0, 0,  0, 0,   1, 0, 0, 1);
749            vs.matcher.add(cs1, "2")
750    
751            if self.outer or self.type == 2:
752                vs.map.put(outer, cs1, cs2)
753            vs.map.put(inner, cs1, cs2)
754    
755  class StillMotionScene:  class StillMotionScene:
756      def __init__(self, type = 0, flag = 0):      def __init__(self, type = 0, flag = 0):
# Line 885  def r(sc, filename): Line 947  def r(sc, filename):
947      saveanim.saveframe(filename, w)      saveanim.saveframe(filename, w)
948    
949  def makeScreenshots():  def makeScreenshots():
     w.setLocation(0,0,1024,768)  
950    
951      # flag = 0: canvas edge shown      # flag = 0: canvas edge shown
952      # flag = 1: no canvas edge shown      # flag = 1: no canvas edge shown
# Line 897  def makeScreenshots(): Line 958  def makeScreenshots():
958      # other parameters are hardcoded      # other parameters are hardcoded
959      # with if's in StillMotionScene class      # with if's in StillMotionScene class
960    
961      ## pre-computed angles      if 0:
962      #ps = StillMotionScene(type = "0b", flag = 1)          w.setLocation(0,0,1024,768)
963      #r(ps, "shots/motion0b.png")          ## pre-computed angles
964            #ps = StillMotionScene(type = "0b", flag = 1)
965      ps = StillMotionScene(type = 0)          #r(ps, "shots/motion0b.png")
966      r(ps, "shots/motion.png")  
967            ps = StillMotionScene(type = 0)
968      ps = StillMotionScene(type = 0, flag = 1)          r(ps, "shots/motion.png")
969      r(ps, "shots/motion0.png")  
970      ps = StillMotionScene(type = 1, flag = 1)          ps = StillMotionScene(type = 0, flag = 1)
971      r(ps, "shots/motion1.png")          r(ps, "shots/motion0.png")
972            ps = StillMotionScene(type = 1, flag = 1)
973      if globals().has_key("texHILO"):          r(ps, "shots/motion1.png")
974          ps = StillMotionScene(type = 2, flag = 2)  
975          r(ps, "shots/motion2.png")          if globals().has_key("texHILO"):
976                ps = StillMotionScene(type = 2, flag = 2)
977                r(ps, "shots/motion2.png")
978    
979    
980        if 1:
981            w.setLocation(0,0,600,600)
982    
983            ps = ShapeScene(type = 0)
984            r(ps, "shots/shape1Ddispl.png")
985            ps = ShapeScene(type = 0, outer = 0, inside = 0, color = 1, alphatest = 0, tex = 0)
986            r(ps, "shots/shape1Dcolor.png")
987            ps = ShapeScene(type = 0, outer = 0, inside = 0, color = 1, alphatest = 0, tex = 1)
988            r(ps, "shots/shape1Ddispltex_color.png")
989            ps = ShapeScene(type = 0, outer = 0, inside = 0, color = 0, alphatest = 0, tex = 1)
990            r(ps, "shots/shape1Ddispltex.png")
991            ps = ShapeScene(type = 1)
992            r(ps, "shots/shape1Doffset.png")
993            ps = ShapeScene(type = 1, outer = 0, inside = 0, color = 1, alphatest = 0, tex = 1)
994            r(ps, "shots/shape1Doffsettex_color.png")
995            ps = ShapeScene(type = 1, outer = 0, inside = 0, color = 0, alphatest = 0, tex = 1)
996            r(ps, "shots/shape1Doffsettex.png")
997            ps = ShapeScene(type = 2)
998            r(ps, "shots/shape2D.png")
999            ps = ShapeScene(type = 2, outer = 0)
1000            r(ps, "shots/shape2Dorig.png")
1001    
1002  currentScene = IrreguScene()  currentScene = IrreguScene()
1003    
1004  #currentScene = StillMotionScene(type = 1, flag = 1)  #currentScene = ShapeScene(type = 2, outer = 0)
1005    
1006  #currentScene = ShapeScene()  #currentScene = StillMotionScene(type = 1, flag = 1)
1007    
1008  #GL.call("PolygonMode FRONT_AND_BACK FILL")  #GL.call("PolygonMode FRONT_AND_BACK FILL")

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26