View Single Post
  #1  
Old 01-11-2005, 03:13 PM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
Creating on the fly objects and projecting them on texture

Hi,
to add a graph to my 3d World (e.g. show velocity vs. time) I thought to create on-the-fly points and then add them to a texquad.

The advantage of this "projection" would be, that as it seems the texquad stays on the same place of the monitor.

Generating points works fine, but I don't get my points on the texquad. Or is the whole idea no good?

This wil be my last question for today

Thank you, Johannes

ExampleProgram

import viz

viz.go()

quad = viz.add(viz.TEXQUAD,viz.SCREEN)
quad.translate(0.5,0.5, 0.5)
quad.scale(3,3, 1)
quad.visible(viz.OFF)


RADIUS=1

viz.startlayer(viz.LINE_LOOP)
viz.vertexcolor(2, 4, 4)
viz.vertex(-RADIUS, -RADIUS, RADIUS)
viz.vertex(-RADIUS, RADIUS, RADIUS)
line = viz.endlayer()

viz.startlayer(viz.LINE_LOOP)
viz.vertexcolor(2, 4, 4)
viz.vertex(-RADIUS, -RADIUS, RADIUS)
viz.vertex(RADIUS, -RADIUS, RADIUS)
line2 = viz.endlayer()
#line.translate(3,2,4)

SPIsSet,EPIsSet=0,0
startPoint=[0,0,0]
endPoint=[0,0,0]
show=1
pointListe=[]

def mousedown(button):
#
if button == viz.MOUSEBUTTON_LEFT:
global startPoint,SPIsSet
global endPoint,EPIsSet, pointListe
if SPIsSet==0:
startPoint=viz.screentoworld(viz.mousepos())
#print 'startPoint:',startPoint
#SPIsSet=1
pointListe.append(startPoint)
drawPoints()
else:
print 'forgot option 3'
if button == viz.MOUSEBUTTON_RIGHT:
show=1
drawPoints()

def drawPoints():
viz.startlayer(viz.POINTS)
viz.vertexcolor(0,12,1)
viz.pointsize(2)
for object in pointListe:
print 'pointliste',pointListe
viz.vertex(object)
points = viz.endlayer()
quad.texture(points)
quad.visible(viz.ON)



#Create callbacks for timer events and mouse click events
viz.callback(viz.MOUSEDOWN_EVENT,mousedown)
Reply With Quote