![]() |
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Are you saying I can make on-the-fly textures? That might work. Currently, I generate one 2D checkerboard as a collection of on-the-fly squares, then turn on or off the visibility of the appropriate squares. The only requirement that I can think of is that one a checkerboard is projected onto some plane, it's image must then not change if I move or rotate this plane. It's as if I'm burning the image onto this invisible sheet, which then I use as my new (distorted) checkerboard.
|
|
#2
|
|||
|
|||
|
Yes, here is an example of how to create a texture on-the-fly and modify the data at runtime.
Code:
import viz
viz.go()
WIDTH = 16
HEIGHT = 16
#Create blank texture
tex = viz.addBlankTexture([WIDTH,HEIGHT])
#Create quad to display texture
quad = viz.addTexQuad(pos=(0,1.8,2),texture=tex)
def SetTextureColors(begin,end):
#Get raw image data buffer
data = tex.getImageData()
#Modify image data so it blends from begin to end color
def getColor(c):
return [ chr(int(v*255)) for v in c ]
for y in xrange(HEIGHT):
for x in xrange(WIDTH):
index = y*WIDTH*3 + x*3
r,g,b = getColor(vizmat.Interpolate(begin,end,float(x)/WIDTH))
data[index] = r
data[index+1] = g
data[index+2] = b
#Notify Vizard that texture data has been modified
tex.hint(viz.TEXTURE_MODIFIED_HINT)
SetTextureColors(viz.WHITE,viz.RED)
#Toggle texture color when space key is pressed
vizact.onkeydown(' ',SetTextureColors,viz.WHITE,vizact.choice([viz.GREEN,viz.BLUE,viz.RED]))
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| orthographic projection in a head-tracked cave environment | michaelrepucci | Vizard | 5 | 12-14-2011 10:29 AM |
| RE: Shadow Module | nige777 | Vizard | 2 | 05-08-2008 04:52 PM |
| Viewing Projection | pkhoosh | Vizard | 2 | 01-25-2006 09:52 AM |
| Fading/lightening-Problem and viz.go in module | Johannes | Vizard | 6 | 09-02-2005 04:28 PM |
| vhil module | vadrian | Vizard | 2 | 01-27-2005 11:52 AM |