PDA

View Full Version : locate a certain point in the scene 3D


Johannes
02-28-2005, 02:06 PM
Is it possible to locate a certain point in the scene by clicking on it with the mouse?

I would like to use this to position my objects (e.g. I click on a certain position with my mouse and get the position printed) then I cann translate my object there...


def mouse...

if button == viz.MOUSEBUTTON_RIGHT:
line = viz.screentoworld(viz.mousepos())
begin = line[:3]
end = line[3:]
viz.startlayer(viz.LINE_LOOP)
viz.vertex(begin)
viz.vertex(end)
cube = viz.endlayer()
print end

Johannes

P.S. out of certain reasons I don't want to use the stage.

farshizzo
02-28-2005, 02:09 PM
The code you supplied pretty much does what you want. All you have to do is pick a point on the line and translate the object there. Let me know if I misunderstood your question.

Johannes
02-28-2005, 02:29 PM
Well, maybe I'm just not good enough to pick a point on the line (because the line is so small....).
I just want to use this to get the position of a certain point in the scene...


def mouseclick(button):
global beginPos0502, line0503
pos = viz.mousepos()
print 'mouse is currently at',pos
if button == viz.MOUSEBUTTON_RIGHT:
line = viz.screentoworld(viz.mousepos())
begin = line[:3]
end = line[3:]
viz.startlayer(viz.LINE_LOOP)
viz.vertex(begin)
viz.vertex(end)
line0503 = viz.endlayer()
print end
if button == viz.MOUSEBUTTON_LEFT:
object = viz.pick()
#if object.valid() and object != arrow:
if (object.valid() and object ==airtrack.slider):
pos = object.get(viz.POSITION)
beginPos0502=pos[0]
viz.mousedata(viz.ABSOLUTE,viz.ABSOLUTE)
viz.callback(viz.MOUSEMOVE_EVENT, mymousemove)
viz.mouse(viz.OFF)
if button == viz.MOUSEBUTTON_MIDDLE:
print 'middle'
object = viz.pick()
if (object.valid()and object ==line0503):
print object.get(viz.POSITION)

farshizzo
02-28-2005, 02:46 PM
Clicking on the screen can correspond to an infinite number of points. Do you want a point that is a certain distance from the user? Do you want a point that intersects with an object?

Johannes
03-01-2005, 08:09 AM
Thank you, I found a way to do it. Your suggestions (I used the intersect-approach) helped!
Johannes

P.S. is there a way to bring self illumination (from 3ds) to vizard?
Did not find anything in the help-file

viz.TEXGEN
Automatically generate texture coordinates to simulate sphere mapping (reflective surface).

viz.TEXMIPMAP
Linear and mipmap filtering for texture magnification and minification.

viz.TEXNEAREST
Do not perform mipmapping of the texture.

viz.MODULATE
Force modulation of texture with any scene lights and the surfaces underlying material color properties.

viz.DECAL
Display the exact bitmap as the surface texture.

viz.ENVIRONMENT_MAP
Automatically generate texture coordinates to reflect an environment map (aka cube mapping).

Johannes
03-01-2005, 08:12 AM
Just thought I poste the code of the "point-finder" in case somebody else likes to use it:

def mouseclick(button):
if button == viz.MOUSEBUTTON_MIDDLE:
print 'middle'
line = viz.screentoworld(viz.mousepos())
begin = line[:3]
end = line[3:]
#viz.startlayer(viz.LINE_LOOP)
#viz.vertex(begin)
#viz.vertex(end)
#line0503 = viz.endlayer()

info = table.intersect(begin,end)
if info.intersected:
print 'p1:',info.intersectPoint

farshizzo
03-01-2005, 10:16 AM
To find the intersect point you can also use the pick command.info = viz.pick(1)
if info.intersected:
print 'p1:',info.intersectPoint
Have you tried disabling lighting on the object?object.disable(viz.LIGHTING)This will prevent lighting calculations from being performed on the object, which will make it brighter.