Panda3D
fltGeometry.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 fltGeometry.h
10  * @author drose
11  * @date 2001-02-28
12  */
13 
14 #ifndef FLTGEOMETRY_H
15 #define FLTGEOMETRY_H
16 
17 #include "pandatoolbase.h"
18 
19 #include "fltBeadID.h"
20 #include "fltPackedColor.h"
21 #include "fltHeader.h"
22 
23 #include "luse.h"
24 
25 class FltTexture;
26 class FltMaterial;
27 
28 /**
29  * This is a base class for both FltFace and FltMesh, which are two different
30  * kinds of geometric primitives that might be encountered in a MultiGen file.
31  * They have similar properties.
32  */
33 class FltGeometry : public FltBeadID {
34 public:
35  FltGeometry(FltHeader *header);
36 
37  enum DrawType {
38  DT_solid_cull_backface = 0,
39  DT_solid_no_cull = 1,
40  DT_wireframe = 2,
41  DT_wireframe_close = 3,
42  DT_wireframe_highlight = 4,
43  DT_omni_light = 8,
44  DT_uni_light = 9,
45  DT_bi_light = 10
46  };
47 
48  enum BillboardType {
49  BT_none = 0,
50  BT_fixed = 1,
51  BT_axial = 2,
52  BT_point = 4
53  };
54 
55  enum Flags {
56  F_terrain = 0x80000000,
57  F_no_color = 0x40000000,
58  F_no_alt_color = 0x20000000,
59  F_packed_color = 0x10000000,
60  F_terrain_footprint = 0x08000000,
61  F_hidden = 0x04000000
62  };
63 
64  enum LightMode {
65  LM_face_no_normal = 0,
66  LM_vertex_no_normal = 1,
67  LM_face_with_normal = 2,
68  LM_vertex_with_normal = 3
69  };
70 
71  int _ir_color;
72  int _relative_priority;
73  DrawType _draw_type;
74  bool _texwhite;
75  int _color_name_index;
76  int _alt_color_name_index;
77  BillboardType _billboard_type;
78  int _detail_texture_index;
79  int _texture_index;
80  int _material_index;
81  int _dfad_material_code;
82  int _dfad_feature_id;
83  int _ir_material_code;
84  int _transparency;
85  int _lod_generation_control;
86  int _line_style_index;
87  unsigned int _flags;
88  LightMode _light_mode;
89  FltPackedColor _packed_color;
90  FltPackedColor _alt_packed_color;
91  int _texture_mapping_index;
92  int _color_index;
93  int _alt_color_index;
94 
95 public:
96  INLINE bool has_texture() const;
97  INLINE FltTexture *get_texture() const;
98  INLINE void set_texture(FltTexture *texture);
99 
100  INLINE bool has_material() const;
101  INLINE FltMaterial *get_material() const;
102  INLINE void set_material(FltMaterial *material);
103 
104  INLINE bool has_color() const;
105  LColor get_color() const;
106  void set_color(const LColor &color);
107  LRGBColor get_rgb() const;
108  void set_rgb(const LRGBColor &rgb);
109 
110  bool has_alt_color() const;
111  LColor get_alt_color() const;
112  LRGBColor get_alt_rgb() const;
113 
114 
115 protected:
116  virtual bool extract_record(FltRecordReader &reader);
117  virtual bool build_record(FltRecordWriter &writer) const;
118 
119 public:
120  virtual TypeHandle get_type() const {
121  return get_class_type();
122  }
123  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
124  static TypeHandle get_class_type() {
125  return _type_handle;
126  }
127  static void init_type() {
128  FltBeadID::init_type();
129  register_type(_type_handle, "FltGeometry",
130  FltBeadID::get_class_type());
131  }
132 
133 private:
134  static TypeHandle _type_handle;
135 };
136 
137 #include "fltGeometry.I"
138 
139 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
LRGBColor get_rgb() const
Returns the primary color of the face, as a three-component value ignoring transparency.
This class writes a sequence of FltRecords to an ostream, handling opcode and size counts properly.
A base class for any of a broad family of flt beads that include an ID.
Definition: fltBeadID.h:24
This class turns an istream into a sequence of FltRecords by reading a sequence of Datagrams and extr...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_color(const LColor &color)
Sets the primary color of the face, using the packed color convention.
Definition: fltGeometry.cxx:91
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
Represents a single material in the material palette.
Definition: fltMaterial.h:28
FltMaterial * get_material() const
Returns the material applied to this face, or NULL if no material was applied.
Definition: fltGeometry.I:58
This is a base class for both FltFace and FltMesh, which are two different kinds of geometric primiti...
Definition: fltGeometry.h:33
bool has_material() const
Returns true if the face has a material applied, false otherwise.
Definition: fltGeometry.I:49
bool has_color() const
Returns true if the face has a primary color indicated, false otherwise.
Definition: fltGeometry.I:80
This is the first bead in the file, the top of the bead hierarchy, and the primary interface to readi...
Definition: fltHeader.h:44
void set_material(FltMaterial *material)
Applies the indicated material to this face, or if the material is NULL, clears it.
Definition: fltGeometry.I:67
Represents a single texture in the texture palette.
Definition: fltTexture.h:27
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A packed color record, A, B, G, R.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
LColor get_alt_color() const
If has_alt_color() indicates true, returns the alternate color of the face, as a four-component value...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
LColor get_color() const
Returns the primary color of the face, as a four-component value (including alpha as the transparency...
Definition: fltGeometry.cxx:59
LRGBColor get_alt_rgb() const
If has_alt_color() indicates true, returns the alternate color of the face, as a three-component valu...
bool has_texture() const
Returns true if the face has a texture applied, false otherwise.
Definition: fltGeometry.I:18
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
void set_rgb(const LRGBColor &rgb)
Sets the primary color of the face, using the packed color convention; does not affect transparency.
void set_texture(FltTexture *texture)
Applies the indicated texture to this face, or if the texture is NULL, clears it.
Definition: fltGeometry.I:36
bool has_alt_color() const
Returns true if the face has an alternate color indicated, false otherwise.
FltTexture * get_texture() const
Returns the texture applied to this face, or NULL if no texture was applied.
Definition: fltGeometry.I:27