pycvc_gl Lab: ergonomic texture surface (set_texture + mesh/terrain UVs) - #162
Open
transfix wants to merge 1 commit into
Open
pycvc_gl Lab: ergonomic texture surface (set_texture + mesh/terrain UVs)#162transfix wants to merge 1 commit into
transfix wants to merge 1 commit into
Conversation
Wrap the cvcGL GeometryNode::setTexture surface (#156) in the Lab helper so scripts can drape a raster on a mesh without touching the raw node: - add_mesh(..., uvs=): attach texture coordinates alongside verts/tris. - add_terrain(): emit planar UVs (u along +x, v along +y) so a terrain surface is texturable out of the box. - set_texture(name, image): accept a pycvc.image OR an (H,W,C) numpy array (via pycvc.image.from_numpy) and apply it via the node's set_texture / set_texture_copy. zero_copy aliases the buffer; False copies. Motivating use: paint a river onto terrain from a scene watermask instead of a separate lifted water mesh that z-fights the ground (platoon demo).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wraps the cvcGL
GeometryNode::setTexturesurface added in #156 in thepycvc_gl.Labhelper, so a script can drape a raster on a mesh without reaching for the raw node.Added to
Labadd_mesh(..., uvs=)— attach flat[u,v,...]texture coordinates alongside verts/tris (geometry.set_uvs).add_terrain()— now emits planar UVs (u along +x, v along +y), so a terrain surface is texturable out of the box.set_texture(name, image)— accepts apycvc.imageor an(H,W,C)uint8/uint16/float32 numpy array (viapycvc.image.from_numpy), applied through the node'sset_texture/set_texture_copy.zero_copy=Truealiases the buffer (memory-safe: the C++ side holds the COW buffer inm_textureStorage);Falsecopies.Pure-Python, additive; the underlying
.ibindings (set_texture,set_uvs,image.from_numpy) already merged in #156.Motivation
The DBG platoon demo painted its river as a separate lifted water mesh that z-fought the terrain. With this, it drapes the river onto the terrain surface from the scene watermask (
Lab.set_texture("terrain", water_rgba)) — see CVC-DBG/grl-snam-dbg#20.