QueasyCam FOV problem

I am making a game, and I am using queasycam as the camera library. I am getting this output when I run the game:

It should render the surface fully but its showing the surface like that. What can I do to solve this?

call this from setup() please

void avoidClipping() {
  // avoid clipping (at camera): 
  // https : // 
  // forum.processing.org/two/discussion/4128/quick-q-how-close-is-too-close-why-when-do-3d-objects-disappear
  perspective(PI/3.0, (float) width/height, 1, 1000000);
}//func 
//
2 Likes

I am using a modified version of QueasyCam. I modified so that it only runs when the current game screen is main game screen. Here’s the full class definition of the modified QueasyCam →

package io.yedox.minecestor.util;

import java.awt.GraphicsEnvironment;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Robot;
import java.util.HashMap;

import io.yedox.minecestor.core.Game;
import processing.core.PApplet;
import processing.core.PVector;
import processing.event.KeyEvent;

public class Camera {
    public static final String VERSION = "1.5";
    public boolean controllable;
    public float speed;
    public float sensitivity;
    public PVector position;
    public float pan;
    public float tilt;
    public PVector velocity;
    public float friction;
    public Robot robot;
    private PApplet applet;
    private PVector center;
    private PVector up;
    private PVector right;
    private PVector forward;
    private Point mouse;
    private Point prevMouse;
    private HashMap<Character, Boolean> keys;

    public Camera(PApplet var1) {
        this.applet = var1;

        var1.registerMethod("keyEvent", this);
//        var1.registerMethod("draw", this);

        try {
            this.robot = new Robot();
        } catch (Exception var3) {
            Utils.printExceptionMessage(var3, applet);
        }

        this.controllable = true;
        this.speed = 3.0F;
        this.sensitivity = 0.5F;
        this.position = new PVector(0.0F, 0.0F, 0.0F);
        this.up = new PVector(0.0F, 1.0F, 0.0F);
        this.right = new PVector(1.0F, 0.0F, 0.0F);
        this.forward = new PVector(0.0F, 0.0F, 1.0F);
        this.velocity = new PVector(0.0F, 0.0F, 0.0F);
        this.pan = 0.0F;
        this.tilt = 0.0F;
        this.friction = 0.75F;
        this.keys = new HashMap();
        var1.perspective(1.0471976F, (float)var1.width / (float)var1.height, 0.00001F, 10000.0F);
    }

    public void draw() {
        if(Game.getCurrentScreen().equals(Game.Screen.MAIN_GAME_SCREEN)) {
            if (this.controllable) {
                this.mouse = MouseInfo.getPointerInfo().getLocation();
                if (this.prevMouse == null) {
                    this.prevMouse = new Point(this.mouse.x, this.mouse.y);
                }

                int var1 = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().width;
                int var2 = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height;
                if (this.mouse.x < 1 && this.mouse.x - this.prevMouse.x < 0) {
                    this.robot.mouseMove(var1 - 2, this.mouse.y);
                    this.mouse.x = var1 - 2;
                    this.prevMouse.x = var1 - 2;
                }

                if (this.mouse.x > var1 - 2 && this.mouse.x - this.prevMouse.x > 0) {
                    this.robot.mouseMove(2, this.mouse.y);
                    this.mouse.x = 2;
                    this.prevMouse.x = 2;
                }

                if (this.mouse.y < 1 && this.mouse.y - this.prevMouse.y < 0) {
                    this.robot.mouseMove(this.mouse.x, var2 - 2);
                    this.mouse.y = var2 - 2;
                    this.prevMouse.y = var2 - 2;
                }

                if (this.mouse.y > var2 - 1 && this.mouse.y - this.prevMouse.y > 0) {
                    this.robot.mouseMove(this.mouse.x, 2);
                    this.mouse.y = 2;
                    this.prevMouse.y = 2;
                }

                this.pan += PApplet.map((float) (this.mouse.x - this.prevMouse.x), 0.0F, (float) this.applet.width, 0.0F, 6.2831855F) * this.sensitivity;
                this.tilt += PApplet.map((float) (this.mouse.y - this.prevMouse.y), 0.0F, (float) this.applet.height, 0.0F, 3.1415927F) * this.sensitivity;
                this.tilt = this.clamp(this.tilt, -1.5629815F, 1.5629815F);
                if (this.tilt == 1.5707964F) {
                    this.tilt += 0.001F;
                }

                this.forward = new PVector(PApplet.cos(this.pan), PApplet.tan(this.tilt), PApplet.sin(this.pan));
                this.forward.normalize();
                this.right = new PVector(PApplet.cos(this.pan - 1.5707964F), 0.0F, PApplet.sin(this.pan - 1.5707964F));
                this.prevMouse = new Point(this.mouse.x, this.mouse.y);
                if (this.keys.containsKey('a') && (Boolean) this.keys.get('a')) {
                    this.velocity.add(PVector.mult(this.right, this.speed));
                }

                if (this.keys.containsKey('d') && (Boolean) this.keys.get('d')) {
                    this.velocity.sub(PVector.mult(this.right, this.speed));
                }

                if (this.keys.containsKey('w') && (Boolean) this.keys.get('w')) {
                    this.velocity.add(PVector.mult(this.forward, this.speed));
                }

                if (this.keys.containsKey('s') && (Boolean) this.keys.get('s')) {
                    this.velocity.sub(PVector.mult(this.forward, this.speed));
                }

                if (this.keys.containsKey('z') && (Boolean) this.keys.get('z')) {
                    this.velocity.add(PVector.mult(this.up, this.speed));
                }

                if (this.keys.containsKey('x') && (Boolean) this.keys.get('x')) {
                    this.velocity.sub(PVector.mult(this.up, this.speed));
                }

                this.velocity.mult(this.friction);
                this.position.add(this.velocity);
                this.center = PVector.add(this.position, this.forward);
                this.applet.camera(this.position.x, this.position.y, this.position.z, this.center.x, this.center.y, this.center.z, this.up.x, this.up.y, this.up.z);
            }
        }
    }

    public void keyEvent(KeyEvent var1) {
        char var2 = var1.getKey();
        switch(var1.getAction()) {
            case 1:
                this.keys.put(Character.toLowerCase(var2), true);
                break;
            case 2:
                this.keys.put(Character.toLowerCase(var2), false);
        }

    }

    private float clamp(float var1, float var2, float var3) {
        if (var1 > var3) {
            return var3;
        } else {
            return var1 < var2 ? var2 : var1;
        }
    }

    public PVector getForward() {
        return this.forward;
    }

    public PVector getUp() {
        return this.up;
    }

    public PVector getRight() {
        return this.right;
    }
}

I tried it but still same output :confused:
Should I change the perspective() function call in the Camera class that I specified above?

Okay! I fixed it! I put the code you sent in the draw() function.
Now it works as intended!

1 Like