i've added the code but my doors seem to be opening in a strange direction, when i click on them they rotate and end up somewhere else, i've added my code below for you 2 have a look at.
one more thing i have exported baked textures from 3ds max and one of them comes with grey patches for some reason, the rest work fine.
import viz
viz.go()
viz.clearcolor (0.5,0.5,1)
myHUD = viz.addTexQuad(viz.SCREEN)
myImage = viz.add('myHud.png')
myHUD.setPosition(0.5,0.5,0)
myHUD.setScale(0.2,0.2,0)
myHUD.texture(myImage)
door1 = viz.add('door1.ive')
door2 = viz.add('door2.ive')
import vizinfo
info = vizinfo.add("Click on the door")
#Door1
#change the origin and where door will rotate
door1.center(1,1,0.1)
#create a spinning action for the door
opendoor = vizact.spinto(0,6,0,90,90)
#add the action to the door when clicked on
vizact.onpick(door1, door1.addAction, opendoor)
#Door2
#change the origin and where door will rotate
door2.center(1,1,0.1)
#create a spinning action for the door
opendoor = vizact.spinto(0,6,0,-90,90)
#add the action to the door when clicked on
vizact.onpick(door2, door2.addAction, opendoor)
MOVE_SPEED = 5
TURN_SPEED = 60
view = viz.get(viz.MAIN_VIEWPOINT)
def mytimer (num):
if viz.iskeydown(viz.KEY_UP):
view.move(0,0,MOVE_SPEED*viz.elapsed(),viz.BODY_OR I)
elif viz.iskeydown(viz.KEY_DOWN):
view.move(0,0,-MOVE_SPEED*viz.elapsed(),viz.BODY_ORI)
elif viz.iskeydown(viz.KEY_RIGHT):
view.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.BOD Y_ORI,viz.REL_PARENT)
elif viz.iskeydown(viz.KEY_LEFT):
view.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.REL_PARE NT)
viz.callback(viz.TIMER_EVENT,mytimer)
viz.starttimer(0,0.01,viz.FOREVER)
def mousemove(e):
euler = view.getEuler(viz.HEAD_ORI)
euler[0] += e.dx*0.1
euler[1] += -e.dy*0.1
euler[1] = viz.clamp(euler[1],-95.0,85.0)
view.rotate(euler,viz.HEAD_ORI)
viz.callback(viz.MOUSE_MOVE_EVENT,mousemove)
viz.mouse(viz.OFF)
viz.cursor(viz.OFF)
viz.restrictmouse(viz.ON)
|