![]() |
#1
|
|||
|
|||
locate a certain point in the scene 3D
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... Code:
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 P.S. out of certain reasons I don't want to use the stage. |
#2
|
|||
|
|||
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.
|
#3
|
|||
|
|||
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... Code:
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) |
#4
|
|||
|
|||
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?
|
#5
|
|||
|
|||
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). |
#6
|
|||
|
|||
Just thought I poste the code of the "point-finder" in case somebody else likes to use it:
Code:
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 |
#7
|
|||
|
|||
To find the intersect point you can also use the pick command.
Code:
info = viz.pick(1) if info.intersected: print 'p1:',info.intersectPoint Code:
object.disable(viz.LIGHTING) |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|