- sgVec3 center;
- calc_center_point( nodes, pnt_i, center );
- // cout << center[0] << "," << center[1] << "," << center[2] << endl;
-
- sgVec3 nup;
- sgNormalizeVec3( nup, up );
-
- ssgVertexArray *vl = new ssgVertexArray( 3 * pnt_i.size() );
- ssgNormalArray *nl = new ssgNormalArray( 3 * pnt_i.size() );
- ssgColourArray *cl = new ssgColourArray( 3 * pnt_i.size() );
-
- unsigned int i;
- sgVec3 pt, normal;
- for ( i = 0; i < pnt_i.size(); ++i ) {
- sgSetVec3( pt, nodes[pnt_i[i]][0], nodes[pnt_i[i]][1],
- nodes[pnt_i[i]][2] );
- sgSubVec3( pt, center );
- sgSetVec3( normal, normals[nml_i[i]][0], normals[nml_i[i]][1],
- normals[nml_i[i]][2] );
-
- // calculate a vector perpendicular to dir and up
- sgVec3 perp;
- sgVectorProductVec3( perp, normal, nup );
-
- // front face
- sgVec3 tmp3;
- sgCopyVec3( tmp3, pt );
- vl->add( tmp3 );
- sgAddVec3( tmp3, nup );
- vl->add( tmp3 );
- sgAddVec3( tmp3, perp );
- vl->add( tmp3 );
- // sgSubVec3( tmp3, nup );
- // vl->add( tmp3 );
-
- nl->add( normal );
- nl->add( normal );
- nl->add( normal );
- // nl->add( normal );
-
- sgVec4 color;
- sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 );
- cl->add( color );
- sgSetVec4( color, 1.0, 1.0, 1.0, 0.0 );
- cl->add( color );
- cl->add( color );
- // cl->add( color );
- }
-
- ssgLeaf *leaf =
- new ssgVtxTable ( GL_TRIANGLES, vl, nl, NULL, cl );
-
- SGMaterial *mat = matlib->find( "RWY_WHITE_LIGHTS" );
-
- if ( mat != NULL ) {
- leaf->setState( mat->get_state() );
- } else {
- SG_LOG( SG_TERRAIN, SG_ALERT,
- "Warning: can't find material = RWY_WHITE_LIGHTS" );
- }
-
- leaf->setCallback( SSG_CALLBACK_PREDRAW, StrobePreDraw );
- leaf->setCallback( SSG_CALLBACK_POSTDRAW, StrobePostDraw );
-
- ssgTimedSelector *reil = new ssgTimedSelector;
-
- // need to add this twice to work around an ssg bug
- reil->addKid( leaf );
- reil->addKid( leaf );
-
- reil->setDuration( 60 );
- reil->setLimits( 0, 2 );
- reil->setMode( SSG_ANIM_SHUTTLE );
- reil->control( SSG_ANIM_START );
-
- // put an LOD on each lighting component
- ssgRangeSelector *lod = new ssgRangeSelector;
- lod->setRange( 0, SG_ZERO );
- lod->setRange( 1, 12000 );
- lod->addKid( reil );
-
- // create the transformation.
- sgCoord coord;
- sgSetCoord( &coord, center[0], center[1], center[2], 0.0, 0.0, 0.0 );
- ssgTransform *trans = new ssgTransform;
- trans->setTransform( &coord );
- trans->addKid( lod );
-
- return trans;
+ osg::Vec3Array* vertices = new osg::Vec3Array;
+ osg::Vec4Array* colors = new osg::Vec4Array;
+
+ vertices->push_back(toOsg(light.position));
+ colors->push_back(toOsg(light.color));
+
+ osg::Geometry* geometry = new osg::Geometry;
+ geometry->setVertexArray(vertices);
+ geometry->setNormalBinding(osg::Geometry::BIND_OFF);
+ geometry->setColorArray(colors);
+ geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
+
+ // Enlarge the bounding box to avoid such light nodes being victim to
+ // small feature culling.
+ geometry->setComputeBoundingBoxCallback(new SGEnlargeBoundingBox(1));
+
+ osg::DrawArrays* drawArrays;
+ drawArrays = new osg::DrawArrays(osg::PrimitiveSet::POINTS,
+ 0, vertices->size());
+ geometry->addPrimitiveSet(drawArrays);
+ return geometry;