Skip to content

pycvc_gl Lab: ergonomic texture surface (set_texture + mesh/terrain UVs) - #162

Open
transfix wants to merge 1 commit into
masterfrom
feat/pycvc-gl-texture-helpers
Open

pycvc_gl Lab: ergonomic texture surface (set_texture + mesh/terrain UVs)#162
transfix wants to merge 1 commit into
masterfrom
feat/pycvc-gl-texture-helpers

Conversation

@transfix

Copy link
Copy Markdown
Owner

Wraps the cvcGL GeometryNode::setTexture surface added in #156 in the pycvc_gl.Lab helper, so a script can drape a raster on a mesh without reaching for the raw node.

Added to Lab

  • add_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 a pycvc.image or an (H,W,C) uint8/uint16/float32 numpy array (via pycvc.image.from_numpy), applied through the node's set_texture/set_texture_copy. zero_copy=True aliases the buffer (memory-safe: the C++ side holds the COW buffer in m_textureStorage); False copies.

Pure-Python, additive; the underlying .i bindings (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.

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant