[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx/demo paperbasis.py
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx/demo paperbasis.py |
Date: |
Mon, 16 Sep 2002 06:18:49 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/09/16 06:18:49
Modified files:
gfx/demo : paperbasis.py
Log message:
Do not use papermill; generate all paper code for total control
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/paperbasis.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/paperbasis.py
diff -c gzz/gfx/demo/paperbasis.py:1.8 gzz/gfx/demo/paperbasis.py:1.9
*** gzz/gfx/demo/paperbasis.py:1.8 Mon Sep 16 05:19:39 2002
--- gzz/gfx/demo/paperbasis.py Mon Sep 16 06:18:48 2002
***************
*** 2,8 ****
from gfx.libutil import nvcode
! execfile("gfx/libpaper/papermill.py")
passmask = [ 1, 0, 0, 0 ]
--- 2,16 ----
from gfx.libutil import nvcode
! from gzz.gfx.gl import GZZGL,Paper,PaperMill
!
! import java
! from java.lang import Math
!
! execfile("gfx/libcolor/spaces.py")
! execfile("gfx/libpaper/textures.py")
! execfile("gfx/libpaper/texcoords.py")
! execfile("gfx/libpaper/colors.py")
passmask = [ 1, 0, 0, 0 ]
***************
*** 71,77 ****
"""),
}
isectcodes = {
! "ALL" : "",
"DOT" : nvcode.combinercode("""
CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1
--- 79,147 ----
"""),
}
isectcodes = {
! "BAND" : nvcode.combinercode("""
! # Band-like texture
! CombinerParameterNV NUM_GENERAL_COMBINERS_NV 2
!
! # SPARE0 <- (TEX0 . TEX1)
! CI0 RGB A TEXTURE0 EXPAND_NORMAL_NV RGB
! CI0 RGB B TEXTURE1 EXPAND_NORMAL_NV RGB
! CO0 RGB SPARE0_NV DISCARD_NV DISCARD_NV NONE NONE TRUE FALSE
FALSE
!
! # SPARE1 <- SPARE0 * SPARE0 * 2
! # SPARE0 <- (TEX0 . CONST0) * 2
! CI1 RGB A SPARE0_NV SIGNED_IDENTITY_NV RGB
! CI1 RGB B SPARE0_NV SIGNED_IDENTITY_NV RGB
! CI1 RGB C TEXTURE0 EXPAND_NORMAL_NV RGB
! CI1 RGB D CONSTANT_COLOR0_NV EXPAND_NORMAL_NV RGB
! CO1 RGB SPARE1_NV SPARE0_NV DISCARD_NV SCALE_BY_TWO_NV NONE
FALSE TRUE FALSE
!
! # EF <- SPARE0 * SPARE1
! FCI E SPARE1_NV UNSIGNED_INVERT_NV RGB
! FCI F SPARE0_NV UNSIGNED_IDENTITY_NV RGB
!
! # lerp(EF, PRI_COL, SEC_COL)
! FCI A E_TIMES_F_NV UNSIGNED_IDENTITY_NV RGB
! FCI B PRIMARY_COLOR_NV UNSIGNED_IDENTITY_NV RGB
! FCI C SECONDARY_COLOR_NV UNSIGNED_IDENTITY_NV RGB
! FCI D ZERO UNSIGNED_IDENTITY_NV RGB
!
! FCI G ZERO UNSIGNED_INVERT_NV BLUE
! """),
! "I3COL" : nvcode.combinercode("""
! # Interpolate between three colors using two dot products
! CombinerParameterNV NUM_GENERAL_COMBINERS_NV 2
!
! # SPARE0 <- (TEX0 . CONST0)
! # SPARE1 <- (TEX1 . CONST1)
! CI0 RGB A TEXTURE0 EXPAND_NORMAL_NV RGB
! CI0 RGB B CONSTANT_COLOR0_NV EXPAND_NORMAL_NV RGB
! CI0 RGB C TEXTURE1 EXPAND_NORMAL_NV RGB
! CI0 RGB D CONSTANT_COLOR1_NV EXPAND_NORMAL_NV RGB
! CO0 RGB SPARE0_NV SPARE1_NV DISCARD_NV NONE NONE TRUE TRUE FALSE
!
! # PRI_COL <- lerp(SPARE0, PRI_COL, SEC_COL)
! CI1 RGB A PRIMARY_COLOR_NV UNSIGNED_IDENTITY_NV RGB
! CI1 RGB B SPARE0_NV UNSIGNED_IDENTITY_NV RGB
! CI1 RGB C SECONDARY_COLOR_NV UNSIGNED_IDENTITY_NV RGB
! CI1 RGB D SPARE0_NV UNSIGNED_INVERT_NV RGB
! CO1 RGB DISCARD_NV DISCARD_NV PRIMARY_COLOR_NV NONE NONE FALSE
FALSE FALSE
!
! # SPARE1.alpha <- SPARE0^2 - SPARE1^2
! CI1 ALPHA A SPARE0_NV SIGNED_IDENTITY_NV BLUE
! CI1 ALPHA B SPARE0_NV SIGNED_IDENTITY_NV BLUE
! CI1 ALPHA C SPARE1_NV SIGNED_NEGATE_NV BLUE
! CI1 ALPHA D SPARE1_NV SIGNED_IDENTITY_NV BLUE
! CO1 ALPHA DISCARD_NV DISCARD_NV SPARE1_NV NONE NONE FALSE
FALSE FALSE
!
! # lerp(SPARE1, PRI_COL, FOG)
! FCI A SPARE1_NV UNSIGNED_IDENTITY_NV RGB
! FCI B PRIMARY_COLOR_NV UNSIGNED_IDENTITY_NV RGB
! FCI C FOG UNSIGNED_IDENTITY_NV RGB
! FCI D ZERO UNSIGNED_IDENTITY_NV RGB
!
! FCI G ZERO UNSIGNED_INVERT_NV ALPHA
! """),
"DOT" : nvcode.combinercode("""
CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1
***************
*** 90,124 ****
tex0comb = "RGB"
tex1comb = "RGB"
! isectcomb = "ALL"
! def getpaper(seed, vecseed0 = 0, vecseed1 = 0, colseed = 0):
! pap = ThePaperMill().getPaper(seed, passmask=passmask)
! constcode = ""
! if colseed:
! colors = Colors(colseed)
! c0,c1,c2,c3 = [ colors.getColorStr(i) for i in range(0,4) ]
! constcode += """
Color %(c0)s
SecondaryColorEXT %(c1)s
Fog FOG_COLOR %(c2)s
! """ % locals()
! if vecseed0:
! colors = Colors(vecseed0)
! constcode += ("CombinerParameterNV CONSTANT_COLOR0_NV %s\n"
! % (colors.getNVDP3VecStr(0)))
! if vecseed1:
! colors = Colors(vecseed1)
! constcode += ("CombinerParameterNV CONSTANT_COLOR1_NV %s\n"
! % (colors.getNVDP3VecStr(1)))
! print seed, vecseed0, vecseed1, colseed
! print constcode
return GZZGL.createBasisPaperQuad(pap, -1, -1, 1, 1,
! tex0codes[tex0comb] + constcode,
! tex1codes[tex1comb] + constcode,
! isectcodes[isectcomb] + constcode)
rng = java.util.Random()
--- 160,220 ----
tex0comb = "RGB"
tex1comb = "RGB"
! isectcomb = "I3COL"
! def getpaper(vecs, cols):
! pap = Paper()
! pap.setNPasses(1)
! ppass = pap.getPass(0)
! ppass.setSetupcode("""
! PushAttrib ENABLE_BIT TEXTURE_BIT DEPTH_BUFFER_BIT
! """)
! ppass.setTeardowncode("""
! PopAttrib
! ActiveTexture TEXTURE0
! """)
! texid = ptextures["RGB2"][0].getTexId();
!
! constcode = """
! ActiveTexture TEXTURE0
! Enable TEXTURE_2D
! BindTexture TEXTURE_2D %(texid)s
! TexParameter TEXTURE_2D TEXTURE_WRAP_S REPEAT
! TexParameter TEXTURE_2D TEXTURE_WRAP_T REPEAT
! TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
! TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
!
! ActiveTexture TEXTURE1
! Enable TEXTURE_2D
! BindTexture TEXTURE_2D %(texid)s
! TexParameter TEXTURE_2D TEXTURE_WRAP_S REPEAT
! TexParameter TEXTURE_2D TEXTURE_WRAP_T REPEAT
! TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
! TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
!
! Enable BLEND
! BlendFunc SRC_ALPHA ONE_MINUS_SRC_ALPHA
! BlendEquation FUNC_ADD
! Disable ALPHA_TEST
!
! Enable REGISTER_COMBINERS_NV
! """ % locals()
!
! r0,r1 = vecs
! c0,c1,c2,c3 = cols
! constcode += """
Color %(c0)s
SecondaryColorEXT %(c1)s
Fog FOG_COLOR %(c2)s
! CombinerParameterNV CONSTANT_COLOR0_NV %(r0)s
! CombinerParameterNV CONSTANT_COLOR1_NV %(r1)s
! """ % locals()
return GZZGL.createBasisPaperQuad(pap, -1, -1, 1, 1,
! constcode + tex0codes[tex0comb],
! constcode + tex1codes[tex1comb],
! constcode + isectcodes[isectcomb])
rng = java.util.Random()
***************
*** 127,140 ****
def __init__(self):
self.bgcolor = (0.7, 0.8, 0.6)
- self.seed = 0
self.vecseed0 = 0
self.vecseed1 = 0
self.colseed = 0
self.initpaper()
! self.x0, self.y0 = 600, 300
! self.x1, self.y1 = 600, 450
self.texgen0 = TexGenXYRepeatUnit(vecs = [[.5,0], [0,.5]])
self.texgen1 = TexGenXYRepeatUnit(vecs = [[.25,.25], [.25,-.25]])
--- 223,238 ----
def __init__(self):
self.bgcolor = (0.7, 0.8, 0.6)
self.vecseed0 = 0
self.vecseed1 = 0
self.colseed = 0
+
+ self.initvecs()
+ self.initcols()
self.initpaper()
! self.x0, self.y0 = 600, 450
! self.x1, self.y1 = 600, 600
self.texgen0 = TexGenXYRepeatUnit(vecs = [[.5,0], [0,.5]])
self.texgen1 = TexGenXYRepeatUnit(vecs = [[.25,.25], [.25,-.25]])
***************
*** 150,176 ****
End
""")
! def initpaper(self):
! self.pq = getpaper(self.seed, self.vecseed0, self.vecseed1,
self.colseed)
AbstractUpdateManager.setNoAnimation()
def key(self, k):
global tex0comb,tex1comb,isectcomb
- oldseed = self.seed
if k == "v":
! self.seed = rng.nextInt(2000000000)
! self.vecseed0 = 0
! self.vecseed1 = 0
! self.colseed = 0
self.initpaper()
elif k == "1":
self.vecseed0 = rng.nextInt(2000000000)
self.initpaper()
elif k == "3":
self.vecseed1 = rng.nextInt(2000000000)
self.initpaper()
elif k == "2":
self.colseed = rng.nextInt(2000000000)
self.initpaper()
elif k == "F4":
self.texgen0 = TexGenXYRepeatUnit(rnd=rng)
--- 248,291 ----
End
""")
! def initvecs(self):
! colors = Colors(self.vecseed0)
! r0 = colors.getNVDP3VecStr(0)
! colors = Colors(self.vecseed1)
! r1 = colors.getNVDP3VecStr(1)
! self.vecs = [ r0, r1 ]
!
! def initcols(self):
! rnd = java.util.Random(self.colseed)
! colors = Colors(rnd.nextInt())
! colorbase = rnd.nextInt()
! self.cols = [ colors.getColorStr(colorbase+i)
! for i in range(0,4) ]
!
! def initpaper(self):
! self.pq = getpaper(self.vecs, self.cols)
AbstractUpdateManager.setNoAnimation()
def key(self, k):
global tex0comb,tex1comb,isectcomb
if k == "v":
! self.vecseed0 = rng.nextInt(2000000000)
! self.vecseed1 = rng.nextInt(2000000000)
! self.colseed = rng.nextInt(2000000000)
! self.initvecs()
! self.initcols()
self.initpaper()
elif k == "1":
self.vecseed0 = rng.nextInt(2000000000)
+ self.initvecs()
self.initpaper()
elif k == "3":
self.vecseed1 = rng.nextInt(2000000000)
+ self.initvecs()
self.initpaper()
elif k == "2":
self.colseed = rng.nextInt(2000000000)
+ self.initcols()
self.initpaper()
elif k == "F4":
self.texgen0 = TexGenXYRepeatUnit(rnd=rng)
***************
*** 183,199 ****
elif k == "F1":
list = tex0codes.keys()
tex0comb = list[(list.index(tex0comb) + 1) % len(list)]
! print "Using", tex0comb, tex1comb, isectcomb, "combiners"
self.initpaper()
elif k == "F3":
list = tex1codes.keys()
tex1comb = list[(list.index(tex1comb) + 1) % len(list)]
! print "Using", tex0comb, tex1comb, isectcomb, "combiners"
self.initpaper()
elif k == "F2":
list = isectcodes.keys()
isectcomb = list[(list.index(isectcomb) + 1) % len(list)]
! print "Using", tex0comb, tex1comb, isectcomb, "combiners"
self.initpaper()
def scene(self, vs):
--- 298,314 ----
elif k == "F1":
list = tex0codes.keys()
tex0comb = list[(list.index(tex0comb) + 1) % len(list)]
! print "Using", tex0comb, isectcomb, tex1comb, "combiners"
self.initpaper()
elif k == "F3":
list = tex1codes.keys()
tex1comb = list[(list.index(tex1comb) + 1) % len(list)]
! print "Using", tex0comb, isectcomb, tex1comb, "combiners"
self.initpaper()
elif k == "F2":
list = isectcodes.keys()
isectcomb = list[(list.index(isectcomb) + 1) % len(list)]
! print "Using", tex0comb, isectcomb, tex1comb, "combiners"
self.initpaper()
def scene(self, vs):
***************
*** 219,223 ****
--- 334,345 ----
vs.map.put(self.pq, cs1, cs2)
vs.map.put(self.frame, cs1)
vs.map.put(self.frame, cs2)
+
+ for i in range(0,3):
+ cs = vs.coords.affineCoordsys(0, "col" + str(i), 10, 600 +
(i-1)*150, 80, 50, 0, 0, 50)
+ col = self.cols[i].split()
+ cq = coloredQuad((col[0], col[1], col[2]))
+ vs.map.put(cq, cs)
+ vs.map.put(self.frame, cs)
currentScene = PaperScene()