PDA

View Full Version : viz.vertex coordinates


lilio
05-13-2009, 10:43 AM
Hello,

I want to create a vertex at the mouseclick position, but I don't know how to do it.

If I create two vertex points:
viz.startlayer(viz.POINTS)
viz.pointsize(10)
viz.vertexcolor(viz.RED)
viz.vertex(0,0,10)
viz.vertex(1,1,10)
line = viz.endlayer()

And afterthat I click with my mouse at these points and look at my output window:
print viz.mouse.getPosition()

Then I had to recognize, that there are absolutly different values.

The vertex are at [0,0,10] and [1,1,10] and my mouseposition shows [0.6,0.3] and [0.5,0.2]!

Are the vertex coordinates world coordinates? Or what means 0,0,10? And what are the mouseposition coordinates?

What's the reason for this difference. I want to create vertex at the mouseclick position.

Can anybody help me - please.

lilio
05-14-2009, 03:31 AM
If I create the vertex with this command:

point = viz.endlayer(viz.WORLD)

then the vertex will be placed at another position like the mouse is.

But if I use

point = viz.endlayer(viz.SCREEN)

then the vertex will be placed at the mouseclick position.

But I don't want to place the vertex at the screen. It should be placed in the world at the mouseposition and at 0 on the z-axis.

I hope somebody understand my problem.

I only want to create a vertex in the world (not at the screen), but exactly at the mouseposition.

Is this possible?

Gladsomebeast
05-14-2009, 10:56 AM
Use the "screentoworld" method to get a direction vector. Then use vizmat.MoveAlongVector to find a place in space.

Chrissy2009
05-15-2009, 04:25 AM
Hey Gladsomebeast,

I've got the same problem. I want to create points in the world, not on the screen.

But I don't understand your answer. Could you write down the code, please?

THANKS!

Gladsomebeast
05-15-2009, 11:58 AM
Looks like we don't need MoveAlongVector. Got this code from viztracker.py:


line = viz.screentoworld(viz.Mouse.getPosition())
line.length = desiredMetersFromView
print line.end

Chrissy2009
05-16-2009, 09:09 AM
Oh great, thanks a lot!!

Gladsomebeast
05-16-2009, 04:36 PM
Helping make me happy.