WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   New project need HELP (https://forum.worldviz.com/showthread.php?t=1907)

minawageh 03-13-2009 01:49 PM

New project need HELP
 
i'm working on big project i need help in a lot of things
first i need to move parts with mouse and assemble them to each other so i tried to make snap function like in 3d's programs but i can't get it so
can any one help me how to get 2 objects aligned when they r close

Jeff 03-13-2009 03:18 PM

You could keep track of both objects' positions. Once they are in a certain range of eachother set one to be the parent of the other and set the child's position so it has the correct offset to appear aligned. Then when you move the parent object the child will move with it.

minawageh 03-14-2009 12:45 PM

thats wot work for me because i wanna align them but in the same time allaow user to move it along axis

i tried to draw a line using vertex commands but i cant get its position
so if you have onther idea how to do this pls tell me
thx

Jeff 03-16-2009 10:18 AM

Sorry, I'm not sure I understand your question

minawageh 03-16-2009 01:13 PM

Quote:

Originally Posted by Jeff (Post 7424)
Sorry, I'm not sure I understand your question

ok don't warry about that i tried your suggestion and it works but i have anather problem i want an object is close enough to be child it not allawed to move in all directions in other words i want the object to move only in one axis (x for example) so it only sliding along this axis
and thx again

Jeff 03-17-2009 03:17 PM

If you want to move your object with the mouse along just the x-axis you could either translate mouse movement into object movement with something like this
Code:

#Disable mouse navigation
viz.mouse(viz.OFF)

ball = viz.add('ball.wrl')

def mymouse(e):
    #Move the object based on the mouse position
    ball.setPosition((e.x-0.5)*6,2,8)

viz.callback(viz.MOUSE_MOVE_EVENT, mymouse)

or you could move the object with the mouse buttons
Code:

#Disable mouse navigation
viz.mouse(viz.OFF)

ball = viz.add('ball.wrl', pos = [0,2,8])

#use buttons to control ball
vizact.whilemousedown(viz.MOUSEBUTTON_LEFT, ball.translate,vizact.elapsed(-1),0,0,viz.REL_PARENT)
vizact.whilemousedown(viz.MOUSEBUTTON_RIGHT, ball.translate,vizact.elapsed(1),0,0,viz.REL_PARENT)



All times are GMT -7. The time now is 07:17 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC