DirectGUI interferes with glowShader?

I have stumbled upon an interesting “bug?” with the glowShader given in the tron example that I am now trying to use in my game development. My game has parts where I use the standard lineSegs and I make them glow using the glowShader.

        lines = LineSegs()
        lines.moveTo(x1,self.y,z1) 
        lines.drawTo(x2,self.y,z2) 
        lines.setThickness(4) 
        node = lines.create() 
        self.myNodePath = NodePath(node) 
        self.myNodePath.reparentTo(render)
        self.myNodePath.setColor(globals.colors['guiblue1'])
        self.setGlow(self.myNodePath)
 
    def setGlow(self, sim):
        """Does the object glow"""
        sim.setShaderInput('glow',Vec4(self.glow,0,0,0),self.glow)

This works nicely, however I have noticed (at least in linux) that when I put in some DirectGUI stuff sometimes the gloweffect goes away. Sometimes it comes back if I pop in more directGUI controls. I’m unsure why directGUI would have an effect on the glowShader, but it seems to. I have also noticed that the glow effect is not bothered on my other sims, just the line segments.

Has anyone come across this before?

If this is not enough information I can put together a runnable example, but I thought I would throw this out there first to see if it has come up before.

Thanks,

C

I guess nobody has come across this, which is too bad, but I’ll throw another question out there that would get the job done for me without worrying about LineSegs.

I’ve noticed that regular objects glow properly, so I experimented with loading a square image and stretching it out so it looks like a line. Looks great with the glow effect, it also doesn’t seem to have much of a performance hit compared to the lineSegs.

LineSegs is nice because you give it x1, y1, x2, y2 and it does the rest, with this other method I did the following:

  • Calculated the middle of the two points and placed the object there.
  • Calculated the range between the two points and made the object stretch out between them

My problem (and question for you) is how to calculate the angle properly between the two points so that I can rotate the image so that it lines up properly. I’m only concerned with x and z, y is constant. All this work is on the x, z plane.

I’ve looked on the forums and found some things, but everything I have tried has not quite done the job.

This is the function (that I made from a previous game) that I tried to use, it was “close”, but in some cases it did not do the job. Also I noticed I had to add 90 degrees if the range was in (0,90,180,270).

def getRelativeAngle(x1, y1, x2, y2):

    """Return the Relative Angle from Point A's perspective between point 

    A and point B.  Return in degrees"""

    dx = x2-x1

    dy = y2-y1

    angle = 0.0



    # calculate angle

    if dx == 0.0:

        if dy == 0.0:

            angle = 0.0

        elif dy > 0.0:

            angle = math.pi / 2.0

        else:

            angle = math.pi * 3.0 / 2.0  

    elif dy == 0.0:

        if  dx > 0.0:

            angle = 0.0

        else:

            angle = math.pi

    else:

        ratio = float(dy)/float(dx)

        if  dx < 0.0:

            angle = math.atan(ratio) + math.pi

        elif dy < 0.0:

            angle = math.atan(ratio) + (2 * math.pi)

        else:

            angle = math.atan(ratio)

        

    # convert to degrees

    angle = 180.0*angle/math.pi

    

    if angle < 0:

        angle += 360.0

    return angle

Any help would be appreciated!

C

use lookAt :

CM=CardMaker('')
CM.setFrame(0,1,-.003,.003)
card=aspect2d.attachNewNode(CM.generate())
card.setH(90)
card.flattenLight()
card.lookAt(aPoint)