mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
Add patch from community member teedee to improve alternate coordinate-system support
This commit is contained in:
parent
be7f483478
commit
807a6f61da
@ -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.
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user