Pārlūkot izejas kodu

add << for proj node

cxgeorge 24 gadi atpakaļ
vecāks
revīzija
fa35929f1d

+ 7 - 0
panda/src/sgraph/projectionNode.I

@@ -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;
+}
+
+

+ 18 - 2
panda/src/sgraph/projectionNode.cxx

@@ -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;
+}
+

+ 1 - 2
panda/src/sgraph/projectionNode.h

@@ -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;
   }