added offset to billboard, and added do_billboard_*

This commit is contained in:
David Rose 2001-05-25 04:03:08 +00:00
parent e11869a26c
commit 2a9f41802f
3 changed files with 66 additions and 24 deletions

View File

@ -1284,9 +1284,9 @@ has_two_sided() const {
// will rotate in two dimensions around the up axis.
////////////////////////////////////////////////////////////////////
INLINE void NodePath::
set_billboard_axis() {
set_billboard_axis(float offset) {
nassertv(has_arcs());
arc()->set_transition(new BillboardTransition(BillboardTransition::axis()));
arc()->set_transition(new BillboardTransition(BillboardTransition::axis(offset)));
}
////////////////////////////////////////////////////////////////////
@ -1298,9 +1298,9 @@ set_billboard_axis() {
// camera.
////////////////////////////////////////////////////////////////////
INLINE void NodePath::
set_billboard_point_eye() {
set_billboard_point_eye(float offset) {
nassertv(has_arcs());
arc()->set_transition(new BillboardTransition(BillboardTransition::point_eye()));
arc()->set_transition(new BillboardTransition(BillboardTransition::point_eye(offset)));
}
////////////////////////////////////////////////////////////////////
@ -1311,9 +1311,9 @@ set_billboard_point_eye() {
// keeping its up vector oriented to the sky.
////////////////////////////////////////////////////////////////////
INLINE void NodePath::
set_billboard_point_world() {
set_billboard_point_world(float offset) {
nassertv(has_arcs());
arc()->set_transition(new BillboardTransition(BillboardTransition::point_world()));
arc()->set_transition(new BillboardTransition(BillboardTransition::point_world(offset)));
}
////////////////////////////////////////////////////////////////////

View File

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

View File

@ -73,6 +73,13 @@ class GraphicsStateGuardianBase;
// just a special case of this.) The globbing characters may not be
// used with the typename matches.
//
// The special characters "@@", appearing at the beginning of a node
// name, indicate a stashed node. Normally, stashed nodes are not
// returned by a find (but see the special flags, below), but a
// stashed node may be found if it is explicitly named with its
// leading @@ characters. By extension, "@@*" may be used to identify
// any stashed node.
//
// Examples:
//
// "room//graph" will look for a node named "graph", which is a child
@ -96,6 +103,18 @@ class GraphicsStateGuardianBase;
// paths, it will sort them so that the shortest paths appear first in
// the output.
//
//
// Special flags. The entire string may optionally be followed by the
// ";" character, followed by one or more of the following special
// control flags, with no intervening spaces or punctuation:
//
// -h Do not return hidden nodes.
// +h Do return hidden nodes.
// -s Do not return stashed nodes unless explicitly referenced with @@.
// +s Return stashed nodes even without any explicit @@ characters.
//
// The default flags are +h-s.
//
////////////////////////////////////////////////////////////////////
// Class : NodePath
@ -448,12 +467,12 @@ PUBLISHED:
INLINE bool has_two_sided() const;
bool get_two_sided() const;
void do_billboard_axis(const NodePath &camera);
void do_billboard_point_eye(const NodePath &camera);
void do_billboard_point_world(const NodePath &camera);
INLINE void set_billboard_axis();
INLINE void set_billboard_point_eye();
INLINE void set_billboard_point_world();
void do_billboard_axis(const NodePath &camera, float offset);
void do_billboard_point_eye(const NodePath &camera, float offset);
void do_billboard_point_world(const NodePath &camera, float offset);
INLINE void set_billboard_axis(float offset = 0.0);
INLINE void set_billboard_point_eye(float offset = 0.0);
INLINE void set_billboard_point_world(float offset = 0.0);
INLINE void clear_billboard();
INLINE bool has_billboard() const;