00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <stdio.h>
00042 #include <string.h>
00043 #ifndef __UNIX_
00044 #include <malloc.h>
00045 #endif
00046 #include "memvirtu.h"
00047 #include "lowparam.h"
00048 #include "lowmacro.h"
00049 #include "lowsolid.h"
00050 #include "mancommd.h"
00051 #include "disdispl.h"
00052 #include "gphgraph.h"
00053 #include "vectorop.h"
00054
00055 int MSD_highCheckCamera(real Ex, real Ey, real Ez, real Rx, real Ry,
00056 real Rz, real scale, int mode, int hidtype,
00057 int dash, int smooth)
00058 {
00059 vector eye, ref;
00060
00061 makevec(eye, Ex, Ey, Ez, 1.0);
00062 makevec(ref, Rx, Ry, Rz, 1.0);
00063 return(MSD_lowCheckCamera(eye, ref, scale, mode, hidtype, dash, smooth));
00064 }
00065
00066 int MSD_lowCheckCamera(vector eye, vector ref, real scale, int mode,
00067 int hidtype, int dash, int smooth)
00068 {
00069 if (vecd(eye, ref) < abseps * 10.0)
00070 {
00071 return(FALSE);
00072 }
00073 if (scale < releps * 100.0)
00074 {
00075 return(FALSE);
00076 }
00077 if ((mode < 1) || (mode > 3))
00078 {
00079 return(FALSE);
00080 }
00081 if ((hidtype < 0) || (hidtype > 3))
00082 {
00083 return(FALSE);
00084 }
00085 if ((dash < 0) || (dash > 1))
00086 {
00087 return(FALSE);
00088 }
00089 if ((smooth < 0) || (smooth > 1))
00090 {
00091 return(FALSE);
00092 }
00093 return(TRUE);
00094 }
00095
00096 void MSD_highSetCamera(CTYPE *cptr, real Ex, real Ey, real Ez,
00097 real Rx, real Ry, real Rz, real scale,
00098 int mode, int hidtype, int dash, int smooth)
00099 {
00100 vector eye, ref;
00101
00102 makevec(eye, Ex, Ey, Ez, 1.0);
00103 makevec(ref, Rx, Ry, Rz, 1.0);
00104 MSD_lowSetCamera(cptr, eye, ref, scale, mode, hidtype, dash, smooth);
00105 }
00106
00107 void MSD_lowSetCamera(CTYPE *cptr, vector eye, vector ref, real scale,
00108 int mode, int hidtype, int dash, int smooth)
00109 {
00110 veccopy(cptr->eye, eye);
00111 veccopy(cptr->ref, ref);
00112 cptr->scale = scale;
00113 cptr->mode = mode;
00114 cptr->hid = hidtype;
00115 cptr->dash = dash;
00116 cptr->smooth = smooth;
00117 MSD_lowSetCameraTransformation(cptr);
00118 }
00119
00120 void MSD_lowSetCameraTransformation(CTYPE *cptr)
00121 {
00122 real sint, cost, sinp, cosp, al, als;
00123
00124 cptr->cdis = al = vecd(cptr->eye, cptr->ref);
00125 if ((als = vecd2(cptr->eye, cptr->ref)) > abseps * 10.0)
00126 {
00127 sint = (cptr->eye[1] - cptr->ref[1]) / als;
00128 cost = (cptr->eye[0] - cptr->ref[0]) / als;
00129 sinp = (cptr->eye[2] - cptr->ref[2]) / al;
00130 cosp = als / al;
00131 }
00132 else
00133 {
00134 sint = 0.0;
00135 cost = 1.0;
00136 sinp = 1.0;
00137 cosp = 0.0;
00138 }
00139 matident(cptr->drot);
00140 cptr->drot[0][0] = -sint;
00141 cptr->drot[0][1] = cost;
00142 cptr->drot[0][2] = 0.0;
00143 cptr->drot[1][0] = -sinp * cost;
00144 cptr->drot[1][1] = -sinp * sint;
00145 cptr->drot[1][2] = cosp;
00146 cptr->drot[2][0] = -cosp * cost;
00147 cptr->drot[2][1] = -cosp * sint;
00148 cptr->drot[2][2] = -sinp;
00149 vecminus(cptr->eyedir, cptr->eye, cptr->ref);
00150 normalize(cptr->eyedir);
00151 }
00152
00153 void MSD_lowSetCamera3View(int type, CTYPE *cptr)
00154 {
00155 vector eye3;
00156
00157 switch (type)
00158 {
00159 case 0:
00160 veccopy(dwindbox, windbox);
00161 break;
00162
00163 case 1:
00164 eye3[0] = cptr->ref[0];
00165 eye3[1] = cptr->ref[1];
00166 eye3[2] = cptr->ref[2] + cptr->cdis;
00167 MSD_lowSetCamera(camptr, eye3, cptr->ref, cptr->scale, 2,
00168 cptr->hid, cptr->dash, cptr->smooth);
00169 dwindbox[0] = windbox[0];
00170 dwindbox[1] = windbox[1] + windbox[2] / 2.0;
00171 dwindbox[2] = windbox[2] / 2.0;
00172 break;
00173
00174 case 2:
00175 eye3[0] = cptr->ref[0] + cptr->cdis;
00176 eye3[1] = cptr->ref[1];
00177 eye3[2] = cptr->ref[2];
00178 MSD_lowSetCamera(camptr, eye3, cptr->ref, cptr->scale, 2,
00179 cptr->hid, cptr->dash, cptr->smooth);
00180 dwindbox[0] = windbox[0];
00181 dwindbox[1] = windbox[1];
00182 dwindbox[2] = windbox[2] / 2.0;
00183 break;
00184
00185 case 3:
00186 eye3[0] = cptr->ref[0];
00187 eye3[1] = cptr->ref[1] + cptr->cdis;
00188 eye3[2] = cptr->ref[2];
00189 MSD_lowSetCamera(camptr, eye3, cptr->ref, cptr->scale, 2,
00190 cptr->hid, cptr->dash, cptr->smooth);
00191 dwindbox[0] = windbox[0] + windbox[2] / 2.0;
00192 dwindbox[1] = windbox[1];
00193 dwindbox[2] = windbox[2] / 2.0;
00194 break;
00195
00196 case 4:
00197 dwindbox[0] = windbox[0] + windbox[2] / 2.0;
00198 dwindbox[1] = windbox[1] + windbox[2] / 2.0;
00199 dwindbox[2] = windbox[2] / 2.0;
00200 camptr = cptr;
00201 }
00202 }