View Single Post
  #9  
Old 04-26-2009, 07:23 AM
nasr nasr is offline
Member
 
Join Date: Apr 2009
Posts: 27
could u plz help me...i am also developing similar application

i am also practising to develop a similar application which u come across with. i want to create a virtual room with a table and some books on it. along with a chair and i want to move, rotate the chair with the help of mouse. can u plz post the code for picking up the objects and moving, rotating, thanking you..
Quote:
Originally Posted by nlfrnassimi View Post
my code is to select a ball and move it by mouse, I want to click a key and the ball will remain in that position, but have no idea how to do it.

please help

this is my code :


import viz

viz.go()

ground = viz.add('tut_ground.wrl')
viz.clearcolor(0.5,0.5,1)
ground.disable(viz.PICKING)

soccerball1 = viz.add('soccerball.ive')
soccerball2 = viz.add('soccerball.ive')
soccerball3 = viz.add('soccerball.ive')

soccerball1.translate(-1,1.5,3)
soccerball2.translate(0,1.5,3)
soccerball3.translate(1,1.5,3)

viz.mouse(viz.OFF)

def mouseclick(button):
global ball
if button == viz.MOUSEBUTTON_LEFT:
pickObj = viz.pick()
if pickObj.valid():
ball = pickObj


def mymouse(e):
global ball
if not ball:
return
else:
ball.setPosition((e.x-0.5)*3,e.y*3.5,3)


viz.callback(viz.MOUSEDOWN_EVENT,mouseclick)
viz.callback(viz.MOUSE_MOVE_EVENT,mymouse)
Reply With Quote