|
#1
|
|||
|
|||
Create a clipping box
I was wondering if it is possible to create a clipping box, such that an object inside the box would appear fully, but if the object was scaled such that any part of it fell outside the box, that portion would be clipped.
I have tried to use multiple clipping planes, but when creating the box, I am only able to create clipping planes on three sides of the box, and never two parallel sides. If, for example, I try to create two clipping planes that would form the top and bottom of the box, the plane I create second supersedes the first. See the example below for this behavior. Any help would be greatly appreciated, thanks! Code:
import viz import vizshape viz.go() vizshape.addGrid(color=[0.2]*3) viz.clearcolor(viz.GRAY) sphere = vizshape.addSphere(radius=3) sphere.clipPlane([1,0,0,-1],num=1) sphere.clipPlane([1,0,0,1],num=2) import vizcam vizcam.PivotNavigate(center=[0,2,0],distance=10) |
#2
|
|||
|
|||
It doesn't look like you are specifying the clip planes correctly. Here is a sample script that shows how to apply a clip box to the model:
Code:
import viz import vizact import vizshape viz.go() model = viz.add('logo.ive') expand = vizact.sizeTo([3,3,3],speed=0.5) shrink = vizact.sizeTo([1,1,1],speed=0.5) model.runAction(vizact.sequence(expand,shrink,viz.FOREVER)) model.runAction(vizact.spin(0,1,0,20,viz.FOREVER),pool=1) def applyClipBox(node, center, size): x,y,z = center sx,sy,sz = [ v / 2.0 for v in size ] node.clipPlane([1,0,0,x-sx],num=0) node.clipPlane([-1,0,0,-x-sx],num=1) node.clipPlane([0,1,0,y-sy],num=2) node.clipPlane([0,-1,0,-y-sy],num=3) node.clipPlane([0,0,1,z-sz],num=4) node.clipPlane([0,0,-1,-z-sz],num=5) BOX_CENTER = [0,2,0] BOX_SIZE = [2,2,2] applyClipBox(model,center=BOX_CENTER,size=BOX_SIZE) box = vizshape.addBox(size=BOX_SIZE,pos=BOX_CENTER,color=viz.RED,lighting=False) box.polyMode(viz.POLY_WIRE) viz.clearcolor(viz.GRAY) vizshape.addGrid(color=[0.2]*3) import vizcam vizcam.PivotNavigate(center = BOX_CENTER, distance = 10.0) |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Clipping Plane | envisC | Vizard | 8 | 10-23-2012 01:36 PM |
Can I make a moving clipping plane? | Salvar | Vizard | 3 | 04-18-2012 01:32 PM |
Near and far clipping on infinite terrain | vijaykiran | Vizard | 2 | 01-21-2011 05:59 AM |
Create Button or Text | Chrissy2009 | Vizard | 1 | 07-15-2009 06:34 PM |
How to create a sky? | guxmy01 | Vizard | 1 | 05-28-2008 01:07 PM |