1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "http://www.web3d.org/specifications/x3d-3.3.dtd">
3
<X3D profile='Full' version='3.3' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.3.xsd'>
5
<meta name='comment' content='World of Titania'/>
6
<meta name='created' content='Fri, 07 Oct 2016 02:56:59 GMT'/>
7
<meta name='creator' content='Holger Seelig'/>
8
<meta name='generator' content='Titania V2.0.1, http://titania.create3000.de'/>
9
<meta name='identifier' content='file:///home/holger/Projekte/Cobweb/cobweb.js/tests/Components/Shaders/LineMatrix3VertexAttribute.x3d'/>
10
<meta name='modified' content='Wed, 19 Oct 2016 08:51:01 GMT'/>
13
<ProtoDeclare name='Grid'>
15
<field accessType='inputOutput' type='SFVec3f' name='translation'/>
16
<field accessType='inputOutput' type='SFRotation' name='rotation'/>
17
<field accessType='inputOutput' type='SFVec3f' name='scale' value='1 1 1'/>
18
<field accessType='inputOutput' type='MFInt32' name='dimension' value='10, 10, 10'/>
19
<field accessType='inputOutput' type='MFInt32' name='majorLineEvery' value='5, 5, 5'/>
20
<field accessType='inputOutput' type='MFInt32' name='majorLineOffset' value='0, 0, 0'/>
21
<field accessType='inputOutput' type='SFColor' name='color' value='0.5 0.5 0.5'/>
22
<field accessType='inputOutput' type='SFFloat' name='transparency' value='0.61803'/>
23
<field accessType='inputOutput' type='SFColor' name='lineColor' value='1 0.7 0.7'/>
24
<field accessType='inputOutput' type='SFFloat' name='lineTransparency' value='0.8'/>
25
<field accessType='inputOutput' type='SFColor' name='majorLineColor' value='1 0.7 0.7'/>
26
<field accessType='inputOutput' type='SFFloat' name='majorLineTransparency' value='0.6'/>
27
<field accessType='initializeOnly' type='SFBool' name='solid' value='true'/>
32
<connect nodeField='translation' protoField='translation'/>
33
<connect nodeField='rotation' protoField='rotation'/>
34
<connect nodeField='scale' protoField='scale'/>
36
<Transform DEF='Plane'
37
rotation='-3.09087122910219e-08 0.70710528118436 0.707108281185553 3.14159'
41
<Material DEF='Material2'
44
<connect nodeField='emissiveColor' protoField='color'/>
45
<connect nodeField='transparency' protoField='transparency'/>
52
<connect nodeField='solid' protoField='solid'/>
57
<Shape DEF='MajorGrid'>
59
<Material DEF='MajorMaterial'>
61
<connect nodeField='emissiveColor' protoField='majorLineColor'/>
62
<connect nodeField='transparency' protoField='majorLineTransparency'/>
66
<IndexedLineSet DEF='MajorGrid_1'
67
coordIndex='0, 1, -1, 2, 3, -1, 4, 5, -1, 6, 7, -1, 8, 9, -1, 10, 11, -1'>
69
point='-5 0 -5.25, -5 0 5.25, 0 0 -5.25, 0 0 5.25, 5 0 -5.25, 5 0 5.25, -5.25 0 -5, 5.25 0 -5, -5.25 0 0, 5.25 0 0, -5.25 0 5, 5.25 0 5'/>
72
<Shape DEF='MinorGrid'>
74
<Material DEF='MinorMaterial'>
76
<connect nodeField='emissiveColor' protoField='lineColor'/>
77
<connect nodeField='transparency' protoField='lineTransparency'/>
81
<IndexedLineSet DEF='MinorGrid_1'
82
coordIndex='0, 1, -1, 2, 3, -1, 4, 5, -1, 6, 7, -1, 8, 9, -1, 10, 11, -1, 12, 13, -1, 14, 15, -1, 16, 17, -1, 18, 19, -1, 20, 21, -1, 22, 23, -1, 24, 25, -1, 26, 27, -1, 28, 29, -1, 30, 31, -1'>
84
point='-4 0 -5, -4 0 5, -3 0 -5, -3 0 5, -2 0 -5, -2 0 5, -1 0 -5, -1 0 5, 1 0 -5, 1 0 5, 2 0 -5, 2 0 5, 3 0 -5, 3 0 5, 4 0 -5, 4 0 5, -5 0 -4, 5 0 -4, -5 0 -3, 5 0 -3, -5 0 -2, 5 0 -2, -5 0 -1, 5 0 -1, -5 0 1, 5 0 1, -5 0 2, 5 0 2, -5 0 3, 5 0 3, -5 0 4, 5 0 4'/>
87
<Shape DEF='MajorPoints'>
90
linewidthScaleFactor='6'/>
91
<Material USE='MajorMaterial'/>
93
<PointSet DEF='MajorPoints_1'>
95
point='0 -5 0, 0 0 0, 0 5 0'/>
98
<Shape DEF='MinorPoints'>
101
linewidthScaleFactor='4'/>
102
<Material USE='MinorMaterial'/>
104
<PointSet DEF='MinorPoints_1'>
106
point='0 -4 0, 0 -3 0, 0 -2 0, 0 -1 0, 0 1 0, 0 2 0, 0 3 0, 0 4 0'/>
110
<Script DEF='GridScript'
113
<field accessType='inputOutput' type='MFInt32' name='dimension'/>
114
<field accessType='inputOutput' type='MFInt32' name='majorLineEvery'/>
115
<field accessType='inputOutput' type='MFInt32' name='majorLineOffset'/>
116
<field accessType='initializeOnly' type='SFNode' name='plane'>
117
<Transform USE='Plane'/>
119
<field accessType='initializeOnly' type='SFNode' name='majorGrid'>
120
<IndexedLineSet USE='MajorGrid_1'/>
122
<field accessType='initializeOnly' type='SFNode' name='minorGrid'>
123
<IndexedLineSet USE='MinorGrid_1'/>
125
<field accessType='initializeOnly' type='SFNode' name='majorPoints'>
126
<PointSet USE='MajorPoints_1'/>
128
<field accessType='initializeOnly' type='SFNode' name='minorPoints'>
129
<PointSet USE='MinorPoints_1'/>
132
<connect nodeField='dimension' protoField='dimension'/>
133
<connect nodeField='majorLineEvery' protoField='majorLineEvery'/>
134
<connect nodeField='majorLineOffset' protoField='majorLineOffset'/>
138
function initialize ()
143
function eventsProcessed ()
147
plane .scale = new SFVec3f (dimension [0], dimension [2], 1);
151
generateGrid (true, majorGrid);
152
generateGrid (false, minorGrid);
156
generatePoints (true, majorPoints .coord .point);
157
generatePoints (false, minorPoints .coord .point);
160
function generateGrid (major, grid)
162
var point = grid .coord .point;
163
var coordIndex = new MFInt32 ();
164
var scaleX1_2 = dimension [0] / 2;
165
var scaleZ1_2 = dimension [2] / 2;
166
var majorAdd = major / 4;
169
for (var i = 0, size = dimension [0] + 1; i < size; ++ i)
171
if (major - isMajorLine (i, 0))
174
var x = -scaleX1_2 + i;
176
point [p] = new SFVec3f (x, 0, -scaleZ1_2 - majorAdd);
177
point [p + 1] = new SFVec3f (x, 0, scaleZ1_2 + majorAdd);
178
coordIndex [coordIndex .length] = p;
179
coordIndex [coordIndex .length] = p + 1;
180
coordIndex [coordIndex .length] = -1;
185
for (var i = 0, size = dimension [2] + 1; i < size; ++ i)
187
if (major - isMajorLine (i, 2))
190
var z = -scaleZ1_2 + i;
192
point [p] = new SFVec3f (-scaleX1_2 - majorAdd, 0, z);
193
point [p + 1] = new SFVec3f ( scaleX1_2 + majorAdd, 0, z);
194
coordIndex [coordIndex .length] = p;
195
coordIndex [coordIndex .length] = p + 1;
196
coordIndex [coordIndex .length] = -1;
203
grid .set_coordIndex = coordIndex;
206
function generatePoints (major, point)
208
var scaleY1_2 = -dimension [1] / 2;
211
for (var i = 0, size = dimension [1] + 1; i < size; ++ i)
213
if (major - isMajorLine (i, 1))
216
point [p] = new SFVec3f (0, scaleY1_2 + i, 0);
223
function isMajorLine (i, index)
225
for (var d = index; d < majorLineEvery .length; d += 3)
227
if (isMajor (i, dimension [index], majorLineEvery [d], majorLineOffset [d]))
234
function isMajor (i, dimension, majorLineEvery, majorLineOffset)
238
var index = Math .floor (i - dimension / 2 - majorLineOffset);
240
return !(index % majorLineEvery);
250
<MetadataSet DEF='Titania'
252
reference='http://titania.create3000.de'>
253
<MetadataSet DEF='AngleGrid' containerField='value'
255
reference='http://titania.create3000.de'>
256
<MetadataBoolean DEF='enabled' containerField='value'
258
reference='http://titania.create3000.de'
261
<MetadataSet DEF='Grid' containerField='value'
263
reference='http://titania.create3000.de'>
264
<MetadataBoolean DEF='enabled_1' containerField='value'
266
reference='http://titania.create3000.de'
269
<MetadataSet DEF='NavigationInfo' containerField='value'
270
name='NavigationInfo'
271
reference='http://titania.create3000.de'>
272
<MetadataString DEF='type' containerField='value'
274
reference='http://titania.create3000.de'
277
<MetadataSet DEF='Viewpoint' containerField='value'
279
reference='http://titania.create3000.de'>
280
<MetadataDouble DEF='position' containerField='value'
282
reference='http://titania.create3000.de'
284
<MetadataDouble DEF='orientation' containerField='value'
286
reference='http://titania.create3000.de'
288
<MetadataDouble DEF='centerOfRotation' containerField='value'
289
name='centerOfRotation'
290
reference='http://titania.create3000.de'
293
<MetadataSet DEF='Selection' containerField='value'
295
reference='http://titania.create3000.de'>
296
<MetadataSet DEF='previous' containerField='value'
298
reference='http://titania.create3000.de'>
299
<Transform DEF='Rectangle2D' containerField='value'>
305
<![CDATA[data:text/plain,
307
uniform mat4 x3d_ProjectionMatrix;
308
uniform mat4 x3d_ModelViewMatrix;
310
attribute vec4 x3d_Vertex;
311
attribute mat3 rotation;
316
vec4 vertex = vec4 (rotation * vec3 (x3d_Vertex), 1.0);
318
gl_Position = x3d_ProjectionMatrix * x3d_ModelViewMatrix * vertex;
323
<![CDATA[data:text/plain,
328
gl_FragColor = vec4 (1.0, 0.0, 0.0, 1.0);
334
coordIndex='0, 1, 2, 0, -1, 2, 3, 0'>
335
<Matrix3VertexAttribute
337
value='0 0 -1 0 1 0 1 0 0, 0 0 -1 0 1 0 1 0 0, 0 0 -1 0 1 0 1 0 0, 0 0 -1 0 1 0 1 0 0'/>
339
point='0 -1 -1, 0 -1 1, 0 1 1, 0 1 -1'/>
344
<MetadataSet DEF='children' containerField='value'
346
reference='http://titania.create3000.de'>
347
<Transform DEF='Text' containerField='value'
348
translation='-5.01454 -2.98505 0'>
354
string='"Must show a 2x2 rectangle."'
366
<ProtoInstance name='Grid'>
367
<fieldValue name='rotation' value='1 0 0 1.5707963267949'/>
368
<fieldValue name='transparency' value='0.8'/>
370
<Transform USE='Rectangle2D'/>
371
<Transform USE='Text'/>