From 38e4d64f220db5a69330ae4fe0e11375a8398867 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 9 Aug 2012 05:55:24 +0000 Subject: [PATCH] add set_texcoord_3d --- panda/src/distort/projectionScreen.I | 27 ++++++++++++++++++++++++++ panda/src/distort/projectionScreen.cxx | 4 +++- panda/src/distort/projectionScreen.h | 4 ++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/panda/src/distort/projectionScreen.I b/panda/src/distort/projectionScreen.I index b93764f1b3..2c7e9a84a6 100644 --- a/panda/src/distort/projectionScreen.I +++ b/panda/src/distort/projectionScreen.I @@ -86,6 +86,33 @@ get_invert_uvs() const { return _invert_uvs; } +//////////////////////////////////////////////////////////////////// +// Function: ProjectionScreen::set_texcoord_3d +// Access: Published +// Description: Set this true to force 3-D texture coordinates to be +// created for the geometry. When this is true and the +// geometry has only 2-D texture coordinates, those +// texture coordinates are dumped in favor of 3-D +// coordinates. When this is false, whatever texture +// coordinates already exist are preserved as-is. +//////////////////////////////////////////////////////////////////// +INLINE void ProjectionScreen:: +set_texcoord_3d(bool texcoord_3d) { + _texcoord_3d = texcoord_3d; + _stale = true; +} + + +//////////////////////////////////////////////////////////////////// +// Function: ProjectionScreen::get_texcoord_3d +// Access: Published +// Description: See set_texcoord_3d(). +//////////////////////////////////////////////////////////////////// +INLINE bool ProjectionScreen:: +get_texcoord_3d() const { + return _texcoord_3d; +} + //////////////////////////////////////////////////////////////////// // Function: ProjectionScreen::set_vignette_on // Access: Published diff --git a/panda/src/distort/projectionScreen.cxx b/panda/src/distort/projectionScreen.cxx index 9aba77cd38..5ab3167d21 100644 --- a/panda/src/distort/projectionScreen.cxx +++ b/panda/src/distort/projectionScreen.cxx @@ -40,6 +40,7 @@ ProjectionScreen(const string &name) : PandaNode(name) _texcoord_name = InternalName::get_texcoord(); _invert_uvs = project_invert_uvs; + _texcoord_3d = false; _vignette_on = false; _vignette_color.set(0.0f, 0.0f, 0.0f, 1.0f); _frame_color.set(1.0f, 1.0f, 1.0f, 1.0f); @@ -547,7 +548,8 @@ recompute_geom(Geom *geom, const LMatrix4 &rel_mat) { // Iterate through all the vertices in the Geom. CPT(GeomVertexData) vdata = geom->get_vertex_data(); - if (!vdata->has_column(_texcoord_name)) { + CPT(GeomVertexFormat) vformat = vdata->get_format(); + if (!vformat->has_column(_texcoord_name) || (_texcoord_3d && vformat->get_column(_texcoord_name)->get_num_components() < 3)) { // We need to add a new column for the new texcoords. vdata = vdata->replace_column (_texcoord_name, 3, Geom::NT_stdfloat, Geom::C_texcoord); diff --git a/panda/src/distort/projectionScreen.h b/panda/src/distort/projectionScreen.h index f13f053d90..890ea2898d 100644 --- a/panda/src/distort/projectionScreen.h +++ b/panda/src/distort/projectionScreen.h @@ -82,6 +82,9 @@ PUBLISHED: INLINE void set_invert_uvs(bool invert_uvs); INLINE bool get_invert_uvs() const; + INLINE void set_texcoord_3d(bool texcoord_3d); + INLINE bool get_texcoord_3d() const; + INLINE void set_vignette_on(bool vignette_on); INLINE bool get_vignette_on() const; @@ -123,6 +126,7 @@ private: PT(LensNode) _projector_node; PT(InternalName) _texcoord_name; bool _invert_uvs; + bool _texcoord_3d; bool _vignette_on; LColor _vignette_color; LColor _frame_color;