Apply Texture Unsupported Texture width (Not using Drawable)

Started by dubbox, September 30, 2014, 11:45:22 PM

Previous topic - Next topic

dubbox

Hey Guys,

I know there are many topics on this theme but i am not getting it to work

I try to load a .ser object with texture


Texture th= new Texture(masterContext.getResources().openRawResource(R.raw.th));
TextureManager tm = TextureManager.getInstance();
if(!tm.containsTexture("teppichHems.JPG")){
tm.addTexture("teppichHems.JPG", th);
}


i keep getting the error: unsupportedTextureWidth: 254


i know there is a way to rescale it with a bitmap

but is there another way ?
if not can sombody explain to me how to use a bitmap i never did that before

the code for serializing the object is here i got it from an tutorial i think it works fine no errors here


public static void main(String[] args) {
if(args.length > 3){
int last = args.length - 1;
for(int i = 0; i <= last; i++){
if(args[i].equals("-i3ds")){
if(i == last){
System.err.println("Error missing parameters! "
+ usageMessage);
System.exit(-1);
}else{
objName += args[i + 1];
}
}else if(args[i].equals("-t")){
if(i == last){
System.err.println("Error missing parameters! "
+ usageMessage);
System.exit(-1);
}else{
int k=i;
textureFileName = new String[last-k];
for(int j=0; j<textureFileName.length;j++){
textureFileName[j]="";
}
while(k != last){
k++;
textureFileName[k-i-1] += args[k];
}
}
}
}
}else{
System.err.println(usageMessage);
System.exit(-1);
}
if(objName.equals("") || textureFileName.length==0){
System.err.println(usageMessage);
System.exit(-1);
}

TextureManager tm = TextureManager.getInstance();
for(int i=0; i<textureFileName.length;i++){
tm.addTexture(textureFileName[i],new
Texture(inputPath+textureFileName[i]));
}
try{
File objfile = new File(inputPath+""+objName+".3DS");
Object3D[] obj = Loader.load3DS(new FileInputStream(objfile),
1);
inputObject3D = Object3D.mergeAll(obj);
}catch(FileNotFoundException fnfEX){
System.err.println(""+fnfEX);
System.exit(-1);
};
inputObject3D.build();
DeSerializer deSer = new DeSerializer();
try {
fileSer = new File(inputPath+""+objName+".ser");
FileOutputStream outStreamSer = new FileOutputStream(fileSer);
deSer.serialize(inputObject3D, outStreamSer, true);
} catch (FileNotFoundException e) {
System.err.println(""+e);
System.exit(-1);
}
System.out.println("Finished!");
}


EgonOlsen

Just don't use textures of that size. Width and height have to be a power of two (so in your case 256, not 254). So just go ahead and rescale your textures in some image editing program. That's far better than doing any kind of rescaling in the app itself.

dubbox

thanks egon !!!

but now there is another problem

i created the model using blender and everything looks rigth the texture is applied via uv-map and is saved correctly
but when i add the tex onto the model in java and move the camera it gets the effect like a fisheye sorry dont know how to explain it but the tex near to the camera looks like the camera would be a fisheye how can i avoid this?

thanks for your great help and work Egon  :)

EgonOlsen

Do you have a screen shot? I'm not sure what you mean... ???

dubbox

sorry for not giving you feedback i was busy

it was just an emulator bug on my smartphone everything is fine so its all good

thank you for your fast help egon