Panda3D
Loading...
Searching...
No Matches
pfmVizzer.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 pfmVizzer.h
10 * @author drose
11 * @date 2012-09-30
12 */
13
14#ifndef PFMVIZZER_H
15#define PFMVIZZER_H
16
17#include "pandabase.h"
18#include "nodePath.h"
19#include "internalName.h"
20#include "lens.h"
21#include "pfmFile.h"
22
23class GeomNode;
24class Lens;
26
27/**
28 * This class aids in the visualization and manipulation of PfmFile objects.
29 */
30class EXPCL_PANDA_GRUTIL PfmVizzer {
31PUBLISHED:
32 explicit PfmVizzer(PfmFile &pfm);
33 INLINE ~PfmVizzer();
34 INLINE PfmFile &get_pfm();
35 INLINE const PfmFile &get_pfm() const;
36
37 BLOCKING void project(const Lens *lens, const PfmFile *undist_lut = nullptr);
38 BLOCKING void extrude(const Lens *lens);
39
40 INLINE void set_vis_inverse(bool vis_inverse);
41 INLINE bool get_vis_inverse() const;
42 INLINE void set_flat_texcoord_name(InternalName *flat_texcoord_name);
43 INLINE void clear_flat_texcoord_name();
45 INLINE void set_vis_2d(bool vis_2d);
46 INLINE bool get_vis_2d() const;
47 INLINE void set_keep_beyond_lens(bool keep_beyond_lens);
48 INLINE bool get_keep_beyond_lens() const;
49
50 INLINE void set_vis_blend(const PNMImage *vis_blend);
51 INLINE void clear_vis_blend();
52 INLINE const PNMImage *get_vis_blend() const;
53
54 INLINE void set_aux_pfm(const PfmFile *pfm);
55 INLINE void clear_aux_pfm();
56 INLINE const PfmFile *get_aux_pfm() const;
57
58 enum ColumnType {
59 CT_texcoord2,
60 CT_texcoord3,
61 CT_vertex1,
62 CT_vertex2,
63 CT_vertex3,
64 CT_normal3,
65 CT_blend1,
66 CT_aux_vertex1,
67 CT_aux_vertex2,
68 CT_aux_vertex3,
69 };
70 void clear_vis_columns();
71 void add_vis_column(ColumnType source, ColumnType target,
72 InternalName *name,
73 const TransformState *transform = nullptr, const Lens *lens = nullptr,
74 const PfmFile *undist_lut = nullptr);
75
76 BLOCKING NodePath generate_vis_points() const;
77
78 enum MeshFace {
79 MF_front = 0x01,
80 MF_back = 0x02,
81 MF_both = 0x03,
82 };
83 BLOCKING NodePath generate_vis_mesh(MeshFace face = MF_front) const;
84
85 BLOCKING double calc_max_u_displacement() const;
86 BLOCKING double calc_max_v_displacement() const;
87 BLOCKING void make_displacement(PNMImage &result, double max_u, double max_v, bool for_32bit) const;
88 BLOCKING void make_displacement(PfmFile &result, double max_u, double max_v, bool for_32bit) const;
89
90private:
91 bool uses_aux_pfm() const;
92 void r_fill_displacement(PNMImage &result, int xi, int yi,
93 double nxi, double nyi, double u_scale, double v_scale,
94 int distance) const;
95 void r_fill_displacement(PfmFile &result, int xi, int yi,
96 double nxi, double nyi, double u_scale, double v_scale,
97 int distance) const;
98
99 void make_vis_mesh_geom(GeomNode *gnode, bool inverted) const;
100
101
102 class VisColumn {
103 public:
104 INLINE VisColumn();
105 bool add_data(const PfmVizzer &vizzer, GeomVertexWriter &vwriter, int xi, int yi, bool reverse_normals) const;
106 bool transform_point(LPoint2f &point) const;
107 bool transform_point(LPoint3f &point) const;
108 bool transform_vector(LVector3f &vec) const;
109
110 public:
111 ColumnType _source;
112 ColumnType _target;
113 PT(InternalName) _name;
114 CPT(TransformState) _transform;
115 CPT(Lens) _lens;
116 const PfmFile *_undist_lut;
117 };
118 typedef pvector<VisColumn> VisColumns;
119
120 static void add_vis_column(VisColumns &vis_columns,
121 ColumnType source, ColumnType target,
122 InternalName *name,
123 const TransformState *transform = nullptr,
124 const Lens *lens = nullptr, const PfmFile *undist_lut = nullptr);
125 void build_auto_vis_columns(VisColumns &vis_columns, bool for_points) const;
126 CPT(GeomVertexFormat) make_array_format(const VisColumns &vis_columns) const;
127
128private:
129 PfmFile &_pfm;
130 const PfmFile *_aux_pfm;
131
132 bool _vis_inverse;
133 PT(InternalName) _flat_texcoord_name;
134 bool _vis_2d;
135 bool _keep_beyond_lens;
136 const PNMImage *_vis_blend;
137
138 VisColumns _vis_columns;
139
140 friend class VisColumn;
141};
142
143#include "pfmVizzer.I"
144
145#endif
A node that holds Geom objects, renderable pieces of geometry.
Definition geomNode.h:34
This class defines the physical layout of the vertex data stored within a Geom.
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
Encodes a string name in a hash table, mapping it to a pointer.
A base class for any number of different kinds of lenses, linear and otherwise.
Definition lens.h:41
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
Definition pnmImage.h:58
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component,...
Definition pfmFile.h:31
bool get_vis_inverse() const
Returns the vis_inverse flag.
Definition pfmVizzer.I:53
NodePath generate_vis_points() const
Creates a point cloud with the points of the pfm as 3-d coordinates in space, and texture coordinates...
void clear_aux_pfm()
Removes the auxiliary PfmFile from this PfmVizzer.
Definition pfmVizzer.I:183
void clear_vis_columns()
Removes all of the previously-added vis columns in preparation for building a new list.
void clear_flat_texcoord_name()
Resets the flat_texcoord_name to empty, so that additional texture coordinates are not created.
Definition pfmVizzer.I:81
bool get_keep_beyond_lens() const
Returns the keep_beyond_lens flag.
Definition pfmVizzer.I:128
const PfmFile * get_aux_pfm() const
Returns the reference to the auxiliary PfmFile queried by this PfmVizzer.
Definition pfmVizzer.I:193
NodePath generate_vis_mesh(MeshFace face=MF_front) const
Creates a triangle mesh with the points of the pfm as 3-d coordinates in space, and texture coordinat...
void set_aux_pfm(const PfmFile *pfm)
Assigns an auxiliary PfmFile to this PfmVizzer.
Definition pfmVizzer.I:173
double calc_max_u_displacement() const
Computes the maximum amount of shift, in pixels either left or right, of any pixel in the distortion ...
void set_vis_blend(const PNMImage *vis_blend)
Specifies a blending map–a grayscale image–that will be applied to the vertex color during generate_v...
Definition pfmVizzer.I:143
void extrude(const Lens *lens)
Converts each (u, v, depth) point of the Pfm file to an (x, y, z) point, by reversing project().
InternalName * get_flat_texcoord_name() const
Returns the flat_texcoord_name.
Definition pfmVizzer.I:89
void set_vis_2d(bool vis_2d)
Sets the vis_2d flag.
Definition pfmVizzer.I:101
void clear_vis_blend()
Removes the blending map set by a prior call to set_vis_blend().
Definition pfmVizzer.I:151
PfmVizzer(PfmFile &pfm)
The PfmVizzer constructor receives a reference to a PfmFile which it will operate on.
Definition pfmVizzer.cxx:36
void make_displacement(PNMImage &result, double max_u, double max_v, bool for_32bit) const
Assuming the underlying PfmFile is a 2-d distortion mesh, with the U and V in the first two component...
PfmFile & get_pfm()
Returns the reference to the PfmFile manipulated by this PfmVizzer.
Definition pfmVizzer.I:18
double calc_max_v_displacement() const
Computes the maximum amount of shift, in pixels either up or down, of any pixel in the distortion map...
void project(const Lens *lens, const PfmFile *undist_lut=nullptr)
Adjusts each (x, y, z) point of the Pfm file by projecting it through the indicated lens,...
Definition pfmVizzer.cxx:52
void set_keep_beyond_lens(bool keep_beyond_lens)
Sets the keep_beyond_lens flag.
Definition pfmVizzer.I:120
void set_flat_texcoord_name(InternalName *flat_texcoord_name)
If the flat_texcoord_name is specified, it is the name of an additional vertex column that will be cr...
Definition pfmVizzer.I:69
void set_vis_inverse(bool vis_inverse)
Sets the vis_inverse flag.
Definition pfmVizzer.I:44
bool get_vis_2d() const
Returns the vis_2d flag.
Definition pfmVizzer.I:110
const PNMImage * get_vis_blend() const
Returns the blending map set by the most recent call to set_vis_blend(), or NULL if there is no blend...
Definition pfmVizzer.I:160
void add_vis_column(ColumnType source, ColumnType target, InternalName *name, const TransformState *transform=nullptr, const Lens *lens=nullptr, const PfmFile *undist_lut=nullptr)
Adds a new vis column specification to the list of vertex data columns that will be generated at the ...
Indicates a coordinate-system transform on vertices.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.