From b9f0c5ce47f3686ea40327f83fff51756e03db47 Mon Sep 17 00:00:00 2001 From: Gilles Marckmann <gilles.marckmann@ec-nantes.fr> Date: Fri, 22 Oct 2010 11:04:45 +0000 Subject: [PATCH] correction on previous commitment of ~ files. --- Graphics/Camera.cpp~ | 194 ------------------------------------------- Graphics/Camera.h~ | 138 ------------------------------ 2 files changed, 332 deletions(-) delete mode 100644 Graphics/Camera.cpp~ delete mode 100644 Graphics/Camera.h~ diff --git a/Graphics/Camera.cpp~ b/Graphics/Camera.cpp~ deleted file mode 100644 index fa53fb57f8..0000000000 --- a/Graphics/Camera.cpp~ +++ /dev/null @@ -1,194 +0,0 @@ -#include <string> -#include <iostream> -#include "Camera.h" -#include "Gmsh.h" -#include "GmshConfig.h" -#include "GmshMessage.h" -#include "Trackball.h" -#include "Context.h" -#include "drawContext.h" - -#if defined(HAVE_FLTK) -#include <FL/Fl_JPEG_Image.H> -#include <FL/Fl_PNG_Image.H> -#endif - -using namespace std; - - -Camera::Camera( ) { - aperture = 40; - focallength = 100.; - distance=focallength; - // eyesep =0.88 ; - ratio=1./50.; - closeness=1.; - target = origin; - position = origin; - position.z = focallength ; - view.x =0.; - view.y =0.; - view.z =-1.; - up.x = 0; - up.y = 1; - up.z = 0; - screenwidth=400; - screenheight=400; - stereoEnable=false; - ref_distance=distance; - this->update(); -} - -Camera::~Camera(){}; - - -void Camera::lookAtCg(){ - target.x=CTX::instance()->cg[0]; - target.y=CTX::instance()->cg[1]; - target.z=CTX::instance()->cg[2]; - double W=CTX::instance()->max[0]-CTX::instance()->min[0]; - double H=CTX::instance()->max[1]-CTX::instance()->min[1]; - double P=CTX::instance()->max[2]-CTX::instance()->min[2]; - // cout<<" H "<<H << " W"<< W <<endl; - Lc=sqrt(1.*W*W+1.*H*H+1.*P*P); - // cout<<" "<< 1.*W*W+1.*H*H <<endl; - // cout<<" "<< tan(aperture) <<endl; - distance=fabs(.5*Lc*4./3./tan(aperture*.01745329/2.)); - // cout<<" RC "<<RC << " distance"<< distance <<endl; - position.x=target.x-distance*view.x; - position.y=target.y-distance*view.y; - position.z=target.z-distance*view.z; - // cout<<" cg "<<target.x << " "<< target.y << " "<<target.z<<endl; - update(); - focallength=distance; - eyesep=focallength*ratio; -} - - -void Camera::init(){ - aperture = 40; - focallength = 100; - ratio=1./50.; - target = origin; - distance=focallength*1.4; - position = origin; - position.z = distance ; - view.x =0.; - view.y =0.; - view.z =-1.; - up.x = 0; - up.y = 1; - up.z = 0; - ref_distance=distance; - eyesep=focallength*ratio; - // closeness=distance/focallength; - lookAtCg(); -} - -void Camera::update() { - right.x=view.y*up.z-view.z*up.y; - right.y=view.z*up.x-view.x*up.z; - right.z=view.x*up.y-view.y*up.x; - up.x=right.y*view.z-right.z*view.y; - up.y=right.z*view.x-right.x*view.z; - up.z=right.x*view.y-right.y*view.x; - ref_distance=distance; - normalize(up); - normalize(right); - normalize(view); -} - -void Camera::moveRight(double theta) { - this->update(); - - position.x=position.x-distance*tan(theta)*right.x; - position.y=position.y-distance*tan(theta)*right.y; - position.z=position.z-distance*tan(theta)*right.z; - target.x=position.x+distance*view.x; - target.y=position.y+distance*view.y; - target.z=position.z+distance*view.z; - this->update(); -} - -void Camera::moveUp(double theta) { - this->update(); - position.x=position.x+distance*tan(theta)*up.x; - position.y=position.y+distance*tan(theta)*up.y; - position.z=position.z+distance*tan(theta)*up.z; - target.x=position.x+distance*view.x; - target.y=position.y+distance*view.y; - target.z=position.z+distance*view.z; - this->update(); -} - -void Camera::rotate(double* q) { - this->update(); - // rotation projection in global coordinates - quaternion omega; - omega.x=-q[0]*right.x+q[1]*up.x+q[2]*view.x ; - omega.y=-q[0]*right.y+q[1]*up.y+q[2]*view.y ; - omega.z=-q[0]*right.z+q[1]*up.z+q[2]*view.z ; - omega.w=q[3]; - - quaternion q_view,q_position,new_q_view,new_q_position; - quaternion q_right,q_up,new_q_right,new_q_up; - - // normalize the axe of rotation in the quaternion omega if not null - double sina=sin(acos(omega.w)); - double length; - if (sina != 0.){ - length=(omega.x*omega.x+omega.y*+omega.y+omega.z*omega.z)/(sina*sina); - } - else{ - length=0.; - } - length=sqrt(length); - if (length!=0.){ - - omega.x=omega.x/length; - omega.y=omega.y/length; - omega.z=omega.z/length; - // rotation of the camera (view,up and right vectors) - // arround 0 0 0 the CenterOfRotation - //normalize(camera.view); - - //rotate view direction - q_view.x=view.x; - q_view.y=view.y; - q_view.z=view.z; - q_view.w=0.; - normalize(q_view); - new_q_view=mult(mult(omega,q_view),conjugate(omega)); - view.x=new_q_view.x ; - view.y=new_q_view.y; - view.z=new_q_view.z; - //rotate up direction - q_up.x=up.x; - q_up.y=up.y; - q_up.z=up.z; - q_up.w=0.; - normalize(q_up); - new_q_up=mult(mult(omega,q_up),conjugate(omega)); - up.x=new_q_up.x ; - up.y=new_q_up.y; - up.z=new_q_up.z; - //rotate right direction - q_right.x=right.x; - q_right.y=right.y; - q_right.z=right.z; - q_right.w=0.; - normalize(q_right); - new_q_right=mult(mult(omega,q_right),conjugate(omega)); - right.x=new_q_right.x ; - right.y=new_q_right.y; - right.z=new_q_right.z; - - //actualize camera position - position.x=target.x-view.x*distance; - position.y=target.y-view.y*distance; - position.z=target.z-view.z*distance; - - } - this->update(); -} - diff --git a/Graphics/Camera.h~ b/Graphics/Camera.h~ deleted file mode 100644 index ff5bf4ffc1..0000000000 --- a/Graphics/Camera.h~ +++ /dev/null @@ -1,138 +0,0 @@ - -#ifndef _CAMERA_H_ -#define _CAMERA_H_ - -#include <stdio.h> -#include <math.h> -# - - -typedef struct { - double x,y,z; -} XYZ; -typedef struct { - double x,y,z,w; -} quaternion; - -XYZ origin = {0.0,0.0,0.0}; - -class Camera { -public: - XYZ position; /* camera position */ - XYZ view; /* View direction vector */ - XYZ up; /* View up direction */ - XYZ right; /* View right direction */ - XYZ target; /* center of rotation and screen */ - double focallength; /* Focal Length along vd */ - double aperture; /* Camera aperture */ - double eyesep; /* Eye separation */ - int screenwidth,screenheight; - double distance; - double ref_distance; - bool button_left_down; - bool button_middle_down; - bool button_right_down; - bool stereoEnable; - double Lc; - double ratio; - double closeness; - Camera(); - ~Camera(); - void lookAtCg(); - void init(); - void rotate(double* q); - void moveRight(double theta); - void moveUp(double theta); -private: - void update(); -}; - - - -class mouseAndKeyboard { -public: - bool button_left_down; - bool button_middle_down; - bool button_right_down; - int key; - int mode; - mouseAndKeyboard() {}; - ~mouseAndKeyboard() {}; -}; - - - - -// Quaternion and XYZ functions -double length(quaternion quat) -{ - return sqrt(quat.x * quat.x + quat.y * quat.y + - quat.z * quat.z + quat.w * quat.w); -} -double length(XYZ p) -{ - return sqrt(p.x * p.x + p.y * p.y + p.z * p.z); -} -quaternion normalize(quaternion &quat) -{ - double L = length(quat); - - quat.x /= L; - quat.y /= L; - quat.z /= L; - quat.w /= L; - - return quat; -} - -XYZ normalize(XYZ &p) -{ - double L = length(p); - - p.x /= L; - p.y /= L; - p.z /= L; - - return p; -} -quaternion conjugate(quaternion quat) -{ - quat.x = -quat.x; - quat.y = -quat.y; - quat.z = -quat.z; - return quat; -} -quaternion mult(quaternion A, quaternion B) -{ - quaternion C; - - C.x = A.w*B.x + A.x*B.w + A.y*B.z - A.z*B.y; - C.y = A.w*B.y - A.x*B.z + A.y*B.w + A.z*B.x; - C.z = A.w*B.z + A.x*B.y - A.y*B.x + A.z*B.w; - C.w = A.w*B.w - A.x*B.x - A.y*B.y - A.z*B.z; - return C; -} - -XYZ rotate(quaternion omega,XYZ axe) { - XYZ new_axe; - quaternion qaxe,new_qaxe; - qaxe.x=axe.x; - qaxe.y=axe.y; - qaxe.z=axe.z; - qaxe.w=0.; - new_qaxe=mult(mult(omega,qaxe),conjugate(omega)); - axe.x=new_qaxe.x ; - axe.y=new_qaxe.y; - axe.z=new_qaxe.z; - -} - - - - - - - - - -#endif -- GitLab