May 28, 2009

Scrolling Materials in PaperVision

For a project we were building recently in PaperVision3D I came across a problem when trying to clip MovieMaterials inside of a plane.  Another big factor was that my stage was not set to scaleToStage, which seemed to fix the problems the little I played with it.  However, for this site it wasn't an option. Following is some insight into the steps I took to solve this problem in hopes that it saves someone else some time.  Admittedly, this problem should be no biggie for the papervision buff, but it took me a while to track down an answer.

scrollrectheader
Problem 1:

I have a MovieClip that I am using as the target of a MovieMaterial, and I want to add another clip to it which happens to be a lot larger than the original clip.  If you simply add it, it will be clipped off at the size of the original.  However, if your added clip contains multiple buttons, the hit areas of the buttons will all squish to fit in the plane, even though it won't look like it.  Confusing?  Very.  To see the true hit areas of your buttons you can set the allowAutoResize property on the MovieMaterial to true, and just like that your whole MovieClip is visible on the plane.  This leads us into..

Problem 2:

Sure the whole clip is visible, but it's now terribly squished.  My first thought was to set a mask on my added MovieClip which gave me some weird results.  However, applying a scrollRect to the MovieClip seemed to solve my problems.  MouseEvents translated well and I could scroll my material by altering the scrollRect of my MovieClip.  It was all peachy until I resized the stage.

Problem 3:

When scaling the stage all of the sudden MouseEvents because unpredictable.  They seemed to be off by an amount proportionate to how much I scaled the stage.  After a whole lot of searching I eventually stumbled across a post I believe by Andy Zupko (to which I have lost the link) giving a solution to a similiar situation.  MovieMaterials have a fifth parameter called 'rect' which is just what you'd think it would be.  This parameter describes the rectangle of a material to draw, and by changing that you can scroll your material, and the VirtualMouse adjusts correctly, even when resizing.

Included below is a file demonstrating the three above problems.

» Source

Share this Post


                           

Comments


Joe Critchley     Jun 02, 2009
How weird, I was randomly browsing good WordPress themes (http://webdesignledger.com/inspiration/15-impressive-and-beautiful-uses-of-wordpress) and co-incidentally found this solution to a long-term problem I've been having with adding scrollbars (which obviously included masked large pieces of content).

I'll be trying this very shortly. Hopefully this is THE solution I've been waiting for.

Ed     May 31, 2009
I have used rect property to move the texture too, I like rect method better since it is easy to implement:
http://www.xllusion.net/ed/2008/12/30/pv3d-moving-material/

Patrick Matte     May 29, 2009
One way you could also have done that is by overriding the height and width getters for your target movieclip.

Charlie Whitney     May 29, 2009
@MSFX not the one I was thinking of but a cool one. The one you posted is actually changing the uvs which deal with how the texture is mapped to the object. That's a neat solution I didn't think of. I still think I'd recommend the rect method to most users, but a cool solution nonetheless!

MSFX     May 28, 2009
Not sure if this is the link your refering to but this is regarding scrolling materials in papervision so i'll post it anyway! :) Nice one for publishing the files!

http://pv3d.org/2009/05/23/moving-a-texture-inside-of-a-plane/


Speak






Submit »