add << for proj node

This commit is contained in:
cxgeorge 2001-10-18 01:06:34 +00:00
parent 355b3144c8
commit fa35929f1d
3 changed files with 26 additions and 4 deletions

View File

@ -49,3 +49,10 @@ operator = (const ProjectionNode &copy) {
NamedNode::operator = (copy);
_projection = copy._projection;
}
INLINE ostream &operator << (ostream &out, const ProjectionNode &projnode) {
projnode.output(out);
return out;
}

View File

@ -184,8 +184,9 @@ void ProjectionNode::
get_near_far(float &cnear, float &cfar) const {
if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
cnear = proj->get_frustum()._fnear;
cfar = proj->get_frustum()._ffar;
Frustumf frust = proj->get_frustum();
cnear = frust._fnear;
cfar = frust._ffar;
}
}
@ -349,3 +350,18 @@ set_far(float cfar) {
float cnear = get_near();
set_near_far(cnear, cfar);
}
void ProjectionNode::
output(ostream &out) const {
if (_projection->get_type() == PerspectiveProjection::get_class_type()) {
PerspectiveProjection *proj = DCAST(PerspectiveProjection, _projection);
float xfov,yfov,aspect_ratio,cnear,cfar;
proj->get_frustum().get_perspective_params(xfov, yfov, aspect_ratio, cnear, cfar);
out << "X-FOV: " << xfov << " deg, Y-FOV: " << yfov << " deg"
<< "Aspect ratio: " << aspect_ratio << ", Near plane: " << cnear << ", Far plane: " << cfar << endl;
}
out << "Projection Matrix: " << _projection->get_projection_mat(CS_default) << endl;
}

View File

@ -41,7 +41,7 @@ PUBLISHED:
public:
INLINE ProjectionNode(const ProjectionNode &copy);
INLINE void operator = (const ProjectionNode &copy);
void output(ostream &out) const;
virtual Node *make_copy() const;
PUBLISHED:
@ -74,7 +74,6 @@ protected:
PT(Projection) _projection;
public:
static TypeHandle get_class_type( void ) {
return _type_handle;
}