% \iffalse meta-comment, etc.
%%
%% Package `pst-ob3d.dtx'
%%
%% Denis Girou (CNRS/IDRIS - France) <Denis.Girou@idris.fr>
%% Herbert Voss <hvoss@tug.org>
%%
%% August 22, 2007
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%%   `pst-ob3d' is a PSTricks package to draw basic three dimensional
%%   objects with various customizations.
%%
% \fi
%
% \changes{v0.21}{2007/08/22}{Updated the style file}
% \changes{v0.20}{2006/11/25}{First CTAN release}
% \changes{v0.11 Beta}{2002/05/09}{Fourth packaged release.}
% \changes{v0.1 Beta}{1994}{First beta version in 1994 (unpublished).}
%
% \DoNotIndex{\\,\^,\@}
% \DoNotIndex{\@empty,\@ifnextchar,\@nameuse,\@ne,\@nil,\@tempa}
% \DoNotIndex{\@undefined}
% \DoNotIndex{\advance}
% \DoNotIndex{\baselineskip,\begin,\bgroup}
% \DoNotIndex{\c@CodelineNo,\catcode,\CodelineIndex,\count@,\csname}
% \DoNotIndex{\def,\define@key,\divide,\DocInput,\documentclass,\DoNotIndex}
% \DoNotIndex{\edef,\egroup,\else,\EnableCrossrefs,\end,\endcsname,\endgroup}
% \DoNotIndex{\endinput}
% \DoNotIndex{\expandafter}
% \DoNotIndex{\fi,\filedate,\fileversion}
% \DoNotIndex{\GetFileInfo,\global}
% \DoNotIndex{\hbadness,\hbox,\hfuzz,\hspace}
% \DoNotIndex{\if@inlabel,\ifcase,\ifdim,\ifnum,\ifx,\ignorespaces,\item}
% \DoNotIndex{\input}
% \DoNotIndex{\let,\llap,\long,\loop}
%
% \DoNotIndex{\m@cro@,\m@ne,\macro@cnt,\MacroTopsep,\makeatletter,\makeatother}
% \DoNotIndex{\makelabel,\message,\multiply}
% \DoNotIndex{\newif,\nobreak,\noexpand}
% \DoNotIndex{\OnlyDescription,\or}
% \DoNotIndex{\PrintMacroName,\PrintEnvName,\ProvidesPackage}
% \DoNotIndex{\pspolygon,\psdots,\psframe,\psk@viewpoint,\psset}
% \DoNotIndex{\pssetxlength,\pssetylength,\pssetzlength,\PstAtCode}
% \DoNotIndex{\pst@cnth}
% \DoNotIndex{\pst@dima,\pst@dimb,\pst@dimc,\pst@dimd,\pst@dimg,\pst@dimh}
% \DoNotIndex{\pst@dimtonum,\pst@expandafter,\pst@getint,\pst@getcolor}
% \DoNotIndex{\pst@tempa,\pst@tempb,\pst@tempc,\pst@tempd}
% \DoNotIndex{\pst@tempe,\pst@tempf,\pst@tempg,\pst@temph}
% \DoNotIndex{\PstObjectsThreeDLoaded,\PSTricksLoaded,\PSTthreeDLoaded}
% \DoNotIndex{\psxunit,\psyunit}
% \DoNotIndex{\RecordChanges,\repeat,\relax,\rput}
%
% \DoNotIndex{\saved@macroname,\setrannum,\space,\SpecialMainEnvIndex}
% \DoNotIndex{\SpecialMainIndex,\string,\strut}
% \DoNotIndex{\the,\ThreeDput,\topsep,\trivlist,\tw@}
% \DoNotIndex{\usepackage}
% \DoNotIndex{\vss,\vtop}
% \DoNotIndex{\z@}
%
% \setcounter{IndexColumns}{2}
%
% \newcommand{\PstObjectsThreeDPackage}{`\textsf{pst-ob3d}'}
% \newcommand{\PstThreeDPackage}{`\textsf{pst-3d}'}
% \newcommand{\RandomPackage}{`\textsf{random}'}
%
% ^^A From ltugboat.cls
%
% ^^A Typeset the name of an environment
% \providecommand\env[1]{\textsf{#1}}
% \providecommand\clsname[1]{\textsf{#1}}
% \providecommand\pkgname[1]{\textsf{#1}}
% \providecommand\optname[1]{\textsf{#1}}
% \providecommand\progname[1]{\textsf{#1}}
%
% ^^A A list of options for a package/class
% \newenvironment{optlist}{\begin{description}%
%   \renewcommand\makelabel[1]{%
%     \descriptionlabel{\mdseries\optname{##1}}}%
%   \itemsep0.25\itemsep}%
%  {\end{description}}
%
% ^^A Utility macros
%
%
% ^^A Example macros - adapted from the `fvrb-ex' package
% ^^A ---------------------------------------------------
%
% ^^A Take care that we use here the four /?_W characters as escape
% ^^A characters, so we can't use these characters in the examples!
%
% \makeatletter
%
% ^^A To highlight some verbatim sequences (comments, macro names, etc.)
% \def\HLEmphasize#1{\textit{#1}}
% \newcommand{\BS}{\texttt{\symbol{`\\}}}
% \def\HLMacro#1{\BS{}def\HLMacro@i#1\@nil}
% \def\HLMacro@i#1def#2\@nil{\HLReverse{#2}}
% \def\HLReverse#1{{\setlength{\fboxsep}{1pt}\HLReverse@i{#1}}}
% \def\HLReverse@i#1{\colorbox{black}{\textcolor{white}{\textbf{#1}}}}
%
% \newif\ifFVrbEx@Grid
% \def\showgrid{\FVrbEx@Gridtrue}
% \newpsobject{FVrbExGrid}{psgrid}{subgriddiv=0,griddots=10,gridlabels=7pt}
%
% \def\Example{\FV@Environment{}{Example}}
% \def\endExample{%
% \end{VerbatimOut}
% \Below@Example{\input{\jobname.tmp}}
% \endgroup}
%
% \def\CenterExample{\FV@Environment{}{Example}}
% \def\endCenterExample{%
% \end{VerbatimOut}
% \begin{center}
%   \Below@Example{\input{\jobname.tmp}}
% \end{center}
% \endgroup}
%
% \def\SideBySideExample{\FV@Environment{}{Example}}
% \def\endSideBySideExample{%
% \end{VerbatimOut}
% \SideBySide@Example{\input{\jobname.tmp}}
% \endgroup}
%
% \def\PCenterExample{\FV@Environment{}{PExample}}
%
% \def\endPCenterExample{%
%   \end{VerbatimOut}%
%   \Below@Example{%
%     \begin{center}
%       \expandafter\pspicture\PstPicture@Size
%       \ifFVrbEx@Grid\FVrbExGrid\fi\relax
%         \input{\jobname.tmp}%
%       \endpspicture
%     \end{center}}
%   \endgroup}
%
% \def\PSideBySideExample{\FV@Environment{}{PExample}}
%
% \def\endPSideBySideExample{%
%   \end{VerbatimOut}%
%   \SideBySide@Example{%
%     \expandafter\pspicture\PstPicture@Size
%       \ifFVrbEx@Grid\vskip 5pt\fi
%       \input{\jobname.tmp}%
%     \endpspicture
%     \ifFVrbEx@Grid\vskip 5pt\fi
%     \smallskip}%
%   \endgroup}
%
% \def\FVB@Example{%
% \begingroup
% \FV@UseKeyValues
% \parindent=0pt
% \multiply\topsep\tw@
% \VerbatimEnvironment
% \begin{VerbatimOut}[gobble=4,codes={\catcode`\W=12}]{\jobname.tmp}}
%
% \def\Below@Example#1{%
% \VerbatimInput[gobble=0,commentchar=W,commandchars=/?_,frame=single,
%                numbers=left,numbersep=3pt]{\jobname.tmp}
% \catcode`\%=14\relax
% \catcode`\W=9\relax
% ^^A We suppress the effect of the highlighting macros
% \catcode`/=0\relax
% \catcode`?=1\relax
% \catcode`_=2\relax
% \def\HLEmphasize##1{##1}%
% \def\HLMacro##1{##1}%
% \def\HLReverse##1{##1}%
% #1
% \par}
%
% \def\SideBySide@Example#1{%
% \vskip 1mm
% \@tempdimb=\FV@XRightMargin
% \advance\@tempdimb -5mm
% \begin{minipage}[c]{\@tempdimb}
%   \fvset{xrightmargin=0pt}
%   \catcode`\%=14\relax
%   \catcode`\W=9\relax
%   ^^A We suppress the effect of the highlighting macros
%   \catcode`/=0\relax
%   \catcode`?=1\relax
%   \catcode`_=2\relax
%   \def\HLEmphasize##1{##1}%
%   \def\HLMacro##1{##1}%
%   \def\HLReverse##1{##1}%
%   #1
% \end{minipage}%
% \@tempdimb=\textwidth
% \advance\@tempdimb -\FV@XRightMargin
% \advance\@tempdimb 5mm
% \begin{minipage}[c]{\@tempdimb}
%   \VerbatimInput[gobble=0,commentchar=W,commandchars=/?_,
%                  frame=single,numbers=left,numbersep=3pt,
%                  xleftmargin=5mm,xrightmargin=0pt]{\jobname.tmp}
% \end{minipage}
% \vskip 1mm}
%
% \def\FVB@PExample{%
% \begingroup
% \FV@UseKeyValues
% \FVB@PExample@i}
%
% \def\FVB@PExample@i(#1,#2){%
% \@ifnextchar({\FVB@PExample@ii(#1,#2)}{\FVB@PExample@ii(0,0)(#1,#2)}}
%
% \def\FVB@PExample@ii(#1,#2)(#3,#4){%
% \def\PstPicture@Size{(#1,#2)(#3,#4)}%
% \parindent=0pt
% \multiply\topsep\tw@
% \VerbatimEnvironment
% \begin{VerbatimOut}[gobble=4,codes={\catcode`\W=12}]{\jobname.tmp}}
%
% \makeatother
%
% ^^A End of example macros from `fvrb-ex'
%
% ^^A For the possible index and changes log
% \setlength{\columnseprule}{0.6pt}
%
% ^^A Beginning of the documentation itself
%
% \title{The \PstObjectsThreeDPackage{} package\\
%        A PSTricks package\\
%        for three dimensional basic objects}
% \author{Denis \textsc{Girou}\thanks{CNRS/IDRIS ---
%         Centre National de la Recherche Scientifique /
%         Institut du D\'eveloppement et des Ressources en Informatique
%         Scientifique --- Orsay --- France ---
%         \protect\url{Denis.Girou@idris.fr}.} \and 
%	Herbert Vo\ss\thanks{\protect\url{hvoss@tug.org} for the \texttt{CTAN} Version}}
% \date{Version 0.21\\August 22, 2007}
%
% \maketitle
%
% \begin{abstract}
%     This package allow to draw basic three dimensional objects. Up to now
%   only cubes (which can be deformed to rectangular parallelipiped ones) and
%   dies (which are only a special kind of cubes) are defined.
% \end{abstract}
%
% \tableofcontents
%
% \section{Introduction}
%
%   \PstObjectsThreeDPackage{} define basic three dimensional objects. Up to
% now only cubes of several kinds are defined (as this is the easiest thing to
% do!), so the interest of this package is still limited...
%
%   As usual, all the relevant PSTricks parameters can be use and few ones are
% added specially for these 3d objects.
%
%   You must take care that these objects are \emph{pure graphics} ones, that
% is to say that they have no dimension (in any case, it would be very
% difficult to compute their bounding boxes accurately, according to the user
% point of vue chosen --- the \emph{viewpoint}). So, we have to compute their
% sizes and to put these objects in a \texttt{pspicture} environment by
% ourselves.
%
% \section{Usage}
%
% \subsection{Macros}
%
%   Two macros are currently defined: \cs{PstCube} to draw a cube and
% \cs{PstDie} to draw a die (which is only a cube with dots on it faces).
%
% \subsubsection{Cubes}
%
%   \cs{PstCube} has three required parameters, respectively for the X, Y and
% Z lengths, as we can distord the cubes to parallelipiped ones.
%
% \vspace{1mm}
% \noindent%
% \fbox{\cs{PstCube}\texttt{[optional\_parameters]\{X\_length\}\{Y\_length\}\{Z\_length\}}}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(0.75,1.7)
%   \PstCube{1}{1}{1}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(1.4,2.5)
%   \PstCube{1}{2}{1.5}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(1.4,2.5)
%   \PstCube[linestyle=dashed]{1}{2}{1.5}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(0.75,1.7)
%   \PstCube[fillstyle=hlines]{1}{1}{1}
% \end{PSideBySideExample}
%
%   As special care is made to draw the faces in the right order, according to
% the user point of view, to draw last the visible faces, we can use a solid
% color for the faces and still got a correct drawing of the borders.
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(2,3.3)
%   \PstCube[fillstyle=solid,fillcolor=red]{1}{3}{2}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(2,3.3)
%   \PstCube[linestyle=dotted,fillstyle=solid,fillcolor=white]
%           {1}{3}{2}
% \end{PSideBySideExample}
%
%   The \texttt{unit} parameter can still be used and has for effect to
% multiply each of the three dimensions by it. In fact the value for
% \texttt{xunit} is used both for the X and Y directions, and the
% \texttt{yunit} one for the Z direction.
%
% \begin{PCenterExample}(-1.5,0)(5.4,3.3)
%   \rput(0,0){\PstCube[fillstyle=solid,fillcolor=white]{2}{2}{2}}
%   \rput(4,0){\PstCube[unit=2,fillstyle=solid,fillcolor=white]{1}{1}{1}}
% \end{PCenterExample}
%
% \begin{PCenterExample}(-1.5,0)(5.4,2.5)
%   \rput(0,0){\PstCube[fillstyle=solid,fillcolor=white]{2}{2}{1}}
%   \rput(4,0){\PstCube[xunit=2,fillstyle=solid,fillcolor=white]{1}{1}{1}}
% \end{PCenterExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(2.75,2.5)
%   \PstCube[fillstyle=solid,fillcolor=white]{1}{1}{2}
%   \rput(2,0){%
%     \PstCube[yunit=2,fillstyle=solid,fillcolor=white]
%             {1}{1}{1}}
% \end{PSideBySideExample}
%
%   We can of course use the \texttt{viewpoint} and \texttt{viewangle}
% parameters of the \PstThreeDPackage{} package to change the user point of
% vue.
%
% \begin{PCenterExample}(-1,-1.2)(16,3.5)
%   \rput(0,0){\PstCube{1}{3}{2}}
%   \rput(3,0){\PstCube[viewangle=20]{1}{3}{2}}
%   \rput(7.5,0){\PstCube[viewangle=-10]{1}{3}{2}}
%   \rput(10.5,0){\PstCube[viewpoint=1 -1 0.3]{1}{3}{2}}
%   \rput(13,0){\PstCube[viewpoint=1 1 1]{1}{3}{2}}
% \end{PCenterExample}
%
% \subsubsection{Dies}
%
%   \cs{PstDie} has no required parameters, as it must be a cube, so with
% the same lengths in each direction. The \texttt{unit} parameter is enough
% to change it size. Of course, only the visibles faces, according to the user
% point of vue, are shown.
%
% \vspace{1mm}
% \noindent%
% \fbox{\cs{PstDie}\texttt{[optional\_parameters]}}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(0.75,1.7)
%   \PstDie
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.4,-0.4)(2.1,2.1)
%   \PstDie[unit=1.5,dotscale=3,viewangle=45]
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](0,-0.2)(2.5,2.5)
%   \PstDie[unit=2,dotsize=0.25,linecolor=red,viewpoint=1 3 -1]
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-1,0)(0.4,1.7)
%   \PstDie[fillstyle=solid,fillcolor=yellow,
%           viewpoint=0.4 -1 1]
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-1.5,-0.5)(0,1.3)
%   \PstDie[fillstyle=solid,fillcolor=yellow,
%           viewpoint=-1 -1 -1]
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-1.5,-0.5)(0,1.3)
%   \PstDie[fillstyle=solid,fillcolor=yellow,viewpoint=-1 -1 1]
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,-0.9)(0.75,0.9)
%   \PstDie[fillstyle=solid,fillcolor=yellow,viewpoint=-1 1 1]
% \end{PSideBySideExample}
%
% \begin{PCenterExample}(-0.8,-1.3)(14.7,1.8)
%   \psset{fillstyle=solid,fillcolor=yellow}
%   \multido{\iPos=0+2,\nViewPointZ=-2.1+0.5}{8}{%
%     \rput(\iPos,0){\PstDie[viewpoint=1 -1 \nViewPointZ]}}
% \end{PCenterExample}
%
% \begin{PCenterExample}(-1.2,-0.5)(15,1.7)
%   \psset{fillstyle=solid,fillcolor=yellow}
%   \rput(0,0){\PstDie[viewpoint=-5 -1 1]}
%   \rput(2,0){\PstDie[viewpoint=-3 -1 1]}
%   \rput(4,0){\PstDie[viewpoint=-1 -1 1]}
%   \rput(6,0){\PstDie[viewpoint=-0.3 -1 1]}
%   \rput(8,0){\PstDie[viewpoint=0.3 -1 1]}
%   \rput(10,0){\PstDie[viewpoint=1 -1 1]}
%   \rput(12,0){\PstDie[viewpoint=3 -1 1]}
%   \rput(14,0){\PstDie[viewpoint=5 -1 1]}
% \end{PCenterExample}
%
% \begin{PCenterExample}(-1,-0.5)(15.2,1.7)
%   \psset{fillstyle=solid,fillcolor=yellow}
%   \rput(0,0){\PstDie[viewpoint=1 -5 1]}
%   \rput(2,0){\PstDie[viewpoint=1 -3 1]}
%   \rput(4,0){\PstDie[viewpoint=1 -1 1]}
%   \rput(6,0){\PstDie[viewpoint=1 -0.3 1]}
%   \rput(8,0){\PstDie[viewpoint=1 0.3 1]}
%   \rput(10,0){\PstDie[viewpoint=1 1 1]}
%   \rput(12,0){\PstDie[viewpoint=1 3 1]}
%   \rput(14,0){\PstDie[viewpoint=1 5 1]}
% \end{PCenterExample}
%
% \subsection{Parameters}
%
% \begin{optlist}
%   \item [PstDebug (integer)]: to obtain some internal debugging informations
%   --- here, a letter is printed at the center of each face, to help to
%   locate the various faces according to the user point of vue. It can take
%   the  values 0 (no debug) or 1.
%   (\emph{Default:~0} --- no debugging informations).
% \end{optlist}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.4,0)(2.2,2.3)
%   \PstCube[PstDebug=1]{0.5}{3}{1}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-2.3,-0.2)(0,2.3)
%   \PstCube[PstDebug=1,viewpoint=-0.8 -1 1]{0.5}{3}{1}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-1.9,0)(0.4,2.5)
%   \PstCube[PstDebug=1,viewpoint=-0.8 1 -1]{0.5}{3}{1}
% \end{PSideBySideExample}
%
% \begin{optlist}
%   \item [OnlyVisibleFaces (boolean)]: to draw only the (three) visible
%   faces, according to the user point of view
%   (\emph{Default:~false}).
% \end{optlist}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(0.75,1.7)
%   \PstCube[OnlyVisibleFaces=true]{1}{1}{1}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.8,0)(1.9,3.5)
%   \PstCube[PstDebug=1,OnlyVisibleFaces=true,
%            viewpoint=0.8 -1 1]{1}{3}{2}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-2.7,-0.4)(0,3)
%   \PstCube[PstDebug=1,OnlyVisibleFaces=true,
%            viewpoint=-0.8 -1 1]{1}{3}{2}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](0,-1.5)(2.7,2)
%   \PstCube[PstDebug=1,OnlyVisibleFaces=true,
%            viewpoint=0.8 1 1]{1}{3}{2}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-2.7,-0.4)(0,3.1)
%   \PstCube[PstDebug=1,OnlyVisibleFaces=true,
%            viewpoint=-0.8 -1 1]{1}{3}{2}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](0,-0.4)(2.7,3)
%   \PstCube[PstDebug=1,OnlyVisibleFaces=true,
%            viewpoint=0.8 1 -1]{1}{3}{2}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-1.9,0)(0.8,3.5)
%   \PstCube[PstDebug=1,OnlyVisibleFaces=true,
%            viewpoint=-0.8 1 -1]{1}{3}{2}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.8,-1.8)(1.9,1.7)
%   \PstCube[PstDebug=1,OnlyVisibleFaces=true,
%            viewpoint=0.8 -1 -1]{1}{3}{2}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-2.7,-1.5)(0,2)
%   \PstCube[PstDebug=1,OnlyVisibleFaces=true,
%            viewpoint=-0.8 -1 -1]{1}{3}{2}
% \end{PSideBySideExample}
%
% \begin{optlist}
%   \item [Corners (boolean)]: to mark corners. This is mostly an aesthetics
%   effect, in fact mainly pleasant for dies\footnote{I only follow here an
%   idea first implemented by Manuel \textsc{Luque} in his own PSTricks macro
%   for dies.}.
%   (\emph{Default:~false}).
% \end{optlist}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(2.75,1.7)
%   \PstCube[Corners=true]{1}{1}{1}
%   \rput(2,0){%
%     \PstCube[OnlyVisibleFaces=true,Corners=true]{1}{1}{1}}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(0.75,1.7)
%   \PstCube[fillstyle=solid,fillcolor=green,Corners=true]
%           {1}{1}{1}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(0.75,1.7)
%   \PstDie[dotscale=1.5,fillstyle=solid,fillcolor=yellow,
%           Corners=true]
% \end{PSideBySideExample}
%
% \begin{optlist}
%   \item [CornersLength (real)]: the length of the corners, when they are
%   shown. This value is multiplied by the unit values in each direction.
%   (\emph{Default:~0.15} --- it must rather be a number between 0~and~0.5,
%   otherwise there will not be any error but the results will look
%   strange...).
% \end{optlist}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(0.75,1.7)
%   \PstCube[fillstyle=solid,fillcolor=green,
%            Corners=true,CornersLength=0.25]{1}{1}{1}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(0.75,1.7)
%   \PstCube[OnlyVisibleFaces=true,Corners=true,
%            CornersLength=0.3]{1}{1}{1}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(0.75,1.7)
%   \PstCube[OnlyVisibleFaces=true,Corners=true,
%            CornersLength=0.5]{1}{1}{1}
% \end{PSideBySideExample}
%
% \begin{optlist}
%   \item [CornersColor (color)]: the color of the corners
%   (\emph{Default:~black}).
% \end{optlist}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-1.5,0)(2.2,2.8)
%   \PstCube[fillstyle=solid,fillcolor=cyan,Corners=true,
%            CornersColor=blue]{2}{3}{1}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-2.6,-1.5)(0,1.9)
%   \PstCube[viewpoint=-0.8 -1 -1,
%            Corners=true,CornersColor=red,CornersLength=0.2,
%            fillstyle=solid,fillcolor=green]{1}{3}{2}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-1.5,0.2)(2.2,2.6)
%   \PstCube[fillstyle=solid,fillcolor=yellow,
%            Corners=true,CornersColor=magenta,
%            CornersLength=0.4]{2}{3}{1}
% \end{PSideBySideExample}
%
% \begin{PCenterExample}(-1,0)(11,1.7)
%   \psset{fillstyle=solid,fillcolor=yellow,Corners=true,CornersColor=red}
%   \multido{\iPos=0+2,\nCornersLength=0+0.1}{6}{%
%     \rput(\iPos,0){\PstCube[CornersLength=\nCornersLength]{1}{1}{1}}}
% \end{PCenterExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(0.75,1.7)
%   \PstDie[dotscale=1.5,fillstyle=solid,fillcolor=yellow,
%           Corners=true]
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.3,0)(1.2,1.7)
%   \PstDie[dotscale=1.5,fillstyle=solid,fillcolor=yellow,
%           viewangle=30,Corners=true,CornersColor=red]
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(0.75,1.7)
%   \PstDie[dotscale=1.5,fillstyle=solid,fillcolor=yellow,
%           Corners=true,CornersColor=red,CornersLength=0.2]
% \end{PSideBySideExample}
%
% \begin{optlist}
%   \item [RandomFaces (boolean)]: to generate random faces. This has only a
%   meaning for dies, to simulate a throw of them. The hazard is managed by
%   the \RandomPackage{} package from Donald \textsc{Arseneau}. The random
%   seed is set by using the time when the compilation occur. But take care
%   that \TeX{} allow to access only to minutes and not to microseconds, so
%   several consecutive usages of this parameter will give the same behavior,
%   and no hazard at all... To force it, we must use the \cs{randomi} macro,
%   to initialize the random seed to an arbitrary integer value (see the
%   documentation of the \RandomPackage{} package).
%   (\emph{Default:~false}).
% \end{optlist}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(0.75,1.7)
%   \PstDie[dotscale=2,fillstyle=solid,fillcolor=cyan,
%           RandomFaces=true]
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.75,0)(0.75,2)
%   \randomi=12345
%   \PstDie[dotscale=1.5,fillstyle=solid,fillcolor=magenta,
%           Corners=true,CornersColor=yellow,RandomFaces=true]
% \end{PSideBySideExample}
%
% \subsection{Hooks}
%
%   Twelve hooks can be used, to put arbitrary stuff on the faces. Six hooks
% allow to put some material on a specified position (by default in the point
% \texttt{(0,0)} of the face) and six other put it on the center of the faces,
% according of the lengths in each direction.
%
%   The name of these hooks are \cs{PstObjectsThreeDFace}\emph{Letter} and
% \cs{PstObjectsThreeDFaceCenter}\emph{Letter} (with \emph{Letter} being a
% letter between \textbf{A} and \textbf{F}).
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.6,-0.1)(0.9,1.8)
%   \def\PstObjectsThreeDFaceC{%
%     \psframe[fillstyle=solid,fillcolor=blue](1,1)}
%   \PstCube[viewpoint=0.6 -0.4 1]{1}{1}{1}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-0.6,-0.3)(0.9,1.8)
%   \def\PstObjectsThreeDFaceA{\rput(0.5,-0.5){\LARGE X}}
%   \def\PstObjectsThreeDFaceB{\rput(0.5,-0.5){\LARGE Y}}
%   \PstCube[viewpoint=0.6 -0.4 1]{1}{1}{1}
% \end{PSideBySideExample}
%
% \begin{PCenterExample}(-0.6,-0.5)(9,3.1)
%   \psset{viewpoint=0.6 -0.4 1}
%   \def\PstObjectsThreeDFaceA{\LARGE X}
%   \def\PstObjectsThreeDFaceB{\rput(0.5,0.5){\LARGE Y}}
%   \rput(0,0){\PstCube{1}{1}{1}}
%   \def\PstObjectsThreeDFaceCenterC{\LARGE\textcolor{red}{\textbf{1}}}
%   \rput(3,0){\PstCube{3}{1}{1}}
%   \rput(6,0){\PstCube[viewpoint=0.8 1 1]{3}{1}{1}}
% \end{PCenterExample}
%
% \section{Examples}
%
%   We give here some more advanced examples.
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-1.5,0)(1.5,6)
%   \psset{fillstyle=solid}
%   \PstCube[fillcolor=green]{2}{2}{2}
%   \PstCube[fillcolor=red](-0.2,0.2,2){1.6}{1.6}{1.6}
%   \PstCube[fillcolor=yellow](-0.4,0.4,3.6){1.2}{1.2}{1.2}
%   \PstCube[fillcolor=cyan](-0.6,0.6,4.8){0.8}{0.8}{0.8}
%   \PstCube[fillcolor=magenta](-0.8,0.8,5.6){0.4}{0.4}{0.4}
% \end{PSideBySideExample}
%
% \begin{PSideBySideExample}[xrightmargin=4cm](-1.5,0)(1.5,8.5)
%   \psset{unit=2,fillstyle=solid}
%   \def\PstObjectsThreeDFaceCenterA{\Huge\textbf{D}}%
%   \def\PstObjectsThreeDFaceCenterB{\Huge\textbf{L}}%
%   \PstCube[fillcolor=magenta]{1}{1}{1}
%   \def\PstObjectsThreeDFaceCenterA{\Huge\textbf{O}}%
%   \def\PstObjectsThreeDFaceCenterB{\Huge\textbf{R}}%
%   \PstCube[fillcolor=yellow](0,0,1){1}{1}{1}
%   \def\PstObjectsThreeDFaceCenterA{\Huge\textbf{O}}%
%   \def\PstObjectsThreeDFaceCenterB{\Huge\textbf{I}}%
%   \PstCube[fillcolor=cyan](0,0,2){1}{1}{1}
%   \def\PstObjectsThreeDFaceCenterA{%
%     \Huge\textcolor{white}{\textbf{G}}}%
%   \let\PstObjectsThreeDFaceCenterB
%         \PstObjectsThreeDFaceCenterA
%   \PstCube[fillcolor=blue](0,0,3){1}{1}{1}
% \end{PSideBySideExample}
%
% \begin{PCenterExample}(0,-5)(17,5)
%   \definecolor{PaleGreen}{rgb}{0.6,0.98,0.6}
%   \psset{unit=2}
%   \ThreeDput{%
%     \psframe[fillstyle=solid,fillcolor=PaleGreen](6,6)
%     \psgrid[subgriddiv=0,gridlabels=0,griddots=5](6,6)}
%   \psset{fillstyle=solid,dotscale=3.5,RandomFaces=true,Corners=true}
%   \randomi=123817
%   \PstDie[fillcolor=yellow](1,3,0)
%   \randomi=271354
%   \PstDie[fillcolor=cyan,viewpoint=1 0.3 1,CornersColor=blue](0.3,1.5,0)
%   \randomi=93850516
%   \PstDie[fillcolor=blue,linecolor=white,viewpoint=1 -0.5 1,CornersColor=cyan]
%          (3,3,0)
%   \randomi=8873165
%   \PstDie[fillcolor=red,linecolor=white,viewpoint=1 -0.2 1,CornersColor=yellow]
%          (2,5,0)
% \end{PCenterExample}
%
%
% \StopEventually{}
%
% ^^A .................... End of the documentation part ....................
%
% \section{Driver file}
%
%   The next bit of code contains the documentation driver file for \TeX{},
% i.e., the file that will produce the documentation you are currently
% reading. It will be extracted from this file by the \texttt{docstrip}
% program.
%
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\GetFileInfo{pst-ob3d.dtx}
\usepackage{fancyvrb,url}
\usepackage[dvips]{geometry}
\usepackage{pstricks}
\usepackage{pst-ob3d}
\usepackage{multido}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
%\OnlyDescription                % Comment it for implementation details
\hbadness=7000                  % Over and under full box warnings
\hfuzz=3pt
%
% To redefine the format used to print the macro names,
% which was not well adapted to very long names like the ones we used
\makeatletter
\long\def\m@cro@#1#2{\endgroup \topsep\MacroTopsep \trivlist
   \edef\saved@macroname{\string#2}%
% D.G. modification begin - Dec. 15, 2000
%  \def\makelabel##1{\llap{##1}}%
  \def\makelabel##1{\hspace{-2cm}##1}%
% D.G. modification end
  \if@inlabel
    \let\@tempa\@empty \count@\macro@cnt
    \loop \ifnum\count@>\z@
      \edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne \repeat
    \edef\makelabel##1{\llap{\vtop to\baselineskip
                               {\@tempa\hbox{##1}\vss}}}%
    \advance \macro@cnt \@ne
  \else  \macro@cnt\@ne  \fi
  \edef\@tempa{\noexpand\item[%
     #1%
       \noexpand\PrintMacroName
     \else
       \noexpand\PrintEnvName
     \fi
     {\string#2}]}%
  \@tempa
  \global\advance\c@CodelineNo\@ne
   #1%
      \SpecialMainIndex{#2}\nobreak
      \DoNotIndex{#2}%
   \else
      \SpecialMainEnvIndex{#2}\nobreak
   \fi
  \global\advance\c@CodelineNo\m@ne
  \ignorespaces}
\makeatother
%
\begin{document}
  \DocInput{pst-ob3d.dtx}
\end{document}
%</driver>
%    \end{macrocode}
%
% \section{\PstObjectsThreeDPackage{} \LaTeX{} wrapper}
%
%    \begin{macrocode}
%<*latex-wrapper>
\RequirePackage{pstricks}
\ProvidesPackage{pst-ob3d}[2006/11/25 package wrapper for 
  pst-ob3d.tex (hv)]
\input{pst-ob3d.tex}
\ProvidesFile{pst-ob3d.tex}
  [\filedate\space v\fileversion\space `PST-ob3d' (dg,hv)]
%</latex-wrapper>
%    \end{macrocode}
%
% \section{\PstObjectsThreeDPackage{} code}
%
%    \begin{macrocode}
%<*pst-ob3d>
%    \end{macrocode}
%
% \subsection{Preambule}
%
%   Who we are.
%
%    \begin{macrocode}
\def\fileversion{0.21}
\def\filedate{2007/08/22}
\message{`Pst-Objects3d' v\fileversion, \filedate\space (DG,hv)}
\csname PstObjectsThreeDLoaded\endcsname
\let\PstObjectsThreeDLoaded\endinput
%    \end{macrocode}
%
%   Require the PSTricks, `\textsf{pst-3d}', and `\textsf{pst-xkey}' packages.
%
%    \begin{macrocode}
\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi
\ifx\PSTthreeDLoaded\endinput\else\input pst-3d.tex\fi
\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey \fi 
%    \end{macrocode}
%
%   Donald \textsc{Arseneau} package for random number generation.
%
%    \begin{macrocode}
\input random.tex
%    \end{macrocode}
%
%   Catcodes changes.
%
%    \begin{macrocode}
\edef\PstAtCode{\the\catcode`\@}
\catcode`\@=11\relax
%    \end{macrocode}
%
% \subsection{Definition of the parameters}
%
% Add the family name to the key list.
%    \begin{macrocode}
\pst@addfams{pst-ob3d}
%    \end{macrocode}
%   \texttt{PstDebug} is for internal debugging purposes (here letters will be
% printed on the faces). This option is alread defined in the basic PSTricks
% package
%
%   \texttt{OnlyVisibleFaces} to show only the visible faces.
%
%    \begin{macrocode}
\define@boolkey[psset]{pst-ob3d}[PstObjectsThreeD@]{OnlyVisibleFaces}[true]{}
%    \end{macrocode}
%
%   \texttt{RandomFaces} to define randomly the faces of a die, using the
% \RandomPackage{} package.
%
%    \begin{macrocode}
\define@boolkey[psset]{pst-ob3d}[PstObjectsThreeD@]{RandomFaces}[true]{}
%    \end{macrocode}
%
%   \texttt{Corners} to draw corners.
%
%    \begin{macrocode}
\define@boolkey[psset]{pst-ob3d}[PstObjectsThreeD@]{Corners}[true]{}
%    \end{macrocode}
%
%   \texttt{CornersColor} to choose the color of the corners.
%
%    \begin{macrocode}
\define@key[psset]{pst-ob3d}{CornersColor}{\def\PstObjectsThreeD@CornersColor{#1}}
%    \end{macrocode}
%
%   \texttt{CornersLength} to choose the length of the corners.
%
%    \begin{macrocode}
\define@key[psset]{pst-ob3d}{CornersLength}{%
  \def\PstObjectsThreeD@CornersLength{#1}%
  \def\PstObjectsThreeD@CornersLengthTmpA{#1}%
  \def\PstObjectsThreeD@CornersLengthTmpB{#1}}
%    \end{macrocode}
%
%   Next, we set the default values for all these new parameters.
%
%    \begin{macrocode}
\psset[pst-ob3d]{OnlyVisibleFaces=false,RandomFaces=false,
                Corners=false,CornersColor=black,CornersLength=0.15}
%    \end{macrocode}
%
% \subsection{Cube definition}
%
% \begin{macro}{\PstCube}
%    \begin{macrocode}
\def\PstCube{\@ifnextchar[{\PstCube@i}{\PstCube@i[]}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\PstCube@i}
%    \begin{macrocode}
\def\PstCube@i[#1]{\@ifnextchar({\PstCube@ii[#1]}{\PstCube@ii[#1](0,0,0)}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\PstCube@ii}
%    \begin{macrocode}
\def\PstCube@ii[#1](#2,#3,#4)#5#6#7{{%
%    \end{macrocode}
%
%   We force ``\texttt{dimen=middle}''.
%
%    \begin{macrocode}
\psset{dimen=middle}%
%    \end{macrocode}
%
%   Then we set the local changes of parameters.
%
%    \begin{macrocode}
\psset{#1}%
%    \end{macrocode}
%
%   For debugging purposes, we can require to print letters centered on the
% faces.
%
%    \begin{macrocode}
\ifnum\Pst@Debug=\@ne
  \def\PstObjectsThreeDFaceCenterA{A}%
  \def\PstObjectsThreeDFaceCenterB{B}%
  \def\PstObjectsThreeDFaceCenterC{C}%
  \def\PstObjectsThreeDFaceCenterD{D}%
  \def\PstObjectsThreeDFaceCenterE{E}%
  \def\PstObjectsThreeDFaceCenterF{F}%
\fi
%    \end{macrocode}
%
%   We get the signs of the viewpoint coordinates (which are wrong by
% themselves). This is necessary because the order of the drawing of the faces
% must change according to the viewpoint, to hidden the non visible faces.
%
%    \begin{macrocode}
\pst@expandafter\psget@@viewpoint\psk@viewpoint {} {} {} \@nil
%    \end{macrocode}
%
%   If corners must be shown, we will draw octogons, otherwise frames.
%
%    \begin{macrocode}
\ifPstObjectsThreeD@Corners
  \let\PstObjectsThreeD@Shape\PstObjectsThreeD@Octogon
\else
  \let\PstObjectsThreeD@Shape\psframe
\fi
%    \end{macrocode}
%
%   According to the viewpoint, we draw in the right order the faces (three
% ones when we must show only the visible ones, six otherwise).
%
%    \begin{macrocode}
\ifdim\pst@dimc>\z@
  \ifdim\pst@dima>\z@
    \ifdim\pst@dimb>\z@
%    \end{macrocode}
%
%   Case where $x > 0$ ; $y > 0$ ; $z > 0$
%
%    \begin{macrocode}
      \PstCube@DrawFaces{A}{E}{C}{B}{D}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
%    \end{macrocode}
%
%    \begin{macrocode}
    \else
%    \end{macrocode}
%
%   Case where $x > 0$ ; $y < 0$ ; $z > 0$
%
%    \begin{macrocode}
      \PstCube@DrawFaces{E}{D}{C}{A}{B}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
%    \end{macrocode}
%
%    \begin{macrocode}
    \fi
  \else
    \ifdim\pst@dimb>\z@
%    \end{macrocode}
%
%   Case where $x < 0$ ; $y > 0$ ; $z > 0$
%
%    \begin{macrocode}
      \PstCube@DrawFaces{A}{B}{C}{E}{D}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
%    \end{macrocode}
%
%    \begin{macrocode}
    \else
%    \end{macrocode}
%
%   Case where $x < 0$ ; $y < 0$ ; $z > 0$
%
%    \begin{macrocode}
      \PstCube@DrawFaces{D}{B}{C}{E}{A}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
%    \end{macrocode}
%
%    \begin{macrocode}
    \fi
  \fi
\else
  \ifdim\pst@dima>\z@
    \ifdim\pst@dimb>\z@
%    \end{macrocode}
%
%   Case where $x > 0$ ; $y > 0$ ; $z < 0$
%
%    \begin{macrocode}
      \PstCube@DrawFaces{B}{D}{C}{A}{E}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
%    \end{macrocode}
%
%    \begin{macrocode}
    \else
%    \end{macrocode}
%
%   Case where $x > 0$ ; $y < 0$ ; $z < 0$
%
%    \begin{macrocode}
      \PstCube@DrawFaces{A}{B}{C}{E}{D}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
%    \end{macrocode}
%
%    \begin{macrocode}
    \fi
  \else
    \ifdim\pst@dimb>\z@
%    \end{macrocode}
%
%   Case where $x < 0$ ; $y > 0$ ; $z < 0$
%
%    \begin{macrocode}
      \PstCube@DrawFaces{D}{E}{C}{A}{B}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
%    \end{macrocode}
%
%    \begin{macrocode}
    \else
%    \end{macrocode}
%
%   Case where $x < 0$ ; $y > 0$ ; $z < 0$
%
%    \begin{macrocode}
      \PstCube@DrawFaces{E}{A}{C}{D}{B}{F}{(#2,#3,#4)}{(#5,#6,#7)}%
%    \end{macrocode}
%
%    \begin{macrocode}
    \fi
  \fi
\fi}}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Die definition}
%
% \begin{macro}{\PstDie}
%    \begin{macrocode}
\def\PstDie{\@ifnextchar[{\PstDie@i}{\PstDie@i[]}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\PstDie@i}
%    \begin{macrocode}
\def\PstDie@i[#1]{\@ifnextchar({\PstDie@ii[#1]}{\PstDie@ii[#1](0,0,0)}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\PstDie@ii}
%    \begin{macrocode}
\def\PstDie@ii[#1](#2,#3,#4){{%
%    \end{macrocode}
%
%   We force ``\texttt{dimen=middle}''.
%
%    \begin{macrocode}
\psset{dimen=middle}%
%    \end{macrocode}
%
%   We set the local changes of parameters.
%
%    \begin{macrocode}
\psset{#1}%
%    \end{macrocode}
%
%   A die is only a cube where the six faces have dots between 1 and 6.
%
%    \begin{macrocode}
\ifPstObjectsThreeD@RandomFaces
%    \end{macrocode}
%
%   First the case where the faces are defined randomly.
%
%    \begin{macrocode}
  \setrannum{\pst@cnth}{1}{6}%
  \PstDie@Letter{\pst@cnth}{\@tempa}%
  \expandafter\def\csname PstObjectsThreeDFace\@tempa\endcsname{%
    \psdots(.5,.5)}%
  \PstDie@Letter{\pst@cnth}{\@tempa}%
  \expandafter\def\csname PstObjectsThreeDFace\@tempa\endcsname{%
    \psdots(.2,.2)(.8,.8)}%
  \PstDie@Letter{\pst@cnth}{\@tempa}%
  \expandafter\def\csname PstObjectsThreeDFace\@tempa\endcsname{%
    \psdots(.2,.2)(.5,.5)(.8,.8)}%
  \PstDie@Letter{\pst@cnth}{\@tempa}%
  \expandafter\def\csname PstObjectsThreeDFace\@tempa\endcsname{%
    \psdots(.2,.2)(.2,.5)(.2,.8)(.8,.2)(.8,.5)(.8,.8)}%
  \PstDie@Letter{\pst@cnth}{\@tempa}%
  \expandafter\def\csname PstObjectsThreeDFace\@tempa\endcsname{%
    \psdots(.2,.2)(.2,.8)(.5,.5)(.8,.2)(.8,.8)}%
  \PstDie@Letter{\pst@cnth}{\@tempa}%
  \expandafter\def\csname PstObjectsThreeDFace\@tempa\endcsname{%
    \psdots(.2,.2)(.2,.8)(.8,.2)(.8,.8)}%
%    \end{macrocode}
%
%    \begin{macrocode}
\else
%    \end{macrocode}
%
%   Then the case where the faces are defined fixedly (the face ``4'' will be
% above).
%
%    \begin{macrocode}
  \def\PstObjectsThreeDFaceA{\psdots(.5,.5)}%
  \def\PstObjectsThreeDFaceB{\psdots(.2,.2)(.8,.8)}%
  \def\PstObjectsThreeDFaceC{\psdots(.2,.2)(.5,.5)(.8,.8)}%
  \def\PstObjectsThreeDFaceD{%
    \psdots(.2,.2)(.2,.5)(.2,.8)(.8,.2)(.8,.5)(.8,.8)}%
  \def\PstObjectsThreeDFaceE{\psdots(.2,.2)(.2,.8)(.5,.5)(.8,.2)(.8,.8)}%
  \def\PstObjectsThreeDFaceF{\psdots(.2,.2)(.2,.8)(.8,.2)(.8,.8)}%
%    \end{macrocode}
%
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
%   Now that the faces are defined, we can draw the cube, with only the
% visible faces if corners are not to be drawn.
%
%    \begin{macrocode}
\ifPstObjectsThreeD@Corners
\else
  \PstObjectsThreeD@OnlyVisibleFacestrue
\fi
\PstCube(#2,#3,#4){1}{1}{1}}}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Internal functions to draw the faces}
%
%   To draw successively the six faces in the right order.
%
% \begin{macro}{\PstCube@DrawFaces}
%    \begin{macrocode}
\def\PstCube@DrawFaces#1#2#3#4#5#6#7#8{%
\ifPstObjectsThreeD@OnlyVisibleFaces
\else
  \bgroup
    \ifPstObjectsThreeD@Corners
      \psset{linecolor=\PstObjectsThreeD@CornersColor,
             fillcolor=\PstObjectsThreeD@CornersColor}%
    \fi
    \bgroup
      \ifPstObjectsThreeD@Corners
        \def\PstObjectsThreeD@CornersLengthTmpA{0}%
      \fi
      \expandafter\csname PstCube@DrawFace#1\endcsname#7#8
      \expandafter\csname PstCube@DrawFace#2\endcsname#7#8
    \egroup
    \bgroup
      \ifPstObjectsThreeD@Corners
        \def\PstObjectsThreeD@CornersLengthTmpB{0}%
      \fi
      \expandafter\csname PstCube@DrawFace#3\endcsname#7#8
    \egroup
  \egroup
\fi
\expandafter\csname PstCube@DrawFace#4\endcsname#7#8
\expandafter\csname PstCube@DrawFace#5\endcsname#7#8
\expandafter\csname PstCube@DrawFace#6\endcsname#7#8}
%    \end{macrocode}
% \end{macro}
%
%   To draw the face A.
%
% \begin{macro}{\PstCube@DrawFaceA}
%    \begin{macrocode}
\def\PstCube@DrawFaceA(#1,#2,#3)(#4,#5,#6){%
\pst@dima=-#4\psxunit
\divide\pst@dima\tw@
\pst@dimc=#6\psyunit
\divide\pst@dimc\tw@
\ThreeDput[normal=0 -1 0](#1,#2,#3){%
  \PstObjectsThreeD@Shape(-#4,#6)
  \ifx\PstObjectsThreeDFaceA\@undefined
  \else
    \rput[bl](-#4,0){\PstObjectsThreeDFaceA}
  \fi
  \ifx\PstObjectsThreeDFaceCenterA\@undefined
  \else
    \rput[c](\pst@dima,\pst@dimc){\PstObjectsThreeDFaceCenterA}
  \fi}}
%    \end{macrocode}
% \end{macro}
%
%   To draw the face B.
%
% \begin{macro}{\PstCube@DrawFaceB}
%    \begin{macrocode}
\def\PstCube@DrawFaceB(#1,#2,#3)(#4,#5,#6){%
\pst@dimb=#5\psxunit
\divide\pst@dimb\tw@
\pst@dimc=#6\psyunit
\divide\pst@dimc\tw@
\ThreeDput[normal=1 0 0](#1,#2,#3){%
  \PstObjectsThreeD@Shape(#5,#6)
  \ifx\PstObjectsThreeDFaceB\@undefined
  \else
    \rput[bl](0,0){\PstObjectsThreeDFaceB}
  \fi
  \ifx\PstObjectsThreeDFaceCenterB\@undefined
  \else
    \rput[c](\pst@dimb,\pst@dimc){\PstObjectsThreeDFaceCenterB}
  \fi}}
%    \end{macrocode}
% \end{macro}
%
%   To draw the face C.
%
% \begin{macro}{\PstCube@DrawFaceC}
%    \begin{macrocode}
\def\PstCube@DrawFaceC(#1,#2,#3)(#4,#5,#6){%
\pst@dimg=-#4\psxunit
\advance \pst@dimg by #1\psxunit
\pst@dima=#4\psxunit
\divide\pst@dima\tw@
\pst@dimb=#5\psxunit
\divide\pst@dimb\tw@
\ThreeDput[normal=0 0 1](\pst@dimg,#2,#3){{%
  \psyunit=\psxunit
  \PstObjectsThreeD@Shape(#4,#5)
  \ifx\PstObjectsThreeDFaceC\@undefined
  \else
    \rput[bl](0,0){\PstObjectsThreeDFaceC}
  \fi
  \ifx\PstObjectsThreeDFaceCenterC\@undefined
  \else
    \rput[c](\pst@dima,\pst@dimb){\PstObjectsThreeDFaceCenterC}
  \fi}}}
%    \end{macrocode}
% \end{macro}
%
%   To draw the face D.
%
% \begin{macro}{\PstCube@DrawFaceD}
%    \begin{macrocode}
\def\PstCube@DrawFaceD(#1,#2,#3)(#4,#5,#6){%
\pst@dimg=#5\psxunit
\advance \pst@dimg by #2\psyunit
\pst@dima=-#4\psxunit
\divide\pst@dima\tw@
\pst@dimc=#6\psyunit
\divide\pst@dimc\tw@
\ThreeDput[normal=0 -1 0](#1,\pst@dimg,#3){%
  \PstObjectsThreeD@Shape(-#4,#6)
  \ifx\PstObjectsThreeDFaceD\@undefined
  \else
    \rput[bl](-#4,0){\PstObjectsThreeDFaceD}
  \fi
  \ifx\PstObjectsThreeDFaceCenterD\@undefined
  \else
    \rput[c](\pst@dima,\pst@dimc){\PstObjectsThreeDFaceCenterD}
  \fi}}
%    \end{macrocode}
% \end{macro}
%
%   To draw the face E.
%
% \begin{macro}{\PstCube@DrawFaceE}
%    \begin{macrocode}
\def\PstCube@DrawFaceE(#1,#2,#3)(#4,#5,#6){%
\pst@dimg=-#4\psxunit
\advance \pst@dimg by #1\psxunit
\pst@dimb=#5\psxunit
\divide\pst@dimb\tw@
\pst@dimc=#6\psyunit
\divide\pst@dimc\tw@
\ThreeDput[normal=1 0 0](\pst@dimg,#2,#3){%
  \PstObjectsThreeD@Shape(#5,#6)
  \ifx\PstObjectsThreeDFaceE\@undefined
  \else
    \rput[bl](0,0){\PstObjectsThreeDFaceE}
  \fi
  \ifx\PstObjectsThreeDFaceCenterE\@undefined
  \else
    \rput[c](\pst@dimb,\pst@dimc){\PstObjectsThreeDFaceCenterE}
  \fi}}
%    \end{macrocode}
% \end{macro}
%
%   To draw the face F.
%
% \begin{macro}{\PstCube@DrawFaceF}
%    \begin{macrocode}
\def\PstCube@DrawFaceF(#1,#2,#3)(#4,#5,#6){%
\pst@dimg=-#4\psxunit
\advance \pst@dimg by #1\psxunit
\pst@dimh=#6\psyunit
\advance \pst@dimh by #3\psyunit
\pst@dima=#4\psxunit
\divide\pst@dima\tw@
\pst@dimb=#5\psxunit
\divide\pst@dimb\tw@
\ThreeDput[normal=0 0 1](\pst@dimg,#2,\pst@dimh){{%
  \psyunit=\psxunit
  \PstObjectsThreeD@Shape(#4,#5)
  \ifx\PstObjectsThreeDFaceF\@undefined
  \else
    \rput[bl](0,0){\PstObjectsThreeDFaceF}
  \fi
  \ifx\PstObjectsThreeDFaceCenterF\@undefined
  \else
    \rput[c](\pst@dima,\pst@dimb){\PstObjectsThreeDFaceCenterF}
  \fi}}}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Internal functions}
%
%   The \cs{psget@@viewpoint} macro is derived from the \cs{psset@@viewpoint}
% one (the values will not be the good ones, but in fact we are only
% interested by the signs of them...)
%
% \begin{macro}{\psget@@viewpoint}
%    \begin{macrocode}
\def\psget@@viewpoint#1 #2 #3 #4\@nil{%
\pssetxlength{\pst@dima}{#1}%
\pssetylength{\pst@dimb}{#2}%
\pssetzlength{\pst@dimc}{#3}}
%    \end{macrocode}
% \end{macro}
%
%   Macro to draw an octogon. This is useful to put it on each face, to let
% corners appear on a cube in another color. This is specially suited for dies.
%
% \begin{macro}{\PstObjectsThreeD@Octogon}
%    \begin{macrocode}
\def\PstObjectsThreeD@Octogon(#1,#2){%
\pst@dimh=\PstObjectsThreeD@CornersLength pt
\multiply\pst@dimh#1
\pst@dimtonum{\pst@dimh}{\pst@tempa}%
\pst@dimh=\PstObjectsThreeD@CornersLengthTmpB pt
\multiply\pst@dimh#1
\pst@dimtonum{\pst@dimh}{\pst@tempg}%
\pst@dimh=\@ne pt
\advance\pst@dimh-\PstObjectsThreeD@CornersLength pt
\multiply\pst@dimh#1
\pst@dimtonum{\pst@dimh}{\pst@tempb}%
\pst@dimh=\@ne pt
\advance\pst@dimh-\PstObjectsThreeD@CornersLengthTmpA pt
\multiply\pst@dimh#1
\pst@dimtonum{\pst@dimh}{\pst@tempe}%
\pst@dimh=\PstObjectsThreeD@CornersLength pt
\multiply\pst@dimh#2
\pst@dimtonum{\pst@dimh}{\pst@tempc}%
\pst@dimh=\PstObjectsThreeD@CornersLengthTmpA pt
\multiply\pst@dimh#2
\pst@dimtonum{\pst@dimh}{\pst@tempf}%
\pst@dimh=\@ne pt
\advance\pst@dimh-\PstObjectsThreeD@CornersLength pt
\multiply\pst@dimh#2
\pst@dimtonum{\pst@dimh}{\pst@tempd}%
\pst@dimh=\@ne pt
\advance\pst@dimh-\PstObjectsThreeD@CornersLengthTmpB pt
\multiply\pst@dimh#2
\pst@dimtonum{\pst@dimh}{\pst@temph}%
\pspolygon(\pst@tempa,0)(\pst@tempe,0)(#1,\pst@tempf)(#1,\pst@tempd)
          (\pst@tempb,#2)(\pst@tempg,#2)(0,\pst@temph)(0,\pst@tempc)}
%    \end{macrocode}
% \end{macro}
%
%   Macro to increment the counter (\texttt{\#1}) and define (\texttt{\#2})
% the corresponding letter between A (for~1) and F (for~6).
%
% \begin{macro}{\PstDie@Letter}
%    \begin{macrocode}
\def\PstDie@Letter#1#2{%
\advance#1\@ne
\ifnum#1>6
  #1=\@ne
\fi
\def#2{\ifcase#1\or A\or B\or C\or D\or E\or F\fi}}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Closing}
%
%   Catcodes restoration.
%
%    \begin{macrocode}
\catcode`\@=\PstAtCode\relax
%    \end{macrocode}
%
%    \begin{macrocode}
%</pst-ob3d>
%    \end{macrocode}
%
% \Finale
% \PrintIndex
% \PrintChanges
%
\endinput
%%
%% End of file `pst-ob3d.dtx'