Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to make a picture of some 3D boxes (i.e., parallelepipeds) that intersect themselves in some complicated ways, so I tried pst-solides3d.

Here's the minimal working example: A long and thin blue box should pierce a flat yellow box at its center.

\documentclass{standalone}
\usepackage{pstricks,pst-solides3d}
\begin{document}
\begin{pspicture}(-5,-5)(5,5)
    \psset{viewpoint=20 25 15,Decran=50,solidmemory}
    \axesIIID(0,0,0)(2,2,2)
    \psSolid[name=longbox,
        object=parallelepiped,
        a=3,b=.2,c=.2,
        fillcolor=blue](.5,.5,.5)
    \psSolid[
        name=flatbox,
        object=parallelepiped,
        a=.25,b=2,c=2,
        fillcolor=yellow](.5,.5,.5)
    \psSolid[object=fusion,
        action=draw,
        base=flatbox longbox]
        (0,0,0)
    \composeSolid
\end{pspicture}
\end{document}

The output is very strange: A piece of the thin box became yellow. It seems that the package is unable to determine which pieces of surfaces are in front.

output

With the option action=draw**, the result is even worse:

enter image description here

Am I doing something wrong?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

You need more than the six polygon shapes of the blue cube to draw hidden surfaces. And, of course, all objects must be calculated with action=none except of the last one:

\documentclass{standalone}
\usepackage{pst-solides3d}
\begin{document}
\begin{pspicture}(-3,-2)(3,3)
    \psset{viewpoint=20 25 15,Decran=50,solidmemory,action=none}
    \axesIIID(0,0,0)(2,2,2)
    \multido{\rA=0.0+0.3,\iA=0+1}{11}{%
      \psSolid[name=l\iA, object=parallelepiped,a=0.3,b=.2,c=.2,
          fillcolor=blue](-0.75 \rA\space add .5 .5)}
    \psSolid[
        name=flatbox,
        object=parallelepiped, a=.25,b=2,c=2,fillcolor=yellow](.5,.5,.5)
  \def\List{l0 }
  \psforeach{\iA}{1,2,..,10}{\xdef\List{\List\space l\iA\space }}
    \psSolid[object=fusion,action=draw**,base=flatbox \List]
\end{pspicture}

\end{document}

enter image description here

share|improve this answer
    
Thanks for your answer. It's now clear that the package is less powerful than I expected, so boxes need to be partioned manually. –  Jairo Bochi Jul 19 at 21:44
    
it is simple to define a new object, which does this itself. –  Herbert Jul 20 at 5:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.