Panda3D
Loading...
Searching...
No Matches
directionalLight.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file directionalLight.h
10 * @author mike
11 * @date 1997-01-09
12 */
13
14#ifndef DIRECTIONALLIGHT_H
15#define DIRECTIONALLIGHT_H
16
17#include "pandabase.h"
18
19#include "lightLensNode.h"
20
21/**
22 * A light shining from infinitely far away in a particular direction, like
23 * sunlight.
24 */
25class EXPCL_PANDA_PGRAPHNODES DirectionalLight : public LightLensNode {
26PUBLISHED:
27 explicit DirectionalLight(const std::string &name);
28
29protected:
31
32public:
33 virtual PandaNode *make_copy() const;
34 virtual void xform(const LMatrix4 &mat);
35 virtual void write(std::ostream &out, int indent_level) const;
36
37 virtual bool get_vector_to_light(LVector3 &result,
38 const LPoint3 &from_object_point,
39 const LMatrix4 &to_object_space);
40
41PUBLISHED:
42 INLINE const LColor &get_specular_color() const final;
43 INLINE void set_specular_color(const LColor &color);
44 INLINE void clear_specular_color();
45 MAKE_PROPERTY(specular_color, get_specular_color, set_specular_color);
46
47 INLINE const LPoint3 &get_point() const;
48 INLINE void set_point(const LPoint3 &point);
49 MAKE_PROPERTY(point, get_point, set_point);
50
51 INLINE const LVector3 &get_direction() const;
52 INLINE void set_direction(const LVector3 &direction);
53 MAKE_PROPERTY(direction, get_direction, set_direction);
54
55 virtual int get_class_priority() const;
56
57public:
58 virtual void bind(GraphicsStateGuardianBase *gsg, const NodePath &light,
59 int light_id);
60
61private:
62 // This is the data that must be cycled between pipeline stages.
63 class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
64 public:
65 INLINE CData();
66 INLINE CData(const CData &copy);
67 virtual CycleData *make_copy() const;
68 virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
69 virtual void fillin(DatagramIterator &scan, BamReader *manager);
70 virtual TypeHandle get_parent_type() const {
71 return DirectionalLight::get_class_type();
72 }
73
74 LColor _specular_color;
75 LPoint3 _point;
76 LVector3 _direction;
77 };
78
80 typedef CycleDataReader<CData> CDReader;
81 typedef CycleDataWriter<CData> CDWriter;
82
83public:
84 static void register_with_read_factory();
85 virtual void write_datagram(BamWriter *manager, Datagram &dg);
86
87protected:
88 static TypedWritable *make_from_bam(const FactoryParams &params);
89 void fillin(DatagramIterator &scan, BamReader *manager);
90
91public:
92 static TypeHandle get_class_type() {
93 return _type_handle;
94 }
95 static void init_type() {
96 LightLensNode::init_type();
97 register_type(_type_handle, "DirectionalLight",
98 LightLensNode::get_class_type());
99 }
100 virtual TypeHandle get_type() const {
101 return get_class_type();
102 }
103 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
104
105private:
106 static TypeHandle _type_handle;
107};
108
109INLINE std::ostream &operator << (std::ostream &out, const DirectionalLight &light) {
110 light.output(out);
111 return out;
112}
113
114#include "directionalLight.I"
115
116#endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
Definition camera.cxx:69
static void register_with_read_factory()
Tells the BamReader how to create objects of type Camera.
Definition camera.cxx:262
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A single page of data maintained by a PipelineCycler.
Definition cycleData.h:50
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
A light shining from infinitely far away in a particular direction, like sunlight.
const LColor & get_specular_color() const final
Returns the color of specular highlights generated by the light.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.
Definition lensNode.cxx:53
A derivative of Light and of Camera.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual bool get_vector_to_light(LVector3 &result, const LPoint3 &from_object_point, const LMatrix4 &to_object_space)
Computes the vector from a particular vertex to this light.
Definition light.cxx:189
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...