certain jpg textures do not load and generate black output

Software: Away3D 4.x

flex-o-matic, Newbie
Posted: 06 June 2012 09:39 PM   Total Posts: 13

Hi.

I have a strange problem with jpg textures, some will load and some will not, resulting in a completely black image.

Please observe this code:

// Embedded bitmap assets
[Embed(source=“assets/carp03M.JPG”)]
private var assetFloor:Class;
private var floorTexture:BitmapTexture;
private var floorMaterial:TextureMaterial;

// bitmap materials
floorTexture = new BitmapTexture(new assetFloor().bitmapData);
floorMaterial = new TextureMaterial(floorTexture);
floorMaterial.lightPicker = lightPicker;
floorMaterial.smooth = true;
floorMaterial.gloss = 100;
floorMaterial.repeat = true;

//main geometry
var cubeFloor:CubeGeometry = new CubeGeometry(roomLength,2.5,roomWidth, 2, 2, 2);
var floor:Mesh = new Mesh(cubeFloor, floorMaterial);

//deploy
scene.addChild(floor);

This works flawlessly, resulting in the attached output.
Now when i exchange the jpg for the attached concrete.jpg image, the output in the browser is completely black.

I can’t see any difference in the jpg’s, the concrete.jpg works fine in 3ds max or photoshop or else.

Any idea?

 

   

flex-o-matic, Newbie
Posted: 06 June 2012 10:08 PM   Total Posts: 13   [ # 1 ]

To add, I tried about 20 different jpg and png files and I’m seeing very erratic behavior.

Sometimes the scene will load, sometimes it will not. I have to change the asset class to another name and back again to get the same image to load.

The concrete.jog image is still not able to be loaded and start the scene.

I am on Flash Builder Premium 4.6.1 (build 335153)

 

   

flex-o-matic, Newbie
Posted: 07 June 2012 12:54 AM   Total Posts: 13   [ # 2 ]

Ok, found the solution in an old thread. Seems the bitmap needs to have 2^n resolution. Once I made them 512x512 they loaded fine. Maybe nice to put this into the API reference.

 

   

Avatar
Fabrice Closier, Administrator
Posted: 07 June 2012 08:12 AM   Total Posts: 1265   [ # 3 ]

Doesn’t the fired error event tell you exactly that? If not, that’s a bug.

 

   

flex-o-matic, Newbie
Posted: 07 June 2012 04:39 PM   Total Posts: 13   [ # 4 ]

Nope, didn’t throw any error. Just a black screen.

 

   

flex-o-matic, Newbie
Posted: 07 June 2012 04:49 PM   Total Posts: 13   [ # 5 ]

Admin, i have found another weirdness.

Please look at the attached pic.

I am creating a room, in this case 4 seperate cubes, each of the CubeGeometry done with this function:

var cubeRear:CubeGeometry = new CubeGeometry(1,roomHeight,roomWidth, 2, 2, 2);
var rear:Mesh = new Mesh(cubeRear, rearTexture);
var translateRear : Matrix3D = new Matrix3D();
translateRear.appendTranslation(-(roomLength/2), 0, 0);
cubeRear.applyTransformation(translateRear);

Since I am creating the room dynamically there are no UV’s so i need to add the scaleU/V and offsetU/V to get the right placement of the textures.

rear.subMeshes[0].scaleU = 2;
rear.subMeshes[0].scaleV = 3;
rear.subMeshes[0].offsetU = -1;
rear.subMeshes[0].offsetV = 0;

The individual Bitmap function looks like this:

rearBitmap = new BitmapTexture(new assetRear().bitmapData);
rearTexture = new TextureMaterial(rearBitmap);
//rearTexture.lightPicker = lightPicker;
rearTexture.smooth = true;
rearTexture.gloss = 100;
rearTexture.repeat = false;
rearTexture.animateUVs = true;
rearTexture.alpha = 1;

All the functions are exactly identical for the rear, left and right wall shown in the attachement, the floor has a simple colormaterial.

As you can see in the attachment, the left and right walls have the texture on just 1 side while the rear wall has the texture on both sides??
Also the color of the cube seen in the attachment is blueish for the left wall and grey for the right wall, I have no clue where this comes from.

Do you have an idea what causes this?

Thanks so much!

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X