View Single Post
  #2  
Old 01-24-2013, 07:11 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can use the viz.addBlankTexture command to create 3D textures with a specified depth. Here is a sample script showing how to load images into each depth slot:
Code:
import viz
viz.go()

#Create list of 2D images that will make up 3D texture
files = [ 'launch_stills/sts90launch'+ str(i+1) + '.jpg' for i in range(31) ]

#Create blank 3D texture
tex = viz.addBlankTexture([64,64,len(files)],viz.TEX_3D,minFilter=viz.LINEAR_MIPMAP_LINEAR)

#Load each image into 3D texture
for i,f in enumerate(files):
	tex.load(f,i)
	
#Apply texture to quad
quad = viz.addTexQuad(pos=(0,1.8,2),texture=tex)

#Create slider to change z texture coordinate of quad
slider = viz.addSlider(pos=(0.5,0.1,0))
def SetDepth(pos):
	m = viz.Matrix.translate(0,0,pos)
	quad.texmat(m)
vizact.onslider(slider,SetDepth)


viz.startlayer(viz.QUADS)

#Lower left
viz.texcoord(0,0,0)
viz.vertex(0.4,0.01,0)

#Upper left
viz.texcoord(1,0,0)
viz.vertex(0.4,0.05,0)

#Upper right
viz.texcoord(1,0,1)
viz.vertex(0.6,0.05,0)

#Lower right
viz.texcoord(0,0,1)
viz.vertex(0.6,0.01,0)

otf = viz.endlayer(parent=viz.SCREEN,texture=tex)
Hope this clears things up.
Reply With Quote