X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Ftgdb%2Fapt_signs.cxx;h=4053dda16ff204b0a513d4af480ba9d48a1bd3dc;hb=d4c7e950927b1e19a7a7622a7919f32233a6b7a8;hp=543882c734e72f142f749513fe3feaea6cfd047e;hpb=d3bacd0b738416da978c49149f50dbf909c5e41d;p=simgear.git diff --git a/simgear/scene/tgdb/apt_signs.cxx b/simgear/scene/tgdb/apt_signs.cxx index 543882c7..4053dda1 100644 --- a/simgear/scene/tgdb/apt_signs.cxx +++ b/simgear/scene/tgdb/apt_signs.cxx @@ -33,7 +33,6 @@ #include #include -#include #include #include @@ -42,7 +41,7 @@ #define SIGN "OBJECT_SIGN: " #define RWY "OBJECT_RUNWAY_SIGN: " -SG_USING_STD(vector); +using std::vector; // for temporary storage of sign elements struct element_info { @@ -69,18 +68,18 @@ struct pair { const char *keyword; const char *glyph_name; } cmds[] = { - {"@u", "up"}, - {"@d", "down"}, - {"@l", "left"}, - {"@lu", "left-up"}, - {"@ul", "left-up"}, - {"@ld", "left-down"}, - {"@dl", "left-down"}, - {"@r", "right"}, - {"@ru", "right-up"}, - {"@ur", "right-up"}, - {"@rd", "right-down"}, - {"@dr", "right-down"}, + {"@u", "^u"}, + {"@d", "^d"}, + {"@l", "^l"}, + {"@lu", "^lu"}, + {"@ul", "^lu"}, + {"@ld", "^ld"}, + {"@dl", "^ld"}, + {"@r", "^r"}, + {"@ru", "^ru"}, + {"@ur", "^ru"}, + {"@rd", "^rd"}, + {"@dr", "^rd"}, {0, 0}, }; @@ -355,63 +354,27 @@ SGMakeSign(SGMaterialLib *matlib, const string& path, const string& content) return object; } - - - - osg::Node* SGMakeRunwaySign(SGMaterialLib *matlib, const string& path, const string& name) { // for demo purposes we assume each element (letter) is 1x1 meter. // Sign is placed 0.25 meters above the ground - osg::Group *object = new osg::Group; - object->setName(name); - - double width = name.length() / 3.0; - - string material = name; - - point_list nodes; - point_list normals; - point_list texcoords; - int_list vertex_index; - int_list normal_index; - int_list tex_index; - - nodes.push_back( Point3D( -width, 0, 0.25 ) ); - nodes.push_back( Point3D( width + 1, 0, 0.25 ) ); - nodes.push_back( Point3D( -width, 0, 1.25 ) ); - nodes.push_back( Point3D( width + 1, 0, 1.25 ) ); + float width = name.length() / 3.0; - normals.push_back( Point3D( 0, -1, 0 ) ); + osg::Vec3 corner(-width, 0, 0.25f); + osg::Vec3 widthVec(2*width + 1, 0, 0); + osg::Vec3 heightVec(0, 0, 1); + osg::Geometry* geometry; + geometry = osg::createTexturedQuadGeometry(corner, widthVec, heightVec); - texcoords.push_back( Point3D( 0, 0, 0 ) ); - texcoords.push_back( Point3D( 1, 0, 0 ) ); - texcoords.push_back( Point3D( 0, 1, 0 ) ); - texcoords.push_back( Point3D( 1, 1, 0 ) ); - - vertex_index.push_back( 0 ); - vertex_index.push_back( 1 ); - vertex_index.push_back( 2 ); - vertex_index.push_back( 3 ); - - normal_index.push_back( 0 ); - normal_index.push_back( 0 ); - normal_index.push_back( 0 ); - normal_index.push_back( 0 ); - - tex_index.push_back( 0 ); - tex_index.push_back( 1 ); - tex_index.push_back( 2 ); - tex_index.push_back( 3 ); - - osg::Node* leaf = SGMakeLeaf( path, GL_TRIANGLE_STRIP, matlib, material, - nodes, normals, texcoords, - vertex_index, normal_index, tex_index, - false, NULL ); + SGMaterial *mat = matlib->find(name); + if (mat) + geometry->setStateSet(mat->get_state()); - object->addChild(leaf); + osg::Geode* geode = new osg::Geode; + geode->setName(name); + geode->addDrawable(geometry); - return object; + return geode; }