I want to fill the cube (side length L) with cuboids (a,b,c which are divors of L) in cheesboard style.
There goes something wrong. What have I to do?
(I have spared the filling of the roof for the time being.)
\documentclass[margin=5pt, tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\begin{document}
\pgfmathsetmacro{\L}{10}
\pgfmathsetmacro{\a}{2}
\pgfmathsetmacro{\b}{2}
\pgfmathsetmacro{\c}{1}
\begin{tikzpicture}[scale=1.5,
z ={(0,0,-cos(45))}, % z ={(0,0,-1)},
>=latex,
font=\footnotesize,
]
% Big Cube
\coordinate[] (A) at (0,0,0);
\coordinate[] (B) at (\L,0,0);
\coordinate[] (C) at (\L,0,\L);
\coordinate[] (D) at (0,0,\L);
\coordinate[] (A-s) at (0,\L,0);
\coordinate[] (B-s) at (\L,\L,0);
\coordinate[] (C-s) at (\L,\L,\L);
\coordinate[] (D-s) at (0,\L,\L);
\draw[] (A) -- (B) -- (C) -- (D) --cycle;
\draw[] (A-s) -- (B-s) -- (C-s) -- (D-s) --cycle;
\foreach \Punkt in {A,B,C,D} \draw[gray] (\Punkt) -- (\Punkt-s);
% Front Filling
\pgfmathsetmacro{\A}{int(\L-1)}
\foreach \x in {0,...,\A} \foreach \y in {0,...,\A}{%
\pgfmathparse{mod(\x+\y,2)==0 ? "lightgray" : "red!50"}
\colorlet{Color}{\pgfmathresult}
\pgfmathsetmacro\M{mod(\x,2)==0 && mod(\y,2)==0 ? 1 : 0}
\ifnum\M=1
\draw[shift={(\x,\y)}, very thick, fill=Color] (0,0) rectangle (\a,\b);
\else\fi
}%% %
% Side Filling
\foreach \y in {0,...,\A} \foreach \z in {0,...,\A} {%
\pgfmathparse{mod(\y+\z,2)==0 ? "lightgray" : "red!50"}
\colorlet{Color}{\pgfmathresult}
\pgfmathsetmacro\M{mod(\y,2)==0 ? 1 : 0}
\ifnum\M=1
\draw[shift={(0,\y,\z)}, very thick, fill=Color] (10,0,0) -- (10,0,\c) -- (10,\b,\c) -- (10,\b,0) --cycle;
\else\fi
}
% Roof Filling
% ......
% CoSy
\draw[->] (-0.5,0,0) -- (3,0,0) node[right]{$x$};
\draw[->] (0,-0.5,0) -- (0,3,0) node[above]{$y$};
\draw[->] (0,0,-1) -- (0,0,3) node[pos=1.05]{$z$};
\end{tikzpicture}
\end{document}