indexedfaceset.html 7.88 KB
Newer Older
Athanasios's avatar
Athanasios committed
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title> Indexed Face Set </title>
	<link rel="stylesheet" type="text/css" href="x3dom.css">
	</link>
</head>

<body>
	<h1> Indexed Face Set </h1>
	<table width="100%" height="85%" border="0">
		<tr>
			<td width="50%" align="center" valign="top" scope="col">
				<X3D id="shapedata" width="600px" height="600px" style="float:left">
					<Scene>
						<Shape>
							<Appearance>
								<Material diffuseColor="0.5 0.5 0.5"> </Material>
							</Appearance>
							<IndexedFaceSet solid="true" ccw="true" coordIndex=" 0 1 5 4 -1 1 2 6 5 -1 2 3 7 6 -1
                             3 0 4 7 -1 0 3 2 1 -1 7 4 8 -1
                             4 5 8 -1 5 6 8 -1 6 7 8 -1">
								<Coordinate point="-1 0 1, 1 0 1, 1 0 -1, -1 0 -1,
             	            -1 2 1, 1 2 1, 1 2 -1, -1 2 -1, 0 3 0 ">
								</Coordinate>
							</IndexedFaceSet>
						</Shape>
						<!-- add points (as spheres) and labels -->
						<!-- P0 -->
						<Transform translation='-1 0 1'>
							<Shape DEF='Point'>
								<Appearance DEF='Green'>
									<Material diffuseColor='0 1 0'> </Material>
								</Appearance>
								<Sphere radius="0.1"> </Sphere>
							</Shape>
							<Transform translation='0 -0.75 0'>
								<Billboard>
									<Shape>
										<Appearance DEF='LABEL_APPEARANCE'>
											<Material diffuseColor='0 0 0'> </Material>
										</Appearance>
										<Text string='"P0"'>
											<FontStyle DEF='LABEL_FONT' family='"SANS"' justify='"MIDDLE" "MIDDLE"' size='.2'> </FontStyle>
										</Text>
									</Shape>
								</Billboard>
							</Transform>
						</Transform>
						<!-- P1 -->
						<Transform translation='1 0 1'>
							<Shape USE="Point">
							</Shape>
							<Transform translation='0 -0.75 0'>
								<Billboard>
									<Shape>
										<Appearance USE='LABEL_APPEARANCE'>
										</Appearance>
										<Text string='"P1"'>
											<FontStyle DEF='LABEL_FONT' family='"SANS"' justify='"MIDDLE" "MIDDLE"' size='.2'> </FontStyle>
										</Text>
									</Shape>
								</Billboard>
							</Transform>
						</Transform>
						<!-- P2 -->
						<Transform translation='1 0 -1'>
							<Shape USE="Point">
							</Shape>
							<Transform translation='0 -0.75 0'>
								<Billboard>
									<Shape>
										<Appearance USE='LABEL_APPEARANCE'>
										</Appearance>
										<Text string='"P2"'>
											<FontStyle DEF='LABEL_FONT' family='"SANS"' justify='"MIDDLE" "MIDDLE"' size='.2'> </FontStyle>
										</Text>
									</Shape>
								</Billboard>
							</Transform>
						</Transform>
						<!-- P3 -->
						<Transform translation='-1 0 -1'>
							<Shape USE="Point">
							</Shape>
							<Transform translation='0 -0.75 0'>
								<Billboard>
									<Shape>
										<Appearance USE='LABEL_APPEARANCE'>
										</Appearance>
										<Text string='"P3"'>
											<FontStyle DEF='LABEL_FONT' family='"SANS"' justify='"MIDDLE" "MIDDLE"' size='.2'> </FontStyle>
										</Text>
									</Shape>
								</Billboard>
							</Transform>
						</Transform>
						<!-- P4 -->
						<Transform translation='-1 2 1'>
							<Shape USE="Point">
							</Shape>
							<Transform translation='0 -0.75 0'>
								<Billboard>
									<Shape>
										<Appearance USE='LABEL_APPEARANCE'>
										</Appearance>
										<Text string='"P4"'>
											<FontStyle DEF='LABEL_FONT' family='"SANS"' justify='"MIDDLE" "MIDDLE"' size='.2'> </FontStyle>
										</Text>
									</Shape>
								</Billboard>
							</Transform>
						</Transform>
						<!-- P5 -->
						<Transform translation='1 2 1'>
							<Shape USE="Point">
							</Shape>
							<Transform translation='0 -0.75 0'>
								<Billboard>
									<Shape>
										<Appearance USE='LABEL_APPEARANCE'>
										</Appearance>
										<Text string='"P5"'>
											<FontStyle DEF='LABEL_FONT' family='"SANS"' justify='"MIDDLE" "MIDDLE"' size='.2'> </FontStyle>
										</Text>
									</Shape>
								</Billboard>
							</Transform>
						</Transform>
						<!-- P6 -->
						<Transform translation='1 2 -1'>
							<Shape USE="Point">
							</Shape>
							<Transform translation='0 -0.75 0'>
								<Billboard>
									<Shape>
										<Appearance USE='LABEL_APPEARANCE'>
										</Appearance>
										<Text string='"P6"'>
											<FontStyle DEF='LABEL_FONT' family='"SANS"' justify='"MIDDLE" "MIDDLE"' size='.2'> </FontStyle>
										</Text>
									</Shape>
								</Billboard>
							</Transform>
						</Transform>
						<!-- P7 -->
						<Transform translation='-1 2 -1'>
							<Shape USE="Point">
							</Shape>
							<Transform translation='0 -0.75 0'>
								<Billboard>
									<Shape>
										<Appearance USE='LABEL_APPEARANCE'>
										</Appearance>
										<Text string='"P7"'>
											<FontStyle DEF='LABEL_FONT' family='"SANS"' justify='"MIDDLE" "MIDDLE"' size='.2'> </FontStyle>
										</Text>
									</Shape>
								</Billboard>
							</Transform>
						</Transform>
						<!-- P8 -->
						<Transform translation='0 3 0'>
							<Shape USE="Point">
							</Shape>
							<Transform translation='0 0.0 0'>
								<Billboard>
									<Shape>
										<Appearance USE='LABEL_APPEARANCE'>
										</Appearance>
										<Text string='"P8"'>
											<FontStyle DEF='LABEL_FONT' family='"SANS"' justify='"MIDDLE" "MIDDLE"' size='.2'> </FontStyle>
										</Text>
									</Shape>
								</Billboard>
							</Transform>
						</Transform>
					</Scene>
				</X3D>
			</td>
			<td width="50%" align="left" valign="top" scope="col">
				An IndexedFaceSet is used to define a polygonal shape. For example, it can be used to model a building.
				The building geometry is given by a set of points P={P0, P1, ..., Pn}
				and a set of polygons F={F0, F1, ..., Fm}. Each point Pi is given by its coordinates Pi=(xi,yi,zi).
				Each polygon Fi is defined by a list of m coplanar points (m >=3) given in counterclockwise order:
				Fi=(Pi0, Pi1, ... Pim)
				<pre>
	Example:
	P = {P0, P1, P2, P3, P4, P5, P6, P7, P8}
	with
        P0 = (-1.0, 0.0,  1.0)
	P1 = ( 1.0, 0.0,  1.0)
	P2 = ( 1.0, 0.0, -1.0)
	P3 = (-1.0, 0.0, -1.0)
        P4 = (-1.0, 2.0,  1.0)
	P5 = ( 1.0, 2.0,  1.0)
	P6 = ( 1.0, 2.0, -1.0)
	P7 = (-1.0, 2.0, -1.0)
	P8 = ( 0.0, 3.0,  0.0)
	F = {F0, F1, F2, F3, F4, F5, F6, F7, F8}
        wall: 
        F0 = (P0, P1, P5, P4)
        F1 = (P1, P2, P6, P5) 
	F2 = (P2, P3, P7, P6)
	F3 = (P3, P0, P4, P7)
	ground:
	F4 = (P0, P3, P2, P1)
	roof:
	F5 = (P7, P4, P8)
	F6 = (P4, P5, P8)
	F7 = (P5, P6, P8)
	F8 = (P6, P7, P8)
        </pre>
				<br>
				In the IndexedFaceSet the point set P is defined in the Coordinate node.
				The set of polygons F is defined in the attribute coordIndex. Each polygon is given by a list of point indices
				followed by -1 to indicate the end of a polygon and the beginning of a new one.
				<br>
				<pre class="prettyprint">
	&lt;X3D id="shapedata" width="600px" height="600px" style="float:left"&gt;
	  &lt;Scene&gt;
	    &lt;Shape&gt;
   	      &lt;Appearance&gt;
     	        &lt;Material diffuseColor="0.5 0.5 0.5"&gt; &lt;/Material&gt;
   	      &lt;/Appearance&gt;
  	      &lt;IndexedFaceSet solid="true" ccw ="true" 
   	        coordIndex=" 0 1 5 4 -1 1 2 6 5 -1 2 3 7 6 -1
                             3 0 4 7 -1 0 3 2 1 -1 7 4 8 -1
                             4 5 8 -1 5 6 8 -1 6 7 8 -1"&gt;
   	        &lt;Coordinate point="-1 0 1, 1 0 1, 1 0 -1, -1 0 -1,
             	            -1 2 1, 1 2 1, 1 2 -1, -1 2 -1, 0 3 0 " &gt; 
   	        &lt;/Coordinate&gt;
	      &lt;/IndexedFaceSet&gt;
	    &lt;/Shape&gt;
	  &lt;/Scene&gt;
	&lt;/X3D&gt; 
        </pre>
			</td>
Athanasios's avatar
Athanasios committed
240
241
242
		</tr>
	</table>
	<script type="text/javascript" src="x3dom.js"></script>
Athanasios's avatar
Athanasios committed
243
244
245
</body>

</html>