File: faces.html

package info (click to toggle)
python-visual 3.2.9-4.1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,796 kB
  • ctags: 2,664
  • sloc: cpp: 11,958; sh: 8,185; python: 3,709; ansic: 480; makefile: 311
file content (154 lines) | stat: -rw-r--r-- 6,022 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><HTML>

<HEAD>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">

<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<META NAME="GENERATOR" CONTENT="Adobe FrameMaker 5.5/HTML Export Filter">

<LINK REL="STYLESHEET" HREF="VisualRef.css" CHARSET="ISO-8859-1" TYPE="text/css">

<TITLE> Description of Objects in VPython</TITLE>

</HEAD>

<BODY BGCOLOR="#ffffff">

<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">

<tr>

      <td><A HREF="curve.html"><img src="icons/previous.gif" border="0" height="32"

  alt="Previous Page" width="32"></A></td>

      <td><A HREF="index.html"><img src="icons/up.gif" border="0" height="32"

  alt="Up One Level" width="32"></A></td>

      <td><A HREF="label.html"><img src="icons/next.gif" border="0" height="32"

  alt="Next Page" width="32"></A></td>

<td align="center" width="100%">Visual Reference</td>

      <td><A HREF="index.html"><img src="icons/contents.gif" border="0" height="32"

  alt="Contents" width="32"></A></td>

      <td><img src="icons/blank.gif" border="0" height="32"

  alt="" width="32"></td>

      <td><img src="icons/blank.gif" border="0" height="32"

  alt="" width="32"></td>

</tr></table>

  <b class="navlabel">Previous:</b> <a class="sectref" HREF="frame.html">The frame 
  object</A> <b class="navlabel">Up:</b> <a class="sectref" HREF="index.html">Contents</A> 
  <b class="navlabel">Next:</b> <a class="sectref" HREF="options.html">Additional 
  Attributes</A> <br>
  <hr>

</DIV>

<DIV>

  <H1 CLASS="Heading-1"> <font color="#0000A0">The faces Object</font></H1>
  
</DIV>
<DIV>
  <p>The "faces" primitive takes a list of triangles (position, color, and normal 
    for each vertex). This is useful for writing routines in Python to import 
    3D models made with other 3D modeling tools. You would still need to do lots 
    of calculations of normals and so on, but you would not need to do C coding 
    to import an arbitrary model file.</p>
  <p>The faces object is an array primitive (like curve, convex, etc), so you 
    have to use a frame to move it around. It consists of a set of one-sided triangles 
    with user-specified vertices, colors, and normals. The <font color="#FF0000">pos</font>, 
    <font color="#FF0000">color</font>, and <font color="#FF0000">normal</font> 
    attributes look like this:</p>
  <p class="program"> pos = [ t0v0, t0v1, t0v2, t1v0, t1v1, t1v2, t2v0, t2v1, 
    t2v2, ... ] </p>
  <p>where t0v0 is the position of vertex 0 of triangle 0, t0v1 is vertex 1 of 
    triangle 0, etc.</p>
  <p>Each face is a one-sided surface. Which side is illuminated is determined 
    by the &quot;winding&quot; order of the face. When you are looking at a face, 
    it is illuminated if the order of the vertices in the <span class="attribute">pos</span> 
    list goes counter-clockwise. If you need the triangle to be visible from either 
    side, you must create another triangle with the opposite winding order.</p>
  <p>If you don't specify normals at the vertices, the face is illuminated only 
    by &quot;ambient&quot; light. In order for the main lighting to affect the 
    appearance, you must specify normals to the surface at the vertices. In the 
    simplest case, a normal at a vertex is perpendicular to the face, and adjoining 
    faces have a hard edge where they join. A soft edge can be produced by averaging 
    the normals to the two faces at their common vertices. The brightness of a 
    face is proportional to the cosine of the angle between the normal and the 
    light. </p>
  <p>If you specify different colors at the vertices of one triangular face, VPython 
    interpolates across the face, in which case the face is not all one color. 
    There is a similar interpolation for normals if there are different normals 
    at the vertices, in which case the face is not all one brightness.</p>
  <p>The faces object is intended to help with writing model importers and other 
    new primitives in Python, not for direct manipulation by normal programs. 
    It is considerably lower-level than any of the other objects in Visual (although 
    it is not necessarily any faster, at least right now). It is flexible enough 
    to implement smooth or facet shading, per-vertex coloration, two-sided or 
    one-sided lighting, etc, but all of these calculations must be made by the 
    programmer (when setting up <font color="#FF0000">pos</font>, <font color="#FF0000">color</font>, 
    <font color="#FF0000">normal</font>). </p>
  <p>For examples of the use of the faces object, see the faces demo programs.</p>
  </DIV>

<DIV></DIV>

<hr>

<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">

<tr>

      <td><A HREF="curve.html"><img src="icons/previous.gif" border="0" height="32"

  alt="Previous Page" width="32"></A></td>

      <td><A HREF="index.html"><img src="icons/up.gif" border="0" height="32"

  alt="Up One Level" width="32"></A></td>

      <td><A HREF="label.html"><img src="icons/next.gif" border="0" height="32"

  alt="Next Page" width="32"></A></td>

<td align="center" width="100%">Visual Reference</td>

      <td><A HREF="index.html"><img src="icons/contents.gif" border="0" height="32"

  alt="Contents" width="32"></A></td>

      <td><img src="icons/blank.gif" border="0" height="32"

  alt="" width="32"></td>

      <td><img src="icons/blank.gif" border="0" height="32"

  alt="" width="32"></td>

</tr></table>

  <b class="navlabel">Previous:</b> <a class="sectref" HREF="frame.html">The frame 
  Object</A> <b class="navlabel">Up:</b> <a class="sectref" HREF="index.html">Contents</A> 
  <b class="navlabel">Next:</b> <a class="sectref" HREF="options.html">Additional 
  Attributes</A> <br>
  <hr>

</DIV>

</BODY>

</HTML>