mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
add set_vis_blend()
This commit is contained in:
parent
7c830b277f
commit
306bb1ff42
@ -592,6 +592,49 @@ get_vis_2d() const {
|
|||||||
return _vis_2d;
|
return _vis_2d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PfmFile::set_vis_blend
|
||||||
|
// Access: Published
|
||||||
|
// Description: 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
|
||||||
|
// PfmFile.
|
||||||
|
//
|
||||||
|
// Ownership of the pointer is not kept by the PfmFile;
|
||||||
|
// it is your responsibility to ensure it does not
|
||||||
|
// destruct during the lifetime of the PfmFile (or at
|
||||||
|
// least not before your subsequent call to
|
||||||
|
// generate_vis_mesh()).
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void PfmFile::
|
||||||
|
set_vis_blend(const PNMImage *vis_blend) {
|
||||||
|
_vis_blend = vis_blend;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PfmFile::set_vis_blend
|
||||||
|
// Access: Published
|
||||||
|
// Description: Removes the blending map set by a prior call to
|
||||||
|
// set_vis_blend().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void PfmFile::
|
||||||
|
clear_vis_blend() {
|
||||||
|
_vis_blend = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PfmFile::get_vis_blend
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the blending map set by the most recent call
|
||||||
|
// to set_vis_blend(), or NULL if there is no blending
|
||||||
|
// map in effect.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE const PNMImage *PfmFile::
|
||||||
|
get_vis_blend() const {
|
||||||
|
return _vis_blend;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PfmFile::get_table
|
// Function: PfmFile::get_table
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -45,6 +45,7 @@ PfmFile() {
|
|||||||
_has_point = has_point_noop;
|
_has_point = has_point_noop;
|
||||||
_vis_inverse = false;
|
_vis_inverse = false;
|
||||||
_vis_2d = false;
|
_vis_2d = false;
|
||||||
|
_vis_blend = NULL;
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +63,8 @@ PfmFile(const PfmFile ©) :
|
|||||||
_no_data_value(copy._no_data_value),
|
_no_data_value(copy._no_data_value),
|
||||||
_has_point(copy._has_point),
|
_has_point(copy._has_point),
|
||||||
_vis_inverse(copy._vis_inverse),
|
_vis_inverse(copy._vis_inverse),
|
||||||
_vis_2d(copy._vis_2d)
|
_vis_2d(copy._vis_2d),
|
||||||
|
_vis_blend(copy._vis_blend)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +83,7 @@ operator = (const PfmFile ©) {
|
|||||||
_has_point = copy._has_point;
|
_has_point = copy._has_point;
|
||||||
_vis_inverse = copy._vis_inverse;
|
_vis_inverse = copy._vis_inverse;
|
||||||
_vis_2d = copy._vis_2d;
|
_vis_2d = copy._vis_2d;
|
||||||
|
_vis_blend = copy._vis_blend;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -94,6 +97,7 @@ clear() {
|
|||||||
_y_size = 0;
|
_y_size = 0;
|
||||||
_scale = 1.0;
|
_scale = 1.0;
|
||||||
_num_channels = 3;
|
_num_channels = 3;
|
||||||
|
_vis_blend = NULL;
|
||||||
_table.clear();
|
_table.clear();
|
||||||
clear_no_data_value();
|
clear_no_data_value();
|
||||||
}
|
}
|
||||||
@ -110,6 +114,7 @@ clear(int x_size, int y_size, int num_channels) {
|
|||||||
_y_size = y_size;
|
_y_size = y_size;
|
||||||
_scale = 1.0;
|
_scale = 1.0;
|
||||||
_num_channels = num_channels;
|
_num_channels = num_channels;
|
||||||
|
_vis_blend = NULL;
|
||||||
|
|
||||||
_table.clear();
|
_table.clear();
|
||||||
int size = _x_size * _y_size * _num_channels;
|
int size = _x_size * _y_size * _num_channels;
|
||||||
@ -2149,6 +2154,11 @@ build_auto_vis_columns(VisColumns &vis_columns, bool for_points) const {
|
|||||||
// We need an additional texcoord column for the flat texcoords.
|
// We need an additional texcoord column for the flat texcoords.
|
||||||
add_vis_column(vis_columns, CT_texcoord2, CT_texcoord2, _flat_texcoord_name);
|
add_vis_column(vis_columns, CT_texcoord2, CT_texcoord2, _flat_texcoord_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_vis_blend != (PNMImage *)NULL) {
|
||||||
|
// The blend map, if specified, also gets applied to the vertices.
|
||||||
|
add_vis_column(vis_columns, CT_blend1, CT_blend1, InternalName::get_color());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -2196,6 +2206,12 @@ make_array_format(const VisColumns &vis_columns) const {
|
|||||||
numeric_type = GeomEnums::NT_float32;
|
numeric_type = GeomEnums::NT_float32;
|
||||||
contents = GeomEnums::C_vector;
|
contents = GeomEnums::C_vector;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CT_blend1:
|
||||||
|
num_components = 4;
|
||||||
|
numeric_type = GeomEnums::NT_uint8;
|
||||||
|
contents = GeomEnums::C_color;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
nassertr(num_components != 0, NULL);
|
nassertr(num_components != 0, NULL);
|
||||||
|
|
||||||
@ -2394,6 +2410,16 @@ add_data(const PfmFile &file, GeomVertexWriter &vwriter, int xi, int yi, bool re
|
|||||||
vwriter.set_data3f(n);
|
vwriter.set_data3f(n);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CT_blend1:
|
||||||
|
{
|
||||||
|
const PNMImage *vis_blend = file.get_vis_blend();
|
||||||
|
if (vis_blend != NULL) {
|
||||||
|
double gray = vis_blend->get_gray(xi, yi);
|
||||||
|
vwriter.set_data3d(gray, gray, gray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +123,10 @@ PUBLISHED:
|
|||||||
INLINE void set_vis_2d(bool vis_2d);
|
INLINE void set_vis_2d(bool vis_2d);
|
||||||
INLINE bool get_vis_2d() const;
|
INLINE bool get_vis_2d() const;
|
||||||
|
|
||||||
|
INLINE void set_vis_blend(const PNMImage *vis_blend);
|
||||||
|
INLINE void clear_vis_blend();
|
||||||
|
INLINE const PNMImage *get_vis_blend() const;
|
||||||
|
|
||||||
enum ColumnType {
|
enum ColumnType {
|
||||||
CT_texcoord2,
|
CT_texcoord2,
|
||||||
CT_texcoord3,
|
CT_texcoord3,
|
||||||
@ -130,6 +134,7 @@ PUBLISHED:
|
|||||||
CT_vertex2,
|
CT_vertex2,
|
||||||
CT_vertex3,
|
CT_vertex3,
|
||||||
CT_normal3,
|
CT_normal3,
|
||||||
|
CT_blend1,
|
||||||
};
|
};
|
||||||
void clear_vis_columns();
|
void clear_vis_columns();
|
||||||
void add_vis_column(ColumnType source, ColumnType target,
|
void add_vis_column(ColumnType source, ColumnType target,
|
||||||
@ -223,6 +228,7 @@ private:
|
|||||||
bool _vis_inverse;
|
bool _vis_inverse;
|
||||||
PT(InternalName) _flat_texcoord_name;
|
PT(InternalName) _flat_texcoord_name;
|
||||||
bool _vis_2d;
|
bool _vis_2d;
|
||||||
|
const PNMImage *_vis_blend;
|
||||||
|
|
||||||
VisColumns _vis_columns;
|
VisColumns _vis_columns;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user