[Tex/LaTex] Drawing 3d crystal lattice with molecular layer in tikz

tikz-pgf

I would like to achieve the following diagram (may be colored) wit Tikz. enter image description here
Here is what I have done till now:
i)Drawing a 3d cube with Tikz
ii)Get the Molecular layer from here
Here is my code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,fadings,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\cubex}{4}
\pgfmathsetmacro{\cubey}{4}
\pgfmathsetmacro{\cubez}{4}
\draw (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
\draw (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
\draw (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;
\end{tikzpicture}
\\[1cm]
\begin{tikzpicture}
  \def\nuPi{3.1459265}
  \foreach \i in {11,10,...,0}{% This one doesn't matter
    \foreach \j in {5,4,...,0}{% This will crate a membrane
                               % with the front lipids visible
      % top layer
      \pgfmathsetmacro{\dx}{rand*0.1}% A random variance in the x coordinate
      \pgfmathsetmacro{\dy}{rand*0.1}% A random variance in the y coordinate,
                                     % gives a hight fill to the lipid
      \pgfmathsetmacro{\rot}{rand*0.1}% A random variance in the
                                      % molecule orientation
      \shade[ball color=red] ({\i+\dx+\rot},{0.5*\j+\dy+0.4*sin(\i*\nuPi*10)}) circle(0.45);
      \shade[ball color=gray] (\i+\dx,{0.5*\j+\dy+0.4*sin(\i*\nuPi*10)-0.9}) circle(0.45);
      \shade[ball color=gray] (\i+\dx-\rot,{0.5*\j+\dy+0.4*sin(\i*\nuPi*10)-1.8}) circle(0.45);
      % bottom layer
      \pgfmathsetmacro{\dx}{rand*0.1}
      \pgfmathsetmacro{\dy}{rand*0.1}
      \pgfmathsetmacro{\rot}{rand*0.1}
      \shade[ball color=gray] (\i+\dx+\rot,{0.5*\j+\dy+0.4*sin(\i*\nuPi*10)-2.8}) circle(0.45);
      \shade[ball color=gray] (\i+\dx,{0.5*\j+\dy+0.4*sin(\i*\nuPi*10)-3.7}) circle(0.45);
      \shade[ball color=red] (\i+\dx-\rot,{0.5*\j+\dy+0.4*sin(\i*\nuPi*10)-4.6}) circle(0.45);
    }
  }
\end{tikzpicture}
\end{document} 

enter image description here

How do I fix the layer onto the cube is my ultimate question and drawing the inner cube as in the diagram (preferably with axes)

Best Answer

I tried to exclude complex bits of code and maths. This is the brute force attack.

\documentclass{article}
\usepackage{tikz}
%\usetikzlibrary{calc,fadings,decorations.pathreplacing}

\tikzset{My Line Style/.style={ultra thick, blue, fill=yellow!10, fill opacity=0.5,join=round}}

\begin{document}
\begin{tikzpicture}[rotate around x=5] 
    \foreach \x in {0,1,2,3,4,5,6}{% 
      \foreach \z in {0,1,2,3,4,5,6}{%      
      \shade[ball color=gray] (\x,0,\z) circle(0.5);
      }
    }
    \foreach \x in {0.5,1.5,2.5,3.5,4.5,5.5}{%
      \foreach \z in {0,1,2,3,4,5,6}{%
      \shade[ball color=gray] (\x,{sqrt(0.74)},\z) circle(0.5);
      }
    }
    \foreach \x in {0,1,2,3,4,5,6}{%
      \foreach \z in {0,1,2,3,4,5,6}{%
      \shade[ball color=gray] (\x,{2*sqrt(0.74)},\z) circle(0.5);
      }
    }
    \foreach \x in {0.5,1.5,2.5,3.5,4.5,5.5}{%
      \foreach \z in {0,1,2,3,4,5,6}{%
      \shade[ball color=gray] (\x,{3*sqrt(0.74)},\z) circle(0.5);
      }
    }
    \foreach \x in {0,1,2,3,4,5,6}{%
      \foreach \z in {0,1,2,3,4,5,6}{%
      \shade[ball color=gray] (\x,{4*sqrt(0.74)},\z) circle(0.5);
      }
    }
    \foreach \x in {0.5,1.5,2.5,3.5,4.5,5.5}{%
      \foreach \z in {0,1,2,3,4,5,6}{%
      \shade[ball color=gray] (\x,{5*sqrt(0.74)},\z) circle(0.5);
      }
    }
    \foreach \x in {0,1,2,3,4,5,6}{%
      \foreach \z in {0,1,2,3,4,5,6}{%
      \shade[ball color=gray] (\x,{6*sqrt(0.74)},\z) circle(0.5);
      }
    }

    \draw [My Line Style] (6,{4*sqrt(0.74)},6) -- (4,{4*sqrt(0.74)},6) -- (4,{6*sqrt(0.74)},6) -- 
                          (6,{6*sqrt(0.74)},6) -- cycle;
    \draw [My Line Style] (4,{6*sqrt(0.74)},6) -- (4,{6*sqrt(0.74)},4) -- (6,{6*sqrt(0.74)},4) --
                          (6,{6*sqrt(0.74)},6) -- cycle;
    \draw [My Line Style] (6,{4*sqrt(0.74)},6) -- (6,{4*sqrt(0.74)},4) -- (6,{6*sqrt(0.74)},4) --
                          (6,{6*sqrt(0.74)},6) -- cycle;
\end{tikzpicture}
\end{document}

enter image description here