next up previous
Next: /Polyline ... /EndPolyline Up: Formats of 3D primitives Previous: /PolyGon

/Polyhedron ... /EndPolyhedron

/Polyhedron ... /EndPolyhedron describes a general polyhedron composed of a set of 3D polygons. Concave polygons are available but not recommended. Lists of vertices and facets are described between /Polyhedron and /EndPolyhedron. The following is the format for a polyhedron with N vertices and M facets.

Format /Polyhedron
  /Vertex x1 y1 z1
  /Vertex x2 y2 z2
  ......
  /Vertex xN yN zN
  /Facet f1_v1 f1_v2 f1_v3 ...
  /Facet f2_v1 f2_v2 f2_v3 ...
  ......
  /Facet fM_v1 fM_v2 fM_v3 ...
  /EndPolyhedron
(xi, yi, zi) 3D position of the i-th vertex
  of the polyhedron ().
  The integer label `i'' is assigned to
  vertices incrementally, beginning from 1.
fa_vj the j-th vertex label of the a-th facet,
  whose absolute value must coincide with
  one of the vertex labels {}.
fa_v1 fa_v2 fa_v3 ... the a-th facet expressed by connecting
  vertex labels in counter-clock-wise order
  viewing from its front side.
  Edge fa_vi--fa_vj is regarded as
  an invisible edge if fa_vj is negative.
  At least three vertices must be described.


Note that positive-integer labels are incrementally and automatically assinged to vertices given by /Vertex ..., beginning from 1, not 0.

An invisible edge is expressed by assigning a negative integer vertex label to its ending point. For example, ``/Facet 1 -2 6 5 ;'' describes a facet 12651, in which the edge connecting vertices 1 and 2 is invisible.

Vertex data (/Vertex ...) and facet data (/Facet ...) can be described at any position with any order between /Polyhedron ... /EndPolyhedron, but it is recommended that all vertex data are described beforehand.

The following is a sample description of a red box using /Polyhedron .../EndPolyhedron.

Example: 1 box

##G4.PRIM-FORMAT-2.4
##################################################
# 1x4x9 box with /polyhedron ... /EndPolyhedron ##
##################################################

/BoundingBox -0.5 -2.0 -4.5  0.5  2.0  4.5
!SetCamera
!OpenDevice 
!BeginModeling

/ColorRGB  1.0 0.0 0.0

/Polyhedron
/Vertex -0.500000000 -2.000000000 -4.500000000
/Vertex  0.500000000 -2.000000000 -4.500000000
/Vertex -0.500000000 2.000000000 -4.500000000
/Vertex  0.500000000 2.000000000 -4.500000000
/Vertex -0.500000000 -2.000000000 4.500000000
/Vertex  0.500000000 -2.000000000 4.500000000
/Vertex -0.500000000 2.000000000 4.500000000
/Vertex  0.500000000 2.000000000 4.500000000
/Facet 3 4 2 1 
/Facet 1 2 6 5 
/Facet 2 4 8 6 
/Facet 4 3 7 8 
/Facet 3 1 5 7 
/Facet 5 6 8 7 
/EndPolyhedron


!EndModeling
!DrawAll 
!CloseDevice


next up previous
Next: /Polyline ... /EndPolyline Up: Formats of 3D primitives Previous: /PolyGon
Satoshi Tanaka
4/9/1998