Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Implementing a Free 3D Camera

$
0
0

Hello! in this occasion i`ve a difficult to implement a mouse3D spaceNavigator as a free Camera (like the viewer example from the spaceNavigator software or any other example for this type of camera). when i worked with peasyCam, the lookAt vector was for default the center of the scene. In the spaceNavigator viewer the target was upload (and displayed with a little box) according the camera "navigates". This is what i was trying to do, use the spaceNavigator to navigate the 3D world moving the camera around the 3d shapes. Nevertheless, im a little bit lost and i don't know exactly how calculates the coordinates and the transformations for the camera. this is only the Camera-Player class with the spaceNavigator inputs (post only the class assuming that not everybody has a spaceNavigator) in the comments the description of the spaceNavigator manual for everyValue. Also, Every value is from negative 0.538 to positive 0.538 mapping as left-right, up-down, in-out, etc; I really appreciate some kind of help. Thank you very much

class Player {
  PVector pos;
  PVector lookAt;
  PVector up;

  PApplet parent;

  Player(PApplet p) {

    pos = new PVector(0, 0, 0);
    lookAt = new PVector(0, 0, -100);
    up = new PVector(0, 1, 0);
  }

  void update() {
    beginCamera();
    float xx = (Float)spaceNavigator.get("x");     // Right/Left: Moves (pan) the model or document right and left
    float yy = (Float)spaceNavigator.get("y");     // Up/Down: Moves (pan) the model or document up and down
    float zz = (Float)spaceNavigator.get("z");    // In/Out: Zoom the model or document in and out
    float rx = (Float)spaceNavigator.get("rx");   // Tilt: Tilts the model or scene forwards and backwards
    float ry = (Float)spaceNavigator.get("ry");   // Spin:   Spins the model or scene like a top
    float rz = (Float)spaceNavigator.get("rz");  // Roll:   Rolls the model or scene sideways

    float b0 = (Float)spaceNavigator.get("b0");  //button
    float b1 = (Float)spaceNavigator.get("b1");  //button


    camera(pos.x, pos.y, pos.z, lookAt.x, lookAt.y, lookAt.z, up.x, up.y, up.z);
    endCamera();
  }
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles