diff --git a/panda/src/gobj/perspectiveLens.I b/panda/src/gobj/perspectiveLens.I index f190bd3395..1ca054df41 100644 --- a/panda/src/gobj/perspectiveLens.I +++ b/panda/src/gobj/perspectiveLens.I @@ -21,6 +21,16 @@ INLINE PerspectiveLens:: PerspectiveLens() { } +//////////////////////////////////////////////////////////////////// +// Function: PerspectiveLens::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE PerspectiveLens:: +PerspectiveLens(float hfov, float vfov) { + _fov.set(hfov, vfov); +} + //////////////////////////////////////////////////////////////////// // Function: PerspectiveLens::Copy Constructor // Access: Public diff --git a/panda/src/gobj/perspectiveLens.h b/panda/src/gobj/perspectiveLens.h index 39e1ef359e..3104b67769 100644 --- a/panda/src/gobj/perspectiveLens.h +++ b/panda/src/gobj/perspectiveLens.h @@ -27,6 +27,7 @@ class EXPCL_PANDA_GOBJ PerspectiveLens : public Lens { PUBLISHED: INLINE PerspectiveLens(); + INLINE PerspectiveLens(float hfov, float vfov); public: INLINE PerspectiveLens(const PerspectiveLens ©); diff --git a/panda/src/pgraphnodes/pointLight.cxx b/panda/src/pgraphnodes/pointLight.cxx index f1c764b1db..86e26eaf87 100644 --- a/panda/src/pgraphnodes/pointLight.cxx +++ b/panda/src/pgraphnodes/pointLight.cxx @@ -65,8 +65,27 @@ fillin(DatagramIterator &scan, BamReader *) { //////////////////////////////////////////////////////////////////// PointLight:: PointLight(const string &name) : - LightNode(name) + LightLensNode(name) { + PT(Lens) lens; + lens = new PerspectiveLens(90, 90); + lens->set_view_vector(1, 0, 0, 0, 0, 1); + set_lens(0, lens); + lens = new PerspectiveLens(90, 90); + lens->set_view_vector(-1, 0, 0, 0, 0, 1); + set_lens(1, lens); + lens = new PerspectiveLens(90, 90); + lens->set_view_vector(0, 1, 0, 0, 0, 1); + set_lens(2, lens); + lens = new PerspectiveLens(90, 90); + lens->set_view_vector(0, -1, 0, 0, 0, 1); + set_lens(3, lens); + lens = new PerspectiveLens(90, 90); + lens->set_view_vector(0, 0, 1, 0, 0, 1); + set_lens(4, lens); + lens = new PerspectiveLens(90, 90); + lens->set_view_vector(0, 0, -1, 0, 0, 1); + set_lens(5, lens); } //////////////////////////////////////////////////////////////////// @@ -78,9 +97,28 @@ PointLight(const string &name) : //////////////////////////////////////////////////////////////////// PointLight:: PointLight(const PointLight ©) : - LightNode(copy), + LightLensNode(copy), _cycler(copy._cycler) { + PT(Lens) lens; + lens = new PerspectiveLens(90, 90); + lens->set_view_vector(1, 0, 0, 0, 0, 1); + set_lens(0, lens); + lens = new PerspectiveLens(90, 90); + lens->set_view_vector(-1, 0, 0, 0, 0, 1); + set_lens(1, lens); + lens = new PerspectiveLens(90, 90); + lens->set_view_vector(0, 1, 0, 0, 0, 1); + set_lens(2, lens); + lens = new PerspectiveLens(90, 90); + lens->set_view_vector(0, -1, 0, 0, 0, 1); + set_lens(3, lens); + lens = new PerspectiveLens(90, 90); + lens->set_view_vector(0, 0, 1, 0, 0, 1); + set_lens(4, lens); + lens = new PerspectiveLens(90, 90); + lens->set_view_vector(0, 0, -1, 0, 0, 1); + set_lens(5, lens); } //////////////////////////////////////////////////////////////////// @@ -106,7 +144,7 @@ make_copy() const { //////////////////////////////////////////////////////////////////// void PointLight:: xform(const LMatrix4f &mat) { - LightNode::xform(mat); + LightLensNode::xform(mat); CDWriter cdata(_cycler); cdata->_point = cdata->_point * mat; mark_viz_stale(); @@ -199,7 +237,7 @@ register_with_read_factory() { //////////////////////////////////////////////////////////////////// void PointLight:: write_datagram(BamWriter *manager, Datagram &dg) { - LightNode::write_datagram(manager, dg); + LightLensNode::write_datagram(manager, dg); manager->write_cdata(dg, _cycler); } @@ -232,6 +270,6 @@ make_from_bam(const FactoryParams ¶ms) { //////////////////////////////////////////////////////////////////// void PointLight:: fillin(DatagramIterator &scan, BamReader *manager) { - LightNode::fillin(scan, manager); + LightLensNode::fillin(scan, manager); manager->read_cdata(scan, _cycler); } diff --git a/panda/src/pgraphnodes/pointLight.h b/panda/src/pgraphnodes/pointLight.h index 7478677cce..f796197adf 100644 --- a/panda/src/pgraphnodes/pointLight.h +++ b/panda/src/pgraphnodes/pointLight.h @@ -17,14 +17,14 @@ #include "pandabase.h" -#include "lightNode.h" +#include "lightLensNode.h" //////////////////////////////////////////////////////////////////// // Class : PointLight // Description : A light originating from a single point in space, and // shining in all directions. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_PGRAPHNODES PointLight : public LightNode { +class EXPCL_PANDA_PGRAPHNODES PointLight : public LightLensNode { PUBLISHED: PointLight(const string &name); @@ -91,9 +91,9 @@ public: return _type_handle; } static void init_type() { - LightNode::init_type(); + LightLensNode::init_type(); register_type(_type_handle, "PointLight", - LightNode::get_class_type()); + LightLensNode::get_class_type()); } virtual TypeHandle get_type() const { return get_class_type();