Hi! I’ve spent many time trying to figure out what is going on, and nothing I’ve tried worked.
I am trying to draw a laser path using meshdrawer. Everything seems to work at first, but I’ve noticed that when I move my ship to the side, the path disappear.
Here is what I am doing, adapted for easier understanding:
generator = MeshDrawer() generator.setBudget(20) generatorNode = generator.getRoot() generatorNode.reparentTo(render) generatorNode.setDepthWrite(False) generatorNode.setTransparency(True) generatorNode.setTwoSided(True) generatorNode.setTexture(loader.loadTexture("assets/sprites/laser.png")) generatorNode.setTexRotate(TextureStage.getDefault(), 0) generatorNode.setBin("fixed",0) generatorNode.setLightOff(True) taskMgr.add(drawLaser, 'drawLaser', extraArgs=[laser], appendTask=True) def drawLaser(laser, task): generator = laser['GENERATOR'] color = Vec4(1,1,1,1) frame = Vec4(1,1,1,1) laser['TRAIL_PATH'] += [entity['NODE'].getPos()] if len(entity['TRAIL_PATH']) >= 20: del entity['TRAIL_PATH'] head_position = laser['TRAIL_PATH'][-1] tail_position = laser['TRAIL_PATH'] generator.begin(base.cam, render) generator.linkSegment(head_position,frame,1,color) generator.linkSegment(tail_position,frame,1,color) generator.linkSegmentEnd(Vec4(1,1,1,1),color) generator.end() return task.cont
What I get with that is a working laser, but as I said, if I move my camera up,down,left or right too much (not that much), the meshdrawer become invisible. When I move back to my original position, it reappear. If I make a mesh with constant position:
generator.begin(base.cam, render) generator.linkSegment(Vec3(0,1000,0),frame,1,color) generator.linkSegment(Vec3(0,0,0),frame,1,color) generator.linkSegmentEnd(Vec4(1,1,1,1),color) generator.end()
I can move on the side as much as I want, and the trail still appear. Another way to see it is that if someone is by my side and fire a laser in the direction I am looking, the trail is invisible to me.
So a moving laser (meshdrawer) disapear when moving on the side, but not a fixed one.
Help would be much appreciated!