I’m attempting to use MeshDrawer, and in particular the “linkSegment”/“linkSegmentEnd” functions, to depict an object that can be considered more-or-less as a long, narrow strip.
In terms of geometry, this seems to work well.
Things become problematic, however, when I attempt to apply a texture to that geometry.
Specifically, the uv-coordinates (as specified via the “frame” parameter) don’t seem to work as I’d expect:
(0, 0, uSize, 1) doesn’t seem to produce a mapping that starts at the horizontal edge of the texture, and
(0.875, 0, 0.125, 1) seems to produce a mapping that goes past the horizontal edge of the texture.
To illustrate what I mean, consider the simple texture below:
When I attempt to map this to a link-segment strip, I get the following:
Note that the numbers are rendered from left to right, as expected–but that “1” appears after “4”.
I can rectify this be starting with a frame that has a negative x-value–but that makes no sense to me.
Here below is the simple test-program that I used to produce the above:
(Where “numbers.png” is the texture embedded above.)
from direct.showbase.ShowBase import ShowBase from panda3d.core import MeshDrawer, OmniBoundingVolume, SamplerState, Vec4, Vec3 class Game(ShowBase): def __init__(self): ShowBase.__init__(self) self.meshDrawer = MeshDrawer() self.meshDrawer.setBudget(256) self.meshDrawerNP = self.meshDrawer.getRoot() self.meshDrawerNP.reparentTo(self.render) self.meshDrawerNP.setY(20) self.tex = loader.loadTexture("numbers.png") self.meshDrawerNP.setTexture(self.tex) self.meshDrawer.begin(self.cam, self.render) frame = Vec4(0, 0, 1/8, 1) thickness = 1 colour = Vec4(1, 1, 1, 1) pos = Vec3(-4, 1, 0) for i in range(8): print ("segment", frame) self.meshDrawer.linkSegment(pos, frame, thickness, colour) frame.addX(1/8) pos.addX(1) print ("end", frame) self.meshDrawer.linkSegmentEnd(frame, colour) self.meshDrawer.end() app = Game() app.run()
Does anyone see where I might be going wrong…? Or is this perhaps an issue in MeshDrawer…?