One of our users asked on our list last week how to build a RoundedCube... mmm...
The cube is one of the most popular primitives. But none or almost none are rounded cubes, and the very few ones you see around are generated in 3D apps and imported as collada... a waste of bandwidth and ease. The reason for this: no 3D APi for Flash offers one. True until 15 minutes ago.
There is now a RoundedCube primitive in Away3D.
How to use it
First you need to import the class.
import away3d.primitives.RoundedCube;
The roundedcube supports single and multiple materials
like the Cube primitive.
Single material
var mat:BitmapMaterial = new BitmapMaterial(someCoolBmd);
var rc: RoundedCube = new RoundedCube(
{material:mat,
width:1000,
depth: 1000,
height: 1000,
radius:500,
subdivision:3 });
view.scene.addChild(rc);
Multiple materials
first you need to import the CubeMaterialsData class.
import away3d.primitives.data.CubeMaterialsData;
Then just declare a material per side, and pass it to the CubeMaterial instance.
var matleft:BitmapMaterial = new BitmapMaterial(someNiceBmd);
var mattop:BitmapMaterial = new BitmapMaterial(someCoolBmd);
var matbottom:BitmapMaterial = new BitmapMaterial(someWoWBmd);
var matfront:BitmapMaterial = new BitmapMaterial(someGreenBmd);
var matright:BitmapMaterial = new BitmapMaterial(someUglyBmd);
var matback:BitmapMaterial = new BitmapMaterial(someFunnyBmd);
var cubedata:CubeMaterialsData = new CubeMaterialsData(
{top:mattop,
bottom:matbottom,
front:matfront,
back:matback,
left:matleft,
right:matright})
now you just need to pass the variable 'faces' as cubedata variable.
var rc: RoundedCube = new RoundedCube(
{faces:cubedata,
width: 1000,
depth: 1000,
height: 1000,
radius: 500,
subdivision:3 });
view.scene.addChild(rc);
Classic Cube looks soooo passé now...
Fabrice


November 24th, 2008 at 8:18 pm
Looks like candy! Thanks for “reshaping” the way cubes are made in Flash 3D
December 23rd, 2008 at 7:47 am
I did it,but have a problem .
1151: A conflict exists with definition rc in namespace internal.
How to solve it ?
December 23rd, 2008 at 11:25 am
Could you give me the whole code of the Demo,I did it,but have many mistakes.Thanks.
December 23rd, 2008 at 11:29 am
My mail box is dongxinyingying@yahoo.cn。
March 12th, 2009 at 7:13 pm
Hi Fabrice.
Amazing job! Just wanted to let you know my roundedCube was applying the front material to the back faces, no matter what I set the back material to. I checked in the class and on line 415 it says:
addFace(createFace(v1,v0,v2, (_cubeMaterials.front == null)? _material : _cubeMaterials.front, uv1, uv0, uv2 ));
when it should be:
addFace(createFace(v1,v0,v2, (_cubeMaterials.back == null)? _material : _cubeMaterials.back, uv1, uv0, uv2 ));
Again, fantastic job! Keep up the amazing work!
March 13th, 2009 at 12:45 am
Hi Eric,
Glad you like my work, allways nice to hear!
Thx for the fix, i’ll update the trunk asap!
March 13th, 2009 at 12:54 am
Just looked at it. This bug was fixed already, what version are you using? Please check out the latest 2.3.
August 28th, 2009 at 1:23 am
Hi Fabrice,
Awesome work !!! This is exactly what I was looking for !
Would you send me the whole project as I’m a beginner in AS3 and Away3D, but thrilled by all you can do with them !!!
Thank you in advance
September 2nd, 2009 at 2:07 am
Hi again Fabrice,
When I set the subdivisions to more than 2 (even number) my PhongBitmapMaterial render is quite bad. Any solution to this ?
Thank you in advance
September 3rd, 2009 at 12:20 am
it’s not linked to the geometry, extrudes and loaded objects are having similar issues … It’s the way lights are considered that goes wrong somehwere…, we are redoing a lot atm, so keep an eye on the trunk. Hopefully you should be able to render nice phong soon again if not better!
September 15th, 2009 at 2:40 am
Thank you for your fast answer.
Is the RoundedCube compatible with interactive textures ?
September 16th, 2009 at 8:49 pm
Yes it is !
October 22nd, 2009 at 12:46 pm
thank for sending this example.
March 16th, 2010 at 10:15 pm
How are you update RoundedCube?