Graphics Programs Reference
In-Depth Information
if move.positive and obj['hold']:
# calculate how much the pointer moved from the place where
the user clicked to start navigating, both in X and Y
deltaX = (obj['centerX'] - move.position[0])*obj['pointerSpe
ed']
deltaY = (obj['centerY'] - move.position[1])*obj['pointerSpe
ed']
# reset the position of the pointer to the place where the
user pressed down the mouse button
bge.render.setMousePosition(obj['centerX'], obj['centerY'])
# in case the vertical movement of the pointer will cause the
camera to rotate outside of the allowed range…
if (xCurrentRot + deltaY*math.pi/180 > MAX_ANGLE) or
(xCurrentRot + deltaY*math.pi/180 < MIN_ANGLE):
# … set the vertical movement to 0, to ignore it
deltaY = 0
# set the vectors for the rotation of the viewRot ("derived")
and the baseMover ("base")
viewRot.dRot = [deltaY, 0, 0] #deltaY is used to drive the X
rotation of the "derived" object
baseMover.dRot = [0, 0, deltaX] # deltaX is used to drive the
Z rotation of the "base" object
# turn on the two actuators, so that they perform the rotation
given by the two vectors calculated right above
cont.activate(viewRot)
cont.activate(baseMover)
Let's save the file now, to avoid losing what we have done since the last save.
We just need to perform some small tasks to get the project finished.
3. First, let's switch to the Logic Editor ( Shift + F2 ), locate the move controller, and
click on the field with the notepad icon to select the move.py entry; then go to the
look controller and select the look.py script from the list of available scripts.
4. Second, let's go to the 3D View and switch to Camera View ( View → Camera ) to
see if the skydome is geing clipped in the distance. If the clipping happens, we just
need to select the camera, then go to the Object Data tab of the Properies Editor,
and set the Clipping End (in the Lens panel) to a higher value.
Now, the ime has come; ater all that hard work, our interacive walkthrough is ready to be
used. Let's make sure we are in Camera View; press P and start navigaing around the scene.
Isn't it nice how we could do almost everything right inside Blender?
 
Search WWH ::




Custom Search