virtual reality

edited March 2018 in How To...

How to create a simple program with virtual reality object using camera, which allows you to look at it from different angles? I just can't find the solution



  • Please don't post duplicate questions. Keep similar content questions under the same post.


  • Can you give us more information about what you want rather than just posting duplicates.

  • Do you mean a virtual camera or an actual camera, like on a phone (which is more augmented reality)?

  • virtual camera

  • edited March 2018

    A quick google search for "Processing Augmented Reality Object" turns up a page with 8 tutorials.

    Granted, many of them rely on patterned markers, so if you're not using one of those to determine the orientation of your object, well, then you want to be getting the physical camera movement information from your camera's gyros. In this case, this project might be better off written in a native camera (Objective-C or whatever Androids use) language instead of Processing, so that you have (I assume) easy access to the device's orientation information and video feed.

    If you insist of doing it in Processing, start by displaying an image from your device's camera. Can you then draw a 3D object on top of that? Can you post the code of that so we have something to work with? Can you also make sure not to post a new discussion about it?

  • So just a 3d model that you can examine from all angles? There's a rocket in the examples. You can also load models using, I think, PShape.

    Peasycam is great for navigating in 3d space.

  • But, again, more details please. Something more than 2 word answers...

  • Post a link, draw a picture?

  • @igor: just copy here what you PM me

  • Could you help with virtual reality? The program should allow you to see on the table, where there is nothing, a cube, for ex, and if we "go around the table", the cube should be changed

  • edited March 2018

    When the table is existing in reality and the cube is virtual then it’s not virtually reality (vr) but augmented reality (AR).... I said this already in PM: see AR and ARCore.

    And get your vocabulary right otherwise you’ll ask and google in vain. It’s AR.

    See Wikipedia for clarification of vr versus AR please


  • example:

    float xSpeed;
    float ySpeed; 
    float r, d;
    float rotationX=1, rotationY=1, 
      pRotationX=.3, pRotationY=.3;
    float camX, camY, camZ; 
    void setup() { 
      size(displayWidth, displayHeight, P3D);
      r = 0; 
      d = 0;
    void draw() {
      camera(camX, camY, camZ, 
        0, 0, 0, 
        0, -1, 0);
      //  translate(0, 0, 0); 
      fill (255, 0, 0); 
    void deviceMoved() {
      xSpeed = rotationX + pRotationX;
      ySpeed = rotationY + pRotationY;
      d = d + xSpeed*9/3; 
      r = r + ySpeed*9/3;
      camX = 700 * cos(radians(d/9)); 
      camY = 700 * cos(radians(r/9)); 
      camZ = 700 * sin(radians(d/9));
  • Example (More like pseudo-concept). Also check


    Capture cam;   
    final float halfSize=20;
    float ang=0;
    PVector pos, vel;
    void setup() { 
      size(640, 480, P3D);
      fill (255, 0, 0); 
      pos=new PVector(width/2, height/2, 50);
      vel=new PVector(1, 1, 0);
      cam = new Capture(this, Capture.list()[0]);  
    void draw() {
      if (cam.available() == true) {;
      image(cam, 0, 0); 
      translate(pos.x, pos.y, pos.z); 
      rotateX(map(mouseX, 0, width, -TWO_PI, TWO_PI));
    void   moveObject() {
      if (pos.x<halfSize || pos.x>width-halfSize) {
        pos.set(pos.x%width, pos.y, pos.z);
        vel.set(-1*vel.x, vel.y, vel.z);
      if (pos.y<halfSize || pos.y>height-halfSize) {
        pos.set(pos.x, pos.y%height, pos.z);
        vel.set(vel.x, -1*vel.y, vel.z);
Sign In or Register to comment.