views:

109

answers:

3

Hello guys,

I'm a newbi with sandy and action script 3. I has followed tutorial on the sandy web site and I created a cube.

But I don't success to create a cube with a different texture on each cube face. My first texture is duplicate on each face.

So, how can I have a different texture on each face ? I don't find that on the sandy web site.

Thanks for your answer :)

A: 

Please, nobody to help me ?

Kiva
A: 

The solution is to use the getFace function and to set an appearence by box face ;)

Kiva
For any answer (even it's for your own question), please give more explanation and code example. It will be more useful for the community. :)And don't answer yourself with "Please, nobody to help me ?", it really is not an answer.
Andy Li
+1  A: 

Ok guys, here is the code:

var materialFace1:BitmapMaterial = new BitmapMaterial( bitmap1.bitmapData ); materialFace1.lightingEnable = true; var appFace1:Appearance = new Appearance( materialFace1 );

var materialFace2:BitmapMaterial = new BitmapMaterial( bitmap2.bitmapData ); materialFace2.lightingEnable = true; var appFace2:Appearance = new Appearance( materialFace2 );

var materialFace3:BitmapMaterial = new BitmapMaterial( bitmap3.bitmapData ); materialFace3.lightingEnable = true; var appFace3:Appearance = new Appearance( materialFace3 );

var materialFace4:BitmapMaterial = new BitmapMaterial( bitmap4.bitmapData ); materialFace4.lightingEnable = true; var appFace4:Appearance = new Appearance( materialFace4 );

var materialFace5:BitmapMaterial = new BitmapMaterial( bitmap5.bitmapData ); materialFace5.lightingEnable = true; var appFace5:Appearance = new Appearance( materialFace5 );

var materialFace6:BitmapMaterial = new BitmapMaterial( bitmap6.bitmapData ); materialFace6.lightingEnable = true; var appFace6:Appearance = new Appearance( materialFace6 );

var box:Box = new Box( "box",100,100,100);


 var face:PrimitiveFace = box.getFace(Box.FACE_LEFT);
 face.appearance = appFace1;

 face = box.getFace(Box.FACE_BOTTOM);
 face.appearance = appFace2;

 face = box.getFace(Box.FACE_FRONT);
 face.appearance = appFace3;

 face = box.getFace(Box.FACE_BACK);
 face.appearance = appFace4;

 face = box.getFace(Box.FACE_RIGHT);
 face.appearance = appFace5;

 face = box.getFace(Box.FACE_TOP);
 face.appearance = appFace6;

This code allows to have a cube with a different texture by face.

Kiva