PDA

View Full Version : Is that possible to create some connection between to sphere?


haohaoxuexi1
07-29-2016, 01:27 PM
For example, I add two spheres into Vizard to represent the joints.

However, I want to create a line or some other things which can connect these two joints.

When the position of the joints change, the line will move follow the joints.

Thanks.

Jeff
07-30-2016, 05:29 AM
You could create an on-the-fly (http://docs.worldviz.com/vizard/#Creating_3D_models_procedurally--_the_basics.htm) line to connect the two spheres.

haohaoxuexi1
07-31-2016, 11:16 AM
You could create an on-the-fly (http://docs.worldviz.com/vizard/#Creating_3D_models_procedurally--_the_basics.htm) line to connect the two spheres.


import viz,vizact,vizshape, vizmat

viz.go()
grid = vizshape.addGrid()

sphere_0_left = vizshape.addSphere(radius=0.1)
sphere_1_left = vizshape.addSphere(radius=0.1)


So how to connect this two sphere using on the fly

Jeff
07-31-2016, 07:00 PM
If you want to draw a line, create a layer with viz.lines and use the center point of each sphere as a vertex. You can update the vertex positions as the sphere positions change.

haohaoxuexi1
08-01-2016, 09:56 AM
If you want to draw a line, create a layer with viz.lines and use the center point of each sphere as a vertex. You can update the vertex positions as the sphere positions change.

in that way, the system will repeat drawing the line as many as the times of position changes.

is there a way to draw one line and keep updating the position

Jeff
08-02-2016, 06:03 AM
Yes, once you create the line you can move it like any other object:

import viz
import vizshape

viz.go()

viz.clearcolor(viz.SLATE)
vizshape.addGrid()

viz.startLayer(viz.LINES)
viz.vertex(0,0,0)
viz.vertex(0,1,0)
line = viz.endLayer()

line.setPosition([2,0,7])
line.color(viz.RED)

haohaoxuexi1
08-02-2016, 09:11 AM
Yes, once you create the line you can move it like any other object:

import viz
import vizshape

viz.go()

viz.clearcolor(viz.SLATE)
vizshape.addGrid()

viz.startLayer(viz.LINES)
viz.vertex(0,0,0)
viz.vertex(0,1,0)
line = viz.endLayer()

line.setPosition([2,0,7])
line.color(viz.RED)

Is there a way to change the position of line only by change the vertex of it?

In the code you gave to me, the length of the line is fixed, is that possible to get a line which will change its length according to the position of vertex?

haohaoxuexi1
08-08-2016, 01:43 PM
Yes, once you create the line you can move it like any other object:

import viz
import vizshape

viz.go()

viz.clearcolor(viz.SLATE)
vizshape.addGrid()

viz.startLayer(viz.LINES)
viz.vertex(0,0,0)
viz.vertex(0,1,0)
line = viz.endLayer()

line.setPosition([2,0,7])
line.color(viz.RED)

can you help me to solve my last question?

Jeff
08-08-2016, 09:59 PM
Yes, you can modify vertices to change the length of the line. Take a look at the changing vertices (http://docs.worldviz.com/vizard/#Changing_on-the-fly_objects_on-they-fly.htm) page from the on-the-fly section. Does this help answer your question?

haohaoxuexi1
08-09-2016, 01:48 PM
Yes, you can modify vertices to change the length of the line. Take a look at the changing vertices (http://docs.worldviz.com/vizard/#Changing_on-the-fly_objects_on-they-fly.htm) page from the on-the-fly section. Does this help answer your question?

fixed it, thanks