Changeset 1332 for trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc
- Timestamp:
- Aug 3, 2010, 4:21:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/visualization/OpenGL/src/G4OpenGLViewer.cc
r1327 r1332 101 101 // glDisable (GL_POLYGON_SMOOTH); 102 102 103 #ifdef G4DEBUG_VIS_OGL104 printf("G4OpenGLViewer::Creation !!\n");105 #endif106 103 } 107 104 … … 110 107 void G4OpenGLViewer::InitializeGLView () 111 108 { 112 #ifdef G4DEBUG_VIS_OGL113 printf("G4OpenGLViewer::InitializeGLView VVVVV\n");114 #endif115 109 glClearColor (0.0, 0.0, 0.0, 0.0); 116 #ifdef G4DEBUG_VIS_OGL117 printf("G4OpenGLViewer::InitializeGLView ---1---\n");118 #endif119 110 glClearDepth (1.0); 120 #ifdef G4DEBUG_VIS_OGL121 printf("G4OpenGLViewer::InitializeGLView ---2---\n");122 #endif123 111 glDisable (GL_BLEND); 124 #ifdef G4DEBUG_VIS_OGL125 printf("G4OpenGLViewer::InitializeGLView ---3---\n");126 #endif127 112 glDisable (GL_LINE_SMOOTH); 128 #ifdef G4DEBUG_VIS_OGL129 printf("G4OpenGLViewer::InitializeGLView ---4---\n");130 #endif131 113 glDisable (GL_POLYGON_SMOOTH); 132 #ifdef G4DEBUG_VIS_OGL133 printf("G4OpenGLViewer::InitializeGLView ---5---\n");134 #endif135 114 136 115 // if (fVP != NULL) { 137 fWinSize_x = fVP.GetWindowSizeHintX(); 138 fWinSize_y = fVP.GetWindowSizeHintY(); 139 #ifdef G4DEBUG_VIS_OGL 140 printf("G4OpenGLViewer::InitializeGLView ^^^^^^\n"); 141 #endif 142 // } 116 fWinSize_x = fVP.GetWindowSizeHintX(); 117 fWinSize_y = fVP.GetWindowSizeHintY(); 118 // } 143 119 } 144 120 … … 849 825 //phi spin stuff here 850 826 827 828 #ifdef G4DEBUG_VIS_OGL 829 printf("G4OpenGLViewer::rotateScene dx:%f dy:%f delta:%f\n",dx,dy, deltaRotation); 830 #endif 831 851 832 vp = fVP.GetViewpointDirection ().unit (); 852 833 up = fVP.GetUpVector ().unit (); 853 834 835 #ifdef G4DEBUG_VIS_OGL 836 printf("G4OpenGLViewer::rotateScene vp: %f %f %f\n",vp.x(),vp.y(),vp.z()); 837 #endif 854 838 yprime = (up.cross(vp)).unit(); 855 839 zprime = (vp.cross(yprime)).unit(); … … 871 855 // to allow more than 360° rotation 872 856 873 const G4Point3D targetPoint874 = fSceneHandler.GetScene()->GetStandardTargetPoint()875 + fVP.GetCurrentTargetPoint ();876 G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();877 if(radius<=0.) radius = 1.;878 const G4double cameraDistance = fVP.GetCameraDistance (radius);879 const G4Point3D cameraPosition =880 targetPoint + cameraDistance * fVP.GetViewpointDirection().unit();857 // const G4Point3D targetPoint 858 // = fSceneHandler.GetScene()->GetStandardTargetPoint() 859 // + fVP.GetCurrentTargetPoint (); 860 // G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius(); 861 // if(radius<=0.) radius = 1.; 862 // const G4double cameraDistance = fVP.GetCameraDistance (radius); 863 // const G4Point3D cameraPosition = 864 // targetPoint + cameraDistance * fVP.GetViewpointDirection().unit(); 881 865 882 866 if (fVP.GetLightsMoveWithCamera()) { 867 #ifdef G4DEBUG_VIS_OGL 868 printf("G4OpenGLViewer::rotateScene GetLightsMoveWithCamera: %f \n",new_vp.z()*vp.z()); 869 #endif 883 870 new_up = (new_vp.cross(yprime)).unit(); 884 871 if (new_vp.z()*vp.z() <0) { 872 #ifdef G4DEBUG_VIS_OGL 873 printf("G4OpenGLViewer::rotateScene R_____________________________________________\n"); 874 #endif 885 875 new_up.set(new_up.x(),-new_up.y(),new_up.z()); 886 876 } 887 877 } else { 878 #ifdef G4DEBUG_VIS_OGL 879 printf("G4OpenGLViewer::rotateScene : %f \n",new_vp.z()*vp.z()); 880 #endif 888 881 new_up = up; 889 882 if (new_vp.z()*vp.z() <0) { 883 #ifdef G4DEBUG_VIS_OGL 884 printf("G4OpenGLViewer::rotateScene X_____________________________________________\n"); 885 #endif 890 886 new_up.set(new_up.x(),-new_up.y(),new_up.z()); 891 887 } … … 906 902 delta = a2 - a1; 907 903 // So new viewpoint is... 904 908 905 viewPoint = new_vp.unit() + delta; 909 906 907 #ifdef G4DEBUG_VIS_OGL 908 printf("G4OpenGLViewer::rotateScene up: %f %f %f\n",up.x(),up.y(),up.z()); 909 printf("G4OpenGLViewer::rotateScene new up: %f %f %f\n",new_up.x(),new_up.y(),new_up.z()); 910 printf("G4OpenGLViewer::rotateScene new vp: %f %f %f delta:%f %f %f\n",new_vp.x(),new_vp.y(),new_vp.z(),delta.x(),delta.y(),delta.z()); 911 #endif 912 913 910 914 fVP.SetViewAndLights (viewPoint); 911 } 912 913 #endif 915 916 917 } 918 919 920 void G4OpenGLViewer::rotateSceneInViewDirection(G4double dx, G4double dy,G4double deltaRotation) 921 { 922 if (!fSceneHandler.GetScene()) { 923 return; 924 } 925 926 G4Vector3D vp; 927 G4Vector3D up; 928 929 G4Vector3D xprime; 930 G4Vector3D yprime; 931 G4Vector3D zprime; 932 933 G4double delta_alpha; 934 G4double delta_theta; 935 936 G4Vector3D new_vp; 937 G4Vector3D new_up; 938 939 G4double cosalpha; 940 G4double sinalpha; 941 942 G4Vector3D a1; 943 G4Vector3D a2; 944 G4Vector3D delta; 945 G4Vector3D viewPoint; 946 947 948 //phi spin stuff here 949 950 951 #ifdef G4DEBUG_VIS_OGL 952 printf("G4OpenGLViewer::rotateScene dx:%f dy:%f delta:%f\n",dx,dy, deltaRotation); 953 #endif 954 955 vp = fVP.GetViewpointDirection ().unit(); 956 up = fVP.GetUpVector ().unit(); 957 958 959 960 G4Vector3D zPrimeVector = G4Vector3D(up.y()*vp.z()-up.z()*vp.y(), 961 up.z()*vp.x()-up.x()*vp.z(), 962 up.x()*vp.y()-up.y()*vp.x()); 963 G4long zPrimeVectorX = up.y()*vp.z()-up.z()*vp.y(); 964 G4long zPrimeVectorY = up.z()*vp.x()-up.x()*vp.z(); 965 G4long zPrimeVectorZ = up.x()*vp.y()-up.y()*vp.x(); 966 967 viewPoint = vp/deltaRotation + (zPrimeVector*dx - up*dy) ; 968 new_up = G4Vector3D(viewPoint.y()*zPrimeVector.z()-viewPoint.z()*zPrimeVector.y(), 969 viewPoint.z()*zPrimeVector.x()-viewPoint.x()*zPrimeVector.z(), 970 viewPoint.x()*zPrimeVector.y()-viewPoint.y()*zPrimeVector.x()); 971 972 G4long new_upLenLong = sqrt((G4long)new_up.x()*(G4long)new_up.x()+(G4long)new_up.y()*(G4long)new_up.y()+(G4long)new_up.z()*(G4long)new_up.z()); 973 // new_up = new_up/new_upLenLong; 974 // G4double new_upLenDouble = new_up.x()*new_up.x()+new_up.y()*new_up.y()+new_up.z()*new_up.z(); 975 976 G4Vector3D new_upDiv = G4Vector3D((G4double)(new_up.x()/new_upLenLong), 977 (G4double)(new_up.y()/new_upLenLong), 978 (G4double)(new_up.z()/new_upLenLong)); 979 980 G4Vector3D new_upPrec = G4Vector3D(((G4double)(((G4long)viewPoint.y()*(G4long)zPrimeVector.z() 981 -(G4long)viewPoint.z()*(G4long)zPrimeVector.y())/new_upLenLong)), 982 ((G4double)(((G4long)viewPoint.z()*(G4long)zPrimeVector.x() 983 -(G4long)viewPoint.x()*(G4long)zPrimeVector.z())/new_upLenLong)), 984 ((G4double)(((G4long)viewPoint.x()*(G4long)zPrimeVector.y() 985 -(G4long)viewPoint.y()*(G4long)zPrimeVector.x())/new_upLenLong))); 986 G4Vector3D new_upUnit = new_up.unit(); 987 988 989 #ifdef G4DEBUG_VIS_OGL 990 printf("G4OpenGLViewer::rotateScene up: %.10lf %.10lf %.10lf len:%.10lf lenLong:%.10lf %f\n",up.x(),up.y(),up.z(), up.mag(),new_upLenLong,new_upLenLong); 991 printf("G4OpenGLViewer::rotateScene NEW new up UNIT / %.10lf %.10lf %.10lf\n",new_upUnit.x(),new_upUnit.y(),new_upUnit.z()); 992 printf("G4OpenGLViewer::rotateScene NEW new up Prec: %.10lf %.10lf %.10lf\n",new_upPrec.x(),(viewPoint.z()*zPrimeVectorX-viewPoint.x()*zPrimeVectorZ),new_upPrec.z()); 993 printf("G4OpenGLViewer::rotateScene NEW new up Div: %.10lf %.10lf %.10lf\n",new_upDiv.x(),new_upDiv.y(),new_upDiv.z()); 994 printf("G4OpenGLViewer::rotateScene vp: %f %f %f\n",vp.x(),vp.y(),vp.z()); 995 996 viewPoint = viewPoint*deltaRotation; 997 998 printf("G4OpenGLViewer::rotateScene NEW --new vp: %f %f %f\n",viewPoint.x(),viewPoint.y(),viewPoint.z()); 999 #endif 1000 1001 fVP.SetUpVector(new_upUnit); 1002 fVP.SetViewAndLights (viewPoint); 1003 } 1004 1005 #endif
Note: See TracChangeset
for help on using the changeset viewer.