|
@@ -2482,13 +2482,13 @@ get_two_sided() const {
|
|
|
// Description: Performs a billboard-type rotate to the indicated
|
|
// Description: Performs a billboard-type rotate to the indicated
|
|
|
// camera node, one time only, and leaves the object
|
|
// camera node, one time only, and leaves the object
|
|
|
// rotated. This is similar in principle to heads_up().
|
|
// rotated. This is similar in principle to heads_up().
|
|
|
|
|
+// However, it does lose both translate and scale
|
|
|
|
|
+// components of the matrix.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
void NodePath::
|
|
void NodePath::
|
|
|
-do_billboard_axis(const NodePath &camera) {
|
|
|
|
|
|
|
+do_billboard_axis(const NodePath &camera, float offset) {
|
|
|
nassertv(has_arcs());
|
|
nassertv(has_arcs());
|
|
|
|
|
|
|
|
- LPoint3f pos = get_pos();
|
|
|
|
|
-
|
|
|
|
|
NodePath parent(*this);
|
|
NodePath parent(*this);
|
|
|
parent.shorten(1);
|
|
parent.shorten(1);
|
|
|
LMatrix4f rel_mat = camera.get_mat(parent);
|
|
LMatrix4f rel_mat = camera.get_mat(parent);
|
|
@@ -2498,7 +2498,16 @@ do_billboard_axis(const NodePath &camera) {
|
|
|
|
|
|
|
|
LMatrix4f mat;
|
|
LMatrix4f mat;
|
|
|
::heads_up(mat, rel_pos, up);
|
|
::heads_up(mat, rel_pos, up);
|
|
|
- mat.set_row(3, pos);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // Also slide the geometry towards the camera according to the
|
|
|
|
|
+ // offset factor.
|
|
|
|
|
+ if (offset != 0.0f) {
|
|
|
|
|
+ LVector3f translate = rel_mat.get_row3(3);
|
|
|
|
|
+ translate.normalize();
|
|
|
|
|
+ translate *= offset;
|
|
|
|
|
+ mat.set_row(3, translate);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
set_mat(mat);
|
|
set_mat(mat);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2512,11 +2521,9 @@ do_billboard_axis(const NodePath &camera) {
|
|
|
// achieved using the ordinary look_at() call.
|
|
// achieved using the ordinary look_at() call.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
void NodePath::
|
|
void NodePath::
|
|
|
-do_billboard_point_eye(const NodePath &camera) {
|
|
|
|
|
|
|
+do_billboard_point_eye(const NodePath &camera, float offset) {
|
|
|
nassertv(has_arcs());
|
|
nassertv(has_arcs());
|
|
|
|
|
|
|
|
- LPoint3f pos = get_pos();
|
|
|
|
|
-
|
|
|
|
|
NodePath parent(*this);
|
|
NodePath parent(*this);
|
|
|
parent.shorten(1);
|
|
parent.shorten(1);
|
|
|
LMatrix4f rel_mat = camera.get_mat(parent);
|
|
LMatrix4f rel_mat = camera.get_mat(parent);
|
|
@@ -2526,7 +2533,16 @@ do_billboard_point_eye(const NodePath &camera) {
|
|
|
|
|
|
|
|
LMatrix4f mat;
|
|
LMatrix4f mat;
|
|
|
::look_at(mat, rel_pos, up);
|
|
::look_at(mat, rel_pos, up);
|
|
|
- mat.set_row(3, pos);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // Also slide the geometry towards the camera according to the
|
|
|
|
|
+ // offset factor.
|
|
|
|
|
+ if (offset != 0.0f) {
|
|
|
|
|
+ LVector3f translate = rel_mat.get_row3(3);
|
|
|
|
|
+ translate.normalize();
|
|
|
|
|
+ translate *= offset;
|
|
|
|
|
+ mat.set_row(3, translate);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
set_mat(mat);
|
|
set_mat(mat);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2538,11 +2554,9 @@ do_billboard_point_eye(const NodePath &camera) {
|
|
|
// rotated. This is similar in principle to look_at().
|
|
// rotated. This is similar in principle to look_at().
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
void NodePath::
|
|
void NodePath::
|
|
|
-do_billboard_point_world(const NodePath &camera) {
|
|
|
|
|
|
|
+do_billboard_point_world(const NodePath &camera, float offset) {
|
|
|
nassertv(has_arcs());
|
|
nassertv(has_arcs());
|
|
|
|
|
|
|
|
- LPoint3f pos = get_pos();
|
|
|
|
|
-
|
|
|
|
|
NodePath parent(*this);
|
|
NodePath parent(*this);
|
|
|
parent.shorten(1);
|
|
parent.shorten(1);
|
|
|
LMatrix4f rel_mat = camera.get_mat(parent);
|
|
LMatrix4f rel_mat = camera.get_mat(parent);
|
|
@@ -2552,7 +2566,16 @@ do_billboard_point_world(const NodePath &camera) {
|
|
|
|
|
|
|
|
LMatrix4f mat;
|
|
LMatrix4f mat;
|
|
|
::look_at(mat, rel_pos, up);
|
|
::look_at(mat, rel_pos, up);
|
|
|
- mat.set_row(3, pos);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // Also slide the geometry towards the camera according to the
|
|
|
|
|
+ // offset factor.
|
|
|
|
|
+ if (offset != 0.0f) {
|
|
|
|
|
+ LVector3f translate = rel_mat.get_row3(3);
|
|
|
|
|
+ translate.normalize();
|
|
|
|
|
+ translate *= offset;
|
|
|
|
|
+ mat.set_row(3, translate);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
set_mat(mat);
|
|
set_mat(mat);
|
|
|
}
|
|
}
|
|
|
|
|
|