Problem Loading Texture

Started by AGP, August 19, 2011, 09:14:38 PM

Previous topic - Next topic

AGP

Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(R.drawable.andersondiffuse), 128, 128)) doesn't seem to work. I have an image named andersondiffuse.png in each of my three res\drawable directories. The Android docs say I'm doing it right (http://developer.android.com/guide/topics/resources/drawable-resource.html#Bitmap). What gives?

EgonOlsen


AGP

It didn't compile. But I fixed an issue whereby the R.java wasn't being re-generated and it worked, thanks. Now I'm having trouble loading the model (what path do I pass to FileInputStream for a OBJ file at res/drawable-hdpi?). Thanks in advance.

EgonOlsen

Don't put your resources into drawable. Put it into raw (you might have to create that) or assets instead. You are just doing unnecessary  scaling and conversions this way.

AGP

OK, good advice, but then how do I reference that programmatically? How would I load anderson.obj from res/raw/anderson.obj?

EgonOlsen

Just like

res.openRawResource(R.raw.anderson)

AGP


stownshend

And if you use the asset folder it's just:

// Create a stream to grab the data from the 3DS model file.
AssetManager.AssetInputStream inStream = (AssetInputStream) assetManager.open(fileName);

// Insert all of the models from the file into an array of Object3D's.
tempObjects = Loader.load3DS(inStream, 1.0f);