Go to the documentation of this file.
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);
98 xform(
const LMatrix4 &mat) {
107 write(std::ostream &out,
int indent_level)
const {
108 indent(out, indent_level) << *
this <<
":\n";
109 indent(out, indent_level + 2)
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
271 node->fillin(scan, manager);
282 LightLensNode::fillin(scan, manager);
285 _has_specular_color = scan.
get_bool();
287 _has_specular_color =
true;
A container for geometry primitives.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
A single page of data maintained by a PipelineCycler.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_specular_color
Returns the color of specular highlights generated by the light.
A class to retrieve the individual data elements previously stored in a Datagram.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
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.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CPT(RenderState) Spotlight
Returns a RenderState for rendering the spotlight visualization.
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Base class for objects that can be written to and read from Bam files.
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being written.
TypeHandle is the identifier used to differentiate C++ class types.
A node that holds Geom objects, renderable pieces of geometry.
get_attenuation
Returns the terms of the attenuation equation for the light.
bool get_bool()
Extracts a boolean value.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
void read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler)
Reads in the indicated CycleData object.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
PT(Texture) Spotlight
Returns a newly-generated Texture that renders a circular spot image as might be cast from the spotli...
get_color
Returns the basic color of the light.
A light originating from a single point in space, and shining in a particular direction,...
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.
A base class for any number of different kinds of lenses, linear and otherwise.
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.
void write_cdata(Datagram &packet, const PipelineCyclerBase &cycler)
Writes out the indicated CycleData object.
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...
static void register_with_read_factory()
Tells the BamReader how to create objects of type Spotlight.
virtual int get_class_priority() const
Returns the relative priority associated with all lights of this class.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
get_max_distance
Returns the maximum distance at which the light has any effect, as previously specified by set_max_di...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.
void add_bool(bool value)
Adds a boolean value to the datagram.
get_exponent
Returns the exponent that controls the amount of light falloff from the center of the spotlight.
A derivative of Light and of Camera.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic node of the scene graph or data graph.
void add_geom(Geom *geom, const RenderState *state=RenderState::make_empty())
Adds a new Geom to the node.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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 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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.