Panda3D
 All Classes Functions Variables Enumerations
rescaleNormalAttrib.h
1 // Filename: rescaleNormalAttrib.h
2 // Created by: drose (30Dec04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef RESCALENORMALATTRIB_H
16 #define RESCALENORMALATTRIB_H
17 
18 #include "pandabase.h"
19 
20 #include "renderAttrib.h"
21 
22 class FactoryParams;
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : RescaleNormalAttrib
26 // Description : Specifies how polygons are to be drawn.
27 ////////////////////////////////////////////////////////////////////
28 class EXPCL_PANDA_PGRAPH RescaleNormalAttrib : public RenderAttrib {
29 PUBLISHED:
30  enum Mode {
31  // No adjustments are made to normals.
32  M_none,
33 
34  // Normals are counterscaled by the transform's uniform scale, if
35  // supported by the graphics API.
36  M_rescale,
37 
38  // Normals are scaled to unit length; potentially expensive.
39  M_normalize,
40 
41  // Normals are counterscaled in the presence of a uniform scale
42  // transform, or normalized in the presence of a non-uniform scale
43  // transform.
44  M_auto,
45  };
46 
47 private:
48  INLINE RescaleNormalAttrib(Mode mode);
49 
50 PUBLISHED:
51  static CPT(RenderAttrib) make(Mode mode);
52  static CPT(RenderAttrib) make_default();
53 
54  INLINE Mode get_mode() const;
55 
56 public:
57  virtual void output(ostream &out) const;
58 
59 protected:
60  virtual int compare_to_impl(const RenderAttrib *other) const;
61  virtual size_t get_hash_impl() const;
62 
63 private:
64  Mode _mode;
65 
66 PUBLISHED:
67  static int get_class_slot() {
68  return _attrib_slot;
69  }
70  virtual int get_slot() const {
71  return get_class_slot();
72  }
73 
74 public:
75  static void register_with_read_factory();
76  virtual void write_datagram(BamWriter *manager, Datagram &dg);
77 
78 protected:
79  static TypedWritable *make_from_bam(const FactoryParams &params);
80  void fillin(DatagramIterator &scan, BamReader *manager);
81 
82 public:
83  static TypeHandle get_class_type() {
84  return _type_handle;
85  }
86  static void init_type() {
87  RenderAttrib::init_type();
88  register_type(_type_handle, "RescaleNormalAttrib",
89  RenderAttrib::get_class_type());
90  _attrib_slot = register_slot(_type_handle, 100, make_default);
91  }
92  virtual TypeHandle get_type() const {
93  return get_class_type();
94  }
95  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
96 
97 private:
98  static TypeHandle _type_handle;
99  static int _attrib_slot;
100 };
101 
102 EXPCL_PANDA_PGRAPH ostream &operator << (ostream &out, RescaleNormalAttrib::Mode mode);
103 EXPCL_PANDA_PGRAPH istream &operator >> (istream &in, RescaleNormalAttrib::Mode &mode);
104 
105 #include "rescaleNormalAttrib.I"
106 
107 #endif
108 
static int register_slot(TypeHandle type_handle, int sort, RenderAttribRegistry::MakeDefaultFunc *make_default_func)
Adds the indicated TypeHandle to the registry, if it is not there already, and returns a unique slot ...
Definition: renderAttrib.I:163
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:60
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
Specifies how polygons are to be drawn.
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43