view 3d to bitmapdata

Software: Away3D 4.x

maneatingsheep, Newbie
Posted: 21 November 2011 05:03 PM   Total Posts: 12

hi all
i’m trying to draw my model on top of some 2d stuff.
the best way was to draw it to a bitmapdata using:

view3D.renderer.swapBackBuffer false;
view3D.render();
view3D.stage3DProxy.context3D.drawToBitmapData(bmData); 
view3D.renderer.swapBackBuffer true

but as soon as i bring filters into play i get the dreaded

“All buffers need to be cleared every frame before drawing.” error

please tell me how to solve it, and i’ll show you a really cool way to receive your bitmapdata export with a transparent background wink

   

maneatingsheep, Newbie
Posted: 22 November 2011 03:39 PM   Total Posts: 12   [ # 1 ]

OK. figured some of it out and wanna share so you won’t feel so alone

http://xkcd.com/979/

first of all, my problem was to show a 3d object over some 2d stuff. background image is no good, since when i add filters3d, it’s effected too.

so, I’ve done two things:
1. add a large plane or a box (skybox) that will block the full background of your image. Apply a bitmap material to it. The material should use a transparent BitmapData (transparent = true and a color of 0x00RRGGBB).
This way when you use
view3D.stage3DProxy.context3D.drawToBitmapData(bmData);
you should receive a transparent BitmapData with your model on top of it.

problems:
a. if you apply alpha to the model material, it will render black as the background color
b. filters sometimes kill the transparency. make sure your back plane is not associated with any lights

2. the second problem was to render with filters3d. they work great on regular render, but not when you use the drawToBitmapData method.
Here i needed to go inside the away3d files, and change the line 381

_stage3DProxy._context3D.present(); 

simply put it in a remark, that way you wont crash when doing

view3D.renderer.swapBackBuffer false;
view3D.render();
view3D.stage3DProxy.context3D.drawToBitmapData(bmData); 
view3D.renderer.swapBackBuffer true

hope i helped some poor soul

   

cowpie, Newbie
Posted: 08 February 2012 10:54 PM   Total Posts: 3   [ # 2 ]

I had a problem getting this to work with a SkyBox, but it works great with a large Plane in the background using your method. Thanks for this post!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X