We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Pages: 1 2 
OCD Updated (Read 5421 times)
OCD Updated
Jan 3rd, 2008, 3:11am
 
For those of you who have been patiently waiting, OCD has finally been updated to be compatible with the latest version of Processing.

Ben, Casey, I'm not sure of the best way to announce this to the users. The OCD library pages have been updated accordingly.

I've kept the pre 125 compatible library up for those who still need it.

Good Luck!

K. Damkjer
Re: OCD Updated
Reply #1 - Jan 3rd, 2008, 4:34am
 
WooHoo. This is great news. But the link to the new version links to the old version.

I also have a request. Would it be possible to make the variables of the library public. It's quite useful to know where the OCD camera is. Especially if you've got a few of them.

Re: OCD Updated
Reply #2 - Jan 3rd, 2008, 4:32pm
 
Fixed the site. I can probably throw some accessors on the class as well to improve it's utility. Stay tuned.
Re: OCD Updated
Reply #3 - Jan 5th, 2008, 2:15am
 
OK, I've updated the OCD library once again to provide accessors for camera position, target position, camera orientation (attitude), camera "up" direction, and field of view.

Let me know what you think.

All of the reference documentation has been updated on the site as well.
Re: OCD Updated
Reply #4 - Jan 5th, 2008, 10:40pm
 
Sorry Kristian but the 1.2 link doesn't work on the site.

matt
Re: OCD Updated
Reply #5 - Jan 6th, 2008, 7:44pm
 
I had the file permissions set incorrectly. It should be available now.
Re: OCD Updated
Reply #6 - Jan 28th, 2008, 1:33pm
 
Hi Kristian, Sorry I've taken so long to get back to you but work doesn't let up. However I think I've found some weirdness with ocd 1.2 This is the simplified example of the problem. It looks like the aspect ratio is a little out. And once camera.feed() is enabled the aspect stays broken. With ocd 1.1 the aspect ratio is fine.

I have a suspicion that the culprit is this aspect ratio bit. from ocd 1.1

Code:

1f * parent.width / parent.height

and the 1.2 version

Code:

(float)(aParent.width / aParent.height)


But from my understanding this should be two ways of getting the exact same result. But anyway here is the example. Press the mouse button to turn on the ocd camera feed. You should see a cube go a little flat.

Code:
import processing.opengl.*;
import damkjer.ocd.*;

Camera camera1;
boolean enableCamera;


void setup(){
size(600, 400, OPENGL);

camera1 = new Camera(this, width/2.0, height/2.0, (height/2.0) / tan((PI*60.0) / 360.0), width/2.0, height/2.0, 0);
//values of processing standard camera taken from http://processing.org/reference/camera_.html

}


void draw(){

background(16);

if(enableCamera){
camera1.feed();
}

lights();
pushMatrix();
translate(width/2, height/2, -height/2);
rotateX(radians(frameCount));
rotateY(radians(frameCount));

box(100);

popMatrix();
}

void mouseReleased(){
boolean test = !enableCamera ? true : false;
enableCamera = test;
}


thanks for the awesome library by the way. I saves me so much time. It's a life saver.
Re: OCD Updated
Reply #7 - Jan 28th, 2008, 9:09pm
 
I did some more digging and yeah it is the aspect ratio math. The two ints (width and height) divide to give an int and are then converted into a float. So unless the ratio of width/height is a whole number the aspect ratio will always be out of wack. If one of the ints is converted to a float before the divide then the answer will be correct.

Code:

size(640, 480);

// 1.1 method
println( 1f * width / height ); // prints 1.3333334

// 1.2 method
println((float)(width / height) );// prints 1.0

//adjusted 1.2 method
println(float(width) / float(height));// prints 1.3333334

Re: OCD Updated
Reply #8 - Jan 29th, 2008, 12:50pm
 
Thanks for the catch. Updated on the site.
Re: OCD Updated
Reply #9 - Jan 30th, 2008, 12:09am
 
Awesome, thanks for that. It works like a charm.
Re: OCD Updated
Reply #10 - Mar 5th, 2008, 4:03am
 
Kristian,
I'm trying to use the Camera constructor that includes the 'Up' vector components:

Camera(parent,
      cameraX, cameraY, cameraZ,
      targetX, targetY, targetZ,
      upX,     upY,     upZ)

But I'm getting a compile message stating this:

Semantic Error: No applicable overload was found for a constructor with signature "Camera(Temporary_5688_149, float, float, float, float, float, float, float, float, float)" in type "damkjer.ocd.Camera". Perhaps you wanted the overloaded version "Camera(processing.core.PApplet $1, float $2, float $3, float $4, float $5, float $6, float $7);" instead?

I confirmed that I downloaded the ocd-1_3.zip, which I believe is the most recent version.  Any help?

The library looks beautiful, by the way, I'm looking forward to it making my life easier. Smiley

-Andy
Re: OCD Updated
Reply #11 - Mar 23rd, 2008, 2:31am
 
I ran into the same problem, it's because there's no constructor that takes those arguments.  It's an error in the documentation.  I had to look at the source code to find a list of suitable constructors.  I went ahead and copied it here. it's pretty well documented,  Kristian, maybe you should include it in the online documentation.  I take it this doesn't work with the opengl camera, but it shouldn't be to hard to port.  Thanks for the great work!!

//--- Constructors --------

  // Create a camera that sits on the z axis
  public Camera(PApplet aParent)
  {
     this(aParent,
          aParent.height * 0.5f / tan(DEFAULT_FOV * 0.5f));
  }

  // Create a camera that sits on the z axis with a specified shot length
  public Camera(PApplet aParent,
                float   aShotLength)
  {
     this(aParent,
          0, 0, aShotLength);
  }

  // Create a camera at the specified location looking at the world origin
  public Camera(PApplet aParent,
                float   aCameraX, float aCameraY, float aCameraZ)
  {
     this(aParent,
          aCameraX, aCameraY, aCameraZ,
          0, 0, 0);
  }

  // Create a camera at the specified location with the specified target
  public Camera(PApplet aParent,
                float aCameraX, float aCameraY, float aCameraZ,
                float aTargetX, float aTargetY, float aTargetZ)
  {
     this(aParent,
          aCameraX, aCameraY, aCameraZ,
          aTargetX, aTargetY, aTargetZ,
                 0,        1,        0,
          DEFAULT_FOV, (float)(1f * aParent.width / aParent.height), 0, 0);

     theNearClip = theShotLength * 0.1f;
     theFarClip  = theShotLength * 10f;
  }

  // Specify all parameters for camera creation
  public Camera(PApplet aParent,
                float aCameraX, float aCameraY, float aCameraZ,
                float aTargetX, float aTargetY, float aTargetZ,
                float anUpX,    float anUpY,    float anUpZ,
                float anFoV, float anAspect, float aNearClip, float aFarClip)
  {
     theParent   = aParent;
     theCameraX  = aCameraX;
     theCameraY  = aCameraY;
     theCameraZ  = aCameraZ;
     theTargetX  = aTargetX;
     theTargetY  = aTargetY;
     theTargetZ  = aTargetZ;
     theUpX      = anUpX;
     theUpY      = anUpY;
     theUpZ      = anUpZ;
     theFoV      = anFoV;
     theAspect   = anAspect;
     theNearClip = aNearClip;
     theFarClip  = aFarClip;

     theDeltaX   = theCameraX - theTargetX;
     theDeltaY   = theCameraY - theTargetY;
     theDeltaZ   = theCameraZ - theTargetZ;

     theShotLength = magnitude(theDeltaX, theDeltaY, theDeltaZ);

     theAzimuth    = atan2(theDeltaX,
                           theDeltaZ);
     theElevation  = atan2(theDeltaY,
                           sqrt(theDeltaZ * theDeltaZ +
            theDeltaX * theDeltaX));

     if (theElevation > HALF_PI - TOL)
     {
        theUpY =  0;
        theUpZ = -1;
     }    

     if (theElevation < TOL - HALF_PI)
     {
        theUpY =  0;
        theUpZ =  1;
     }

     updateUp();
  }
Re: OCD Updated
Reply #12 - Apr 1st, 2008, 10:33pm
 
I just downloaded this library to learn how to use it, and I am running into the Camera() constructor problem. Specifically I am trying to make a camera with the far clipping plane set very far away.

Is there a way to alter the far clipping plane after the camera has already been constructed?
Re: OCD Updated
Reply #13 - Apr 3rd, 2008, 8:50pm
 
Camera(this, float CameraX, float CameraY, float CameraZ,
      float TargetX, float TargetY, float TargetZ,
      float UpX,    float UpY,    float UpZ,
      float FoV, float Aspect, float NearClip, float FarClip)

Youll' have to initialize the camera with all these setting if you want to change the clipping distance for example:

camera1 = new Camera(this, 0, 0,  600, 0, 0, 0, 0, 1, 0, PI/3, 1.25, 1, 50000);

This will place the camera at coord. 0,0,600 targeting 0,0,0 with up direction being positive Y, Fov Pi/3, aspect ratio of 1.25, short clipping range of 1 and far clip at 50000;
Re: OCD Updated
Reply #14 - Apr 3rd, 2008, 11:37pm
 
Ah, thank you.
Pages: 1 2