0

I'm creating a app in android for mugs like this

enter image description here

I know how to do everything except wrapping an image around an object. It would be a simple task to do if I would only have to stack an image on top of the other, if they were flat, but if it is a round object, as this mug is, it's kinda tricky.

I thought of creating a obj object file in blender and render the image on it in OpenGL or Unity. The obj file size goes to 5MB. And i cannot use this much big file in my app.

Is there any alternate good approach for it? If there please share a reference or example for it

Fahim
  • 12,198
  • 5
  • 39
  • 57
  • Are you making this in Android or Inside Unity Engine? – Aizen Mar 30 '15 at 22:10
  • @aizen I would like to do in android not unity, is it possible? – Fahim Mar 31 '15 at 02:40
  • It is possible ofcourse but you will have to use 3rd party for it. OpenGl can do it and unity3d as well. The problem with opengl having a big file for the obj is because an obj file is not actually compressed. Adding the image must implement the decals component so it will be as one with the obj and you dont have to specifically write a bunch of code to make it look like its attached to it. I am currently in a tablet so I dont have my resources in me. – Aizen Mar 31 '15 at 05:48
  • @Aizen i solved it in different way – Fahim Apr 01 '15 at 12:54

2 Answers2

2

Use in this manner

the work around of it by doing a masking over the image

    ImageView mImageView= (ImageView)findViewById(R.id.imageview_id); 
Bitmap original = BitmapFactory.decodeResource(getResources(),R.drawable.content_image);
 Bitmap mask = BitmapFactory.decodeResource(getResources(),R.drawable.mask);
 Bitmap result = Bitmap.createBitmap(mask.getWidth(), mask.getHeight(), Config.ARGB_8888); 
Canvas mCanvas = new Canvas(result); 
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
 paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
 mCanvas.drawBitmap(original, 0, 0, null);
 mCanvas.drawBitmap(mask, 0, 0, paint); paint.setXfermode(null);
 mImageView.setImageBitmap(result);
 mImageView.setScaleType(ScaleType.CENTER);
 mImageView.setBackgroundResource(R.drawable.background_frame);

As mentioned here Masking(crop) image in frame

Community
  • 1
  • 1
0

I suppose that this is the right way, but using pure OpenGL is difficult. I used LibGDX for simple 3d modeling.

nbumakov
  • 140
  • 6