Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / lib3DMap / src / com / iver / ai2 / gvsig3d / gui / FeatureFactory.java @ 18954

History | View | Annotate | Download (19.4 KB)

1 14979 julio
package com.iver.ai2.gvsig3d.gui;
2
3 15151 julio
import java.awt.Color;
4 15137 julio
import java.util.HashMap;
5
import java.util.Iterator;
6 15033 julio
import java.util.List;
7 18267 jcampos
import java.util.Vector;
8 15033 julio
9 15095 julio
import com.iver.ai2.gvsig3d.resources.ResourcesFactory;
10 15137 julio
import com.iver.ai2.gvsig3d.utils.Punto3D;
11 15033 julio
import com.iver.cit.gvsig.fmap.core.v02.FLabel;
12
13 18219 mten
import es.upv.ai2.osgvp.AutoTransform;
14
import es.upv.ai2.osgvp.Group;
15
import es.upv.ai2.osgvp.Node;
16
import es.upv.ai2.osgvp.Optimizer;
17
import es.upv.ai2.osgvp.Vec3;
18
import es.upv.ai2.osgvp.Vec4;
19
import es.upv.ai2.osgvp.Optimizer.OptimizationOptions;
20
import es.upv.ai2.osgvp.features.PixelPoint;
21
import es.upv.ai2.osgvp.features.Polygon;
22
import es.upv.ai2.osgvp.features.Polyline;
23
import es.upv.ai2.osgvp.features.QuadPoint;
24
import es.upv.ai2.osgvp.features.TessellablePolygon;
25
import es.upv.ai2.osgvp.features.Text;
26
import es.upv.ai2.osgvp.planets.Planet;
27 14979 julio
28 15441 julio
public class FeatureFactory extends Group {
29 14979 julio
30 15011 julio
        private static double radius;
31 14979 julio
32 15033 julio
        static Planet planet;
33 14979 julio
34 15441 julio
        public FeatureFactory(double ra, Planet m_planet) {
35 14979 julio
                super();
36
                radius = ra;
37 15011 julio
                // this.setNodeName("VECTOR");
38 14979 julio
                planet = m_planet;
39
                init();
40
        }
41
42
        private void init() {
43
44 15033 julio
                // this.addChild(insertTexto("Polo norte", poloNorte));
45
                // this.addChild(insertTexto("MADRID", valenciaCar));
46 15046 julio
47 15332 julio
                // Vec3 posIni = new Vec3(0, 0, 0);
48
                // Vec3 posEnd = new Vec3(0, 0, 100000);
49 15046 julio
50 15332 julio
                // Polyline line = (Polyline) VectorTest.insertLineS(posIni, posEnd,
51
                // new Vec4(1.0, 1.0, 1.0, 1.0), 0);
52
                // if (planet.getType() == PlanetType.PLANE_MODE)
53
                // this.addChild(line);
54 15046 julio
55 14979 julio
        }
56
57 15332 julio
        // public Node insertTexto(String texto, Vec3 posicion) {
58 15587 rgaitan
        // // A�adiendo texto
59 15332 julio
        // Text text = new Text();
60
        // // text.setNodeName(texto);
61
        // text.setText(texto);
62
        // text.setCharacterSize(32);
63
        //
64
        // text.setAxisAlignment(Text.AxisAlignment.SCREEN);
65
        // text.setAlignment(Text.AlignmentType.CENTER_CENTER);
66
        // text.setCharacterSizeMode(Text.CharacterSizeMode.SCREEN_COORDS);
67
        // text.setPosition((float) posicion.x(), (float) posicion.y(),
68
        // (float) posicion.z());
69
        //
70
        // if (ResourcesFactory.exitsResouce("arial.ttf"))
71
        // text.setFont(ResourcesFactory.getResourcePath("arial.ttf"));
72
        // else
73
        // text.setFont("arial.ttf");
74
        // text.setAutoRotateToScreen(true);
75
        //
76
        //
77
        // Optimizer opt = new Optimizer();
78
        // opt.optimizeOptions(text, OptimizationOptions.SPATIALIZE_GROUPS);
79
        //
80
        // return text;
81
        // }
82
        // /**
83
        // * this method create a new 3D text. With a value and position. And insert
84
        // a
85
        // * point under 3D text
86
        // *
87
        // * @param texto
88
        // * text that is visible in 3D
89
        // * @param position
90
        // * Position of 3D text in cartesian coordinates
91
        // * @return New node
92
        // */
93
        // public void insertText(String texto, Vec3 posicion) {
94
        // posicion.setZ(posicion.z() + radius);
95
        // Vec3 e = planet.convertLatLongHeightToXYZ(posicion);
96
        //
97
        // this.addChild(insertPoint(e, new Vec4(1.0, 0, 0, 1.0)));
98
        //
99
        // this.addChild(insertTexto(texto, e));
100
        // }
101
        //
102
        // /**
103
        // * this method create a new 3D point. With a color and position
104
        // *
105
        // * @param color
106
        // * Color of the point
107
        // * @param position
108
        // * Position of 3D point in cartesian coordinates
109
        // * @return
110
        // */
111
        // public Node insertPoint(Vec3 position, Vec4 color) {
112
        // // Creating point
113
        // Point p = new Point();
114
        //
115
        // // Adding position and color
116
        // for (int i = 0; i < 1; i++) {
117
        // p.setPointSize(100);
118
        // p.addPoint(position, color);
119
        // }
120
        //
121
        // return p;
122
        // }
123 15033 julio
124 15020 julio
        /**
125
         * Method to create a new 3D text. With a value and position. Text aligment
126
         * is LEFT CENTER, and his font is "Arial.ttf"
127
         *
128
         * @param texto
129
         *            Text that is visible in 3D
130
         * @param position
131
         *            Position of 3D text in cartesian coordinates
132
         * @return New node
133
         */
134 15033 julio
        public static Node insertTextoS(String texto, Vec3 position, Vec4 color,
135 15129 julio
                        int tam, boolean inPixels) {
136 15332 julio
137 15020 julio
                // Creating text node
138 15011 julio
                Text text = new Text();
139 15020 julio
                // Set up text properties
140 15011 julio
                text.setText(texto);
141 15025 julio
                text.setCharacterSize(tam);
142 15175 julio
                // Select that the text will be in pixels or screen coordinates
143 15130 julio
                if (inPixels) {
144 15129 julio
                        text.setCharacterSizeMode(Text.CharacterSizeMode.SCREEN_COORDS);
145 15130 julio
                } else {
146 15129 julio
                        text.setCharacterSizeMode(Text.CharacterSizeMode.OBJECT_COORDS);
147
                }
148 15033 julio
                text.setColor(color);
149 15011 julio
                text.setAxisAlignment(Text.AxisAlignment.SCREEN);
150 15224 julio
                text.setAlignment(Text.AlignmentType.LEFT_BOTTOM);
151 15020 julio
                text.setPosition((float) position.x(), (float) position.y(),
152
                                (float) position.z());
153 15011 julio
154 15175 julio
                // Search font in resources directori
155 15095 julio
                if (ResourcesFactory.exitsResouce("arial.ttf"))
156
                        text.setFont(ResourcesFactory.getResourcePath("arial.ttf"));
157
                else
158
                        text.setFont("arial.ttf");
159 15011 julio
                text.setAutoRotateToScreen(true);
160 15332 julio
161 15175 julio
                // Optimizer generated nodes
162
                Optimizer opt = new Optimizer();
163 15441 julio
                opt.optimize(text, OptimizationOptions.SPATIALIZE_GROUPS);
164 15020 julio
165
                // Return node
166 15011 julio
                return text;
167 15332 julio
168 15011 julio
        }
169
170 15020 julio
        /**
171
         * Method to create a new 3D point. With a color, heigth and position.
172
         *
173
         * @param position
174
         *            Position of 3D text in cartesian coordinates
175
         * @param color
176
         *            color of the 3D point
177
         * @param tam
178
         *            the heigth of the point
179
         * @return New text node
180
         */
181 15011 julio
        public static Node insertPointS(Vec3 position, Vec4 color, int tam) {
182 15020 julio
                AutoTransform au = new AutoTransform();
183 15033 julio
                // Creating point
184 15441 julio
                PixelPoint p = new PixelPoint();
185 15033 julio
                // p.setDistanceAttenuation(new Vec3(0.0,0.0,0.0000001));
186 15057 rgaitan
                p.setPointSize(tam);
187 15020 julio
                p.addPoint(position, color);
188 15011 julio
189 15020 julio
                au.addChild(p);
190 15033 julio
                // return au;
191 15020 julio
                return p;
192
        }
193
194
        /**
195 15137 julio
         * Method to create a new 3D point. With a color, heigth and position.
196
         *
197
         * @param hash
198
         *            Hash Table that contains "Puntos3D" elements
199
         * @return
200
         */
201
        public static Node insertPointS(HashMap hash) {
202
203
                Group g = new Group();
204
205
                // Iterate over the keys in the map
206
                Iterator it = hash.keySet().iterator();
207
                while (it.hasNext()) {
208
                        // Get key
209 16453 jcampos
                        Double key = (Double) it.next();
210 15137 julio
                        List list = (List) hash.get(key);
211
212 15441 julio
                        PixelPoint p = new PixelPoint();
213 16453 jcampos
//                        ShapePoint p = new ShapePoint();
214 18219 mten
//                        es.upv.ai2.osgvp.features.Sphere s = new Sphere();
215 16453 jcampos
//                        p.setShape(s);
216
//                        s.setRadius(100);
217 15137 julio
                        for (Iterator iter = list.iterator(); iter.hasNext();) {
218 15441 julio
                                // Getting PixelPoint
219 15137 julio
                                Punto3D element = (Punto3D) iter.next();
220 16453 jcampos
//                                Vec4 color = element.getColor();
221
                                Vec4 color = new Vec4(1,0,0,1);
222
223 15332 julio
                                // Blending only is active if the alpha component are diferent
224
                                // that 1
225 15175 julio
                                if (color.w() != 1) {
226 15137 julio
                                        p.setEnabledBlending(true);
227
                                }
228 15176 julio
                                // Enabling antialiasing
229
                                p.setEnabledSmoothing(true);
230 15137 julio
231
                                // Set up size, position and color
232 16453 jcampos
//                                p.setPointSize(element.getZize());
233
                                p.setPointSize(20);
234 18219 mten
                                p.setLightingMode(Node.Mode.OFF | Node.Mode.PROTECTED);
235 15137 julio
                                p.addPoint(element.getPosition(), color);
236 16453 jcampos
//                                System.err.println("posicion del punto " +element.getPosition());
237 15137 julio
                        }
238
                        // Adding points to group
239
                        g.addChild(p);
240
                }
241 16453 jcampos
//                System.out.println("nuevo grupo");
242 15332 julio
243 15175 julio
                // Optimizer generated nodes
244 16453 jcampos
//                Optimizer opt = new Optimizer();
245
//                opt.optimize(g, OptimizationOptions.SPATIALIZE_GROUPS);
246 15332 julio
247 15137 julio
                return g;
248
        }
249
250
        /**
251 15020 julio
         * Method to add 3D points to specific point type. With a color, heigth and
252
         * position.
253
         *
254
         * @param point
255
         *            Node to add new 3D point
256
         * @param position
257
         *            Position of 3D text in cartesian coordinates
258
         * @param color
259
         *            color of the 3D point
260
         * @param tam
261
         *            the heigth of the point
262
         * @return New text node
263
         */
264 16453 jcampos
        public static void addPointToNode(Node point, Vec3 position, Vec4 color,
265 15020 julio
                        int tam) {
266 15332 julio
267 15441 julio
                PixelPoint p = null;
268 15033 julio
                // Getting point
269 15332 julio
                if (point != null)
270 15441 julio
                        p = (PixelPoint) point;
271 15020 julio
272 15033 julio
                // If not exits create new
273 15020 julio
                if (p == null)
274 15441 julio
                        p = new PixelPoint();
275 15020 julio
276 15176 julio
                // Blending only is active if the alpha component are diferent that 1
277 15175 julio
                if (color.w() != 1) {
278 15080 julio
                        p.setEnabledBlending(true);
279
                }
280
281 15033 julio
                // Set up size, position and color
282 15057 rgaitan
                p.setPointSize(tam);
283 15011 julio
                p.addPoint(position, color);
284 15332 julio
285 15175 julio
                // Optimizer generated nodes
286
                Optimizer opt = new Optimizer();
287 15441 julio
                opt.optimize(p, OptimizationOptions.SPATIALIZE_GROUPS);
288 15011 julio
289 15020 julio
        }
290
291
        /**
292
         * Method to create a new 3D line. With a color, heigth and position.
293
         *
294
         * @param ini
295
         *            Initial position of line
296
         * @param end
297
         *            End positon of line.
298
         * @param color
299
         *            color of the 3D point
300
         * @param tam
301
         *            the heigth of the point
302
         * @return New line node
303
         */
304
305
        public static Node insertLineS(Vec3 ini, Vec3 end, Vec4 color, int tam) {
306 15033 julio
                // Creating a polyline
307 15020 julio
                Polyline p = new Polyline(ini, end);
308
309 15033 julio
                // Set up parameter
310 15020 julio
                p.setWidth(2f);
311
                p.setPattern((short) 0xFFFF);
312
                p.setFactor(2);
313
                p.setColor(color);
314
315 15332 julio
                // Optimize the node
316 15175 julio
                Optimizer opt = new Optimizer();
317
                opt.optimize(p);
318 15332 julio
319 15033 julio
                // Return the node
320 15011 julio
                return p;
321
        }
322
323 15020 julio
        /**
324
         * Method to add new points to specific line type. With a color, heigth and
325
         * position.
326
         *
327
         * @param line
328
         *            Node to add new point
329
         * @param position
330
         *            Position of 3D point in cartesian coordinates
331
         * @param color
332
         *            color of the 3D point
333
         * @param tam
334
         *            the heigth of the point
335
         */
336
        public static void addNodeToLine(Node line, Vec3 position, Vec4 color,
337
                        int tam) {
338 15033 julio
                // Getting polyline
339 15020 julio
                Polyline p = (Polyline) line;
340
341 15033 julio
                // If not exits, create a new
342 15020 julio
                if (p == null)
343
                        p = new Polyline(position, position);
344
345 15033 julio
                // Add a point and color
346 15441 julio
                p.addVertex(position, color);
347 15020 julio
348
        }
349
350 15033 julio
        /**
351
         * Create a new point node with a color and size. Using a position of 3D
352
         * points
353
         *
354
         * @param position
355
         *            Position of 3D point
356
         * @param color
357
         *            Color of the 3D point
358
         * @param tam
359
         *            Size of the point (in pixels)
360
         * @return
361
         */
362 15011 julio
        public static Node insertPointS(Vec3[] position, Vec4 color, int tam) {
363 15033 julio
                // Creating point node
364 15441 julio
                PixelPoint p = new PixelPoint();
365 15011 julio
366 15033 julio
                // Set up parameters and insert position
367 15011 julio
                for (int i = 0; i < position.length; i++) {
368 15057 rgaitan
                        p.setPointSize(tam);
369 15011 julio
                        p.addPoint(position[i], color);
370
                }
371
372 15175 julio
                // Optimizer generated nodes
373
                Optimizer opt = new Optimizer();
374 15441 julio
                opt.optimize(p, OptimizationOptions.SPATIALIZE_GROUPS);
375 15332 julio
376 15033 julio
                // Return node
377 15011 julio
                return p;
378
        }
379 18103 jcampos
380
        /**
381
         * Create a new quad point node with a color, size and texture. Using a position of 3D
382
         * points
383
         *
384
         * @param position
385
         *            Position of 3D point
386
         * @param color
387
         *            Color of the 3D point
388
         * @param tam
389
         *            Size of the point (in pixels)
390
         * @return
391
         */
392
        public static Node insertQuadPoints(Vec3[] position, Vec4 color, float tam, String texture) {
393
                // Creating point node
394
                QuadPoint p = new QuadPoint(tam);
395 15011 julio
396 18103 jcampos
                // Set up parameters and insert position
397
                for (int i = 0; i < position.length; i++) {
398
                        p.setPointSize(tam);
399
                        p.addPoint(position[i], color);
400
                }
401
402
//                if (texture!=null)
403
//                        p.setTexture(texture);
404
405
                p.setBillboardingEnabled(true);
406
407
408
                // Optimizer generated nodes
409
                Optimizer opt = new Optimizer();
410
                opt.optimize(p, OptimizationOptions.SPATIALIZE_GROUPS);
411
412
                // Return node
413
                return p;
414
        }
415 15033 julio
        /**
416
         * Create a new tesselation poligon with a color using an array of 3D points
417
         *
418
         * @param points
419
         *            Array of 3D points
420
         * @param color
421
         *            Color of the poligon
422
         * @return Poligon node
423
         */
424 18103 jcampos
        public static Node generateQuadPoligon(Vec3 position, Vec4 color,String texture,float tam) {
425 15033 julio
                // Creating a polygon
426 15441 julio
                TessellablePolygon p = new TessellablePolygon();
427 15033 julio
428 18103 jcampos
//                PositionAttitudeTransform pt = new PositionAttitudeTransform();
429
                AutoTransform pt = new AutoTransform();
430
                pt.addChild(p);
431
                pt.setPosition(position);
432
                pt.setAutoRotateMode(AutoTransform.AutoRotateMode.ROTATE_TO_CAMERA);
433 15033 julio
                // Set up parameters
434
                // p.setType(Polygon.PolygonType.FILLED_POLYGON);
435
                p.setWidth(2f);
436
                // p.setPattern((short) 0xFFFF);
437
                // p.setFactor(2);
438 15020 julio
                p.setType(Polygon.PolygonType.FILLED_POLYGON);
439 15033 julio
                // p.setType(Polygon.PolygonType.EMPTY_POLYGON);
440
                // p.setType(Polygon.PolygonType.PATTERN_POLYGON);
441 18103 jcampos
442
                Vec3 bl = new Vec3(-tam/2,-tam/2,0.0);
443
                Vec3 br = new Vec3(tam/2,-tam/2,0.0);
444
                Vec3 tr = new Vec3(tam/2,tam/2,0.0);
445
                Vec3 tl = new Vec3(-tam/2,tam/2,0.0);
446
                p.setEnabledBlending(true);
447 18267 jcampos
//                Vector<Vec3> normal = new Vector<Vec3>();
448
//                normal.add(new Vec3(0,0,1));
449
//                p.setNormalArray(normal);
450
//                p.setNormalBinding(Geometry.AttributeBinding.BIND_OVERALL);
451 18103 jcampos
452 18267 jcampos
                p.setLightingMode(Mode.OFF | Mode.PROTECTED);
453 18103 jcampos
                p.addVertex(bl, color);
454
                p.addVertex(tl, color);
455
                p.addVertex(tr, color);
456
                p.addVertex(br, color);
457
458 18267 jcampos
//                p.setTwoSidedLighting(true);
459 18103 jcampos
460
                // if there was any texture to put we would include it
461
                if (texture != null)
462
                        p.setTexture(texture);
463
                // Tesselation of this poligon
464
                p.tesselate();
465 15033 julio
466 18103 jcampos
                // Optimizer generated nodes
467
//                Optimizer opt = new Optimizer();
468
//                opt.optimize(pt, OptimizationOptions.SPATIALIZE_GROUPS);
469
470
                // Return node
471
                return pt;
472
        }
473
474
        /**
475
         * Create a new tesselation poligon with a color using an array of 3D points
476
         *
477
         * @param points
478
         *            Array of 3D points
479
         * @param color
480
         *            Color of the poligon
481
         * @return Poligon node
482
         */
483
        public static Node insertPolygon(Vec3[] points, Vec4 color,String texture) {
484
                // Creating a polygon
485
                TessellablePolygon p = new TessellablePolygon();
486
487
                // Set up parameters
488
                // p.setType(Polygon.PolygonType.FILLED_POLYGON);
489
                p.setWidth(2f);
490
                // p.setPattern((short) 0xFFFF);
491
                // p.setFactor(2);
492
                p.setType(Polygon.PolygonType.FILLED_POLYGON);
493
                // p.setType(Polygon.PolygonType.EMPTY_POLYGON);
494
                // p.setType(Polygon.PolygonType.PATTERN_POLYGON);
495
496 15033 julio
                // Adding points
497
                for (int i = 0; i < points.length - 1; i++) {
498 15441 julio
                        p.addVertex(points[i], color);
499 15033 julio
                        // System.out.println("Position: " + inv[i].x() + " " + inv[i].y() +
500
                        // " " + inv[i].z());
501 15020 julio
                }
502 18103 jcampos
                // if there was any texture to put we would include it
503
                if (texture != null)
504
                        p.setTexture(texture);
505 15033 julio
                // Tesselation of this poligon
506 15038 rgaitan
                p.tesselate();
507 15020 julio
508 15332 julio
                // Optimizer generated nodes
509 15175 julio
                Optimizer opt = new Optimizer();
510 15441 julio
                opt.optimize(p, OptimizationOptions.SPATIALIZE_GROUPS);
511 15332 julio
512 15033 julio
                // Return node
513 15020 julio
                return p;
514
        }
515 18103 jcampos
516
517 15033 julio
518
        /**
519
         * Create a new tesselation poligon with a color using an List of 3D points
520
         *
521
         * @param points
522
         *            List of 3D points
523
         * @param color
524
         *            Color of the poligon
525
         * @return Poligon node
526
         */
527 18103 jcampos
        public static Node insertPolygon(List points, Vec4 color,String texture) {
528 15033 julio
                // Creating a polygon
529 15441 julio
                TessellablePolygon p = new TessellablePolygon();
530 15033 julio
531
                // Set up parameters
532
                // p.setType(Polygon.PolygonType.FILLED_POLYGON);
533
                p.setWidth(2f);
534
                // p.setPattern((short) 0xFFFF);
535
                // p.setFactor(2);
536 15029 julio
                p.setType(Polygon.PolygonType.FILLED_POLYGON);
537 15033 julio
                // p.setType(Polygon.PolygonType.EMPTY_POLYGON);
538
                // p.setType(Polygon.PolygonType.PATTERN_POLYGON);
539 15046 julio
540 15176 julio
                // Blending only is active if the alpha component are diferent that 1
541 15175 julio
                if (color.w() != 1) {
542 15080 julio
                        p.setEnabledBlending(true);
543
                }
544 15033 julio
                // Adding points
545 15029 julio
                for (int i = 0; i < points.size(); i++) {
546
                        Vec3 element = (Vec3) points.get(i);
547 15441 julio
                        p.addVertex(element, color);
548 15020 julio
                }
549 16453 jcampos
550 15046 julio
551 15080 julio
                // p.setTexture("C:/modelos3d/Images/land_shallow_topo_2048.jpg");
552 18103 jcampos
                // if there was any texture to put we would include it
553
                if (texture != null)
554
                        p.setTexture(texture);
555 15033 julio
                // Tesselation of this poligon
556 15080 julio
                p.tesselate();
557 15046 julio
558 15175 julio
                // Optimizer generated nodes
559
                Optimizer opt = new Optimizer();
560 15441 julio
                opt.optimize(p, OptimizationOptions.ALL_OPTIMIZATIONS);
561 15332 julio
562 15033 julio
                // Return node
563 15020 julio
                return p;
564
        }
565 15033 julio
566
        /**
567
         * Method to create a new 3D line. With a List of 3D points and a color
568
         *
569
         * @param points
570
         *            List of 3D points
571
         * @param color
572
         *            Color of the line
573
         * @return
574 15175 julio
         *
575 15033 julio
         */
576 15046 julio
        public static Node insertLine(List points, Vec4 color, float size) {
577 15033 julio
                Vec3 ori = null, fin = null;
578
579
                // Getting first points
580
                if (points.size() > 1) {
581
                        ori = (Vec3) points.get(0);
582
                        fin = (Vec3) points.get(1);
583 15029 julio
                }
584 15046 julio
585 15033 julio
                // If the line do not have more than 2 points return null
586 15029 julio
                if ((ori == null) || (fin == null))
587
                        return null;
588 15046 julio
589 15033 julio
                // Create new polyline
590
                Polyline p = new Polyline(ori, fin);
591 15479 rgaitan
                p.setVertexColor(0, color);
592
                p.setVertexColor(1, color);
593 15332 julio
594 15033 julio
                // Set up parameters
595 15046 julio
                p.setWidth(size);
596 15029 julio
                p.setPattern((short) 0xFFFF);
597
                p.setFactor(2);
598 15080 julio
599 15176 julio
                // Blending only is active if the alpha component are diferent that 1
600 15175 julio
                if (color.w() != 1) {
601 15080 julio
                        p.setEnabledBlending(true);
602
                }
603 15332 julio
604 15176 julio
                // Enabling antialiasing
605
                p.setEnabledSmoothing(true);
606 15080 julio
607 15029 julio
                p.setColor(color);
608
609 15033 julio
                // Adding points
610 15029 julio
                for (int i = 2; i < points.size(); i++) {
611
                        Vec3 element = (Vec3) points.get(i);
612 15441 julio
                        p.addVertex(element, color);
613 15029 julio
                }
614 15332 julio
615 15175 julio
                // Optimizer generated nodes
616
                Optimizer opt = new Optimizer();
617
                opt.optimize(p);
618 15033 julio
619
                // Return node
620 15029 julio
                return p;
621
622
        }
623 15033 julio
624
        /**
625
         * Create a new group of 3D points with a color and size. Using a List of 3D
626
         * points
627
         *
628
         * @param points
629
         *            List of 3D points
630
         * @param color
631
         *            Color of the line
632
         * @param size
633
         *            Size of the point (in pixels)
634
         * @return
635
         */
636 18954 jcampos
        public static Node insertPointL(List points, Vec4 color, float size) {
637 15033 julio
                // Creating point
638 15441 julio
                PixelPoint p = new PixelPoint();
639 15029 julio
640 15033 julio
                // Set up parameters
641 15057 rgaitan
                p.setPointSize(size);
642 15046 julio
643
                // Adding points
644 15029 julio
                for (int i = 0; i < points.size(); i++) {
645
                        Vec3 element = (Vec3) points.get(i);
646
                        p.addPoint(element, color);
647
                }
648 15332 julio
649 15175 julio
                // Optimizer generated nodes
650
                Optimizer opt = new Optimizer();
651
                opt.optimize(p);
652 15332 julio
653 15033 julio
                // Return node
654
                return p;
655
656
        }
657
658
        /**
659 15151 julio
         * Create a new group of 3D labels with a size and heigth. Using a List of
660
         * 3D points
661 15033 julio
         *
662 15151 julio
         * @param labels
663
         *            List of Flabels
664
         *
665 15033 julio
         * @param size
666
         *            Size of the labels
667 15151 julio
         * @param heigth
668
         *            Heigth of labels
669
         * @param inPixels
670
         *            True indicates that size is in pixel and false indicates real
671
         *            size;
672 15332 julio
         * @param type
673 15151 julio
         * @return Node group
674 15033 julio
         */
675 15129 julio
        public static Node insertLabels(List labels, int size, float heigth,
676 15177 julio
                        boolean inPixels, int planetType) {
677 15033 julio
                // Creating a group node
678
                Group p = new Group();
679 15046 julio
680 15033 julio
                // Getting total size
681
                int total = labels.size();
682 15046 julio
683
                // this is for control a max of labels because the system not suport
684
                // more than 10000
685 15033 julio
                int max = 3000;
686
                if (total > max)
687
                        total = max;
688 15046 julio
689 15033 julio
                if (labels != null) {
690
                        for (int i = 0; i < total; i++) {
691
                                FLabel f = (FLabel) labels.get(i);
692 15046 julio
693 15033 julio
                                // Set up parameters
694
695 15151 julio
                                // Getting color
696 15332 julio
                                // Color co = f.getColor();
697
                                Color co = new Color(255, 255, 255, 255);
698 15151 julio
                                float r, g, b, a;
699
                                r = ((float) co.getRed()) / 255.0f;
700
                                g = ((float) co.getGreen()) / 255.0f;
701
                                b = ((float) co.getBlue()) / 255.0f;
702
                                a = ((float) co.getAlpha()) / 255.0f;
703
                                // Set color
704
                                Vec4 textColor = new Vec4(r, g, b, a);
705
706
                                // Get label name
707 15033 julio
                                String label = f.getString();
708 15080 julio
                                // double heigth = h;
709 15177 julio
                                Vec3 pos = null;
710 15587 rgaitan
                                if (planetType == Planet.CoordinateSystemType.PROJECTED) {
711 15177 julio
                                        pos = new Vec3(f.getOrig().getX(), f.getOrig().getY(),
712 15223 julio
                                                        heigth);
713 15177 julio
                                } else {
714
                                        // Transform geodesical coordinates to cartesian
715 15332 julio
                                        Vec3 posGeo = new Vec3(f.getOrig().getY(), f.getOrig()
716
                                                        .getX(), heigth);
717
718 15177 julio
                                        pos = planet.convertLatLongHeightToXYZ(posGeo);
719
                                }
720 15033 julio
721
                                // Adding new child text nodes
722 15129 julio
                                p.addChild(insertTextoS(label, pos, textColor, size, inPixels));
723 15033 julio
                        }
724
                }
725
726 15175 julio
                // Optimizer generated nodes
727
                Optimizer opt = new Optimizer();
728 15441 julio
                opt.optimize(p, OptimizationOptions.SPATIALIZE_GROUPS);
729 15332 julio
730 15029 julio
                return p;
731
732
        }
733
734 14979 julio
}