Panda3D
 All Classes Functions Variables Enumerations
cLwoSurface.h
1 // Filename: cLwoSurface.h
2 // Created by: drose (25Apr01)
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 CLWOSURFACE_H
16 #define CLWOSURFACE_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "cLwoSurfaceBlock.h"
21 
22 #include "lwoSurface.h"
23 #include "luse.h"
24 #include "eggTexture.h"
25 #include "eggMaterial.h"
26 #include "pt_EggTexture.h"
27 #include "pt_EggMaterial.h"
28 #include "vector_PT_EggVertex.h"
29 
30 #include "pmap.h"
31 
32 class LwoToEggConverter;
33 class LwoSurfaceBlock;
34 class EggPrimitive;
35 
36 ////////////////////////////////////////////////////////////////////
37 // Class : CLwoSurface
38 // Description : This class is a wrapper around LwoSurface and stores
39 // additional information useful during the
40 // conversion-to-egg process.
41 ////////////////////////////////////////////////////////////////////
42 class CLwoSurface {
43 public:
44  CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface);
45  ~CLwoSurface();
46 
47  INLINE const string &get_name() const;
48 
49  void apply_properties(EggPrimitive *egg_prim,
50  vector_PT_EggVertex &egg_vertices,
51  PN_stdfloat &smooth_angle);
52  bool check_texture();
53  bool check_material();
54 
55  INLINE bool has_named_uvs() const;
56  INLINE const string &get_uv_name() const;
57 
58 
59  enum Flags {
60  F_rgb = 0x0001,
61  F_diffuse = 0x0002,
62  F_luminosity = 0x0004,
63  F_specular = 0x0008,
64  F_reflection = 0x0010,
65  F_transparency = 0x0020,
66  F_gloss = 0x0040,
67  F_translucency = 0x0080,
68  F_smooth_angle = 0x0100,
69  F_backface = 0x0200,
70  };
71 
72  int _flags;
73  LRGBColor _rgb;
74  PN_stdfloat _diffuse;
75  PN_stdfloat _luminosity;
76  PN_stdfloat _specular;
77  PN_stdfloat _reflection;
78  PN_stdfloat _transparency;
79  PN_stdfloat _gloss;
80  PN_stdfloat _translucency;
81  PN_stdfloat _smooth_angle;
82  bool _backface;
83 
84  LColor _color;
85  LColor _diffuse_color;
86 
87  LwoToEggConverter *_converter;
88  CPT(LwoSurface) _surface;
89 
90  bool _checked_material;
91  PT_EggMaterial _egg_material;
92 
93  bool _checked_texture;
94  PT_EggTexture _egg_texture;
95 
96  CLwoSurfaceBlock *_block;
97 
98 private:
99  void generate_uvs(vector_PT_EggVertex &egg_vertices);
100 
101  LPoint2d map_planar(const LPoint3d &pos, const LPoint3d &centroid) const;
102  LPoint2d map_spherical(const LPoint3d &pos, const LPoint3d &centroid) const;
103  LPoint2d map_cylindrical(const LPoint3d &pos, const LPoint3d &centroid) const;
104  LPoint2d map_cubic(const LPoint3d &pos, const LPoint3d &centroid) const;
105 
106  // Define a pointer to one of the above member functions.
107  LPoint2d (CLwoSurface::*_map_uvs)(const LPoint3d &pos, const LPoint3d &centroid) const;
108 };
109 
110 #include "cLwoSurface.I"
111 
112 #endif
113 
114 
A base class for any of a number of kinds of geometry primitives: polygons, point lights...
Definition: eggPrimitive.h:51
bool check_material()
Checks whether the surface demands a material or not.
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
bool has_named_uvs() const
Returns true if the surface is set up to reference UV's stored on the vertices, by name (as opposed t...
Definition: cLwoSurface.I:37
This class is a wrapper around LwoSurfaceBlock and stores additional information useful during the co...
const string & get_name() const
Returns the name of the surface.
Definition: cLwoSurface.I:23
Describes the shading attributes of a surface.
Definition: lwoSurface.h:28
This is a two-component point in space.
Definition: lpoint2.h:411
A texture layer or shader, part of a LwoSurface chunk.
bool check_texture()
Checks whether the surface demands a texture or not.
This class is a wrapper around LwoSurface and stores additional information useful during the convers...
Definition: cLwoSurface.h:42
const string & get_uv_name() const
Returns the name of the set of UV's that are associated with this surface, if has_named_uvs() is true...
Definition: cLwoSurface.I:50
void apply_properties(EggPrimitive *egg_prim, vector_PT_EggVertex &egg_vertices, PN_stdfloat &smooth_angle)
Applies the color, texture, etc.
This class supervises the construction of an EggData structure from the data represented by the LwoHe...
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:531