add mirroring and fix set_width/height for model labels

This commit is contained in:
Cary Sandvig 2001-03-07 19:31:18 +00:00
parent 05e09cc0cf
commit bded9a817d
3 changed files with 37 additions and 2 deletions

View File

@ -15,6 +15,7 @@ INLINE GuiLabel::GuiLabel(void) : _type(GuiLabel::NONE),
_background(0., 0., 0., 0.),
_have_width(false), _width(0.),
_have_height(false), _height(0.),
_mirror_x(false), _mirror_y(false),
_hard_pri(0), _highest_pri(false) {
}
@ -35,8 +36,11 @@ INLINE void GuiLabel::set_width(float f) {
_have_width = false;
_width = 0.;
} else {
if (_type == MODEL)
_width = f / this->get_width();
else
_width = f;
_have_width = true;
_width = f;
}
this->set_properties();
}
@ -46,8 +50,11 @@ INLINE void GuiLabel::set_height(float f) {
_have_height = false;
_height = 0.;
} else {
if (_type == MODEL)
_height = f / this->get_height();
else
_height = f;
_have_height = true;
_height = f;
}
this->set_properties();
}
@ -57,6 +64,14 @@ INLINE void GuiLabel::set_scale(float f) {
recompute_transform();
}
INLINE void GuiLabel::set_mirror_x(bool b) {
_mirror_x = b;
}
INLINE void GuiLabel::set_mirror_y(bool b) {
_mirror_y = b;
}
INLINE void GuiLabel::set_pos(float x, float y, float z) {
this->set_pos(LVector3f(x, y, z));
}
@ -70,6 +85,14 @@ INLINE float GuiLabel::get_scale(void) const {
return _scale;
}
INLINE bool GuiLabel::get_mirror_x(void) const {
return _mirror_x;
}
INLINE bool GuiLabel::get_mirror_y(void) const {
return _mirror_y;
}
INLINE LVector3f GuiLabel::get_pos(void) const {
return _pos;
}

View File

@ -16,6 +16,8 @@ void GuiLabel::recompute_transform(void) {
case SIMPLE_TEXT:
{
LMatrix4f mat = LMatrix4f::scale_mat(_scale) *
LMatrix4f::scale_mat(LVector3f::rfu((_mirror_x?-1.:1.), 1.,
(_mirror_y?-1.:1.))) *
LMatrix4f::translate_mat(_pos);
TextNode* n = DCAST(TextNode, _geom);
n->set_transform(mat);
@ -25,6 +27,8 @@ void GuiLabel::recompute_transform(void) {
case SIMPLE_CARD:
{
LMatrix4f mat = LMatrix4f::scale_mat(_scale) *
LMatrix4f::scale_mat(LVector3f::rfu((_mirror_x?-1.:1.), 1.,
(_mirror_y?-1.:1.))) *
LMatrix4f::translate_mat(_pos);
_internal->set_transition(new TransformTransition(mat));
}
@ -34,6 +38,8 @@ void GuiLabel::recompute_transform(void) {
float w=_have_width?_scale*_width:_scale;
float h=_have_height?_scale*_height:_scale;
LMatrix4f mat = LMatrix4f::scale_mat(LVector3f::rfu(w, 1., h)) *
LMatrix4f::scale_mat(LVector3f::rfu((_mirror_x?-1.:1.), 1.,
(_mirror_y?-1.:1.))) *
LMatrix4f::translate_mat(_pos);
_internal->set_transition(new TransformTransition(mat));
}

View File

@ -44,6 +44,8 @@ private:
float _width;
bool _have_height;
float _height;
bool _mirror_x;
bool _mirror_y;
PriorityMap _priorities;
int _hard_pri;
@ -79,10 +81,14 @@ PUBLISHED:
INLINE void set_height(float);
INLINE void set_scale(float);
INLINE void set_mirror_x(bool);
INLINE void set_mirror_y(bool);
INLINE void set_pos(float, float, float);
INLINE void set_pos(const LVector3f&);
INLINE float get_scale(void) const;
INLINE bool get_mirror_x(void) const;
INLINE bool get_mirror_y(void) const;
INLINE LVector3f get_pos(void) const;
INLINE void set_foreground_color(float, float, float, float);