View Single Post
  #2  
Old 09-12-2007, 11:20 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Here is a small example that should provide you with enough to get started. You can use the left/right arrow keys to rotate the menu. Let me know if something is not clear.
Code:
import viz
viz.go()

import math


QUADS = 8		#Number of menu quads
RADIUS = 2		#Radius of menu
ANGLE = (360.0 / QUADS)

#Create overlay window for floating menu, with its own view/scene
menuScene = viz.addScene()

menuView = viz.addView()
menuView.setScene(menuScene)

menuWindow = viz.addWindow()
menuWindow.setClearMask(viz.GL_DEPTH_BUFFER_BIT)
menuWindow.setPosition(0,1)
menuWindow.setSize(1,1)
menuWindow.viewpoint(menuView)


#Create root node for menu quads
menu = viz.addGroup(scene = menuScene)
menu.translate(0,1.8,5)

#Create texture to apply to quads
tex = viz.addTexture('ball.jpg')

#Add each menu quad
for x in xrange(QUADS):
	quad = viz.addTexQuad(parent=menu)
	
	angle = ANGLE * x
	
	x = math.sin( viz.radians(angle) ) * RADIUS
	z = math.cos( viz.radians(angle) ) * RADIUS
	
	quad.translate(x,0,z)
	quad.rotate(0,1,0,angle+180)
	quad.texture(tex)
	quad.alpha(0.7)

#Rotate menu using arrow keys
vizact.onkeydown(viz.KEY_LEFT,menu.addAction,vizact.spin(0,1,0,ANGLE*5,0.2))
vizact.onkeydown(viz.KEY_RIGHT,menu.addAction,vizact.spin(0,1,0,-ANGLE*5,0.2))

#Add some model to the normal scene
viz.add('gallery.ive')
Reply With Quote