Controlling Camera/dragon

Hello All,

When i answered in another thread about moving the camera, in my case a dragon, i unzipped my source and tested back. In fact it doesnt exactly work.

I use the following code:


  # How far did we move based on the amount of time elapsed?
            dt=ClockObject.getGlobalClock().getDt()
            distance = dt * self.speed * self.run_factor
            climb = dt * self.climbSpeed * self.run_factor
            rotation = dt * self.rotationSpeed

            # Take a step in the direction of our previous heading.
            self.vel=Vec3(Vec3.forward() * distance*-1 + 
                          Vec3.up() * climb + 
                          Vec3.right())
            if self.vel != Vec3.zero():
                # rotMat is the rotation matrix corresponding to
                # our previous heading.
                rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up())
                step=rotMat.xform(self.vel)
                self.avatarNodePath.setFluidPos(Point3(self.avatarNodePath.getPos()+step))
            self.avatarNodePath.setH(self.avatarNodePath.getH()+rotation)
            self.avatarNodePath.setP(self.avatarNodePath.getP()+climb)

Basically it is supposed to compute, based on elapsed time since last frame:

  • a distance based on constant speed of the dragon ie distance
  • an horizontal rotation based on left/right move of the mouse ie rotation
  • an vertical climb based on up/down move of the mouse ie climb.

Then orient the dragon in the new direction and make it move forward and
upward/downard in this new forward direction.

However, whatever the signe in the *-1 part of the formula, my dragon is always going backward (meaning it move from the farthesst in screen to the closest in screen).

I dont understand where lie the mistake so any input would be appreciated

[/code]