File: texturetest.py

package info (click to toggle)
python-visual 1%3A5.12-1.6
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 7,708 kB
  • ctags: 7,635
  • sloc: cpp: 15,593; sh: 9,615; ansic: 6,631; python: 4,737; makefile: 384
file content (45 lines) | stat: -rw-r--r-- 1,550 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from visual import *

# Jonathan Brandmeyer
scene.background = color.gray(0.8)

checkerboard = array([[0,0,1,1], 
		      [0,0,1,1],
		      [1,1,0,0],
		      [1,1,0,0]], float)
lum = materials.texture( data=checkerboard,
                         mapping="rectangular",
                         interpolate=False)
op = materials.texture( data=checkerboard,
                         channels=["luminance"],
                         mapping="rectangular",
                         interpolate=False)
balp1 = box( axis=(0,0,1), color=color.orange, material=op)
blum1 = box( axis=(0,0,1), color=color.orange, material=lum, pos=(-2, 0))
box( pos=(0, 2), color=color.orange, opacity=0.5)
box( pos=(0,-2), color=color.orange)
blum2 = box( pos=(0, 0, -2), axis=(0,0,1), color=color.orange, material=lum)
z = arrow(color=color.green)
z.axis *= 2

scene.mouse.getclick()
# Change the texture
save = array(checkerboard[:,1])
checkerboard[:,1] = checkerboard[:,2]
checkerboard[:,2] = save
save = array(checkerboard[1,:])
checkerboard[1,:] = checkerboard[2,:]
checkerboard[2,:] = save
# Recreate and reassign the textures; Visual doesn't check for texture changes
lum = materials.texture( data=checkerboard,
                         mapping="rectangular",
                         interpolate=False)
op = materials.texture( mipmap=False, data=checkerboard,
                         channels=["luminance"],
                         mapping="rectangular",
                         interpolate=False)
balp1.material = op
blum1.material = lum
blum2.material = lum