mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
fix static text in y-up (or other non-default) coordinate system
This commit is contained in:
parent
c8f2dfe40f
commit
abf29fa3fe
@ -34,17 +34,43 @@ TypeHandle StaticTextFont::_type_handle;
|
||||
// Description: The constructor expects the root node to a model
|
||||
// generated via egg-mkfont, which consists of a set of
|
||||
// models, one per each character in the font.
|
||||
//
|
||||
// If a CoordinateSystem value is specified, it informs
|
||||
// the font of the coordinate system in which this model
|
||||
// was generated. "up" in this coordinate system will
|
||||
// be the direction of the top of the letters.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
StaticTextFont::
|
||||
StaticTextFont(PandaNode *font_def) {
|
||||
StaticTextFont(PandaNode *font_def, CoordinateSystem cs) {
|
||||
nassertv(font_def != (PandaNode *)NULL);
|
||||
_font = font_def;
|
||||
_cs = cs;
|
||||
_glyphs.clear();
|
||||
|
||||
if (_cs == CS_default) {
|
||||
_cs = get_default_coordinate_system();
|
||||
}
|
||||
|
||||
NodePath np(font_def);
|
||||
if (_cs != CS_zup_right) {
|
||||
// We have to convert the entire font to CS_zup_right before we
|
||||
// can use it, because the text subsystem assumes the glyphs are
|
||||
// stored in CS_zup_right.
|
||||
NodePath temp_root("root");
|
||||
NodePath temp_child = temp_root.attach_new_node("child");
|
||||
np = np.copy_to(temp_child);
|
||||
LMatrix4 mat = LMatrix4::convert_mat(_cs, CS_zup_right);
|
||||
temp_child.set_mat(mat);
|
||||
temp_root.clear_model_nodes();
|
||||
temp_root.flatten_light();
|
||||
np = temp_root.get_child(0).get_child(0);
|
||||
_font = np.node();
|
||||
_cs = CS_zup_right;
|
||||
}
|
||||
|
||||
// If there is no explicit quality level or filter settings on the
|
||||
// textures in the static font, set the appropriate defaults for
|
||||
// text.
|
||||
NodePath np(font_def);
|
||||
TextureCollection tc = np.find_all_textures();
|
||||
int num_textures = tc.get_num_textures();
|
||||
for (int i = 0; i < num_textures; ++i) {
|
||||
@ -68,7 +94,7 @@ StaticTextFont(PandaNode *font_def) {
|
||||
}
|
||||
}
|
||||
|
||||
find_characters(font_def, RenderState::make_empty());
|
||||
find_characters(_font, RenderState::make_empty());
|
||||
_is_valid = !_glyphs.empty();
|
||||
|
||||
// Check for an explicit space width.
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "config_text.h"
|
||||
#include "coordinateSystem.h"
|
||||
#include "textFont.h"
|
||||
#include "textGlyph.h"
|
||||
#include "pandaNode.h"
|
||||
@ -39,7 +40,7 @@ class GeomPoint;
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA_TEXT StaticTextFont : public TextFont {
|
||||
PUBLISHED:
|
||||
StaticTextFont(PandaNode *font_def);
|
||||
StaticTextFont(PandaNode *font_def, CoordinateSystem cs = CS_default);
|
||||
|
||||
virtual PT(TextFont) make_copy() const;
|
||||
|
||||
@ -59,6 +60,7 @@ private:
|
||||
Glyphs _glyphs;
|
||||
PN_stdfloat _font_height;
|
||||
PT(PandaNode) _font;
|
||||
CoordinateSystem _cs;
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user