1 // obj.cxx -- routines to handle loading scenery and building the plib
4 // Written by Curtis Olson, started October 1997.
6 // Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 # include <simgear_config.h>
31 #include <simgear/compiler.h>
35 #include <osg/Geometry>
38 #include <osg/MatrixTransform>
40 #include <osg/StateSet>
43 #include <simgear/debug/logstream.hxx>
44 #include <simgear/io/sg_binobj.hxx>
45 #include <simgear/math/sg_geodesy.hxx>
46 #include <simgear/math/sg_random.h>
47 #include <simgear/scene/material/mat.hxx>
48 #include <simgear/scene/material/matlib.hxx>
49 #include <simgear/scene/model/SGOffsetTransform.hxx>
50 #include <simgear/scene/util/SGUpdateVisitor.hxx>
51 #include <simgear/scene/util/SGNodeMasks.hxx>
52 #include <simgear/threads/SGThread.hxx>
53 #include <simgear/threads/SGGuard.hxx>
55 #include "SGTexturedTriangleBin.hxx"
56 #include "SGLightBin.hxx"
57 #include "SGDirectionalLightBin.hxx"
59 #include "pt_lights.hxx"
61 typedef std::map<std::string,SGTexturedTriangleBin> SGMaterialTriangleMap;
62 typedef std::list<SGLightBin> SGLightListBin;
63 typedef std::list<SGDirectionalLightBin> SGDirectionalLightListBin;
65 struct SGTileGeometryBin {
66 SGMaterialTriangleMap materialTriangleMap;
67 SGLightBin tileLights;
68 SGLightBin randomTileLights;
69 SGDirectionalLightBin runwayLights;
70 SGDirectionalLightBin taxiLights;
71 SGDirectionalLightListBin vasiLights;
72 SGDirectionalLightListBin rabitLights;
73 SGLightListBin odalLights;
74 SGDirectionalLightListBin reilLights;
77 getMaterialLightColor(const SGMaterial* material)
80 return SGVec4f(1, 1, 1, 0.8);
81 return material->get_light_color();
85 addPointGeometry(SGLightBin& lights,
86 const std::vector<SGVec3d>& vertices,
88 const int_list& pts_v)
90 for (unsigned i = 0; i < pts_v.size(); ++i)
91 lights.insert(toVec3f(vertices[pts_v[i]]), color);
95 addPointGeometry(SGDirectionalLightBin& lights,
96 const std::vector<SGVec3d>& vertices,
97 const std::vector<SGVec3f>& normals,
99 const int_list& pts_v,
100 const int_list& pts_n)
102 // If the normal indices match the vertex indices, use seperate
103 // normal indices. Else reuse the vertex indices for the normals.
104 if (pts_v.size() == pts_n.size()) {
105 for (unsigned i = 0; i < pts_v.size(); ++i)
106 lights.insert(toVec3f(vertices[pts_v[i]]), normals[pts_n[i]], color);
108 for (unsigned i = 0; i < pts_v.size(); ++i)
109 lights.insert(toVec3f(vertices[pts_v[i]]), normals[pts_v[i]], color);
114 insertPtGeometry(const SGBinObject& obj, SGMaterialLib* matlib)
116 if (obj.get_pts_v().size() != obj.get_pts_n().size()) {
117 SG_LOG(SG_TERRAIN, SG_ALERT,
118 "Group list sizes for points do not match!");
122 for (unsigned grp = 0; grp < obj.get_pts_v().size(); ++grp) {
123 std::string materialName = obj.get_pt_materials()[grp];
124 SGMaterial* material = matlib->find(materialName);
125 SGVec4f color = getMaterialLightColor(material);
127 if (3 <= materialName.size() && materialName.substr(0, 3) != "RWY") {
128 // Just plain lights. Not something for the runway.
129 addPointGeometry(tileLights, obj.get_wgs84_nodes(), color,
130 obj.get_pts_v()[grp]);
131 } else if (materialName == "RWY_BLUE_TAXIWAY_LIGHTS"
132 || materialName == "RWY_GREEN_TAXIWAY_LIGHTS") {
133 addPointGeometry(taxiLights, obj.get_wgs84_nodes(), obj.get_normals(),
134 color, obj.get_pts_v()[grp], obj.get_pts_n()[grp]);
135 } else if (materialName == "RWY_VASI_LIGHTS") {
136 vasiLights.push_back(SGDirectionalLightBin());
137 addPointGeometry(vasiLights.back(), obj.get_wgs84_nodes(),
138 obj.get_normals(), color, obj.get_pts_v()[grp],
139 obj.get_pts_n()[grp]);
140 } else if (materialName == "RWY_SEQUENCED_LIGHTS") {
141 rabitLights.push_back(SGDirectionalLightBin());
142 addPointGeometry(rabitLights.back(), obj.get_wgs84_nodes(),
143 obj.get_normals(), color, obj.get_pts_v()[grp],
144 obj.get_pts_n()[grp]);
145 } else if (materialName == "RWY_ODALS_LIGHTS") {
146 odalLights.push_back(SGLightBin());
147 addPointGeometry(odalLights.back(), obj.get_wgs84_nodes(),
148 color, obj.get_pts_v()[grp]);
149 } else if (materialName == "RWY_REIL_LIGHTS") {
150 reilLights.push_back(SGDirectionalLightBin());
151 addPointGeometry(reilLights.back(), obj.get_wgs84_nodes(),
152 obj.get_normals(), color, obj.get_pts_v()[grp],
153 obj.get_pts_n()[grp]);
155 // what is left must be runway lights
156 addPointGeometry(runwayLights, obj.get_wgs84_nodes(),
157 obj.get_normals(), color, obj.get_pts_v()[grp],
158 obj.get_pts_n()[grp]);
167 getTexCoord(const std::vector<SGVec2f>& texCoords, const int_list& tc,
168 const SGVec2f& tcScale, unsigned i)
172 else if (tc.size() == 1)
173 return mult(texCoords[tc[0]], tcScale);
175 return mult(texCoords[tc[i]], tcScale);
179 addTriangleGeometry(SGTexturedTriangleBin& triangles,
180 const std::vector<SGVec3d>& vertices,
181 const std::vector<SGVec3f>& normals,
182 const std::vector<SGVec2f>& texCoords,
183 const int_list& tris_v,
184 const int_list& tris_n,
185 const int_list& tris_tc,
186 const SGVec2f& tcScale)
188 if (tris_v.size() != tris_n.size()) {
189 // If the normal indices do not match, they should be inmplicitly
190 // the same than the vertex indices. So just call ourselves again
191 // with the matching index vector.
192 addTriangleGeometry(triangles, vertices, normals, texCoords,
193 tris_v, tris_v, tris_tc, tcScale);
197 for (unsigned i = 2; i < tris_v.size(); i += 3) {
199 v0.vertex = toVec3f(vertices[tris_v[i-2]]);
200 v0.normal = normals[tris_n[i-2]];
201 v0.texCoord = getTexCoord(texCoords, tris_tc, tcScale, i-2);
203 v1.vertex = toVec3f(vertices[tris_v[i-1]]);
204 v1.normal = normals[tris_n[i-1]];
205 v1.texCoord = getTexCoord(texCoords, tris_tc, tcScale, i-1);
207 v2.vertex = toVec3f(vertices[tris_v[i]]);
208 v2.normal = normals[tris_n[i]];
209 v2.texCoord = getTexCoord(texCoords, tris_tc, tcScale, i);
210 triangles.insert(v0, v1, v2);
215 addStripGeometry(SGTexturedTriangleBin& triangles,
216 const std::vector<SGVec3d>& vertices,
217 const std::vector<SGVec3f>& normals,
218 const std::vector<SGVec2f>& texCoords,
219 const int_list& strips_v,
220 const int_list& strips_n,
221 const int_list& strips_tc,
222 const SGVec2f& tcScale)
224 if (strips_v.size() != strips_n.size()) {
225 // If the normal indices do not match, they should be inmplicitly
226 // the same than the vertex indices. So just call ourselves again
227 // with the matching index vector.
228 addStripGeometry(triangles, vertices, normals, texCoords,
229 strips_v, strips_v, strips_tc, tcScale);
233 for (unsigned i = 2; i < strips_v.size(); ++i) {
235 v0.vertex = toVec3f(vertices[strips_v[i-2]]);
236 v0.normal = normals[strips_n[i-2]];
237 v0.texCoord = getTexCoord(texCoords, strips_tc, tcScale, i-2);
239 v1.vertex = toVec3f(vertices[strips_v[i-1]]);
240 v1.normal = normals[strips_n[i-1]];
241 v1.texCoord = getTexCoord(texCoords, strips_tc, tcScale, i-1);
243 v2.vertex = toVec3f(vertices[strips_v[i]]);
244 v2.normal = normals[strips_n[i]];
245 v2.texCoord = getTexCoord(texCoords, strips_tc, tcScale, i);
247 triangles.insert(v1, v0, v2);
249 triangles.insert(v0, v1, v2);
254 addFanGeometry(SGTexturedTriangleBin& triangles,
255 const std::vector<SGVec3d>& vertices,
256 const std::vector<SGVec3f>& normals,
257 const std::vector<SGVec2f>& texCoords,
258 const int_list& fans_v,
259 const int_list& fans_n,
260 const int_list& fans_tc,
261 const SGVec2f& tcScale)
263 if (fans_v.size() != fans_n.size()) {
264 // If the normal indices do not match, they should be implicitly
265 // the same than the vertex indices. So just call ourselves again
266 // with the matching index vector.
267 addFanGeometry(triangles, vertices, normals, texCoords,
268 fans_v, fans_v, fans_tc, tcScale);
273 v0.vertex = toVec3f(vertices[fans_v[0]]);
274 v0.normal = normals[fans_n[0]];
275 v0.texCoord = getTexCoord(texCoords, fans_tc, tcScale, 0);
277 v1.vertex = toVec3f(vertices[fans_v[1]]);
278 v1.normal = normals[fans_n[1]];
279 v1.texCoord = getTexCoord(texCoords, fans_tc, tcScale, 1);
280 for (unsigned i = 2; i < fans_v.size(); ++i) {
282 v2.vertex = toVec3f(vertices[fans_v[i]]);
283 v2.normal = normals[fans_n[i]];
284 v2.texCoord = getTexCoord(texCoords, fans_tc, tcScale, i);
285 triangles.insert(v0, v1, v2);
290 SGVec2f getTexCoordScale(const std::string& name, SGMaterialLib* matlib)
293 return SGVec2f(1, 1);
294 SGMaterial* material = matlib->find(name);
296 return SGVec2f(1, 1);
298 return material->get_tex_coord_scale();
302 insertSurfaceGeometry(const SGBinObject& obj, SGMaterialLib* matlib)
304 if (obj.get_tris_n().size() < obj.get_tris_v().size() ||
305 obj.get_tris_tc().size() < obj.get_tris_v().size()) {
306 SG_LOG(SG_TERRAIN, SG_ALERT,
307 "Group list sizes for triangles do not match!");
311 for (unsigned grp = 0; grp < obj.get_tris_v().size(); ++grp) {
312 std::string materialName = obj.get_tri_materials()[grp];
313 SGVec2f tcScale = getTexCoordScale(materialName, matlib);
314 addTriangleGeometry(materialTriangleMap[materialName],
315 obj.get_wgs84_nodes(), obj.get_normals(),
316 obj.get_texcoords(), obj.get_tris_v()[grp],
317 obj.get_tris_n()[grp], obj.get_tris_tc()[grp],
321 if (obj.get_strips_n().size() < obj.get_strips_v().size() ||
322 obj.get_strips_tc().size() < obj.get_strips_v().size()) {
323 SG_LOG(SG_TERRAIN, SG_ALERT,
324 "Group list sizes for strips do not match!");
327 for (unsigned grp = 0; grp < obj.get_strips_v().size(); ++grp) {
328 std::string materialName = obj.get_strip_materials()[grp];
329 SGVec2f tcScale = getTexCoordScale(materialName, matlib);
330 addStripGeometry(materialTriangleMap[materialName],
331 obj.get_wgs84_nodes(), obj.get_normals(),
332 obj.get_texcoords(), obj.get_strips_v()[grp],
333 obj.get_strips_n()[grp], obj.get_strips_tc()[grp],
337 if (obj.get_fans_n().size() < obj.get_fans_v().size() ||
338 obj.get_fans_tc().size() < obj.get_fans_v().size()) {
339 SG_LOG(SG_TERRAIN, SG_ALERT,
340 "Group list sizes for fans do not match!");
343 for (unsigned grp = 0; grp < obj.get_fans_v().size(); ++grp) {
344 std::string materialName = obj.get_fan_materials()[grp];
345 SGVec2f tcScale = getTexCoordScale(materialName, matlib);
346 addFanGeometry(materialTriangleMap[materialName],
347 obj.get_wgs84_nodes(), obj.get_normals(),
348 obj.get_texcoords(), obj.get_fans_v()[grp],
349 obj.get_fans_n()[grp], obj.get_fans_tc()[grp],
355 osg::Node* getSurfaceGeometry(SGMaterialLib* matlib) const
357 if (materialTriangleMap.empty())
360 osg::Geode* geode = new osg::Geode;
361 SGMaterialTriangleMap::const_iterator i;
362 for (i = materialTriangleMap.begin(); i != materialTriangleMap.end(); ++i) {
363 // CHUNCKED (sic) here splits up unconnected triangles parts of
364 // the mesh into different Geometry sets, presumably for better
365 // culling. I (timoore) believe it is more performant to build
366 // the biggest indexed sets possible at the expense of tight
370 SGMaterial *mat = matlib->find(i->first);
372 std::list<SGTexturedTriangleBin::TriangleVector> connectSets;
373 i->second.getConnectedSets(connectSets);
375 std::list<SGTexturedTriangleBin::TriangleVector>::iterator j;
376 for (j = connectSets.begin(); j != connectSets.end(); ++j) {
377 osg::Geometry* geometry = i->second.buildGeometry(*j);
379 geometry->setStateSet(mat->get_state());
380 geode->addDrawable(geometry);
383 osg::Geometry* geometry = i->second.buildGeometry();
384 SGMaterial *mat = matlib->find(i->first);
386 geometry->setStateSet(mat->get_state());
387 geode->addDrawable(geometry);
393 void computeRandomSurfaceLights(SGMaterialLib* matlib)
395 SGMaterialTriangleMap::const_iterator i;
396 for (i = materialTriangleMap.begin(); i != materialTriangleMap.end(); ++i) {
397 SGMaterial *mat = matlib->find(i->first);
401 float coverage = mat->get_light_coverage();
404 if (coverage < 10000.0) {
405 SG_LOG(SG_INPUT, SG_ALERT, "Light coverage is "
406 << coverage << ", pushing up to 10000");
410 // generate a repeatable random seed
411 sg_srandom(unsigned(coverage));
413 std::vector<SGVec3f> randomPoints;
414 i->second.addRandomSurfacePoints(coverage, 3, randomPoints);
415 std::vector<SGVec3f>::iterator j;
416 for (j = randomPoints.begin(); j != randomPoints.end(); ++j) {
417 float zombie = sg_random();
418 // factor = sg_random() ^ 2, range = 0 .. 1 concentrated towards 0
419 float factor = sg_random();
424 if ( zombie > 0.5 ) {
425 // 50% chance of yellowish
426 color = SGVec4f(0.9f, 0.9f, 0.3f, bright - factor * 0.2f);
427 } else if (zombie > 0.15f) {
428 // 35% chance of whitish
429 color = SGVec4f(0.9, 0.9f, 0.8f, bright - factor * 0.2f);
430 } else if (zombie > 0.05f) {
431 // 10% chance of orangish
432 color = SGVec4f(0.9f, 0.6f, 0.2f, bright - factor * 0.2f);
434 // 5% chance of redish
435 color = SGVec4f(0.9f, 0.2f, 0.2f, bright - factor * 0.2f);
437 randomTileLights.insert(*j, color);
442 bool insertBinObj(const SGBinObject& obj, SGMaterialLib* matlib)
444 if (!insertPtGeometry(obj, matlib))
446 if (!insertSurfaceGeometry(obj, matlib))
453 class SGTileUpdateCallback : public osg::NodeCallback {
455 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
457 assert(dynamic_cast<osg::Switch*>(node));
458 assert(dynamic_cast<SGUpdateVisitor*>(nv));
460 osg::Switch* lightSwitch = static_cast<osg::Switch*>(node);
461 SGUpdateVisitor* updateVisitor = static_cast<SGUpdateVisitor*>(nv);
463 // The current sun angle in degree
464 float sun_angle = updateVisitor->getSunAngleDeg();
467 lightSwitch->setValue(0, true);
468 if (sun_angle > 85 || updateVisitor->getVisibility() < 5000) {
470 lightSwitch->setValue(1, true);
471 lightSwitch->setValue(2, true);
474 lightSwitch->setValue(1, false);
475 lightSwitch->setValue(2, false);
479 if ( sun_angle > 95 )
480 lightSwitch->setValue(5, true);
482 lightSwitch->setValue(5, false);
483 if ( sun_angle > 92 )
484 lightSwitch->setValue(4, true);
486 lightSwitch->setValue(4, false);
487 if ( sun_angle > 89 )
488 lightSwitch->setValue(3, true);
490 lightSwitch->setValue(3, false);
496 class SGRunwayLightFogUpdateCallback : public osg::StateAttribute::Callback {
498 virtual void operator () (osg::StateAttribute* sa, osg::NodeVisitor* nv)
500 assert(dynamic_cast<SGUpdateVisitor*>(nv));
501 assert(dynamic_cast<osg::Fog*>(sa));
502 SGUpdateVisitor* updateVisitor = static_cast<SGUpdateVisitor*>(nv);
503 osg::Fog* fog = static_cast<osg::Fog*>(sa);
504 fog->setMode(osg::Fog::EXP2);
505 fog->setColor(updateVisitor->getFogColor().osg());
506 fog->setDensity(updateVisitor->getRunwayFogExp2Density());
510 class SGTaxiLightFogUpdateCallback : public osg::StateAttribute::Callback {
512 virtual void operator () (osg::StateAttribute* sa, osg::NodeVisitor* nv)
514 assert(dynamic_cast<SGUpdateVisitor*>(nv));
515 assert(dynamic_cast<osg::Fog*>(sa));
516 SGUpdateVisitor* updateVisitor = static_cast<SGUpdateVisitor*>(nv);
517 osg::Fog* fog = static_cast<osg::Fog*>(sa);
518 fog->setMode(osg::Fog::EXP2);
519 fog->setColor(updateVisitor->getFogColor().osg());
520 fog->setDensity(updateVisitor->getTaxiFogExp2Density());
524 class SGGroundLightFogUpdateCallback : public osg::StateAttribute::Callback {
526 virtual void operator () (osg::StateAttribute* sa, osg::NodeVisitor* nv)
528 assert(dynamic_cast<SGUpdateVisitor*>(nv));
529 assert(dynamic_cast<osg::Fog*>(sa));
530 SGUpdateVisitor* updateVisitor = static_cast<SGUpdateVisitor*>(nv);
531 osg::Fog* fog = static_cast<osg::Fog*>(sa);
532 fog->setMode(osg::Fog::EXP2);
533 fog->setColor(updateVisitor->getFogColor().osg());
534 fog->setDensity(updateVisitor->getGroundLightsFogExp2Density());
539 SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool use_random_objects)
542 if (!obj.read_bin(path))
545 SGTileGeometryBin tileGeometryBin;
546 if (!tileGeometryBin.insertBinObj(obj, matlib))
549 SGVec3d center = obj.get_gbs_center2();
550 SGGeod geodPos = SGGeod::fromCart(center);
551 SGQuatd hlOr = SGQuatd::fromLonLat(geodPos);
552 SGVec3f up = toVec3f(hlOr.backTransform(SGVec3d(0, 0, -1)));
554 osg::Group* vasiLights = new osg::Group;
555 vasiLights->setCullCallback(new SGPointSpriteLightCullCallback(osg::Vec3(1, 0.0001, 0.000001), 6));
556 osg::StateSet* stateSet = vasiLights->getOrCreateStateSet();
557 osg::Fog* fog = new osg::Fog;
558 fog->setUpdateCallback(new SGRunwayLightFogUpdateCallback);
559 stateSet->setAttribute(fog);
561 osg::Group* rwyLights = new osg::Group;
562 rwyLights->setCullCallback(new SGPointSpriteLightCullCallback);
563 stateSet = rwyLights->getOrCreateStateSet();
565 fog->setUpdateCallback(new SGRunwayLightFogUpdateCallback);
566 stateSet->setAttribute(fog);
568 osg::Group* taxiLights = new osg::Group;
569 taxiLights->setCullCallback(new SGPointSpriteLightCullCallback);
570 stateSet = taxiLights->getOrCreateStateSet();
572 fog->setUpdateCallback(new SGTaxiLightFogUpdateCallback);
573 stateSet->setAttribute(fog);
575 osg::Group* groundLights0 = new osg::Group;
576 stateSet = groundLights0->getOrCreateStateSet();
578 fog->setUpdateCallback(new SGGroundLightFogUpdateCallback);
579 stateSet->setAttribute(fog);
581 osg::Group* groundLights1 = new osg::Group;
582 stateSet = groundLights1->getOrCreateStateSet();
584 fog->setUpdateCallback(new SGGroundLightFogUpdateCallback);
585 stateSet->setAttribute(fog);
587 osg::Group* groundLights2 = new osg::Group;
588 stateSet = groundLights2->getOrCreateStateSet();
590 fog->setUpdateCallback(new SGGroundLightFogUpdateCallback);
591 stateSet->setAttribute(fog);
593 osg::Switch* lightSwitch = new osg::Switch;
594 lightSwitch->setUpdateCallback(new SGTileUpdateCallback);
595 lightSwitch->addChild(vasiLights, true);
596 lightSwitch->addChild(rwyLights, true);
597 lightSwitch->addChild(taxiLights, true);
598 lightSwitch->addChild(groundLights0, true);
599 lightSwitch->addChild(groundLights1, true);
600 lightSwitch->addChild(groundLights2, true);
602 osg::Group* lightGroup = new SGOffsetTransform(0.94);
603 lightGroup->addChild(lightSwitch);
605 osg::LOD* lightLOD = new osg::LOD;
606 lightLOD->addChild(lightGroup, 0, 30000);
607 unsigned nodeMask = ~0u;
608 nodeMask &= ~SG_NODEMASK_CASTSHADOW_BIT;
609 nodeMask &= ~SG_NODEMASK_RECIEVESHADOW_BIT;
610 nodeMask &= ~SG_NODEMASK_PICK_BIT;
611 nodeMask &= ~SG_NODEMASK_TERRAIN_BIT;
612 lightLOD->setNodeMask(nodeMask);
614 osg::Group* terrainGroup = new osg::Group;
615 osg::Node* node = tileGeometryBin.getSurfaceGeometry(matlib);
617 terrainGroup->addChild(node);
620 // FIXME: ugly, has a side effect
621 tileGeometryBin.computeRandomSurfaceLights(matlib);
623 osg::Geode* geode = new osg::Geode;
624 groundLights0->addChild(geode);
625 geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.tileLights));
627 groundLights0->addChild(geode);
628 geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights, 4, -0.3f));
630 geode = new osg::Geode;
631 groundLights1->addChild(geode);
632 geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights, 2, -0.15f));
634 geode = new osg::Geode;
635 groundLights2->addChild(geode);
636 geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.randomTileLights));
640 SGVec4f red(1, 0, 0, 1);
641 SGMaterial* mat = matlib->find("RWY_RED_LIGHTS");
643 red = mat->get_light_color();
644 SGVec4f white(1, 1, 1, 1);
645 mat = matlib->find("RWY_WHITE_LIGHTS");
647 white = mat->get_light_color();
649 geode = new osg::Geode;
650 vasiLights->addChild(geode);
651 SGDirectionalLightListBin::const_iterator i;
652 for (i = tileGeometryBin.vasiLights.begin();
653 i != tileGeometryBin.vasiLights.end(); ++i) {
654 geode->addDrawable(SGLightFactory::getVasi(up, *i, red, white));
657 geode = new osg::Geode;
658 rwyLights->addChild(geode);
659 geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.runwayLights));
660 for (i = tileGeometryBin.rabitLights.begin();
661 i != tileGeometryBin.rabitLights.end(); ++i) {
662 rwyLights->addChild(SGLightFactory::getSequenced(*i));
664 for (i = tileGeometryBin.reilLights.begin();
665 i != tileGeometryBin.reilLights.end(); ++i) {
666 rwyLights->addChild(SGLightFactory::getSequenced(*i));
669 SGLightListBin::const_iterator j;
670 for (j = tileGeometryBin.odalLights.begin();
671 j != tileGeometryBin.odalLights.end(); ++j) {
672 rwyLights->addChild(SGLightFactory::getOdal(*j));
675 geode = new osg::Geode;
676 taxiLights->addChild(geode);
677 geode->addDrawable(SGLightFactory::getLights(tileGeometryBin.taxiLights));
680 // The toplevel transform for that tile.
681 osg::MatrixTransform* transform = new osg::MatrixTransform;
682 transform->setName(path);
683 transform->setMatrix(osg::Matrix::translate(center.osg()));
684 transform->addChild(terrainGroup);
685 transform->addChild(lightLOD);