1 \section{Construction from scratch}
3 The object \Lkeyword{new} constructs a solid. Two parameters are used: \Lkeyword{sommets}
4 which indicates the list of coordinates of the different vertices, and \Lkeyword{faces} which
5 gives the list of faces of the solid; a face is characterized by a list of the indices of its\Index{vertices}, listed
6 in counterclockwise order
7 when the face is viewed from the exterior of the solid.
11 \subsection{Example 1: a house}
12 \begin{LTXexample}[width=6.5cm]
14 \psset{lightsrc=10 -20 50,viewpoint=50 -20 30 rtp2xyz,Decran=50}
15 \begin{pspicture*}(-7,-4)(7,7)
18 2 4 3 -2 4 3 -2 -4 3 2 -4 3
19 2 4 0 -2 4 0 -2 -4 0 2 -4 0
22 [0 1 2 3] [7 6 5 4] [0 3 7 4]
23 [3 9 2] [1 8 0] [8 9 3 0]
24 [9 8 1 2] [6 7 3 2] [2 1 5 6]},
25 num=all,show=all,action=draw]
29 Note that the solid \Lkeyword{new} uses the same options as the other solids.
30 For example, we give the same solid as above below, using the parameters
31 \Lkeyword{hollow}, \Lkeyword{incolor}, \Lkeyword{fillcolor}, and \Lkeyword{rm}.
34 \begin{LTXexample}[width=6.5cm]
36 \psset{lightsrc=10 -20 50,viewpoint=50 -20 30 rtp2xyz,Decran=50}
37 \begin{pspicture*}(-7,-3.5)(7,7.5)
38 \psSolid[object=new,fillcolor=red!50,incolor=yellow,
39 action=draw**,hollow,rm=2,
41 2 4 3 -2 4 3 -2 -4 3 2 -4 3
42 2 4 0 -2 4 0 -2 -4 0 2 -4 0
44 faces={ [0 1 2 3][7 6 5 4][0 3 7 4]
45 [3 9 2] [1 8 0] [8 9 3 0][9 8 1 2]
51 \subsection{Example 2: a \Index{hyperboloid} with a fixed radius}
53 %\psset{lightsrc=10 20 30,SphericalCoor=true,viewpoint=50 20 30}
54 %\psset{SphericalCoor=true,viewpoint=50 20 30}
57 As always, the options of the macro \Lcs{psSolid} can handle Postscript code, even \textit{jps code}
59 Unlike an example in pure PostScript, where we use the parameters
60 $a$, $b$ and $h$ which are transmitted by the options of PSTricks.
61 In this way one obtains a variable solid constructed from scratch.
63 Remark: the code being used comes from a \textit{jps} source used in practice, as in:
65 \noindent\url{http://melusine.eu.org/lab/bjps/solide/tour.jps}
66 \begin{LTXexample}[width=6.5cm]
68 \psset{lightsrc=10 -20 50,viewpoint=50 -20 30 rtp2xyz,Decran=50}
69 \begin{pspicture*}(-5,-5)(3,5)
70 \psSolid[object=new,fillcolor=red!50,incolor=yellow,
71 hollow, a=10, %% nb d'etages
72 b=20, %% diviseur de 360, nb de meridiens
74 action=draw**,sommets=
80 /r z0 h a div k mul add dup mul 4 div 1 add sqrt def
81 360 b idiv i mul cos r mul 360 b idiv i mul sin r mul
88 k b mul 1 add 1 k 1 add b mul 1 sub {
90 [i i 1 sub b i add 1 sub b i add]
92 [k b mul k 1 add b mul 1 sub k 2 add b mul 1 sub k 1 add b mul]
100 \subsection{Example 3: importing external files}
103 From a file describing a solid in a particular format (other than \texttt{\Index{.obj}} or \texttt{\Index{.off}}),
104 we can create a \texttt{\Index{.dat}} file containing the coordinates of the vertices,
105 and another \texttt{.dat} file containing the tables of indices of the vertices on each face.
106 These files can then be entered as parameters \Lkeyword{sommets} and \Lkeyword{faces}
107 when using the PostScript instruction \Lkeyword{run}.
110 In the example below, the files \verb+sommets_nefer.dat+
111 and \verb+faces_nefer.dat+ have been placed in the directory of the compiler.
113 \begin{LTXexample}[width=5.5cm]
115 \definecolor{AntiqueWhite}{rgb}{0.98,0.92,0.84}
116 \begin{pspicture}(-7,-9)(7,7)
117 \psset{lightsrc=30 -40 10}
118 \psset{viewpoint=50 -50 20 rtp2xyz,Decran=50}
119 \psset{RotX=90,sommets= (./sommets_nefer.dat) run}
120 \psSolid[object=new,fillcolor=AntiqueWhite,linewidth=0.5\pslinewidth,
121 faces={(./faces_nefer.dat) run}]%
122 \psSolid[object=new,fillcolor=red,linewidth=0.5\pslinewidth,
123 faces={(./faces_nefer_levres.dat) run}]%
124 \psSolid[object=new,fillcolor=black,
125 faces={(./faces_nefer_sourcils.dat) run}]%
128 \begin{pspicture}(-7,-9)(7,7)
129 \psset{lightsrc=-10 -40 -5,lightintensity=.5}
130 \psset{viewpoint=50 -80 10 rtp2xyz,Decran=50}
131 \psset{RotX=90,RotZ=30,sommets= (./sommets_nefer.dat) run}
132 \psSolid[object=new,fillcolor=AntiqueWhite,linewidth=0.5\pslinewidth,
133 grid,faces={(./faces_nefer.dat) run}]
134 \psSolid[object=new,fillcolor=red,linewidth=0.5\pslinewidth,grid,
135 faces={(./faces_nefer_levres.dat) run}]
136 \psSolid[object=new,fillcolor=black,
137 faces={(./faces_nefer_sourcils.dat) run}]