/** * Create a viewFrustum from the given parameters. * * @param eye * @param lookingAt * @param up * @param fovy * the field-of-view in y direction * @param aspect * @param zNear * @param zFar */ public ViewFrustum( Point3d eye, Point3d lookingAt, Vector3d up, double fovy, double aspect, double zNear, double zFar ) { setPerspectiveParams( fovy, aspect, zNear, zFar ); setCameraParams( eye, lookingAt, up ); }
/** * Rotate the viewfrustum around the z-axis (according to the view direction). yaw * * @param delta */ public void rotateZ( double delta ) { rotate( right, backward, delta ); rotate( up, backward, delta ); setCameraParams( eye, lookingAt, up ); }
/** * Rotate the viewfrustum around the y-axis (according to the view direction). roll * * @param delta */ public void rotateY( double delta ) { rotate( right, up, delta ); rotate( backward, up, delta ); lookingAt = new Point3d( eye ); lookingAt.sub( backward ); setCameraParams( eye, lookingAt, up ); }
/** * Move the viewfrustum to the right (according to the view direction). * * @param delta */ public void moveRight( double delta ) { Vector3d deltaVector = new Vector3d( right ); deltaVector.scale( delta ); eye.add( deltaVector ); lookingAt.add( deltaVector ); setCameraParams( eye, lookingAt, up ); }
/** * Move the viewfrustum to the up (according to the view direction). * * @param delta */ public void moveUp( double delta ) { Vector3d deltaVector = new Vector3d( up ); deltaVector.scale( delta ); eye.add( deltaVector ); lookingAt.add( deltaVector ); setCameraParams( eye, lookingAt, up ); }
/** * Move the viewfrustum to the forward (according to the view direction). * * @param delta */ public void moveForward( double delta ) { Vector3d deltaVector = new Vector3d( backward ); deltaVector.scale( -delta ); eye.add( deltaVector ); lookingAt.add( deltaVector ); setCameraParams( eye, lookingAt, up ); }
/** * Rotate the viewfrustum around the x-axis (according to the view direction). pitch * * @param delta */ public void rotateX( double delta ) { rotate( up, right, delta ); rotate( backward, right, delta ); lookingAt = new Point3d( eye ); lookingAt.sub( backward ); setCameraParams( eye, lookingAt, up ); }
/** * Create a view Frustum by using the given roll, pitch, yaw and distance to the point of interest (looking at), to * calculate the eye and the up vector. * * @param pitch * @param yaw * @param roll * @param distance * @param lookingAt * @param fovy * the field-of-view in y direction * @param aspect * @param zNear * @param zFar */ public ViewFrustum( double pitch, double yaw, double roll, double distance, Point3d lookingAt, double fovy, double aspect, double zNear, double zFar ) { Point3d calculatedEye = calcObserPosition( lookingAt, pitch, yaw, distance ); Vector3d calculatedUp = calcUp( roll, calculatedEye, lookingAt ); setPerspectiveParams( fovy, aspect, zNear, zFar ); setCameraParams( calculatedEye, lookingAt, calculatedUp ); }
/** * Set the new projection plane dimensions * * @param width * @param height */ public void setProjectionPlaneDimensions( int width, int height ) { projectionWidth = width; projectionHeight = height; double aspect = (double) width / height; vf.setPerspectiveParams( vf.getFOVY(), aspect, vf.getZNear(), vf.getZFar() ); vf.setCameraParams( vf.getEyePos(), vf.getLookingAt(), vf.getUp() ); }