32 return new CData(*
this);
39 void Spotlight::CData::
42 _specular_color.write_datagram(dg);
43 _attenuation.write_datagram(dg);
53 void Spotlight::CData::
56 _specular_color.read_datagram(scan);
57 _attenuation.read_datagram(scan);
67 Spotlight(
const std::string &name) :
69 _lenses[0]._lens->set_interocular_distance(0);
107 write(std::ostream &out,
int indent_level)
const {
108 indent(out, indent_level) << *
this <<
":\n";
109 indent(out, indent_level + 2)
110 <<
"color " << get_color() <<
"\n";
111 if (_has_specular_color) {
112 indent(out, indent_level + 2)
115 indent(out, indent_level + 2)
117 indent(out, indent_level + 2)
121 indent(out, indent_level + 2)
126 if (lens !=
nullptr) {
127 lens->write(out, indent_level + 2);
145 const LMatrix4 &to_object_space) {
162 make_spot(
int pixel_width, PN_stdfloat full_radius, LColor &fg, LColor &bg) {
164 if (fg[0] == fg[1] && fg[1] == fg[2] &&
165 bg[0] == bg[1] && bg[1] == bg[2]) {
172 if (fg[3] != 1.0f || bg[3] != 1.0f) {
176 PNMImage image(pixel_width, pixel_width, num_channels);
177 image.
render_spot(LCAST(
float, fg), LCAST(
float, bg), full_radius, 1.0);
181 tex->set_border_color(bg);
182 tex->set_wrap_u(SamplerState::WM_border_color);
183 tex->set_wrap_v(SamplerState::WM_border_color);
185 tex->set_minfilter(SamplerState::FT_linear);
186 tex->set_magfilter(SamplerState::FT_linear);
199 return (
int)CP_spot_priority;
207 gsg->bind_light(
this, light, light_id);
217 if (lens ==
nullptr) {
221 PT(
Geom) geom = lens->make_geometry();
222 if (geom ==
nullptr) {
226 viz_geom->
add_geom(geom, get_viz_state());
234 return RenderState::make
235 (ColorAttrib::make_flat(get_color()));
271 node->fillin(scan, manager);
282 LightLensNode::fillin(scan, manager);
285 _has_specular_color = scan.
get_bool();
287 _has_specular_color =
true;
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.
A basic node of the scene graph or data graph.
PT(Texture) Spotlight
Returns a newly-generated Texture that renders a circular spot image as might be cast from the spotli...
virtual int get_class_priority() const
Returns the relative priority associated with all lights of this class.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool get_bool()
Extracts a boolean value.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A base class for any number of different kinds of lenses, linear and otherwise.
CPT(RenderState) Spotlight
Returns a RenderState for rendering the spotlight visualization.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
void read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler)
Reads in the indicated CycleData object.
PN_stdfloat get_exponent() const final
For spotlights, returns the exponent that controls the amount of light falloff from the center of the...
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
A single page of data maintained by a PipelineCycler.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Base class for objects that can be written to and read from Bam files.
void write_cdata(Datagram &packet, const PipelineCyclerBase &cycler)
Writes out the indicated CycleData object.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being written.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
Lens * get_lens(int index=0) const
Returns a pointer to the particular Lens associated with this LensNode, or NULL if there is not yet a...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
void add_bool(bool value)
Adds a boolean value to the datagram.
get_max_distance
Returns the maximum distance at which the light has any effect, as previously specified by set_max_di...
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
A container for geometry primitives.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
A light originating from a single point in space, and shining in a particular direction,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
static void register_with_read_factory()
Tells the BamReader how to create objects of type Spotlight.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
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.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.
A derivative of Light and of Camera.
void render_spot(const LColorf &fg, const LColorf &bg, float min_radius, float max_radius)
Renders a solid-color circle, with a fuzzy edge, into the center of the PNMImage.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
A class to retrieve the individual data elements previously stored in a Datagram.
const LVecBase3 & get_attenuation() const final
Returns the terms of the attenuation equation for the light.
TypeHandle is the identifier used to differentiate C++ class types.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
const LColor & get_specular_color() const final
Returns the color of specular highlights generated by the light.
A node that holds Geom objects, renderable pieces of geometry.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_geom(Geom *geom, const RenderState *state=RenderState::make_empty())
Adds a new Geom to the node.