WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-26-2013, 02:48 PM
pswaney pswaney is offline
Member
 
Join Date: Feb 2013
Posts: 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)
Reply With Quote
  #2  
Old 03-01-2013, 12:19 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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)
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
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
Create Button or Text Chrissy2009 Vizard 1 07-15-2009 05:34 PM
How to create a sky? guxmy01 Vizard 1 05-28-2008 12:07 PM


All times are GMT -7. The time now is 04:39 PM.


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