#1
|
|||
|
|||
Looking for a shape
For a model I'm working on I need a shape that looks like a cone with its tip cut off. I want to be able to control the diameter of both sides. Is there a way to achieve this in Vizard?
|
#2
|
|||
|
|||
Code:
import vizshape myshape = vizshape.addCylinder(height=1.0,bottomRadius=0.5,topRadius=0.1) |
#3
|
|||
|
|||
Alright, that was what I was looking for. Now I want to manipulate it from within the program. This is what I have:
Code:
import viz import vizshape viz.go() viz.MainView.setPosition(0,0,-4) slider = viz.addSlider() slider.setPosition(0.2, 0.1) slider.set(0.1) def onSlider(): x = slider.get() print x myshape = vizshape.addCylinder(height=1.0,bottomRadius=0.5,topRadius=x) vizact.onupdate(0, onSlider) |
#4
|
|||
|
|||
You'll need to remove the cylinder you already added to see the new clinder you add with a smaller radius:
Code:
import viz import vizshape viz.go() viz.MainView.setPosition(0,0,-4) slider = viz.addSlider() slider.setPosition(0.2, 0.1) slider.set(0.1) myshape = vizshape.addCylinder(height=1.0,bottomRadius=0.5,topRadius=0.1) def changeRadius(pos): global myshape myshape.remove() myshape = vizshape.addCylinder(height=1.0,bottomRadius=0.5,topRadius=slider.get()) vizact.onslider(slider, changeRadius) |
#5
|
|||
|
|||
Thanks, that works well. I was just wondering if there was an easier way to do that--i.e., instead of erasing cones and rendering new ones, could I call, say, the topRadius with a command and change it?
|
|
|