15 #include "spotlight.h"
16 #include "graphicsStateGuardianBase.h"
17 #include "bamWriter.h"
18 #include "bamReader.h"
20 #include "datagramIterator.h"
21 #include "colorAttrib.h"
23 #include "config_pgraph.h"
35 return new CData(*
this);
44 void Spotlight::CData::
47 _specular_color.write_datagram(dg);
48 _attenuation.write_datagram(dg);
58 void Spotlight::CData::
61 _specular_color.read_datagram(scan);
62 _attenuation.read_datagram(scan);
71 Spotlight(
const string &name) :
123 write(ostream &out,
int indent_level)
const {
124 indent(out, indent_level) << *
this <<
":\n";
125 indent(out, indent_level + 2)
127 indent(out, indent_level + 2)
129 indent(out, indent_level + 2)
131 indent(out, indent_level + 2)
135 if (lens != (
Lens *)NULL) {
136 lens->write(out, indent_level + 2);
182 make_spot(
int pixel_width, PN_stdfloat full_radius,
LColor &fg,
LColor &bg) {
184 if (fg[0] == fg[1] && fg[1] == fg[2] &&
185 bg[0] == bg[1] && bg[1] == bg[2]) {
192 if (fg[3] != 1.0f || bg[3] != 1.0f) {
196 PNMImage image(pixel_width, pixel_width, num_channels);
197 image.render_spot(LCAST(
float, fg), LCAST(
float, bg), full_radius, 1.0);
201 tex->set_border_color(bg);
222 get_class_priority()
const {
223 return (
int)CP_spot_priority;
233 gsg->bind_light(
this, light, light_id);
245 if (lens == (
Lens *)NULL) {
249 PT(
Geom) geom = lens->make_geometry();
250 if (geom == (
Geom *)NULL) {
254 viz_geom->
add_geom(geom, get_viz_state());
265 return RenderState::make
266 (ColorAttrib::make_flat(get_color()));
306 parse_params(params, scan, manager);
307 node->fillin(scan, manager);
321 LightLensNode::fillin(scan, manager);
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.
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...
A base class for any number of different kinds of lenses, linear and otherwise.
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.
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.
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.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PN_stdfloat get_exponent() const FINAL
Returns the exponent that controls the amount of light falloff from the center of the spotlight...
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
This is a 4-by-4 transform matrix.
A container for geometry primitives.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
A light originating from a single point in space, and shining in a particular direction, with a cone-shaped falloff.
const LColor & get_specular_color() const FINAL
Returns the color of specular highlights generated by the light.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
static void register_with_read_factory()
Tells the BamReader how to create objects of type Spotlight.
Represents a set of settings that indicate how a texture is sampled.
This is the base class for all three-component vectors and points.
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.
const LColor & get_color() const
Returns the basic color of the light.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
const LVecBase3 & get_attenuation() const FINAL
Returns the terms of the attenuation equation for the light.
A class to retrieve the individual data elements previously stored in a Datagram. ...
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
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...
A node that holds Geom objects, renderable pieces of geometry.
void add_geom(Geom *geom, const RenderState *state=RenderState::make_empty())
Adds a new Geom to the node.
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...