From 509a388ccc909339e640c173dbc2f993c79c71b4 Mon Sep 17 00:00:00 2001 From: mfranz Date: Sun, 9 Apr 2006 19:21:13 +0000 Subject: [PATCH] support for font textures. They are normal (but rather lenghty) , but contain entries with , and . The latter two describe where in the texture a letter or symbol begins and where it ends. (range 0-1). defines a horizontal scaling factor. --- simgear/scene/material/mat.cxx | 24 +++++++++++++++++++++++ simgear/scene/material/mat.hxx | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/simgear/scene/material/mat.cxx b/simgear/scene/material/mat.cxx index 77eeab32..37bf0491 100644 --- a/simgear/scene/material/mat.cxx +++ b/simgear/scene/material/mat.cxx @@ -159,6 +159,15 @@ SGMaterial::read_properties( const string &fg_root, const SGPropertyNode * props ((SGPropertyNode *)props)->getChildren("object-group"); for (unsigned int i = 0; i < object_group_nodes.size(); i++) object_groups.push_back(new SGMatModelGroup(object_group_nodes[i])); + + // handling of glyphs for taxi-/runway-signs + xscale = props->getDoubleValue("xscale", 1.0); + vector glyph_nodes = props->getChildren("glyph"); + for (unsigned int i = 0; i < glyph_nodes.size(); i++) { + const char *name = glyph_nodes[i]->getStringValue("name"); + if (name) + glyphs[name] = new SGMaterialGlyph(glyph_nodes[i]); + } } @@ -176,6 +185,8 @@ SGMaterial::init () ysize = 0; wrapu = true; wrapv = true; + xscale = 1; + mipmap = true; light_coverage = 0.0; shininess = 1.0; @@ -276,4 +287,17 @@ void SGMaterial::set_ssg_state( ssgSimpleState *s ) _status.push_back( _internal_state( s, "", true ) ); } + + +//////////////////////////////////////////////////////////////////////// +// SGMaterialGlyph. +//////////////////////////////////////////////////////////////////////// + +SGMaterialGlyph::SGMaterialGlyph(SGPropertyNode *p) : + _left(p->getDoubleValue("left", 0.0)), + _right(p->getDoubleValue("right", 1.0)) +{ +} + + // end of mat.cxx diff --git a/simgear/scene/material/mat.hxx b/simgear/scene/material/mat.hxx index 048d88b3..93c28777 100644 --- a/simgear/scene/material/mat.hxx +++ b/simgear/scene/material/mat.hxx @@ -34,6 +34,7 @@ #include STL_STRING // Standard C++ string library #include +#include #include #include @@ -46,6 +47,10 @@ SG_USING_STD(string); SG_USING_STD(vector); +SG_USING_STD(map); + + +class SGMaterialGlyph; /** @@ -163,6 +168,19 @@ public: return object_groups[index]; } + /** + * Get the horizontal scaling factor for runway/taxiway signs. + */ + virtual inline double get_xscale() const { return xscale; } + + /** + * Return pointer to glyph class, or 0 if it doesn't exist. + */ + virtual SGMaterialGlyph * get_glyph (const string& name) const { + map::const_iterator it = glyphs.find(name); + return it != glyphs.end() ? it->second : 0; + } + protected: @@ -216,6 +234,10 @@ private: vector > object_groups; + // taxiway-/runway-sign elements + double xscale; + map glyphs; + //////////////////////////////////////////////////////////////////// // Internal constructors and methods. @@ -230,4 +252,17 @@ private: }; + +class SGMaterialGlyph { +public: + SGMaterialGlyph(SGPropertyNode *); + inline double get_left() const { return _left; } + inline double get_right() const { return _right; } + inline double get_width() const { return _right - _left; } + +protected: + double _left; + double _right; +}; + #endif // _SG_MAT_HXX -- 2.39.5