Open topic with navigation
Matrix transformations
\examples\matrixTransforms\matrix.py
This script demonstrates how to apply your own 4x4 matrix to an object.
"""
This script demonstrates how to apply your own 4x4 matrix to an object.
Press the spacebar to switch between transforming the cone and viewpoint
"""
import viz
import vizact
import vizshape
viz.setMultiSample(4)
viz.fov(60)
viz.go()
import vizinfo
vizinfo.InfoPanel()
#Variable for translation
translation = 0
mode = 0
viz.addChild('ground.osgb')
cone = viz.addChild('tut_cone.wrl')
X = viz.Transform()
X.makeIdent()
X.postTrans(translation,1.6,7)
viz.MainView.setMatrix(X)
cone.setMatrix(X)
def changeMode():
global mode
mode = mode ^ 1
vizact.onkeydown(' ', changeMode)
def animate():
global translation
X.makeIdent()
X.postTrans(translation,1.6,7)
translation = translation + .01
if translation > 3:
translation = -3
if mode:
viz.MainView.setMatrix(X)
else:
cone.setMatrix(X)
vizact.ontimer(0, animate)
viz.clearcolor(viz.SLATE)