Vizard 8 » Tutorials & Examples » Viewpoints & windows » Viewpoint control » Tutorial: Getting viewpoint information
8.0

Tutorial: Getting viewpoint information

Next, we need to attach the car to the viewpoints BODY_ORI. Every time an arrow key is pressed the BODY_ORI is changed, so we also need to update the car. Add the following to the updatecar() function

    car.setPosition(view.getPosition())
    car.setEuler(view.getEuler(viz.BODY_ORI))
    car.setPosition([0.35,-1.2,0.2],viz.REL_LOCAL)

This function will update the position and orientation of the car so that it will follow the BODY_ORI. The first thing we do is translate the car to the position of the viewpoint. Next we rotate the car to the same orientation as the BODY_ORI. The last thing we need to do is move the car so that it looks like the viewpoint is in the driver seat.  We translate the car by an offset but notice that the last argument is viz.REL_LOCAL. This tells vizard to translate the car relative to its local coordinate system (i.e. relative to the direction the car is facing).

 

Now run your script. When you move around the car will move with you.

Setting up a vehicle

Forward/back motion

Left/right turning

Getting viewpoint information

Head and body motion