Skip to content

Commit

Permalink
fixed errors in Core
Browse files Browse the repository at this point in the history
  • Loading branch information
CreedVI committed Jul 1, 2021
1 parent 3b533e4 commit 8b7cfc8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
16 changes: 8 additions & 8 deletions src/com/creedvi/raylib/java/rlj/core/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -858,14 +858,14 @@ void BeginMode3D(Camera3D camera){

float aspect = (float) window.currentFbo.getWidth() / (float) window.currentFbo.getHeight();

if (camera.getTypeI() == CAMERA_PERSPECTIVE.getCamType()){
if (camera.getType() == CAMERA_PERSPECTIVE.getCamType()){
// Setup perspective projection
double top = RL_CULL_DISTANCE_NEAR * Math.tan(camera.getFovy() * 0.5 * DEG2RAD);
double right = top * aspect;

rlFrustum(-right, right, -top, top, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
}
else if (camera.getTypeI() == CAMERA_ORTHOGRAPHIC.getCamType()){
else if (camera.getType() == CAMERA_ORTHOGRAPHIC.getCamType()){
// Setup orthographic projection
double top = camera.getFovy() / 2.0;
double right = top * aspect;
Expand Down Expand Up @@ -974,12 +974,12 @@ public Ray GetMouseRay(Vector2 mouse, Camera3D camera){

Matrix matProj = MatrixIdentity();

if (camera.getType() == CAMERA_PERSPECTIVE){
if (camera.getType() == CAMERA_PERSPECTIVE.getCamType()){
// Calculate projection matrix from perspective
matProj = MatrixPerspective(camera.getFovy() * DEG2RAD,
((double) GetScreenWidth() / (double) GetScreenHeight()), RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
}
else if (camera.getType() == CAMERA_ORTHOGRAPHIC){
else if (camera.getType() == CAMERA_ORTHOGRAPHIC.getCamType()){
float aspect = (float) window.screen.getWidth() / (float) window.screen.getHeight();
double top = camera.getFovy() / 2.0;
double right = top * aspect;
Expand All @@ -1003,10 +1003,10 @@ else if (camera.getType() == CAMERA_ORTHOGRAPHIC){
// Calculate normalized direction vector
Vector3 direction = Vector3Normalize(Vector3Subtract(farPoint, nearPoint));

if (camera.getType() == CAMERA_PERSPECTIVE){
if (camera.getType() == CAMERA_PERSPECTIVE.getCamType()){
ray.position = camera.getPosition();
}
else if (camera.getType() == CAMERA_ORTHOGRAPHIC){
else if (camera.getType() == CAMERA_ORTHOGRAPHIC.getCamType()){
ray.position = cameraPlanePointerPos;
}

Expand Down Expand Up @@ -1063,12 +1063,12 @@ Vector2 GetWorldToScreenEx(Vector3 position, Camera3D camera, int width, int hei
// Calculate projection matrix (from perspective instead of frustum
Matrix matProj = MatrixIdentity();

if (camera.getType() == CAMERA_PERSPECTIVE){
if (camera.getType() == CAMERA_PERSPECTIVE.getCamType()){
// Calculate projection matrix from perspective
matProj = MatrixPerspective(camera.getFovy() * DEG2RAD, ((double) width / (double) height),
RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
}
else if (camera.getType() == CAMERA_ORTHOGRAPHIC){
else if (camera.getType() == CAMERA_ORTHOGRAPHIC.getCamType()){
float aspect = (float) window.screen.getWidth() / (float) window.screen.getHeight();
double top = camera.getFovy() / 2.0;
double right = top * aspect;
Expand Down
10 changes: 3 additions & 7 deletions src/com/creedvi/raylib/java/rlj/core/camera/Camera3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public Camera3D(){

}

public Camera3D(Vector3 position, Vector3 target, Vector3 up, Float fovy, CameraProjection type){
public Camera3D(Vector3 position, Vector3 target, Vector3 up, Float fovy, int type){
this.position = position;
this.target = target;
this.up = up;
Expand All @@ -20,14 +20,10 @@ public float getFovy(){
return fovy;
}

public CameraProjection getType(){
public int getType(){
return type;
}

public int getTypeI(){
return type.camType;
}

@Override
public void update(){

Expand Down Expand Up @@ -57,7 +53,7 @@ public void setPosition(Vector3 position){
this.position = position;
}

public void setType(CameraProjection type){
public void setType(int type){
this.type = type;
}

Expand Down

0 comments on commit 8b7cfc8

Please sign in to comment.