PDA

View Full Version : about an exercise in "Vizard Teacher in a book"


haohaoxuexi1
09-22-2015, 01:35 PM
I meet some problem in texture part (maybe in page 32)

The exercise is "1. Add the "art/wall.ive" model to a world, add the "art/stone wall.jpg" texture and apply it to that model."

However based on the example above the exercise I cannot get the right things I want

The example is like

import viz
viz.go()
viz.MainView.setPosition( 0, .65,-1.3 )
model = viz.add('art/wall.ive')
window = model.getChild( 'glass' )
walls = viz.addTexture('art/tileclouds.jpg')
moon = viz.addTexture('art/full moon.jpg')
window.texture( walls, '', 1 )
window.texture( moon, '', 0 )


#clouds.wrap( viz.WRAP_S, viz.REPEAT )
#clouds.wrap( viz.WRAP_T, viz.REPEAT )
#slider = viz.addSlider()
#slider.setPosition(.5,.1)
#def swap_textures( slider_position ):
#cloud_amt = slider_position
#window.texblend( cloud_amt, '', 1 )
#vizact.onslider( slider, swap_textures )
#swap_textures(0)
#matrix = vizmat.Transform()
#def move_clouds():
#matrix.postTrans(.0005,.0005,0)
#window.texmat( matrix, '', 1 )
#vizact.ontimer( .01, move_clouds )


I got some confusion about the "sub-nodes" part

Is there anyone can teach me about this example?

Wish to get some help from the forum......

Jeff
09-22-2015, 05:32 PM
Are you trying to modify the example code included in the tutorial? The original code adds a window model that has a glass sub-part:

#Add a model and grab one of its chidren to put the textures on.
model = viz.add('art/window.ive')
window = model.getChild( 'glass' )

If you open the 'window' model in Inspector you'll see the scene graph and model sub-parts. In your code 'window' was swapped with 'wall'. The 'wall' model does not have a sub-part called 'glass'.

haohaoxuexi1
10-01-2015, 02:28 PM
Are you trying to modify the example code included in the tutorial? The original code adds a window model that has a glass sub-part:

#Add a model and grab one of its chidren to put the textures on.
model = viz.add('art/window.ive')
window = model.getChild( 'glass' )

If you open the 'window' model in Inspector you'll see the scene graph and model sub-parts. In your code 'window' was swapped with 'wall'. The 'wall' model does not have a sub-part called 'glass'.

Yeah I find out that and I now figure out the problem

Thx