Panda3D

Loading...
Searching...
No Matches
materialAttrib.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 materialAttrib.h
10 * @author drose
11 * @date 2002-03-04
12 */
13
14#ifndef MATERIALATTRIB_H
15#define MATERIALATTRIB_H
16
17#include "pandabase.h"
18
19#include "renderAttrib.h"
20#include "material.h"
21
22/**
23 * Indicates which, if any, material should be applied to geometry. The
24 * material is used primarily to control lighting effects, and isn't necessary
25 * (or useful) in the absence of lighting.
26 */
27 class EXPCL_PANDA_PGRAPH MaterialAttrib : public RenderAttrib {
28 private:
29 INLINE MaterialAttrib();
30
31PUBLISHED:
32 static CPT(RenderAttrib) make(Material *material);
33 static CPT(RenderAttrib) make_off();
34 static CPT(RenderAttrib) make_default();
35
36 INLINE bool is_off() const;
37 INLINE Material *get_material() const;
38
39PUBLISHED:
40 MAKE_PROPERTY(material, get_material);
41
42 public:
43 virtual void output(std::ostream &out) const;
44
45 protected:
46 virtual int compare_to_impl(const RenderAttrib *other) const;
47 virtual size_t get_hash_impl() const;
48
49 private:
50 PT(Material) _material;
51
52PUBLISHED:
53 static int get_class_slot() {
54 return _attrib_slot;
55 }
56 virtual int get_slot() const {
57 return get_class_slot();
58 }
59 MAKE_PROPERTY(class_slot, get_class_slot);
60
61 public:
62 static void register_with_read_factory();
63 virtual void write_datagram(BamWriter *manager, Datagram &dg);
64 virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
65
66 protected:
67 static TypedWritable *make_from_bam(const FactoryParams &params);
68 void fillin(DatagramIterator &scan, BamReader *manager);
69
70 public:
71 static TypeHandle get_class_type() {
72 return _type_handle;
73 }
74 static void init_type() {
75 RenderAttrib::init_type();
76 register_type(_type_handle, "MaterialAttrib",
77 RenderAttrib::get_class_type());
78 _attrib_slot = register_slot(_type_handle, 100, new MaterialAttrib);
79 }
80 virtual TypeHandle get_type() const {
81 return get_class_type();
82 }
83 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
84
85 private:
86 static TypeHandle _type_handle;
87 static int _attrib_slot;
88};
89
90#include "materialAttrib.I"
91
92#endif
MaterialAttrib::is_off
bool is_off() const
Returns true if the MaterialAttrib is an 'off' MaterialAttrib, indicating that it should disable the ...
Definition materialAttrib.I:26
MaterialAttrib::make_off
static ConstPointerTo< RenderAttrib > make_off()
Constructs a new MaterialAttrib object suitable for rendering unmateriald geometry.
Definition materialAttrib.cxx:41
MaterialAttrib::make
static ConstPointerTo< RenderAttrib > make(Material *material)
Constructs a new MaterialAttrib object suitable for rendering the indicated material onto geometry.
Definition materialAttrib.cxx:29
MaterialAttrib::make_default
static ConstPointerTo< RenderAttrib > make_default()
Returns a RenderAttrib that corresponds to whatever the standard default properties for render attrib...
Definition materialAttrib.cxx:51
MaterialAttrib::get_material
get_material
If the MaterialAttrib is not an 'off' MaterialAttrib, returns the material that is associated.
Definition materialAttrib.h:40
Material
Defines the way an object appears in the presence of lighting.
Definition material.h:43
RenderAttrib::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition renderAttrib.cxx:527
RenderAttrib::register_slot
static int register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib)
Adds the indicated TypeHandle to the registry, if it is not there already, and returns a unique slot ...
Definition renderAttrib.I:101
TypedWritable::complete_pointers
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Definition typedWritable.cxx:81
materialAttrib.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
material.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22
renderAttrib.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.