diff --git a/direct/src/gui/DirectEntry.py b/direct/src/gui/DirectEntry.py index 5d72b0a6bb..e2b306af06 100644 --- a/direct/src/gui/DirectEntry.py +++ b/direct/src/gui/DirectEntry.py @@ -325,8 +325,25 @@ class DirectEntry(DirectFrame): self.ll.set(left, 0.0, bottom) self.ur.set(right, 0.0, top) - self.ll = mat.xformPoint(self.ll) - self.ur = mat.xformPoint(self.ur) + self.ll = mat.xformPoint(Point3.rfu(left, 0.0, bottom)) + self.ur = mat.xformPoint(Point3.rfu(right, 0.0, top)) + + vec_right = Vec3.right() + vec_up = Vec3.up() + left = (vec_right[0] * self.ll[0] + + vec_right[1] * self.ll[1] + + vec_right[2] * self.ll[2]) + right = (vec_right[0] * self.ur[0] + + vec_right[1] * self.ur[1] + + vec_right[2] * self.ur[2]) + bottom = (vec_up[0] * self.ll[0] + + vec_up[1] * self.ll[1] + + vec_up[2] * self.ll[2]) + top = (vec_up[0] * self.ur[0] + + vec_up[1] * self.ur[1] + + vec_up[2] * self.ur[2]) + self.ll = Point3(left, 0.0, bottom) + self.ur = Point3(right, 0.0, top) # Scale bounds to give a pad around graphics. We also want to # scale around the border width. diff --git a/direct/src/gui/OnscreenText.py b/direct/src/gui/OnscreenText.py index b3a87a03d7..f8160065db 100644 --- a/direct/src/gui/OnscreenText.py +++ b/direct/src/gui/OnscreenText.py @@ -323,9 +323,9 @@ class OnscreenText(DirectObject, NodePath): def updateTransformMat(self): assert(isinstance(self.textNode, TextNode)) mat = ( - Mat4.scaleMat(self.scale[0], 1, self.scale[1]) * - Mat4.rotateMat(self.roll, Vec3(0, -1, 0)) * - Mat4.translateMat(self.pos[0], 0, self.pos[1]) + Mat4.scaleMat(Vec3.rfu(self.scale[0], 1, self.scale[1])) * + Mat4.rotateMat(self.roll, Vec3.back()) * + Mat4.translateMat(Point3.rfu(self.pos[0], 0, self.pos[1])) ) self.textNode.setTransform(mat) diff --git a/direct/src/showbase/BufferViewer.py b/direct/src/showbase/BufferViewer.py index cf2d4a55ad..e8f4224183 100644 --- a/direct/src/showbase/BufferViewer.py +++ b/direct/src/showbase/BufferViewer.py @@ -408,8 +408,8 @@ class BufferViewer(DirectObject): posx = dirx * (1.0 - ((c + 0.5) * (fsizex + fpixelx * bordersize))) - (fpixelx * dirx) posy = diry * (1.0 - ((r + 0.5) * (fsizey + fpixely * bordersize))) - (fpixely * diry) placer = NodePath("card-structure") - placer.setPos(posx, 0, posy) - placer.setScale(fsizex*0.5, 1.0, fsizey*0.5) + placer.setPos(Point3.rfu(posx, 0, posy)) + placer.setScale(Vec3.rfu(fsizex*0.5, 1.0, fsizey*0.5)) placer.setBin(self.cullbin, self.cullsort) placer.reparentTo(self.renderParent) frame.instanceTo(placer) diff --git a/panda/src/pgui/pgEntry.cxx b/panda/src/pgui/pgEntry.cxx index 8caa331d86..7775e1fdc9 100644 --- a/panda/src/pgui/pgEntry.cxx +++ b/panda/src/pgui/pgEntry.cxx @@ -59,6 +59,10 @@ PGEntry(const string &name) : _blink_rate = 1.0f; _text_render_root = NodePath("text_root"); + + CPT(TransformState) transform = TransformState::make_mat(LMatrix4::convert_mat(CS_default, CS_zup_right)); + _text_render_root.set_transform(transform); + _cursor_scale = _text_render_root.attach_new_node("cursor_scale"); _cursor_def = _cursor_scale.attach_new_node("cursor"); _cursor_visible = true; @@ -569,26 +573,45 @@ setup(PN_stdfloat width, int num_lines) { PN_stdfloat line_height = text_node->get_line_height(); // Determine the four corners of the frame. - LPoint3 ll(0.0f, 0.0f, -0.3 * line_height - (line_height * (num_lines - 1))); - LPoint3 ur(width, 0.0f, line_height); - LPoint3 lr(ur[0], 0.0f, ll[2]); - LPoint3 ul(ll[0], 0.0f, ur[2]); - + float bottom = -0.3f * line_height - (line_height * (num_lines - 1)); // Transform each corner by the TextNode's transform. LMatrix4 mat = text_node->get_transform(); - ll = ll * mat; - ur = ur * mat; - lr = lr * mat; - ul = ul * mat; + LPoint3 ll = LPoint3::rfu(0.0f, 0.0f, bottom) * mat; + LPoint3 ur = LPoint3::rfu(width, 0.0f, line_height) * mat; + LPoint3 lr = LPoint3::rfu(width, 0.0f, bottom) * mat; + LPoint3 ul = LPoint3::rfu(0.0f, 0.0f, line_height) * mat; + + LVector3 up = LVector3::up(); + int up_axis; + if (up[1]) { + up_axis = 1; + } + else if (up[2]) { + up_axis = 2; + } + else { + up_axis = 0; + } + LVector3 right = LVector3::right(); + int right_axis; + if (right[0]) { + right_axis = 0; + } + else if (right[2]) { + right_axis = 2; + } + else { + right_axis = 1; + } // And get the new minmax to define the frame. We do all this work // instead of just using the lower-left and upper-right corners, // just in case the text was rotated. LVecBase4 frame; - frame[0] = min(min(ll[0], ur[0]), min(lr[0], ul[0])); - frame[1] = max(max(ll[0], ur[0]), max(lr[0], ul[0])); - frame[2] = min(min(ll[2], ur[2]), min(lr[2], ul[2])); - frame[3] = max(max(ll[2], ur[2]), max(lr[2], ul[2])); + frame[0] = min(min(ll[right_axis], ur[right_axis]), min(lr[right_axis], ul[right_axis])); + frame[1] = max(max(ll[right_axis], ur[right_axis]), max(lr[right_axis], ul[right_axis])); + frame[2] = min(min(ll[up_axis], ur[up_axis]), min(lr[up_axis], ul[up_axis])); + frame[3] = max(max(ll[up_axis], ur[up_axis]), max(lr[up_axis], ul[up_axis])); switch (text_node->get_align()) { case TextNode::A_left: @@ -875,8 +898,8 @@ update_text() { _current_text.set_x(_current_text.get_x() - _current_padding); _current_text.set_scissor(NodePath(this), - LPoint3(0, 0, -0.5), LPoint3(_max_width, 0, -0.5), - LPoint3(_max_width, 0, 1.5), LPoint3(0, 0, 1.5)); + LPoint3::rfu(0, 0, -0.5), LPoint3::rfu(_max_width, 0, -0.5), + LPoint3::rfu(_max_width, 0, 1.5), LPoint3::rfu(0, 0, 1.5)); } _text_geom_stale = false;