WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Point of an intersecting line and plane (https://forum.worldviz.com/showthread.php?t=5979)

Ultim 03-20-2017 02:04 AM

Point of an intersecting line and plane
 
Hello,

I am trying to work with moving objects using the mouse.
for doing this I want to calculate the position of the mouse on XY plane.
When the XY coordinates are known i want to move the ball to those XY coordinates.
I have a ball in my world which will be the object of moving.

here is the code so far:
plane = vizshape.addPlane()
plane.setPosition(0,0,ball.getPosition[2])
mouseposition = Camera.main.ScreenPointToRay(Input.mousePosition);

I tried to use viz.intersect but got a lot of errors.
do you guys have any advice.

With kind regards.

Jeff 03-20-2017 02:46 AM

You could use the viz.pick command to get the point of intersection between the mouse and the object it is pointing at. Here's an example:

Code:

import viz
import vizact
import vizshape

viz.go()

dojo = viz.add('dojo.osgb')
sphere = vizshape.addSphere(radius=0.1,color=viz.GREEN)
sphere.disable(viz.PICKING)

def moveSphere():
        info = viz.pick(info=True)
        point = info.point
        sphere.setPosition(point)
       
vizact.onupdate(0,moveSphere)



All times are GMT -7. The time now is 05:13 PM.

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