|
#1
|
|||
|
|||
Here is a box scaled to have the shape of a door. There is a spinning action that is added to the door when you click on it.
Another way of doing this would be to use the physics engine and add a hinge joint to the door. When you click on the door a force is applied making it swing open Code:
import viz viz.go() import vizinfo info = vizinfo.add("Click on the door") viz.add('tut_ground.wrl') door = viz.add('box.wrl', pos = [0,1,8], scale = [1,2,.05]) #change the origin and where door will rotate door.center(-.5,0,0) #show the rotation point ball = viz.add('ball.wrl', pos = [-.5,1,8], scale = [.2,.2,.2]) #create a spinning action for the door opendoor = vizact.spinto(0,1,0, 120, 30.0) #add the action to the door when clicked on vizact.onpick(door, door.addAction, opendoor) #put someone behind the door female = viz.add('vcc_female.cfg', pos = [0,0,10], euler = [180,0,0]) female.state(5) #disable mouse navigation viz.mouse(viz.OFF) |
#2
|
|||
|
|||
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) |
#3
|
|||
|
|||
Quote:
- bloswald |
#4
|
|||
|
|||
You need to rotate the door based on the GEODE of the door. I used the example of the hierarchical animation, the one with the rotating teapots on the main page.
http://kb.worldviz.com/articles/1157 You also need to make sure that your pivot point is where you want it on the door, as well as your objects xForm is reset (if you use Max.) |
Thread Tools | |
Display Modes | Rate This Thread |
|
|