mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-19 13:15:00 -04:00
use 2-d texture coordinates when possible
This commit is contained in:
parent
781207e5cf
commit
85ff01dba5
@ -47,6 +47,19 @@ set_has_uvs(bool flag) {
|
|||||||
_has_uvs = flag;
|
_has_uvs = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CardMaker::set_has_3d_uvs
|
||||||
|
// Access: Public
|
||||||
|
// Description: Sets the flag indicating whether vertices will be
|
||||||
|
// generated with 3-component UVW's (true) or
|
||||||
|
// 2-component UV's (the default, false). Normally,
|
||||||
|
// this will be implicitly set by setting the uv_range.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void CardMaker::
|
||||||
|
set_has_3d_uvs(bool flag) {
|
||||||
|
_has_3d_uvs = flag;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: CardMaker::set_uv_range
|
// Function: CardMaker::set_uv_range
|
||||||
// Access: Public
|
// Access: Public
|
||||||
@ -62,6 +75,8 @@ set_uv_range(const TexCoord3f &ll, const TexCoord3f &lr, const TexCoord3f &ur, c
|
|||||||
_lr_tex = lr;
|
_lr_tex = lr;
|
||||||
_ur_tex = ur;
|
_ur_tex = ur;
|
||||||
_ul_tex = ul;
|
_ul_tex = ul;
|
||||||
|
_has_uvs = true;
|
||||||
|
_has_3d_uvs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -79,6 +94,8 @@ set_uv_range(const TexCoordf &ll, const TexCoordf &lr, const TexCoordf &ur, cons
|
|||||||
_lr_tex.set(lr[0], lr[1], 0.0f);
|
_lr_tex.set(lr[0], lr[1], 0.0f);
|
||||||
_ur_tex.set(ur[0], ur[1], 0.0f);
|
_ur_tex.set(ur[0], ur[1], 0.0f);
|
||||||
_ul_tex.set(ul[0], ul[1], 0.0f);
|
_ul_tex.set(ul[0], ul[1], 0.0f);
|
||||||
|
_has_uvs = true;
|
||||||
|
_has_3d_uvs = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -96,6 +113,8 @@ set_uv_range(const TexCoordf &ll, const TexCoordf &ur) {
|
|||||||
_lr_tex.set(ur[0], ll[1], 0.0f);
|
_lr_tex.set(ur[0], ll[1], 0.0f);
|
||||||
_ur_tex.set(ur[0], ur[1], 0.0f);
|
_ur_tex.set(ur[0], ur[1], 0.0f);
|
||||||
_ul_tex.set(ll[0], ur[1], 0.0f);
|
_ul_tex.set(ll[0], ur[1], 0.0f);
|
||||||
|
_has_uvs = true;
|
||||||
|
_has_3d_uvs = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -113,6 +132,8 @@ set_uv_range(const LVector4f &x, const LVector4f &y, const LVector4f &z) {
|
|||||||
_lr_tex.set(x[1], y[1], z[1]);
|
_lr_tex.set(x[1], y[1], z[1]);
|
||||||
_ur_tex.set(x[2], y[2], z[2]);
|
_ur_tex.set(x[2], y[2], z[2]);
|
||||||
_ul_tex.set(x[3], y[3], z[3]);
|
_ul_tex.set(x[3], y[3], z[3]);
|
||||||
|
_has_uvs = true;
|
||||||
|
_has_3d_uvs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
void CardMaker::
|
void CardMaker::
|
||||||
reset() {
|
reset() {
|
||||||
_has_uvs = true;
|
_has_uvs = true;
|
||||||
|
_has_3d_uvs = false;
|
||||||
|
|
||||||
_ll_pos.set(0.0f, 0.0f, 0.0f);
|
_ll_pos.set(0.0f, 0.0f, 0.0f);
|
||||||
_lr_pos.set(1.0f, 0.0f, 0.0f);
|
_lr_pos.set(1.0f, 0.0f, 0.0f);
|
||||||
@ -71,6 +72,7 @@ generate() {
|
|||||||
CPT(GeomVertexFormat) format;
|
CPT(GeomVertexFormat) format;
|
||||||
if (_has_normals) {
|
if (_has_normals) {
|
||||||
if (_has_uvs) {
|
if (_has_uvs) {
|
||||||
|
if (_has_3d_uvs) {
|
||||||
format = GeomVertexFormat::register_format(new GeomVertexArrayFormat
|
format = GeomVertexFormat::register_format(new GeomVertexArrayFormat
|
||||||
(InternalName::get_vertex(), 3,
|
(InternalName::get_vertex(), 3,
|
||||||
GeomEnums::NT_float32, GeomEnums::C_point,
|
GeomEnums::NT_float32, GeomEnums::C_point,
|
||||||
@ -80,11 +82,15 @@ generate() {
|
|||||||
GeomEnums::NT_packed_dabc, GeomEnums::C_color,
|
GeomEnums::NT_packed_dabc, GeomEnums::C_color,
|
||||||
InternalName::get_texcoord(), 3,
|
InternalName::get_texcoord(), 3,
|
||||||
GeomEnums::NT_float32, GeomEnums::C_texcoord));
|
GeomEnums::NT_float32, GeomEnums::C_texcoord));
|
||||||
|
} else {
|
||||||
|
format = GeomVertexFormat::get_v3n3cpt2();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
format = GeomVertexFormat::get_v3n3cp();
|
format = GeomVertexFormat::get_v3n3cp();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_has_uvs) {
|
if (_has_uvs) {
|
||||||
|
if (_has_3d_uvs) {
|
||||||
format = GeomVertexFormat::register_format(new GeomVertexArrayFormat
|
format = GeomVertexFormat::register_format(new GeomVertexArrayFormat
|
||||||
(InternalName::get_vertex(), 3,
|
(InternalName::get_vertex(), 3,
|
||||||
GeomEnums::NT_float32, GeomEnums::C_point,
|
GeomEnums::NT_float32, GeomEnums::C_point,
|
||||||
@ -92,6 +98,9 @@ generate() {
|
|||||||
GeomEnums::NT_packed_dabc, GeomEnums::C_color,
|
GeomEnums::NT_packed_dabc, GeomEnums::C_color,
|
||||||
InternalName::get_texcoord(), 3,
|
InternalName::get_texcoord(), 3,
|
||||||
GeomEnums::NT_float32, GeomEnums::C_texcoord));
|
GeomEnums::NT_float32, GeomEnums::C_texcoord));
|
||||||
|
} else {
|
||||||
|
format = GeomVertexFormat::get_v3cpt2();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
format = GeomVertexFormat::get_v3cp();
|
format = GeomVertexFormat::get_v3cp();
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ PUBLISHED:
|
|||||||
INLINE void set_uv_range(const TexCoord3f &ll, const TexCoord3f &lr, const TexCoord3f &ur, const TexCoord3f &ul);
|
INLINE void set_uv_range(const TexCoord3f &ll, const TexCoord3f &lr, const TexCoord3f &ur, const TexCoord3f &ul);
|
||||||
INLINE void set_uv_range(const LVector4f &x, const LVector4f &y, const LVector4f &z);
|
INLINE void set_uv_range(const LVector4f &x, const LVector4f &y, const LVector4f &z);
|
||||||
INLINE void set_has_uvs(bool flag);
|
INLINE void set_has_uvs(bool flag);
|
||||||
|
INLINE void set_has_3d_uvs(bool flag);
|
||||||
INLINE void set_uv_range_cube(int face);
|
INLINE void set_uv_range_cube(int face);
|
||||||
|
|
||||||
INLINE void set_frame(float left, float right, float bottom, float top);
|
INLINE void set_frame(float left, float right, float bottom, float top);
|
||||||
@ -62,7 +63,7 @@ PUBLISHED:
|
|||||||
private:
|
private:
|
||||||
PT(PandaNode) rescale_source_geometry();
|
PT(PandaNode) rescale_source_geometry();
|
||||||
|
|
||||||
bool _has_uvs;
|
bool _has_uvs, _has_3d_uvs;
|
||||||
Vertexf _ul_tex, _ll_tex, _lr_tex, _ur_tex;
|
Vertexf _ul_tex, _ll_tex, _lr_tex, _ur_tex;
|
||||||
TexCoord3f _ul_pos, _ll_pos, _lr_pos, _ur_pos;
|
TexCoord3f _ul_pos, _ll_pos, _lr_pos, _ur_pos;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user