|
#1
|
|||
|
|||
Moveable clipping box
Hi
I'd like to create a clipping box like this http://forum.worldviz.com/showthread...light=clipping but where I can move (translate and rotate) the clipping box. I'm struggling to find a solution. Can anyone help? simon |
#2
|
|||
|
|||
Here's an example. Use the left and right arrow keys to move the box:
Code:
''' Move the clip box left and right with the arrow keys ''' import viz import vizact import vizshape import vizinfo viz.go() vizinfo.InfoPanel() class MovingClipBox(): def __init__(self,node,center,size): self.node = node self.x,self.y,self.z = center self.sx,self.sy,self.sz = [ v / 2.0 for v in size ] self.applyClipBox() self.box = vizshape.addBox(size=size,pos=center,color=viz.RED,lighting=False) self.box.polyMode(viz.POLY_WIRE) def applyClipBox(self): self.node.clipPlane([1,0,0,self.x-self.sx],num=0) self.node.clipPlane([-1,0,0,-self.x-self.sx],num=1) self.node.clipPlane([0,1,0,self.y-self.sy],num=2) self.node.clipPlane([0,-1,0,-self.y-self.sy],num=3) self.node.clipPlane([0,0,1,self.z-self.sz],num=4) self.node.clipPlane([0,0,-1,-self.z-self.sz],num=5) def getBoxCenter(self): return [self.x,self.y,self.z] def setBoxCenter(self,center): self.x,self.y,self.z = center self.applyClipBox() self.box.setPosition(center) viz.clearcolor(viz.GRAY) vizshape.addGrid(color=[0.2]*3) model = viz.add('logo.osgb') 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) BOX_CENTER = [0,2,0] BOX_SIZE = [2,2,2] movingClipBox = MovingClipBox(model,center=BOX_CENTER,size=BOX_SIZE) import vizcam vizcam.PivotNavigate(center = BOX_CENTER, distance = 10.0) def updateClipBox(): x_change = 0 if viz.key.isDown(viz.KEY_LEFT): x_change -= 0.01 elif viz.key.isDown(viz.KEY_RIGHT): x_change += 0.01 if x_change != 0: center = movingClipBox.getBoxCenter() center[0] += x_change movingClipBox.setBoxCenter(center) vizact.onupdate(0,updateClipBox) |
Tags |
box, clipping, move, plane, rotate |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Create a clipping box | pswaney | Vizard | 1 | 03-01-2013 12:19 PM |
Clipping Plane | envisC | Vizard | 8 | 10-23-2012 12:36 PM |
Can I make a moving clipping plane? | Salvar | Vizard | 3 | 04-18-2012 12:32 PM |
Near and far clipping on infinite terrain | vijaykiran | Vizard | 2 | 01-21-2011 04:59 AM |
Does the automatic clipping plane calculation work? | Joran | Vizard | 4 | 07-10-2009 10:35 AM |