#1
|
|||
|
|||
Draw line with a triangle at the end
Hi,
I want to draw a line and at the end of this line I want to draw an arrow. I've made: Code:
viz.startlayer(viz.LINES) viz.linewidth(5) viz.vertexcolor(0,0.6,0) viz.vertex(punkt1) viz.vertex(punkt2) viz.startlayer(viz.TRIANGLES) viz.vertex(1,0,0) viz.vertex(-1,0,0) viz.vertex(0,1,0) name = viz.endlayer(scene=szene) I looked at the tutorial "Hierarchical Models", but this does not help. I want to draw a line and at the end of this line there should be an arrow. And it should be possible to rotate the line along with the arrow. Can anybody help me - please? Thanks a lot! |
#2
|
|||
|
|||
You can set the triangle's parent to be the line and then when you move or rotate the line the triangle will follow.
Code:
triangle = viz.endlayer(parent=line) |
#3
|
|||
|
|||
Hey,
I've done this, but it does not work: Code:
viz.startlayer(viz.LINES) viz.linewidth(5) viz.vertexcolor(0,0.6,0) viz.vertex(punkt1) viz.vertex(punkt2) viz.startlayer(viz.TRIANGLES) viz.vertex(1,0,0) viz.vertex(-1,0,0) viz.vertex(0,1,0) name = viz.endlayer(scene=szene) triangle = viz.endlayer(parent=name) name.center(punkt1) In 02.bmp I've described my problem. I want to draw a line and afterthat I want to draw the triangle in the local coordinate system of the line. So, that I'm able to set the triangle allways on Code:
viz.vertex(1,0,0) viz.vertex(-1,0,0) viz.vertex(0,1,0) Hope somebody can help me. |
#4
|
|||
|
|||
Oh, is there nobody who can help me???
|
#5
|
|||
|
|||
I don't know if it would work, but could you make the triangle vertices a function of the line vertex? Something like this:
Code:
viz.startlayer(viz.TRIANGLES) v1 = line.getVertex(1) viz.vertex(v1[0]+1,v1[1],v1[2]) viz.vertex(v1[0]-1,v1[1],v1[2]) viz.vertex(v1[0],v1[1]+1,v1[2]) triangle = viz.endlayer(parent=line)
__________________
Virtual Environments and Multimodal Interaction (VEMI) Lab This time, it should work... |
#6
|
|||
|
|||
No, that does not work! Sorry!
|
#7
|
|||
|
|||
Oh, the arrows are so important for my project.
Is there no possibility to draw these? |
#8
|
|||
|
|||
Here is a sample script that draws arbitrary arrows on the screen. Hope this helps:
Code:
import viz import vizmat viz.go() def addArrow(begin,end): ARROW_SIZE = 0.015 #Find distance between points d = vizmat.Distance(begin,end) #Draw arrow line viz.startlayer(viz.LINES) viz.linewidth(5) viz.vertex(0,0,0) viz.vertex(0,d,0) #Draw arrow tip viz.startlayer(viz.TRIANGLES) viz.vertex(-ARROW_SIZE,d,0) viz.vertex(0,d+(2*ARROW_SIZE),0) viz.vertex(ARROW_SIZE,d,0) #Finish drawing arrow arrow = viz.endlayer(parent=viz.SCREEN) #Place/rotate arrow to match begin end points arrow.setPosition(begin) arrow.setEuler(0,0,-vizmat.AngleToPoint(begin,end)) return arrow arrow1 = addArrow([0.2,0.2,0],[0.4,0.4,0]) arrow1.color(viz.GREEN) arrow2 = addArrow([0.6,0.2,0],[0.8,0.9,0]) arrow2.color(viz.RED) |
#9
|
|||
|
|||
Oh yes, thanks a lot!
If I draw one line, it works fine. If I draw one line and afterthat I draw a second one it works fine, too. But: If I draw the two lines and turn this lines around the y-axis and afterthat I want to draw a third line from the end of the first line to the end of the second line, than it doesn't work. I've found out, that the problem is the vizmat.AngleToPoint calculation. It works fine, if the two points are at the z-position 0. But If I turn the lines around so that the z-value is for example -0.5 then the calculation is wrong. How can I solve this problem? I want to draw to lines and turn this around the y-axis. And then I want to calculate the third line from the end of line1 to the end of line2. Thanks a lot.... |
#10
|
|||
|
|||
Is there no way to solve my problem???
|
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Draw a triangle instead of a point | Chrissy2009 | Vizard | 1 | 07-21-2009 09:46 AM |
Create line and vertex | Chrissy2009 | Vizard | 2 | 07-20-2009 10:53 AM |
Draw Vector in viewpoint lookat direction | Chrissy2009 | Vizard | 2 | 05-30-2009 12:50 AM |
Draw Line between Points | Chrissy2009 | Vizard | 2 | 05-13-2009 04:42 AM |
Draw Line between Points selected by mouse | Johannes | Vizard | 7 | 01-07-2005 02:50 PM |