%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Positionnement de la camera et du type de camera
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/ScreenDist 0.1 def
/ZoomFactor_x 100 def
/ZoomFactor_y 100 def
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% choix du type de representation
/representationtype (perspective) def
%/representationtype (ortho) def
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Set Camera Position
/SetCamPos { %% Cam_x Cam_y Cam_z
/Cam_z@3d exch def
/Cam_y@3d exch def
/Cam_x@3d exch def
/CamPos@3d {Cam_x@3d Cam_y@3d Cam_z@3d} def
} def
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Get Camera Position
/GetCamPos {
CamPos@3d
} def
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Set Camera Looking vector
/SetCamVec { %% Cam_Vx Cam_Vy Cam_Vz
/Cam_Vz@3d exch def
/Cam_Vy@3d exch def
/Cam_Vx@3d exch def
/CamVec@3d {Cam_Vx@3d Cam_Vy@3d Cam_Vz@3d} def
} def
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Get Camera Looking vector
/GetCamVec {
CamVec@3d
} def
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Set Camera Up vector
/SetCamUp { %% Cam_Ux Cam_Uy Cam_Uz
/Cam_Uz@3d exch def
/Cam_Uy@3d exch def
/Cam_Ux@3d exch def
/UpVec@3d {Cam_Ux@3d Cam_Uy@3d Cam_Uz@3d} def
} def
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Get Camera Up vector
/GetCamUp {
UpVec@3d
} def
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Compute vectors usefull to CamView
/ComputeCamera {
%% Calcule le vecteur directeur ZVecteur relatif a la camera
CamVec@3d dupp3d norme3d -1 exch div mulv3d
/ZVec_z@3d exch def
/ZVec_y@3d exch def
/ZVec_x@3d exch def
/ZVec@3d {ZVec_x@3d ZVec_y@3d ZVec_z@3d} def
%% Calcule le vecteur directeur YVecteur relatif a la camera
ZVec@3d dupp3d UpVec@3d scalprod3d neg mulv3d UpVec@3d addv3d dupp3d norme3d 1 exch div mulv3d
/YVec_z@3d exch def
/YVec_y@3d exch def
/YVec_x@3d exch def
/YVec@3d {YVec_x@3d YVec_y@3d YVec_z@3d} def
%% Calcule le vecteur directeur YVecteur relatif a la camera
YVec@3d ZVec@3d vectprod3d
/XVec_z@3d exch def
/XVec_y@3d exch def
/XVec_x@3d exch def
/XVec@3d {XVec_x@3d XVec_y@3d XVec_z@3d} def
} def
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% On projete le point 3d sur le plan de representation de la camera,
%% selon le mode de representation
/CamView { %% x y z
1 dict begin
/M defpoint3d
representationtype (ortho) eq
{CamPos@3d M vecteur3d dupp3d
ZVec@3d scalprod3d neg ZVec@3d lambdav3d
addv3d dupp3d XVec@3d scalprod3d 0.01 ZoomFactor_x mul mul
4 1 roll YVec@3d scalprod3d 0.01 ZoomFactor_y mul mul
}
{CamPos@3d M vecteur3d dupp3d
ZVec@3d scalprod3d neg ScreenDist exch div mulv3d
dupp3d XVec@3d scalprod3d ZoomFactor_x mul
4 1 roll YVec@3d scalprod3d ZoomFactor_y mul
} ifelse
end
} def
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%%%%%%% NOUVEAU %%%%%%%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %% Set Camera Position
%% /SetCamPos { %% Cam_x Cam_y Cam_z
%% /Cam_z exch def
%% /Cam_y exch def
%% /Cam_x exch def
%% /CamPos {Cam_x Cam_y Cam_z} def
%% } def
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %% Get Camera Position
%% /GetCamPos {
%% CamPos
%% } def
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %% Set Camera Looking vector
%% /SetCamVec { %% Cam_Vx Cam_Vy Cam_Vz
%% /Cam_Vz exch def
%% /Cam_Vy exch def
%% /Cam_Vx exch def
%% /CamVec {Cam_Vx Cam_Vy Cam_Vz} def
%% } def
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %% Get Camera Looking vector
%% /GetCamVec {
%% CamVec
%% } def
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %% Set Camera Up vector
%% /SetCamUp { %% Cam_Ux Cam_Uy Cam_Uz
%% /Cam_Uz exch def
%% /Cam_Uy exch def
%% /Cam_Ux exch def
%% /UpVec {Cam_Ux Cam_Uy Cam_Uz} def
%% } def
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %% Get Camera Up vector
%% /GetCamUp {
%% UpVec
%% } def
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %% Compute vectors usefull to CamView
%% /ComputeCamera {
%%
%% %% Calcule le vecteur directeur ZVecteur relatif a la camera
%% CamVec dupp3d norme3d -1 exch div mulv3d
%% /ZVec_z exch def
%% /ZVec_y exch def
%% /ZVec_x exch def
%% /ZVec {ZVec_x ZVec_y ZVec_z} def
%%
%% %% Calcule le vecteur directeur YVecteur relatif a la camera
%% ZVec dupp3d UpVec scalprod3d neg mulv3d UpVec addv3d dupp3d norme3d 1 exch div mulv3d
%% /YVec_z exch def
%% /YVec_y exch def
%% /YVec_x exch def
%% /YVec {YVec_x YVec_y YVec_z} def
%%
%% %% Calcule le vecteur directeur YVecteur relatif a la camera
%% YVec ZVec vectprod3d
%% /XVec_z exch def
%% /XVec_y exch def
%% /XVec_x exch def
%% /XVec {XVec_x XVec_y XVec_z} def
%% } def
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %% On projete le point 3d sur le plan de representation de la camera,
%% %% selon le mode de representation
%% /CamView { %% x y z
%% 1 dict begin
%% /M defpoint3d
%% representationtype (ortho) eq
%% {CamPos M vecteur3d dupp3d
%% ZVec scalprod3d neg ZVec lambdav3d
%% addv3d dupp3d XVec scalprod3d 0.01 ZoomFactor_x mul mul
%% 4 1 roll YVec scalprod3d 0.01 ZoomFactor_y mul mul
%% }
%% {CamPos M vecteur3d dupp3d
%% ZVec scalprod3d neg ScreenDist exch div mulv3d
%% dupp3d XVec scalprod3d ZoomFactor_x mul
%% 4 1 roll YVec scalprod3d ZoomFactor_y mul
%% } ifelse
%% end
%% } def
%%%%%%%%%%%%% complements, jpv, 09/08/2006 %%%%%%%%%%%%%%%%%%%%%%%%%%
%% syntaxe : M SetCamView --> oriente la camera vers le point M, et
%% affecte les vecteurs CamVec et CamUp en consequence
/SetCamView {
GetCamPos vecteur3d
-1 mulv3d normalize3d
3 copy SetCamVec
GetCamUp
vectprod3d
GetCamVec
vectprod3d normalize3d SetCamUp
ComputeCamera
} def
/xmin3d -5 def
/xmax3d 6 def
/ymin3d -3 def
/ymax3d 5 def
/zmin3d -3 def
/zmax3d 5 def
/setxrange3d {
/xmax3d exch def
/xmin3d exch def
} def
/setyrange3d {
/ymax3d exch def
/ymin3d exch def
} def
/setzrange3d {
/zmax3d exch def
/zmin3d exch def
} def
/3dto2d {
CamView
} def
|