www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: AGP on August 19, 2011, 09:14:38 pm

Title: Problem Loading Texture
Post by: AGP on August 19, 2011, 09:14:38 pm
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 (http://developer.android.com/guide/topics/resources/drawable-resource.html#Bitmap)). What gives?
Title: Re: Problem Loading Texture
Post by: EgonOlsen on August 19, 2011, 09:43:37 pm
And the exact problem is... ???
Title: Re: Problem Loading Texture
Post by: AGP on August 19, 2011, 10:08:43 pm
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.
Title: Re: Problem Loading Texture
Post by: EgonOlsen on August 19, 2011, 10:21:57 pm
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.
Title: Re: Problem Loading Texture
Post by: AGP on August 19, 2011, 10:23:21 pm
OK, good advice, but then how do I reference that programmatically? How would I load anderson.obj from res/raw/anderson.obj?
Title: Re: Problem Loading Texture
Post by: EgonOlsen on August 19, 2011, 10:29:50 pm
Just like

Code: [Select]
res.openRawResource(R.raw.anderson)
Title: Re: Problem Loading Texture
Post by: AGP on August 19, 2011, 10:52:14 pm
Thanks a lot.
Title: Re: Problem Loading Texture
Post by: stownshend on August 20, 2011, 02:33:45 am
And if you use the asset folder it's just:

Code: [Select]
// 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);