MovieMaterial with bitmap

8 views
Skip to first unread message

charglerode

unread,
Aug 26, 2008, 1:20:37 PM8/26/08
to away3d.dev
I have an interesting problem. I have a plane with a MovieMaterial and
in the material is a large bitmap with many smaller movieclips. The
movieclips overlay the bitmap and are aligned to the image. The
problem is that I cant set the precision of the bitmap in the
MovieMaterial so when it's applied the movieclips are fine but the
bitmap gets distorted. I've tried using two separate planes one with
the bitmap material and one with the movie material, but I end up
getting a strong paralaxing effect as the camera moves even though
both planes have a y difference of 0.1.

Any ideas?

Li

unread,
Aug 26, 2008, 3:12:15 PM8/26/08
to away3...@googlegroups.com
Maybe set the ownCanvas = true for both planes and give one of them transparency? Im sure there is a more efficient way around anyways.

charglerode

unread,
Aug 28, 2008, 3:18:25 AM8/28/08
to away3d.dev
Yeah I tried that, but the effects don't change at all.

On Aug 26, 12:12 pm, Li <paleblue...@gmail.com> wrote:
> Maybe set the ownCanvas = true for both planes and give one of them
> transparency? Im sure there is a more efficient way around anyways.
>

tain

unread,
Aug 28, 2008, 4:35:46 AM8/28/08
to away3d.dev
i have seen in some example that complexity of plane can really fix
some material (texture) issues, but i cant find it now.
try changing:

segmentsW: x, segmentsH: y where x and y would be more than 1.

tain

charglerode

unread,
Aug 29, 2008, 12:17:32 AM8/29/08
to away3d.dev
Good suggestion, works great, the paralaxing effect is gone. However,
now what happens is that the moviematerial has triangles cut out for
each segment. So if I have a horizontal segment of 6, I'll get 6
triangles cut across the material.

Peter Kapelyan

unread,
Aug 29, 2008, 9:50:06 AM8/29/08
to away3...@googlegroups.com
I think I've seen this bug...
 
I think the solution was to set the size of the plane, if you leave the plane default size, i think it may happen...
 
If that doesn't help I'll try to find the file where I had the same problem!

-Pete


--
___________________

Actionscript 3.0 Flash 3D Graphics Engine

HTTP://AWAY3D.COM

charglerode

unread,
Aug 29, 2008, 1:13:19 PM8/29/08
to away3d.dev
Yeah the planes are not default size, something like 1000 x 815.

Peter Kapelyan

unread,
Aug 29, 2008, 4:44:01 PM8/29/08
to away3...@googlegroups.com
Ah, ok then.
 
I have also seen this bug if you change the size of the MovieMaterial's Movieclip dimensions after you create the material+object.
 
For instance if you had a 100x100 Movieclip, and used it as a material, then changed it to 200x200 because something moved outside of the original dimensions int he movieclip, you will probably see this bug.

If that's the case, then there may be some ways around it still...

Let me know if that happens to be the case.
-Pete

charglerode

unread,
Aug 30, 2008, 1:14:58 AM8/30/08
to away3d.dev
Not sure I understand exactly, but I'll describe my setup. I have two
planes that are 1000x815. The bottom plane has the bitmap material
applied which is a 1000x815 bitmap in the library. The top plane has a
movie material applied which is a 1000x815 movieclip in the library.
The movie material contains multiple movieclips which all pieced
together (think of puzzle pieces) are 1000x815. There is no resizing
of any of the materials or the planes. They are one size when created
and never change.
> > > HTTP://AWAY3D.COM <http://away3d.com/>

Fabrice

unread,
Aug 30, 2008, 8:34:53 AM8/30/08
to away3...@googlegroups.com
k, I've updated the MovieMaterial and added lockW and lockH to it to
prevent this once and for all

so basically if you set them, no matter how large the mc is, they will
lock on those settings.
you even can set size greater than the source, if you for instance
plan fill the gaps later on. No need to add a rect filled with alpha
to do this.

Also remember the cliprect prop you can set to avoid redraw whole mc
if you know what have changed...

how to use it: (snipet from this little demo)

var sourcemc:MovieClip = new testMC();
var mat1 = new MovieMaterial(sourcemc , {debug:true});
var mat2 = new MovieMaterial(sourcemc, {debug:true, lockW:200,
lockH:200});
var mat3 = new MovieMaterial(sourcemc , {debug:true, lockH:100,
lockW:450});

var p1:Plane = new Plane({width:400, height:300, material:mat1, y:
320} );
var p2:Plane = new Plane({width:400, height:300, material:mat2} );
var p3:Plane = new Plane({width:400, height:300, material:mat3,
y:-320} );

p1.rotationX = p2.rotationX = p3.rotationX = 90;
this.scene.addChild(p1);
this.scene.addChild(p2);
this.scene.addChild(p3);

here this code in action:

http://www.closier.nl/playground/MovieLock.swf

Available in your favourite svn!

Fabrice

charglerode

unread,
Aug 31, 2008, 1:59:48 PM8/31/08
to away3d.dev
My materials dont change size so this doesnt resolve my issue. I still
have the triangular pieces cut out from my material based on how many
segments the plane has. I will put up an example soon if I can.

charglerode

unread,
Aug 31, 2008, 2:27:50 PM8/31/08
to away3d.dev
Ok, so I've uploaded an example. There are a few problems that I see
now that I could also use answers on if possible. The first is that
you'll notice the movieclips in the movie material don't even show up,
at least not all of them. Second, you'll notice that the one clip that
does show up is cut into a triangle even though the movieclip is not a
triangle. Finally, You'll notice that they dont respond to roll over
and roll out mouse events, however the roll over callback will be
called on mouse down and roll out will be called on mouse up.

www.charglerode.com/toybox/test.zip

Thanks,

On Aug 30, 5:34 am, Fabrice <fabric...@gmail.com> wrote:

Jensa

unread,
Sep 1, 2008, 3:48:53 AM9/1/08
to away3d.dev
Hi charglerode,
I ad a peek at the code you uploaded and there were a couple things to
note:

- The planes were too close to each other, so that caused the strange
triangle artifacts you saw. To eliminate these, you could use the
correct Z order renderer, but that will cause a hefty CPU premium so
it'll only work for simple files.
- From the look of your code, you are not using the latest version so
the path to the Clipping class was incorrect. You should also use
RectangleClipping instead of "new Clipping"
- You were listening for standard MouseEvent's and not MouseEvent3D's.
This makes a big difference with Away3D
- You added the event listeners to the materials and not the objects.
- You didn't update the view when the mouse rolled over the planes, so
the change was never reflected. I added an eventListener on
ENTER_FRAME that calls your Render-function. You could also call
view.render() from inside the MouseEvent handlers to save some CPU

I've uploaded a working version of your code here:
http://groups.google.com/group/away3d-dev/web/Main.as.zip?hl=en

I hope that helps a bit :)

J

Jensa

unread,
Sep 1, 2008, 4:16:50 AM9/1/08
to away3d.dev
Ohh! Thanks Fabrice! This just sooo saved me!
I kept getting this error when using a MovieClip as texture:

ArgumentError: Error #2015: Invalid BitmapData.
at flash.display::BitmapData()
at away3d.materials::MovieMaterial()[/Users/jensa/Documents/Flex
Builder 3/Away3D_src/away3d/materials/MovieMaterial.as:128]
at Fredrikstadnett()[/Users/jensa/Documents/Flex Builder 3/
Fredrikstadnett/Fredrikstadnett.as:57]

This will fail:
var metro:MovieMaterial = new MovieMaterial(new metroMC(),
{smooth:true});

This will work as it should:
var metro:MovieMaterial = new MovieMaterial(new metroMC(),
{smooth:true, lockW:1024, lockH:768});

Briliant!

J

Fabrice

unread,
Sep 1, 2008, 4:53:31 AM9/1/08
to away3...@googlegroups.com
You're welcome :)
I think the problem in your case is that it fails because you have 1
frame delay. I think your mc is there one frame too late.
Its not inherent to your code, but the way the system works.
So the lock prevent this by reserving a "parking place" for your mc.
And allows to have fixed size as well.

Btw, thx for the indepth help on your past mail.
That's what I call a usergroup!!

Fabrice

Reply all
Reply to author
Forward
0 new messages