PDA

View Full Version : Why I need two points for viz.startlayer(viz.POINTS)


jincheker
01-28-2011, 06:59 AM
Hi, I want to show the points as mouse moves, and I program like below:


def plotGraph(x,y):
viz.startlayer(viz.POINTS)
viz.pointsize(5)
# viz.vertexcolor(viz.RED)
# viz.vertex(0,0,0)
viz.vertexcolor(viz.BLACK)
viz.vertex(x,y,0)
line = viz.endlayer(viz.SCREEN)
print 'plot',x,y

def onMouseMove(e):
plotGraph(e.x,e.y)

viz.go()
viz.clearcolor(viz.SKYBLUE)
viz.callback(viz.MOUSE_MOVE_EVENT,onMouseMove)


The problem is if i comment

viz.vertexcolor(viz.RED)
viz.vertex(0,0,0)


The code won't work, but if I uncomment them, then it works.
Can anyone tell me why? Is it because startlayer needs at lease two points?

Thank you

farshizzo
01-28-2011, 08:46 AM
OpenSceneGraph will cull objects that appear very small on screen. Since you have one point, it is computed as infinitely small on screen and not rendered. You can disable viz.CULLING on the node to prevent this from happening:line.disable(viz.CULLING)