Panda3D
Classes | Public Types | Public Member Functions | Friends | List of all members
PfmVizzer Class Reference

This class aids in the visualization and manipulation of PfmFile objects. More...

#include "pfmVizzer.h"

Public Types

enum  ColumnType {
  CT_texcoord2, CT_texcoord3, CT_vertex1, CT_vertex2,
  CT_vertex3, CT_normal3, CT_blend1, CT_aux_vertex1,
  CT_aux_vertex2, CT_aux_vertex3
}
 
enum  MeshFace { MF_front = 0x01, MF_back = 0x02, MF_both = 0x03 }
 

Public Member Functions

 PfmVizzer (PfmFile &pfm)
 The PfmVizzer constructor receives a reference to a PfmFile which it will operate on. More...
 
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 next call to generate_vis_points() or generate_vis_mesh(). More...
 
double calc_max_u_displacement () const
 Computes the maximum amount of shift, in pixels either left or right, of any pixel in the distortion map. More...
 
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. More...
 
void clear_aux_pfm ()
 Removes the auxiliary PfmFile from this PfmVizzer. More...
 
void clear_flat_texcoord_name ()
 Resets the flat_texcoord_name to empty, so that additional texture coordinates are not created. More...
 
void clear_vis_blend ()
 Removes the blending map set by a prior call to set_vis_blend(). More...
 
void clear_vis_columns ()
 Removes all of the previously-added vis columns in preparation for building a new list. More...
 
void extrude (const Lens *lens)
 Converts each (u, v, depth) point of the Pfm file to an (x, y, z) point, by reversing project(). More...
 
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 coordinates ranging from 0 . More...
 
NodePath generate_vis_points () const
 Creates a point cloud with the points of the pfm as 3-d coordinates in space, and texture coordinates ranging from 0 . More...
 
const PfmFileget_aux_pfm () const
 Returns the reference to the auxiliary PfmFile queried by this PfmVizzer. More...
 
InternalNameget_flat_texcoord_name () const
 Returns the flat_texcoord_name. More...
 
bool get_keep_beyond_lens () const
 Returns the keep_beyond_lens flag. More...
 
PfmFileget_pfm ()
 Returns the reference to the PfmFile manipulated by this PfmVizzer. More...
 
const PfmFileget_pfm () const
 Returns the reference to the PfmFile manipulated by this PfmVizzer. More...
 
bool get_vis_2d () const
 Returns the vis_2d flag. More...
 
const PNMImageget_vis_blend () const
 Returns the blending map set by the most recent call to set_vis_blend(), or NULL if there is no blending map in effect. More...
 
bool get_vis_inverse () const
 Returns the vis_inverse flag. More...
 
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 components and the third component unused, this computes an AfterEffects-style displacement map that represents the same distortion. More...
 
void make_displacement (PfmFile &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 components and the third component unused, this computes an AfterEffects-style displacement map that represents the same distortion. More...
 
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, converting each point to a (u, v, w) texture coordinate. More...
 
void set_aux_pfm (const PfmFile *pfm)
 Assigns an auxiliary PfmFile to this PfmVizzer. More...
 
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 created for the "flat" texture coordinates, i.e. More...
 
void set_keep_beyond_lens (bool keep_beyond_lens)
 Sets the keep_beyond_lens flag. More...
 
void set_vis_2d (bool vis_2d)
 Sets the vis_2d flag. More...
 
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_vis_mesh() and generate_vis_points(). More...
 
void set_vis_inverse (bool vis_inverse)
 Sets the vis_inverse flag. More...
 

Friends

class VisColumn
 

Detailed Description

This class aids in the visualization and manipulation of PfmFile objects.

Definition at line 30 of file pfmVizzer.h.

Constructor & Destructor Documentation

◆ PfmVizzer()

PfmVizzer::PfmVizzer ( PfmFile pfm)
explicit

The PfmVizzer constructor receives a reference to a PfmFile which it will operate on.

It does not keep ownership of this reference; it is your responsibility to ensure the PfmFile does not destruct during the lifetime of the PfmVizzer.

Definition at line 36 of file pfmVizzer.cxx.

Member Function Documentation

◆ add_vis_column()

void PfmVizzer::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 next call to generate_vis_points() or generate_vis_mesh().

This advanced interface supercedes the higher-level set_vis_inverse(), set_flat_texcoord_name(), and set_vis_2d().

If you use this advanced interface, you must specify explicitly the complete list of data columns to be created in the resulting GeomVertexData, by calling add_vis_column() each time. For each column, you specify the source of the column in the PFMFile, the target column and name in the GeomVertexData, and an optional transform matrix and/or lens to transform and project the point before generating it.

Definition at line 234 of file pfmVizzer.cxx.

◆ calc_max_u_displacement()

double PfmVizzer::calc_max_u_displacement ( ) const

Computes the maximum amount of shift, in pixels either left or right, of any pixel in the distortion map.

This can be passed to make_displacement(); see that function for more information.

Definition at line 367 of file pfmVizzer.cxx.

References PfmFile::get_point(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), and PfmFile::has_point().

◆ calc_max_v_displacement()

double PfmVizzer::calc_max_v_displacement ( ) const

Computes the maximum amount of shift, in pixels either up or down, of any pixel in the distortion map.

This can be passed to make_displacement(); see that function for more information.

Definition at line 395 of file pfmVizzer.cxx.

References PfmFile::get_point(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), and PfmFile::has_point().

◆ clear_aux_pfm()

void PfmVizzer::clear_aux_pfm ( )
inline

Removes the auxiliary PfmFile from this PfmVizzer.

Definition at line 183 of file pfmVizzer.I.

◆ clear_flat_texcoord_name()

void PfmVizzer::clear_flat_texcoord_name ( )
inline

Resets the flat_texcoord_name to empty, so that additional texture coordinates are not created.

This may be used in lieu of the lower-level add_vis_column().

Definition at line 81 of file pfmVizzer.I.

◆ clear_vis_blend()

void PfmVizzer::clear_vis_blend ( )
inline

Removes the blending map set by a prior call to set_vis_blend().

Definition at line 151 of file pfmVizzer.I.

◆ clear_vis_columns()

void PfmVizzer::clear_vis_columns ( )

Removes all of the previously-added vis columns in preparation for building a new list.

See add_vis_column().

Definition at line 216 of file pfmVizzer.cxx.

Referenced by set_flat_texcoord_name(), set_vis_2d(), and set_vis_inverse().

◆ extrude()

void PfmVizzer::extrude ( const Lens lens)

Converts each (u, v, depth) point of the Pfm file to an (x, y, z) point, by reversing project().

If the original file is only a 1-d file, assumes that it is a depth map with implicit (u, v) coordinates.

This method is only valid for a linear lens (e.g. a PerspectiveLens or OrthographicLens). Non-linear lenses don't necessarily compute a sensible depth coordinate.

Definition at line 103 of file pfmVizzer.cxx.

◆ generate_vis_mesh()

NodePath PfmVizzer::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 coordinates ranging from 0 .

. 1 based on the position within the pfm grid.

Definition at line 327 of file pfmVizzer.cxx.

◆ generate_vis_points()

NodePath PfmVizzer::generate_vis_points ( ) const

Creates a point cloud with the points of the pfm as 3-d coordinates in space, and texture coordinates ranging from 0 .

. 1 based on the position within the pfm grid.

Definition at line 246 of file pfmVizzer.cxx.

◆ get_aux_pfm()

const PfmFile * PfmVizzer::get_aux_pfm ( ) const
inline

Returns the reference to the auxiliary PfmFile queried by this PfmVizzer.

This contains the values that will be reflected in CT_aux_vertex3 etc. See set_aux_pfm().

Definition at line 193 of file pfmVizzer.I.

◆ get_flat_texcoord_name()

InternalName * PfmVizzer::get_flat_texcoord_name ( ) const
inline

Returns the flat_texcoord_name.

See set_flat_texcoord_name().

Definition at line 89 of file pfmVizzer.I.

◆ get_keep_beyond_lens()

bool PfmVizzer::get_keep_beyond_lens ( ) const
inline

Returns the keep_beyond_lens flag.

See set_keep_beyond_lens().

Definition at line 128 of file pfmVizzer.I.

◆ get_pfm() [1/2]

PfmFile & PfmVizzer::get_pfm ( )
inline

Returns the reference to the PfmFile manipulated by this PfmVizzer.

Definition at line 18 of file pfmVizzer.I.

◆ get_pfm() [2/2]

const PfmFile & PfmVizzer::get_pfm ( ) const
inline

Returns the reference to the PfmFile manipulated by this PfmVizzer.

Definition at line 30 of file pfmVizzer.I.

◆ get_vis_2d()

bool PfmVizzer::get_vis_2d ( ) const
inline

Returns the vis_2d flag.

See set_vis_2d().

Definition at line 110 of file pfmVizzer.I.

◆ get_vis_blend()

const PNMImage * PfmVizzer::get_vis_blend ( ) const
inline

Returns the blending map set by the most recent call to set_vis_blend(), or NULL if there is no blending map in effect.

Definition at line 160 of file pfmVizzer.I.

◆ get_vis_inverse()

bool PfmVizzer::get_vis_inverse ( ) const
inline

Returns the vis_inverse flag.

See set_vis_inverse().

Definition at line 53 of file pfmVizzer.I.

◆ make_displacement() [1/2]

void PfmVizzer::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 components and the third component unused, this computes an AfterEffects-style displacement map that represents the same distortion.

The indicated PNMImage will be filled in with a displacement map image, with horizontal shift in the red channel and vertical shift in the green channel, where a fully bright (or fully black) pixel indicates a shift of max_u or max_v pixels.

Use calc_max_u_displacement() and calc_max_v_displacement() to compute suitable values for max_u and max_v.

This generates an integer 16-bit displacement image. It is a good idea, though not necessarily essential, to check "Preserve RGB" in the interpret footage section for each displacement image. Set for_32bit true if this is meant to be used in a 32-bit project file, and false if it is meant to be used in a 16-bit project file.

Definition at line 436 of file pfmVizzer.cxx.

References PNMImage::clear(), PNMImageHeader::get_x_size(), and PNMImageHeader::get_y_size().

◆ make_displacement() [2/2]

void PfmVizzer::make_displacement ( PfmFile 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 components and the third component unused, this computes an AfterEffects-style displacement map that represents the same distortion.

The indicated PNMImage will be filled in with a displacement map image, with horizontal shift in the red channel and vertical shift in the green channel, where a fully bright (or fully black) pixel indicates a shift of max_u or max_v pixels.

Use calc_max_u_displacement() and calc_max_v_displacement() to compute suitable values for max_u and max_v.

This generates a 32-bit floating-point displacement image. It is essential to check "Preserve RGB" in the interpret footage section for each displacement image. Set for_32bit true if this is meant to be used in a 32-bit project file, and false if it is meant to be used in a 16-bit project file.

Definition at line 530 of file pfmVizzer.cxx.

References PfmFile::clear(), PNMImageHeader::get_x_size(), and PNMImageHeader::get_y_size().

◆ project()

void PfmVizzer::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, converting each point to a (u, v, w) texture coordinate.

The resulting file can be generated to a mesh (with set_vis_inverse(true) and generate_vis_mesh()) that will apply the lens distortion to an arbitrary texture image.

Definition at line 52 of file pfmVizzer.cxx.

◆ set_aux_pfm()

void PfmVizzer::set_aux_pfm ( const PfmFile pfm)
inline

Assigns an auxiliary PfmFile to this PfmVizzer.

This file will be queried by column types CT_aux_vertex1/2/3, but has no other meaning to the vizzer. This size of this PfmFile should exactly match the base PfmFile. No reference count is held and no copy is made; the caller is responsible for ensuring that the auxiliary PfmFile will persist throughout the lifetime of the PfmVizzer it is assigned to.

Definition at line 173 of file pfmVizzer.I.

References PNMImageHeader::get_x_size(), and PNMImageHeader::get_y_size().

◆ set_flat_texcoord_name()

void PfmVizzer::set_flat_texcoord_name ( InternalName flat_texcoord_name)
inline

If the flat_texcoord_name is specified, it is the name of an additional vertex column that will be created for the "flat" texture coordinates, i.e.

the original 0..1 values that correspond to the 2-D index position of each point in the original pfm file.

These are the same values that will be assigned to the default texture coordinates if the vis_inverse flag is *not* true.

This may be used in lieu of the lower-level add_vis_column().

Definition at line 69 of file pfmVizzer.I.

References clear_vis_columns().

◆ set_keep_beyond_lens()

void PfmVizzer::set_keep_beyond_lens ( bool  keep_beyond_lens)
inline

Sets the keep_beyond_lens flag.

When this flag is true, points that fall outside of the normal lens range in project() or in add_vis_column() will be retained anyway; when it is false, these points will be discarded.

Definition at line 120 of file pfmVizzer.I.

◆ set_vis_2d()

void PfmVizzer::set_vis_2d ( bool  vis_2d)
inline

Sets the vis_2d flag.

When this flag is true, only the first two (x, y) value of each depth point is considered meaningful; the z component is ignored. This is only relevant for generating visualizations.

This may be used in lieu of the lower-level add_vis_column().

Definition at line 101 of file pfmVizzer.I.

References clear_vis_columns().

Referenced by PfmTrans::process_pfm().

◆ set_vis_blend()

void PfmVizzer::set_vis_blend ( const PNMImage vis_blend)
inline

Specifies a blending map–a grayscale image–that will be applied to the vertex color during generate_vis_mesh() and generate_vis_points().

The image size must exactly match the mesh size of the PfmVizzer.

Ownership of the pointer is not kept by the PfmVizzer; it is your responsibility to ensure it does not destruct during the lifetime of the PfmVizzer (or at least not before your subsequent call to generate_vis_mesh()).

Definition at line 143 of file pfmVizzer.I.

◆ set_vis_inverse()

void PfmVizzer::set_vis_inverse ( bool  vis_inverse)
inline

Sets the vis_inverse flag.

When this flag is true, vis meshes and point clouds are generated with the 3-d depth value in the texture coordinates, and the 2-d index value in the vertex position. When it is false, meshes are generated normally, with the 3-d depth value in the vertex position and the 2-d index value in the texture coordinates.

This may be used in lieu of the lower-level add_vis_column().

Definition at line 44 of file pfmVizzer.I.

References clear_vis_columns().

Referenced by PfmTrans::process_pfm().


The documentation for this class was generated from the following files: