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.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Freaky Camera / Geometry Movement
Page Index Toggle Pages: 1
Freaky Camera / Geometry Movement (Read 888 times)
Freaky Camera / Geometry Movement
Dec 9th, 2009, 8:36am
 
Here's a freaky one (this may be a question about libraries or 3D or OPENGL):

In OPENGL I have imported 3ds geometry using the Mri3ds library.  Great.  I have built other 3D geometries inside Processing to go along with these imported geometries.  Great.  I have a lovely camera that works a lot like google earth.  All works great.  Camera orbiting and panning is lovely.  
Then-  when I use perspective()  simply to make the far clipping plane a little further away:

The 3ds geometry and the Processing geometry orbit in different directions!!  As in-  when the camera orbits up to look at the top of the geometry made in processing, the 3ds geometries are moving in the opposite manner such that you end up looking at their bottom!

It's a very freaky experience.
Also freaky-  I tried it on an older version (1.0.3) of Processing on a different computer-  no problem.
Any ideas?

(in case this is related- the new version of processing that I've been using, 1.0.9,  can never find the 'libraries' folder.  I have to put all my libraries in a 'code' folder in each sketch.  It also can't create web apps...  who knows)


The camera, if you're interested  (I'm pretty proud of it  ; )

       // Perspective
           float fov = PI/3.0;
           float cameraZ = (height/2.0) / tan(fov/2.0);
           float clipfactor = 100;
           perspective( fov, float(width)/float(height), cameraZ/clipfactor, cameraZ*clipfactor);


       // Mouse control
           if(mousePressed) {
             
               if(mouseButton==LEFT){
                 TargetXVelocity -= (mouseX-pmouseX) * 4;
                 TargetYVelocity -= (mouseY-pmouseY) * 4;  
               }
             
               else if(mouseButton==RIGHT) {
                 CamRVelocity += (mouseX-pmouseX) * .1;
                 CamTVelocity += (mouseY-pmouseY) * .05;
           } }
           
           
           CameraRadius = CamZoom;
           TargetHeight = 100;
           
           //Camera rotation
           CamRotation += CamRVelocity;
           CamRVelocity *= .8;
           CamTilt += CamTVelocity;
           CamTVelocity *= .8;
           
           //restrict camera tilt
           if (CamTilt < -180) {
             CamTilt = -179.9; }
           else if (CamTilt > -90) {
             CamTilt = -90.1; }

           
           RotateAngle = radians(CamRotation);
           TiltAngle = radians(CamTilt);  
           
           //Camera position
           TargetXVelocity *= .8;
           TargetYVelocity *= .8;    

           TargetX += sin(RotateAngle-PI) * TargetXVelocity + cos(RotateAngle-PI) * TargetYVelocity;
           TargetY += cos(RotateAngle) * TargetXVelocity + sin(RotateAngle-PI) * TargetYVelocity;      

           L = cos(TiltAngle) * CameraRadius;
           CameraX = cos(RotateAngle) * L + TargetX;
           CameraY = sin(RotateAngle) * L + TargetY;
           CameraZ = (sin(TiltAngle)) * CameraRadius - TargetHeight;
                 
           camera(CameraX, CameraZ, CameraY,     TargetX, -TargetHeight, TargetY, 0,1,0);
 


Re: Freaky Camera / Geometry Movement
Reply #1 - Jan 18th, 2010, 5:38pm
 
Hi,
Processing uses a different coord system from opengl even in 3d mode if i remember correctly. processing positive Y axis points down, while GL points up.

check the "Coordinates" section.
http://processing.org/reference/environment/


as for the libraries you will need to place them in the processing libraries folder.. you can find which folder that is in the File/Preferences menu.

Page Index Toggle Pages: 1