Panda3D
 All Classes Functions Variables Enumerations
pfmVizzer.h
1 // Filename: pfmVizzer.h
2 // Created by: drose (30Sep12)
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 PFMVIZZER_H
16 #define PFMVIZZER_H
17 
18 #include "pandabase.h"
19 #include "nodePath.h"
20 #include "internalName.h"
21 #include "lens.h"
22 #include "pfmFile.h"
23 
24 class GeomNode;
25 class Lens;
26 class GeomVertexWriter;
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : PfmVizzer
30 // Description : This class aids in the visualization and manipulation
31 // of PfmFile objects.
32 ////////////////////////////////////////////////////////////////////
33 class EXPCL_PANDA_GRUTIL PfmVizzer {
34 PUBLISHED:
35  PfmVizzer(PfmFile &pfm);
36  INLINE PfmFile &get_pfm();
37  INLINE const PfmFile &get_pfm() const;
38 
39  BLOCKING void project(const Lens *lens, const PfmFile *undist_lut = NULL);
40  BLOCKING void extrude(const Lens *lens);
41 
42  INLINE void set_vis_inverse(bool vis_inverse);
43  INLINE bool get_vis_inverse() const;
44  INLINE void set_flat_texcoord_name(InternalName *flat_texcoord_name);
45  INLINE void clear_flat_texcoord_name();
46  INLINE InternalName *get_flat_texcoord_name() const;
47  INLINE void set_vis_2d(bool vis_2d);
48  INLINE bool get_vis_2d() const;
49  INLINE void set_keep_beyond_lens(bool keep_beyond_lens);
50  INLINE bool get_keep_beyond_lens() const;
51 
52  INLINE void set_vis_blend(const PNMImage *vis_blend);
53  INLINE void clear_vis_blend();
54  INLINE const PNMImage *get_vis_blend() const;
55 
56  INLINE void set_aux_pfm(const PfmFile *pfm);
57  INLINE void clear_aux_pfm();
58  INLINE const PfmFile *get_aux_pfm() const;
59 
60  enum ColumnType {
61  CT_texcoord2,
62  CT_texcoord3,
63  CT_vertex1,
64  CT_vertex2,
65  CT_vertex3,
66  CT_normal3,
67  CT_blend1,
68  CT_aux_vertex1,
69  CT_aux_vertex2,
70  CT_aux_vertex3,
71  };
72  void clear_vis_columns();
73  void add_vis_column(ColumnType source, ColumnType target,
74  InternalName *name,
75  const TransformState *transform = NULL, const Lens *lens = NULL,
76  const PfmFile *undist_lut = NULL);
77 
78  BLOCKING NodePath generate_vis_points() const;
79 
80  enum MeshFace {
81  MF_front = 0x01,
82  MF_back = 0x02,
83  MF_both = 0x03,
84  };
85  BLOCKING NodePath generate_vis_mesh(MeshFace face = MF_front) const;
86 
87  BLOCKING double calc_max_u_displacement() const;
88  BLOCKING double calc_max_v_displacement() const;
89  BLOCKING void make_displacement(PNMImage &result, double max_u, double max_v, bool for_32bit) const;
90  BLOCKING void make_displacement(PfmFile &result, double max_u, double max_v, bool for_32bit) const;
91 
92 private:
93  bool uses_aux_pfm() const;
94  void r_fill_displacement(PNMImage &result, int xi, int yi,
95  double nxi, double nyi, double u_scale, double v_scale,
96  int distance) const;
97  void r_fill_displacement(PfmFile &result, int xi, int yi,
98  double nxi, double nyi, double u_scale, double v_scale,
99  int distance) const;
100 
101  void make_vis_mesh_geom(GeomNode *gnode, bool inverted) const;
102 
103 
104  class VisColumn {
105  public:
106  INLINE VisColumn();
107  bool add_data(const PfmVizzer &vizzer, GeomVertexWriter &vwriter, int xi, int yi, bool reverse_normals) const;
108  bool transform_point(LPoint2f &point) const;
109  bool transform_point(LPoint3f &point) const;
110  bool transform_vector(LVector3f &vec) const;
111 
112  public:
113  ColumnType _source;
114  ColumnType _target;
115  PT(InternalName) _name;
116  CPT(TransformState) _transform;
117  CPT(Lens) _lens;
118  const PfmFile *_undist_lut;
119  };
121 
122  static void add_vis_column(VisColumns &vis_columns,
123  ColumnType source, ColumnType target,
124  InternalName *name,
125  const TransformState *transform = NULL,
126  const Lens *lens = NULL, const PfmFile *undist_lut = NULL);
127  void build_auto_vis_columns(VisColumns &vis_columns, bool for_points) const;
128  CPT(GeomVertexFormat) make_array_format(const VisColumns &vis_columns) const;
129 
130 private:
131  PfmFile &_pfm;
132  const PfmFile *_aux_pfm;
133 
134  bool _vis_inverse;
135  PT(InternalName) _flat_texcoord_name;
136  bool _vis_2d;
137  bool _keep_beyond_lens;
138  const PNMImage *_vis_blend;
139 
140  VisColumns _vis_columns;
141 
142  friend class VisColumn;
143 };
144 
145 #include "pfmVizzer.I"
146 
147 #endif
148 
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
Definition: pnmImage.h:68
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:45
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component, or with a special extension, 2- or 4-component.
Definition: pfmFile.h:34
This is a two-component point in space.
Definition: lpoint2.h:92
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:37
This class aids in the visualization and manipulation of PfmFile objects.
Definition: pfmVizzer.h:33