Multiple materials on Cube

Software: Away3D 3.x

Seabird, Newbie
Posted: 08 May 2012 01:20 PM   Total Posts: 5

Hi,

I would like to have a cube with different materials on each side. This never really was a problem, but now I’ve got this strange thing that only two of the 6 materials are shown on all the sides (1 for the top, bottom, back, front and 1 for the left and right side). I can’t see what I’m doing wrong..

I created a cube with Away3dPhysics:

physics = new Away3DPhysics(view,4

Then I create an array with the textures, where dicetexture1 to 10 are Bitmaps.

var diceTextures:Array = new BitmapMaterial( new diceTexture1(0,0)),
         new 
BitmapMaterial( new diceTexture2(0,0)),
         new 
BitmapMaterial( new diceTexture3(0,0)),
         new 
BitmapMaterial( new diceTexture5(0,0) ),
         new 
BitmapMaterial( new diceTexture4(0,0) ),
         new 
BitmapMaterial( new diceTexture6(0,0)) 

Then I create the cube:

dice physics.createCube({width:diceScaleheight:diceScaledepth:diceScale,segmentsW:1segmentsH:1}); 
 
dice.movable=true 

And finally assign the materials.

Cube(Away3dMesh(dice.skin).mesh).cubeMaterials.left diceTextures[0]
 Cube
(Away3dMesh(dice.skin).mesh).cubeMaterials.right diceTextures[1]
 Cube
(Away3dMesh(dice.skin).mesh).cubeMaterials.front diceTextures[2];
 
Cube(Away3dMesh(dice.skin).mesh).cubeMaterials.back diceTextures[3];
 
Cube(Away3dMesh(dice.skin).mesh).cubeMaterials.top diceTextures[4];
 
Cube(Away3dMesh(dice.skin).mesh).cubeMaterials.bottom diceTextures[5]

I can’t see what is going wrong. I should see a different letter on each side, but all I see is the V and the D.

I’m using 3.6.

 

   

Seabird, Newbie
Posted: 10 May 2012 07:44 AM   Total Posts: 5   [ # 1 ]

This must have been done before..?

   

John Brookes, Moderator
Posted: 10 May 2012 09:56 AM   Total Posts: 732   [ # 2 ]

Seem to remember you cant change the material through cubeMaterialsData once its applied to the face. So doing it that way might not work.

create your materials and cube then add that to a JBox.

eg

var material:BitmapMaterial = new BitmapMaterial(new imgAsset().bitmapData);
var 
material2:BitmapMaterial = new BitmapMaterial(new imgAsset2().bitmapData);
var 
material3:BitmapMaterial = new BitmapMaterial(new imgAsset3().bitmapData);
var 
material4:BitmapMaterial = new BitmapMaterial(new imgAsset4().bitmapData);
var 
material5:BitmapMaterial = new BitmapMaterial(new imgAsset5().bitmapData);
var 
material6:BitmapMaterial = new BitmapMaterial(new imgAsset6().bitmapData);

var 
cube:Cube = new Cube();

var 
cubeMat:CubeMaterialsData = new CubeMaterialsData();
cubeMat.front material1
cubeMat
.left material2
cubeMat
.right material3;
cubeMat.back material4;
cubeMat.top material5;
cubeMat.bottom material6;
cube.cubeMaterials cubeMat

cube
.width cube.height cube.depth 500;
scene.addChild(cube);

var 
jbox:JBox = new JBox(new Away3dMesh(cube), 500500500);
physics.addBody(jbox); 

may work.

I had a modified cube.as that allowed you to change the cubeMaterialsData but cant find it.
Sorry.

   

Seabird, Newbie
Posted: 10 May 2012 10:21 AM   Total Posts: 5   [ # 3 ]

Brilliant! It works! Thank you so much!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X