I need to draw 3D lattice of DO3 type (Ni-Mn-Al, DO3) and more complex ones. Both TiKZ and PSTricks packages draw following objects on top of previously drawn disregarding "real" 3D position. For example, on this picture 2 red atoms on the right cover white ones, when they shouldn't.
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[->]
\draw (0,0) -- (4,0,0);
\draw (0,0) -- (0,4,0);
\draw (0,0) -- (0,0,4);
\foreach \x in {1,2,3}
\foreach \y in {1,2,3}
\foreach \z in {1,2,3}
\draw (\x,\y,\z) circle (2pt);
\foreach \x in {1.5,2.5}
\foreach \y in {1.5,2.5}
\foreach \z in {1,2,3}
\draw[gray,very thin] (\x,\y,\z) +(-.5,-.5) rectangle ++(.5,.5);
\foreach \x in {1,2,3}
\draw (\x,1,1) -- (\x,1,3) (\x,2,1) -- (\x,2,3) (\x,3,1) -- (\x,3,3) ;
\foreach \x in {1.5,2.5}
\foreach \y in {1.5,2.5}
\foreach \z in {1.5,2.5}
\filldraw[red] (\x,\y,\z) circle (2pt);
\end{tikzpicture}
\end{document}
It is possible, to obtain right behavior with layers or certain order of the drawing. However for complex lattices it is very difficult and depends on view angle.