Movement trails - visibility problem [solved]

Im doing a movement trail effect. When i move the middle smily(geom pos) out of cam view from right side, the trail disappears. Same actually happens if the geom pos is behind the cam and the verts are all infront of cam, the trail is not visible.

I think the problem comes from moving around verts but not moving the geom pos. Can i solve this issue without moving the geom around, as it seems to me that then i would do double pos change for every vert.

Thanx in advance.

Example code below.

import direct.directbase.DirectStart
from direct.task import Task
from pandac.PandaModules import *

node=render.attachNewNode('node')

b1=loader.loadModel('smiley')
b1.reparentTo(node)
b1.setScale(0.25)
b1.flattenLight()

b2=loader.loadModel('smiley')
b2.reparentTo(node)
b2.setScale(0.25)
b2.flattenLight()
b2.setX(4)
b2.setR(90)

base.cam.setY(-20)

class Trail():
    def __init__(self,parent,hi):
        self.parent=parent

        #vert data
        self.vdata = GeomVertexData('name',GeomVertexFormat.getV3c4(),Geom.UHDynamic)
        
        #writers
        self.vertex = GeomVertexWriter(self.vdata, 'vertex')        
        self.color = GeomVertexWriter(self.vdata, 'color')        
        
        #trail len
        self.nr=100        
        
        #trail height step
        self.dim=1.0/self.nr
        
                
        for i in range(self.nr):
            alpha=1.0/(i+1)
            xx=i*1
            zz=(self.nr-i)/self.nr
            if i%2:                
                self.vertex.addData3f(xx,0,zz)
                self.color.addData4f(1,1,1,alpha)            
                self.color.addData4f(1,1,1,alpha)            
            else:
                self.vertex.addData3f(xx,0,-zz)
            
            
        #create prim
        prim = GeomTristrips(Geom.UHDynamic)
        for i in range(self.nr):
            prim.addVertex(i)
        prim.closePrimitive()
        
        #geom
        self.geom=Geom(self.vdata)
        self.geom.addPrimitive(prim)
                 
        self.node=GeomNode('gnode')
        self.node.addGeom(self.geom)
        
        self.geom.doublesideInPlace()
         
        self.nodePath = render.attachNewNode(self.node)        
        self.nodePath.setTransparency(TransparencyAttrib.MAlpha)
        
        #pos root
        self.root=self.parent.attachNewNode('root')
                
        #p dif is height
        self.p1=self.root.attachNewNode('p1')
        self.p1.setZ(hi*0.5)
        
        self.p2=self.root.attachNewNode('p2')
        self.p2.setZ(-hi*0.5)        
        
        #trail poses
        self.trpos=[]
        pos=[self.p1.getPos(),self.p2.getPos()]
        
        for i in range(self.nr>>1):
            self.trpos.append((pos))

    def run(self):           
        self.trpos.pop()
        self.trpos.insert(0,[self.p1.getPos(render),self.p2.getPos(render)])
        pos = GeomVertexWriter(self.vdata, 'vertex')
        
        if base.mouseWatcherNode.hasMouse():
            x=base.mouseWatcherNode.getMouseX()
            y=base.mouseWatcherNode.getMouseY()    
            b2.setX(3+y+x)
            
        node.setR(b1,2)
        
        
        


        for i in range(self.nr>>1):
            
            npos=self.root.getPos(render)
            xr,yr,zr=self.root.getPos()
            x1,y1,z1=self.trpos[i][0]
            x2,y2,z2=self.trpos[i][1]
            xx=x1-x2
            yy=y1-y2
            zz=z1-z2

            xdim=self.dim*i*xx
            ydim=self.dim*i*yy
            zdim=self.dim*i*zz
            
            pos.setData3f(x1-xdim,y1-ydim,z1-zdim)
            pos.setData3f(x2+xdim,y2+ydim,z2+zdim)
          
def do(task):

    tr.run()    
    
    return task.cont
    
taskMgr.add(do,'do')
tr=Trail(b2,0.5)

base.setFrameRateMeter(True)
run()

hey this is cool. thanks for sharing

did you see this one already ?
https://discourse.panda3d.org/viewtopic.php?t=2601

Unfotunaltely i could not get the Rayteller’s geomtrails to work, and i could not find anywhere a working link to treeforms code examples.

But still my question is why does the trail dissapear even thou the verts and prims are in cam visible range?

You need to set omini bounds on them.
see github.com/treeform/meshDrawer

Im sorry i dont understand what omni bounds means, and i cant find the solution from the example.

panda3d.org/apiref.php?page= … dingVolume

do show bounds on your node:
panda3d.org/apiref.php?page= … showBounds

g.setBounds(OmniBoundingVolume())
g.setFinal(True)

When you move geom positions them selfs it does not recompute bounding volume. You can either disable the bounds on it (by giving it OmniBoundingVolume) or recompute bounding volume every frame.