![]() |
|
#1
|
|||
|
|||
viewpoint movement
Hi!
I would like to move my view point smoothly 1m per pressing an button and to rotate it 90 degrees if I press another button, and wrote a program shown as below. But there are two major problems. 1. The viewpoint does'nt rotate exactly 90 degrees (like 89.999925...). I want it to rotate just 90 degrees evey time. 2. If you press the button during the view point is changing, the view point moves 1m or rotates 90 degrees from the moment. I want the [x,y,z] of the view point to be always integer when the view point stops. I would appreciate your suggestions. Thank you. ------ def mykeyboard(key): pos = viz.get(viz.HEAD_POS) tx = pos[0] ty = pos[1] tz = pos[2] trans = viz.get(viz.BODY_LOOK) # Translate_Forward if viz.iskeydown(viz.KEY_UP): tx = tx + trans[0] ty = ty + trans[1] tz = tz + trans[2] view.goto(tx,ty,tz,1,viz.TIME) # Yaw_Right elif viz.iskeydown('6'): viz.starttimer(1, 0.01,89) def mytimer(num): if num == 2: #Yaw-Right view.rotate(0,1,0,1,viz.BODY_ORI,viz.RELATIVE_LOCA L) ------- |
|
|