Okay, MeshDrawer is driving me up the wall now.
In attempting to make a small test-program to demonstrate a problem that I’ve been having with UV-mapping geometry generated by MeshDrawer, I bumped into another problem: “linkSegment” doesn’t seem to place the vertices for its segments as expected.
Let me demonstrate. Consider the following simple program:
from direct.showbase.ShowBase import ShowBase from panda3d.core import NodePath, PandaNode, MeshDrawer, Vec3, Vec4 class Game(ShowBase): def __init__(self): ShowBase.__init__(self) self.disableMouse() self.pts = [Vec3(-2, 0, 0), Vec3(-1, 0, 0), Vec3(0, 0, 0), Vec3(1, 0, 0), Vec3(2, 0, 0)] self.camera.setY(-10) self.meshDrawer = MeshDrawer() self.meshDrawer.setBudget(1024) self.meshDrawerNP = self.meshDrawer.getRoot() self.meshDrawerNP.reparentTo(self.render) tex = loader.loadTexture("colours.png") self.meshDrawerNP.setTexture(tex) self.meshDrawer.begin(self.cam, self.render) frame = Vec4(0, 0, 0.25, 1) thickness = 1 colour = Vec4(1, 1, 1, 1) for index, pt in enumerate(self.pts): if index > 1: frame.addX(0.25) self.meshDrawer.linkSegment(pt, frame, thickness, colour) frame.addX(0.25) self.meshDrawer.linkSegmentEnd(frame, colour) self.meshDrawer.end() app = Game() app.run()
And here below is the texture used:
This simply has MeshDrawer created link-segments from a set of evenly-spaced points, with evenly-spaced UVs, and applying a texture composed of even bands of colour.
However, as you may see if you run the program, the colours are not distributed evenly: some bands are significantly thicker than others!
Now, this might be thought to be a UV-mapping issue… But I used the “writeBam” method to save out the geometry produced, loaded it into PView, activated wireframe mode, and this is what I found:
For some reason the segments are not of equal size, despite being produced from points of equal spacing!
Naturally, this rather complicates UV-mapping when the texture is intended to proceed evenly along the strip of segments…
Once again, let me ask: Is this a bug in MeshDrawer? Am I doing something wrong? Is there a workaround, given that my goal is to apply a texture evenly to a dynamically-generated link-segment (i.e. with an updating set of points)?