Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualTheChubu

Posted 07 February 2013 - 02:21 PM

Finally got that part to work a few days ago.

 

 

    public void updateMovement ()
    {
        float deltaMovement = movementSpeed * (UtilsMisc.getTime() - timer);
        /*
         * Movement vectors.
         */
        forwardVec.setValueAt(0, 0, orientationMatrix.getValueAt(0, 2)*deltaMovement);
//        forwardVec.setValueAt(1, 0, orientationMatrix.getValueAt(1, 2)*deltaMovement);
        forwardVec.setValueAt(2, 0, - orientationMatrix.getValueAt(2, 2)*deltaMovement);
        
        rightVec.setValueAt(0, 0, orientationMatrix.getValueAt(0, 0)*deltaMovement);
//        rightVec.setValueAt(1, 0, orientationMatrix.getValueAt(1, 0)*deltaMovement);
        rightVec.setValueAt(2, 0, - orientationMatrix.getValueAt(2, 0)*deltaMovement);
        
//        upwardVec.setValueAt(0, 0, orientationMatrix.getValueAt(0, 1)*deltaMovement);
        upwardVec.setValueAt(1, 0, orientationMatrix.getValueAt(1, 1)*deltaMovement);
//        upwardVec.setValueAt(2, 0, - orientationMatrix.getValueAt(2, 1)*deltaMovement);
    }

I created unit vectors out of the orientation matrix (rotation along X * rotation along Y) so they're based on the camera coordinates instead of the world ones.

 

Now if I press W, I just add the forward vector to the camera's position and it will advance forward in whatever direction is looking at.

 

I commented out certain vectors from affecting some axes (ie, right/strafe vector can't affect the vertical/Y axis) otherwise the camera can move in some weird ways that aren't "FPS like".

 

Now I got mouse input working too, a little jerky but its ok for now.

 

Thanks for all the answers! smile.png


#1TheChubu

Posted 07 February 2013 - 02:21 PM

Finally got that part to work a few days ago.

 

    public void updateMovement ()
    {
        float deltaMovement = movementSpeed * (UtilsMisc.getTime() - timer);
        /*
         * Movement vectors.
         */
        forwardVec.setValueAt(0, 0, orientationMatrix.getValueAt(0, 2)*deltaMovement);
//        forwardVec.setValueAt(1, 0, orientationMatrix.getValueAt(1, 2)*deltaMovement);
        forwardVec.setValueAt(2, 0, - orientationMatrix.getValueAt(2, 2)*deltaMovement);
        
        rightVec.setValueAt(0, 0, orientationMatrix.getValueAt(0, 0)*deltaMovement);
//        rightVec.setValueAt(1, 0, orientationMatrix.getValueAt(1, 0)*deltaMovement);
        rightVec.setValueAt(2, 0, - orientationMatrix.getValueAt(2, 0)*deltaMovement);
        
//        upwardVec.setValueAt(0, 0, orientationMatrix.getValueAt(0, 1)*deltaMovement);
        upwardVec.setValueAt(1, 0, orientationMatrix.getValueAt(1, 1)*deltaMovement);
//        upwardVec.setValueAt(2, 0, - orientationMatrix.getValueAt(2, 1)*deltaMovement);
    }
I created unit vectors out of the orientation matrix (rotation along X * rotation along Y) that were based on the camera coordinates instead of the world ones.

 

So if I press W, I just add the forward vector to the camera's position and it will advance forward in whatever direction is looking at.

 

I commented out certain vectors from affecting some axes (ie, right/strafe vector can't affect the vertical/Y axis) otherwise the camera can move in some weird ways that aren't "FPS like".

 

Now I got mouse input working too, a little jerky but its ok for now.

 

Thanks for all the answers! :)


PARTNERS