PDA

View Full Version : Can I make a moving clipping plane?


Salvar
04-17-2012, 06:42 PM
I'm setting up an experiment in Vizard, and I need to control how much of an object a participant can see during movement. The trick is that I don't want to block anything else but this particular 3dnode, so applying a global fog or clipping plane is out of the picture.

So I had the idea of applying a clipping plane to the node, and using a vizact ontimer event to update its coordinates according to where the viewpoint is a t the time. This is proving difficult.

I basically want a clipping plane that's the equivalent of a horse blinder on the right eye. One that blocks everything on your right side from view, and stays in that position as you move and rotate in the world. Is this possible?

farshizzo
04-18-2012, 10:50 AM
Here is an example that applies a clip plane to a model and updates it every frame so that the plane is relative to the current viewpoint. Let me know if this isn't what you were asking for.
import viz
viz.go()

viz.add('ball.wrl',pos=(0,1.5,2))
model = viz.add('gallery.ive')

import vizact

def UpdateClipPlane():

mat = viz.MainView.getMatrix()
mat.preEuler(0,0,90)

p = viz.Plane()
p.setQuat(mat.getQuat())
p.setPos(mat.getPosition())
model.clipPlane(p)

vizact.onupdate(viz.PRIORITY_LAST_UPDATE,UpdateCli pPlane)

Salvar
04-18-2012, 01:14 PM
You are the man. This is absolutely perfect. Just what I was trying to do, except my attempt looks like a Rube Goldberg machine next to this solution. Thanks!

One last thing: Is there an easy way to offset the plane a little bit to the right?

Salvar
04-18-2012, 01:32 PM
Hmm, thought I could edit posts here. Anyway, I tried to offset the plane by preTrans-ing it right after the preEuler, but it doesn't seem to be working.

Edit: Nevermind, got it. PreTrans-ing before Pre-Eulering did the trick.