[Tex/LaTex] How to draw a cube as the following

pst-solides3dpstricks

\documentclass[pstricks,border=10pt]{standalone}
\usepackage{pst-solides3d}
\begin{document}
\psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
\pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
\def\figure#1#2{%
\begin{pspicture}(-3,-3)(3,3)
\psframe[linestyle=none,fillstyle=solid,fillcolor=blue!50](-3,-3)(3,3)
    \psSolid[action=draw**,a=8,object=cube,fillcolor=green!30,ngrid=3,%
    rm=4 40 13 31 53 22,hollow,incolor=pink!50,Rot#2=-#1\space]%
    \end{pspicture}
}
    \multido{\iA=0+5}{72}{\figure{\iA}{X}}
\end{document}

enter image description here
It is hollowed inside the cube.

So, how to get the similar output to the following image?

enter image description here

%% From Herbert's comment

\documentclass[pstricks]{standalone}
\usepackage{pst-solides3d}
\begin{document}

\begin{pspicture}(-4.5,-3.5)(6,6)
\psset{Decran=60,viewpoint=80 35 15 rtp2xyz,a=1,lightsrc=80 30 20,}
%   \psSolid[object=grille,base=0 7 0 7,fillcolor=gray!40]%%
%   \psSolid[object=grille,base=0 7 0 7,RotY=90,fillcolor=gray!30](0,0,7)%
%   \psSolid[object=grille,base=0 7 0 7,RotX=-90,fillcolor=gray!20](0,0,7)%
\def\figure#1#2#3{\psSolid[object=cube,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)}
    \foreach \i in {0.5,1.5,2.5}{\figure{0.5}{\i}{0.5}}
    \foreach \i in {1.5,2.5}{\figure{\i}{.5}{0.5}}
    \figure{1.5}{2.5}{0.5}
    \foreach \i in {1.5,2.5}{\figure{2.5}{\i}{0.5}}
    \foreach \i in {1.5,2.5}{\figure{.5}{.5}{\i}}
    \figure{2.5}{.5}{1.5}
    \figure{.5}{1.5}{2.5}
    \foreach \i in {1.5,2.5}{\figure{\i}{.5}{2.5}}
    \figure{2.5}{1.5}{2.5}
    \foreach \i in {1.5,2.5}{\figure{.5}{2.5}{\i}}
    \figure{1.5}{2.5}{2.5}
    \foreach \i in {1.5,2.5}{\figure{2.5}{2.5}{\i}}
\end{pspicture}
\end{document}

enter image description here

But with viewpoint=80 135 15 rtp2xyz , I get the following:

enter image description here

Best Answer

If you do not want the inside also with cubes, it is simple:

\documentclass[pstricks,border=10pt]{standalone}
\usepackage{pst-solides3d}
\begin{document}
\psset{viewpoint=120 60 30 rtp2xyz,Decran=50}
\pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
\begin{pspicture}(-3,-3)(3,3)
\psSolid[action=draw**,a=8,object=cube,fillcolor=green!30,ngrid=7,%
    rm=  8  12  24  36  40 
        57  61  73  85  89
       106 110 122 134 138
       155 159 171 183 187
       208 212 220 228 232
       269 273 281 289 293,
        hollow,incolor=blue!30]%
\end{pspicture}
\end{document}

enter image description here

And as single cubes:

\documentclass[pstricks]{standalone}
\usepackage{pst-solides3d}
\def\Figure#1#2#3#4{%
    \psSolid[object=cube,name=c#4,ngrid=1,a=1,
             action=none,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)}

\begin{document}

    \begin{pspicture}(-4.5,-3.5)(6,6)
    \psset{Decran=60,viewpoint=80 10 15 rtp2xyz,lightsrc=viewpoint,solidmemory}
    \foreach \i/\j in {0.5/1,1.5/2,2.5/3}{\Figure{0.5}{\i}{0.5}{\j}}
    \foreach \i/\j in {1.5/4,2.5/5}{\Figure{\i}{.5}{0.5}{\j}}
    \Figure{1.5}{2.5}{0.5}{6}
    \foreach \i/\j in {1.5/7,2.5/8}{\Figure{2.5}{\i}{0.5}{\j}}
    \foreach \i/\j in {1.5/9,2.5/10}{\Figure{.5}{.5}{\i}{\j}}
    \Figure{2.5}{.5}{1.5}{11}
    \Figure{.5}{1.5}{2.5}{12}
    \foreach \i/\j in {1.5/13,2.5/14}{\Figure{\i}{.5}{2.5}{\j}}
    \Figure{2.5}{1.5}{2.5}{15}
    \foreach \i/\j in {1.5/16,2.5/17}{\Figure{.5}{2.5}{\i}{\j}}
    \Figure{1.5}{2.5}{2.5}{18}
    \foreach \i/\j in {1.5/19,2.5/20}{\Figure{2.5}{2.5}{\i}{\j}}
    \psSolid[object=fusion,
             base=c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20]
    \composeSolid
    \end{pspicture}
\end{document}

enter image description here

For a lot of cubes you can simplify the fusion object:

\def\cubes{}
\multido{\iA=1+1}{20}{\xdef\cubes{\cubes\space c\iA}}
\begin{pspicture} ....
    ....    
    \psSolid[object=fusion, base=\cubes]
    ....

and here is a way how you can build the complete cube:

\documentclass[pstricks]{standalone}
\usepackage{pst-solides3d}
\newcounter{fig}
\def\Figure#1#2#3{%
    \stepcounter{fig}%
    \psSolid[object=cube,name=c\thefig,ngrid=1,a=1,
             action=none,fcol=1 (green) 2 (blue) 3 (red) 4 (pink) 5 (orange) 6 (cyan)](#1,#2,#3)}

\begin{document}

    \begin{pspicture}(-5,-3.5)(4,6)
    \psset{Decran=60,viewpoint=80 60 15 rtp2xyz,lightsrc=viewpoint,solidmemory}
    \multido{\iA=0+1}{7}{%
      \multido{\iB=0+1}{7}{%
         \multido{\iC=0+1}{7}{%
           \Figure{\iB}{\iA}{\iC}%
    }}}%
    \psSolid[object=fusion, base=
    % 1
       c1   c2   c3   c4   c5   c6   c7
       c8        c10  c11  c12       c14
       c15  c16  c17  c18  c19  c20  c21
       c22  c23  c24       c26  c27  c28
       c29  c30  c31  c32  c33  c34  c35
       c36       c38  c39  c40       c42
       c43  c44  c45  c46  c47  c48  c49
    % 2
       c50       c52  c53  c54       c56
    %      
       c64       c66  c67  c68       c70
       c71       c73       c75       c77
       c78       c80  c81  c82       c84
    %      
       c92       c94  c95  c96       c98
     % 3 ...
      ]
    \composeSolid
    \end{pspicture}
\end{document}

enter image description here

and the complete image:

enter image description here

Related Question