Thank you. It's done.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote1. assign the corresponding texture to the object before merging them all into one
2. let the auto-assignment do it's magic. Looking at your code, it seems like that should work already. Have you tried to remove your texture assigment code and see if works then?
.......................................
Object3D[] objectsArray2 = Loader.loadOBJ
(context.getResources().getAssets().open(objFileName), context.getResources()
.getAssets().open("smile.mtl"), 4.3f);
Log.e("obj and mtl", "obj and mtl");
newObject = Object3D.mergeAll(objectsArray2);
newObject.setOrigin(new SimpleVector(0, -20, 200));
newObject.rotateX(-0.2f);
newObject.rotateY(160.2f);
newObject.rotateZ(160.2f);
newObject.setName("smile.obj");
................................................
newmtl Texture0
illum 0
Kd 0.7 0.7 0.7
Ks 0 0 0
Ka 0 0 0
newmtl Texture1
illum 0
Kd 0.7 0.7 0.7
Ks 0 0 0
Ka 0 0 0
map_Kd smile1.png
newmtl Texture2
illum 0
Kd 0.7 0.7 0.7
Ks 0 0 0
Ka 0 0 0
map_Kd smile2.png
newmtl Texture3
illum 0
Kd 0.7 0.7 0.7
Ks 0 0 0
Ka 0 0 0
map_Kd smile3.png
# Wavefront OBJ format.
# Generated by FaceGen, for more information visit https://facegen.com
mtllib smile.mtl
o MidlengthStraight
s 1
v 4.057448 11.21256 -4.933716
v 2.369889 12.19813 -3.245485
v 3.069078 12.0395 -3.387058
v 3.638412 11.71071 -3.791797
............................................
tm = TextureManager.getInstance();
this.createTextures();
glSurfaceView = (GLSurfaceView) findViewById(R.id.my_surface_view);
avatarRenderer = new AvatarRenderer(this);
glSurfaceView.setRenderer(avatarRenderer);
avatarRenderer.addObject(Home.this, AvatarRenderer.OBJ_TYPES.RUTURAJ, "smile.obj");
private void createTextures() {
@SuppressLint({"NewApi", "LocalSuppress"}) Texture texture1 = new Texture(BitmapHelper.rescale
(BitmapHelper.convert(Objects.requireNonNull(getBitmapFromAssets("smile1.png"))), 4, 4));
tm.addTexture("smile1.png", texture1);
Log.e("load smile1", "load smile1");
@SuppressLint({"NewApi", "LocalSuppress"}) Texture texture2 = new Texture(BitmapHelper.rescale
(BitmapHelper.convert(Objects.requireNonNull(getBitmapFromAssets("smile2.png"))), 4, 4));
tm.addTexture("smile2.png", texture2);
Log.e("load smile2", "load smile2");
@SuppressLint({"NewApi", "LocalSuppress"}) Texture texture3 = new Texture(BitmapHelper.rescale
(BitmapHelper.convert(Objects.requireNonNull(getBitmapFromAssets("smile3.png"))), 4, 4));
tm.addTexture("smile3.png", texture3);
Log.e("load smile3", "load smile3");
tm.compress();
Log.e("dummy structure", String.valueOf(tm.getDummyTexture()));
Log.e("tm name by id",
tm.getNameByTexture(texture1)
+ "\n" + tm.getNameByTexture(texture2)
+ "\n" + tm.getNameByTexture(texture3));
}
@TargetApi(Build.VERSION_CODES.KITKAT)
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private Drawable getBitmapFromAssets(String s) {
try (@SuppressLint({"NewApi", "LocalSuppress"}) InputStream stream = getApplicationContext().getAssets().open(s)) {
return Drawable.createFromStream(stream, null);
} catch (Exception ignored) {
}
return null;
}
public void addObject(Context context, OBJ_TYPES type, String objFileName) {
Object3D newObject = null;
if (type.ordinal() == OBJ_TYPES.RUTURAJ.ordinal()) {
try {
Object3D[] objectsArray2 = Loader.loadOBJ
(context.getResources().getAssets().open(objFileName), context.getResources()
.getAssets().open("smile.mtl"), 4.3f);
Log.e("obj and mtl", "obj and mtl");
newObject = Object3D.mergeAll(objectsArray2);
newObject.setTexture("smile1.png");
Log.e("smile1", "smile1");
newObject.setTexture("smile2.png");
Log.e("smile2", "smile2");
newObject.setTexture("smile3.png");
Log.e("smile3", "smile3");
newObject.setOrigin(new SimpleVector(0, -20, 200));
newObject.rotateX(-0.2f);
newObject.rotateY(160.2f);
newObject.rotateZ(160.2f);
newObject.setName("smile.obj");
} catch (IOException e) {
e.printStackTrace();
}
}
assert newObject != null;
newObject.strip();
newObject.build();
myWorld.addObject(newObject);
}
06-08 04:08:31.573 4874-4874/? W/System: ClassLoader referenced unknown path: /data/app/my.application.package-2/lib/x86_64
06-08 04:08:31.576 4874-4874/? I/InstantRun: starting instant run server: is main process
06-08 04:08:31.690 4874-4874/? W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
06-08 04:08:32.340 4874-4874/my.application.package D/MediaPlayer: setSubtitleAnchor in MediaPlayer
06-08 04:08:32.360 4874-4916/my.application.package D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
06-08 04:08:32.412 4874-4916/my.application.package I/OpenGLRenderer: Initialized EGL, version 1.4
06-08 04:08:32.412 4874-4916/my.application.package W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
06-08 04:08:32.419 4874-4916/my.application.package D/EGL_emulation: eglCreateContext: 0x7f8abba9d2a0: maj 2 min 0 rcv 2
06-08 04:08:32.445 4874-4916/my.application.package D/EGL_emulation: eglMakeCurrent: 0x7f8abba9d2a0: ver 2 0 (tinfo 0x7f8abc2edca0)
06-08 04:08:32.475 4874-4916/my.application.package D/EGL_emulation: eglMakeCurrent: 0x7f8abba9d2a0: ver 2 0 (tinfo 0x7f8abc2edca0)
06-08 04:08:37.480 4874-4874/my.application.package I/jPCT-AE: Loading Texture...
06-08 04:08:37.480 4874-4874/my.application.package I/jPCT-AE: Texture loaded...64 bytes/4*4 pixels!
06-08 04:08:37.480 4874-4874/my.application.package E/load smile1: load smile1
06-08 04:08:37.486 4874-4874/my.application.package I/jPCT-AE: Loading Texture...
06-08 04:08:37.486 4874-4874/my.application.package I/jPCT-AE: Texture loaded...64 bytes/4*4 pixels!
06-08 04:08:37.486 4874-4874/my.application.package E/load smile2: load smile2
06-08 04:08:37.502 4874-4874/my.application.package I/jPCT-AE: Loading Texture...
06-08 04:08:37.502 4874-4874/my.application.package I/jPCT-AE: Texture loaded...64 bytes/4*4 pixels!
06-08 04:08:37.502 4874-4874/my.application.package E/load smile3: load smile3
06-08 04:08:37.504 4874-4874/my.application.package E/dummy structure: com.threed.jpct.Texture@587ed45
06-08 04:08:37.504 4874-4874/my.application.package E/tm name by id: smile1.png
smile2.png
smile3.png
06-08 04:08:37.560 4874-4874/my.application.package I/jPCT-AE: Adding Lightsource: 0
06-08 04:08:37.575 4874-4874/my.application.package I/jPCT-AE: Loading file from InputStream
06-08 04:08:37.575 4874-4874/my.application.package I/jPCT-AE: Text file from InputStream loaded...358 bytes
06-08 04:08:37.575 4874-4874/my.application.package I/jPCT-AE: Processing new material Texture0!
06-08 04:08:37.575 4874-4874/my.application.package I/jPCT-AE: Processing new material Texture1!
06-08 04:08:37.575 4874-4874/my.application.package I/jPCT-AE: Processing new material Texture2!
06-08 04:08:37.575 4874-4874/my.application.package I/jPCT-AE: Processing new material Texture3!
06-08 04:08:37.575 4874-4874/my.application.package I/jPCT-AE: Loading file from InputStream
06-08 04:08:37.689 4874-4874/my.application.package I/jPCT-AE: Text file from InputStream loaded...2607399 bytes
06-08 04:08:37.749 4874-4874/my.application.package I/jPCT-AE: Processing object from OBJ-file: MidlengthStraight
06-08 04:08:38.206 4874-4874/my.application.package I/jPCT-AE: Processing object from OBJ-file: Surf0
06-08 04:08:40.133 4874-4874/my.application.package I/jPCT-AE: Object 'Surf0_jPCT0' created using 17264 polygons and 12771 vertices.
06-08 04:08:40.133 4874-4874/my.application.package I/jPCT-AE: Processing object from OBJ-file: HeadHires
06-08 04:08:40.319 4874-4874/my.application.package I/jPCT-AE: Processing object from OBJ-file: Surf0
06-08 04:08:42.014 4874-4874/my.application.package I/jPCT-AE: Object 'Surf0_jPCT1' created using 11580 polygons and 5850 vertices.
06-08 04:08:42.014 4874-4874/my.application.package I/jPCT-AE: Processing object from OBJ-file: Mouth
06-08 04:08:42.018 4874-4874/my.application.package I/jPCT-AE: Processing object from OBJ-file: Surf0
06-08 04:08:42.022 4874-4874/my.application.package I/jPCT-AE: Object 'Surf0_jPCT2' created using 172 polygons and 118 vertices.
06-08 04:08:42.022 4874-4874/my.application.package E/obj and mtl: obj and mtl
06-08 04:08:42.040 4874-4874/my.application.package E/smile1: smile1
06-08 04:08:42.041 4874-4874/my.application.package E/smile2: smile2
06-08 04:08:42.042 4874-4874/my.application.package E/smile3: smile3
06-08 04:08:42.553 4874-4874/my.application.package I/jPCT-AE: Normal vectors calculated in 490ms!
06-08 04:08:42.597 4874-4874/my.application.package I/TextToSpeech: Sucessfully bound to com.svox.pico
06-08 04:08:42.597 4874-4874/my.application.package E/output result: [my.application.package.ChatDetails@8bf18c1]
06-08 04:08:42.615 4874-4874/my.application.package I/Choreographer: Skipped 314 frames! The application may be doing too much work on its main thread.
06-08 04:08:42.661 4874-4916/my.application.package D/EGL_emulation: eglMakeCurrent: 0x7f8abba9d2a0: ver 2 0 (tinfo 0x7f8abc2edca0)
06-08 04:08:42.679 4874-4916/my.application.package D/EGL_emulation: eglMakeCurrent: 0x7f8abba9d2a0: ver 2 0 (tinfo 0x7f8abc2edca0)
06-08 04:08:42.681 4874-4919/my.application.package D/EGL_emulation: eglCreateContext: 0x7f8abfcac8e0: maj 1 min 0 rcv 1
06-08 04:08:42.710 4874-4919/my.application.package D/EGL_emulation: eglMakeCurrent: 0x7f8abfcac8e0: ver 1 0 (tinfo 0x7f8abfc87360)
06-08 04:08:42.715 4874-4916/my.application.package D/EGL_emulation: eglMakeCurrent: 0x7f8abba9d2a0: ver 2 0 (tinfo 0x7f8abc2edca0)
06-08 04:08:42.751 4874-4919/my.application.package I/jPCT-AE: GL context is 13808366
06-08 04:08:42.758 4874-4919/my.application.package W/jPCT-AE: [ 1528430922758 ] - WARNING: OpenGL vendor: Google (NVIDIA Corporation)
06-08 04:08:42.760 4874-4919/my.application.package W/jPCT-AE: [ 1528430922758 ] - WARNING: OpenGL renderer: Android Emulator OpenGL ES Translator (GeForce 840M/PCIe/SSE2)
06-08 04:08:42.762 4874-4919/my.application.package W/jPCT-AE: [ 1528430922761 ] - WARNING: OpenGL version: OpenGL ES-CM 1.1 (4.5.0 NVIDIA 378.92)
06-08 04:08:42.762 4874-4919/my.application.package W/jPCT-AE: [ 1528430922762 ] - WARNING: OpenGL renderer initialized (using 2/4 texture stages)
06-08 04:08:42.826 4874-4916/my.application.package E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f8abba9e1a0
06-08 04:08:42.831 4874-4874/my.application.package I/TextToSpeech: Connected to ComponentInfo{com.svox.pico/com.svox.pico.PicoService}
06-08 04:08:42.850 4874-4925/my.application.package I/TextToSpeech: Set up connection to ComponentInfo{com.svox.pico/com.svox.pico.PicoService}
06-08 04:08:43.109 4874-4919/my.application.package I/jPCT-AE: Subobject of object 3/smile.obj compiled to indexed fixed point data using 23997/5575 vertices in 171ms!
06-08 04:08:43.294 4874-4919/my.application.package I/jPCT-AE: Subobject of object 3/smile.obj compiled to indexed fixed point data using 24000/6220 vertices in 184ms!
06-08 04:08:43.504 4874-4919/my.application.package I/jPCT-AE: Subobject of object 3/smile.obj compiled to indexed fixed point data using 24000/6316 vertices in 208ms!
06-08 04:08:43.651 4874-4919/my.application.package I/jPCT-AE: Subobject of object 3/smile.obj compiled to indexed fixed point data using 15051/4007 vertices in 146ms!
06-08 04:08:43.651 4874-4919/my.application.package I/jPCT-AE: Object 3/smile.obj compiled to 4 subobjects in 888ms!
06-08 04:08:43.651 4874-4919/my.application.package I/jPCT-AE: Object 'smile.obj' uses one texture set!
06-08 04:08:43.652 4874-4919/my.application.package I/jPCT-AE: Creating buffers...
06-08 04:08:43.653 4874-4919/my.application.package I/jPCT-AE: VBO created for object 'smile.obj'
06-08 04:08:43.653 4874-4919/my.application.package I/jPCT-AE: Creating buffers...
06-08 04:08:43.756 4874-4919/my.application.package I/jPCT-AE: VBO created for object 'smile.obj'
06-08 04:08:43.756 4874-4919/my.application.package I/jPCT-AE: Creating buffers...
06-08 04:08:43.882 4874-4919/my.application.package I/jPCT-AE: VBO created for object 'smile.obj'
06-08 04:08:43.883 4874-4919/my.application.package I/jPCT-AE: Creating buffers...
06-08 04:08:43.999 4874-4919/my.application.package I/jPCT-AE: VBO created for object 'smile.obj'
Page created in 0.019 seconds with 12 queries.