# pst-solides3d and hidden lines

I am trying to draw figures with pstricks for the first time. Unfortunately, I am struggling with it. I was trying to draw a pentagon-cone and an octahedron using pst-solides3d, but it draws some lines dashed which actually are not hidden. I used this code:

\begin{pspicture}(-2,-1)(3,4)
\psset{viewpoint=25 8 5,Decran=50}
\psSolid[object=new,
action=draw,
sommets=
0 0 0
0.343561 1.05737 1
-0.899454 0.653491 1
-0.899454 -0.653491 1
0.343561 -1.05737 1
1.11179 0 1,
faces={
[0 1 2]
[0 2 3]
[0 3 4]
[0 4 5]
[0 5 1]
[ 1 2 3 4 5]}]%
\end{pspicture}

\begin{pspicture}(-2,-1)(3,4)
\psset{viewpoint=25 8 5,Decran=100}
\psSolid[object=new,
action=draw,
sommets=
%n=4
0 0 0 %0
0.420448 0.420448 0.5 %e1
-0.420448 0.420448 0.5 %e2
-0.420448 -0.420448 0.5 %e3
0.420448 -0.420448 0.5 %e4
0 0 1, %u
faces={
[0 1 4]
[0 1 2]
[0 2 3]
[0 3 4]
[2 3 5]
[3 4 5]
[1 2 5]
[1 4 5]}]%
\end{pspicture}


The result, however, looks like this:

Obiously, lines which should be dashed (because they are hidden) are not and some lines which should be continuous are dashed. Does anyone know how to fix this problem?

Thanks for your answers. There is still something strange. If I set num=all, like in the code

\begin{pspicture}(-2,-1)(3,4)
\psset{viewpoint=25 12 5,Decran=100}
%\axesIIID[showOrigin=false](1,1,1)(3,2,2.5)
\psSolid[object=new,
action=draw*,
fillcolor=red,
opacity=.6,
fcol=8 (Blue),
num=all,
sommets=
%n=4
0 0 0 %0
0.420448 0.420448 0.5 %e1
-0.420448 0.420448 0.5 %e2
-0.420448 -0.420448 0.5 %e3
0.420448 -0.420448 0.5 %e4
0 0 1 %u
0 1.18921 1 %w1
-1.18921 0 1 %w2
0 -1.18921 1 %w3
1.18921 0 1, %w4
faces={
[0 1 4]
[0 2 1]
[0 3 2]
[0 4 3]
[2 3 5]
[3 4 5]
[1 2 5]
[1 5 4]
[6 7 8 9]}]%
\end{pspicture}


then I get the following result: which is obviously not as intended. How can I fix this?

-
You know, that there are ready made objects for a cone and octahedron? –  Herbert Oct 21 '11 at 7:24
@Herbert: I converted the OP's "answer" to an question edit. You might want to re-add your recent comment. –  Martin Scharrer Oct 24 '11 at 7:14
...,num=all,numsep=2pt,.... However, it would make more sense to define your object as two solids –  Herbert Oct 24 '11 at 8:06
ah, perfect, thank you @Herbert –  Tom Jonathan Oct 24 '11 at 8:34

The action key of pst-solides3d defines how the object is drawn:

• none: nothing is drawn.
• draw: draws the solid as a framework and sets up dashed lines for the hidden edges.
• draw*: draws the solid with dashed lines for the hidden edges and colours the visible faces.
• draw**: draws the solid with a painting algorithm, without the hidden edges and with colouration of the visible faces.

Using action=draw**, your document produces the following visibly incomplete polyhedra:

Although the edges of the faces make for a complete visual drawing, there are some missing faces. Now, you may notice that they formed part of your code, but they need to conform to the face specification (from the pst-solides3d documentation):

...a face is characterized by a list of the indices of it's vertices, listed in counter-clockwise order when the face is viewed from the exterior of the solid.

The easiest way to find out the order (and which direction is clockwise or counter-clockwise) is to add the key-value num=all and show=all to your \psSolid object. That is, use

\psSolid[action=draw,num=all,show=all,...]


This numbers all the vertices (sommets) and all the faces (faces). Rewriting the faces in the correct counter-clockwise fashion produce the expected results:

\documentclass{article}
\usepackage{pst-solides3d}% http://ctan.org/pkg/pst-solides3d
\begin{document}
\begin{pspicture}(-2,-1)(3,4)
\psset{viewpoint=25 8 5,Decran=50}
\psSolid[object=new,%num=all,show=all,
action=draw,
sommets=
0 0 0
0.343561 1.05737 1
-0.899454 0.653491 1
-0.899454 -0.653491 1
0.343561 -1.05737 1
1.11179 0 1,
faces={%
[0 1 5]
[0 5 4]
[0 4 3]
[0 3 2]
[0 2 1]
[1 2 3 4 5]}]%
\end{pspicture}

\begin{pspicture}(-2,-1)(3,4)
\psset{viewpoint=25 8 5,Decran=100}
\psSolid[object=new,
action=draw,%num=all,show=all,
sommets=
0 0 0 %0
0.420448 0.420448 0.5 %e1
-0.420448 0.420448 0.5 %e2
-0.420448 -0.420448 0.5 %e3
0.420448 -0.420448 0.5 %e4
0 0 1, %u
faces={
[0 2 1]
[0 1 4]
[0 4 3]
[0 3 2]
[5 1 2]
[5 2 3]
[5 3 4]
[5 4 1]}]%
\end{pspicture}

-
As always, a beautiful answer- I really appreciate how much detail you put in. –  cmhughes Oct 21 '11 at 5:46
@cmhughes: Thanks! –  Werner Oct 21 '11 at 6:03
Thank you, Werner, your answer is perfect. But there is still one thing that does not work as expected, see my answer below. –  Tom Jonathan Oct 24 '11 at 4:20
@TomJonathan: What is wrong with your code? You mention it is "not as intended", but I don't see anything wrong with it. Note that the vertex numbers are displaced quite a distance away from each node... in 3D space. So, it may look scattered. If you want the numbers to be closer to the nodes, you need to place them closer manually. Is this what you're after? –  Werner Oct 24 '11 at 4:50
Yes, that's what I'm after. Thanks. –  Tom Jonathan Oct 24 '11 at 5:22

Using the object octahedron:

\documentclass{article}
\usepackage[dvipsnames]{pstricks}
\usepackage{pst-solides3d}
\begin{document}
\psset{viewpoint=25 8 5,Decran=50}
\begin{pspicture}(-2,-2)(3,3)
\psSolid[object=octahedron, a=1, hue=0.2 0.6]
\end{pspicture}
%
\begin{pspicture}[solidmemory](-2,-2)(2,2)
\psSolid[object=octahedron, a=1,
plansepare={[0 0 1 0]},% plain to cut the object: z=0
name=Octa, action=none]