Giter VIP home page Giter VIP logo

android-3d-model-viewer's Introduction

Android 3D Model Viewer

travis-ci badge

This is a demo of OpenGL ES 2.0. It is basically an android application with a 3D engine that can load Wavefront OBJ, STL, DAE & GLTF files. The purpose of this application is to learn and share how to draw using OpenGL language.

News (04/10/2022)

  • Preparing version 4.0.0 for Google Play release...
  • New orthographic, isometric and free camera views
  • GLTF basic support :)
  • Rebranding to org.the3deer

Demo

Checkout this to see the features of the application: https://www.youtube.com/watch?v=PV92DKohXXk

Android Market

Get in on F-Droid

Notice

  • Collada support is limited. Collada renderer currently supports a maximum of 60 bones.
  • In order to see models in 3D virtual reality, you need red-cyan and/or VR glasses
  • If you have any issue in general,please open an issue and attach model if possible, specifying Android version and Device model.

About

Load 3D models and see how to do it with this open source code application.

The main purpose of this app is to show how to draw in android using the OpenGL 2.0 by sharing the source code. So please, don't expect this application to be much richer or nicer than the ones already published in the app store, but at least it's opened to anyone who wants to contribute or don't want to start a similar project from scratch.

As this is my first android app and Im still learning the OpenGL 2.0 language, it is highly probable that there are bugs; but I will try to continue improving the app and adding more features. So please send me your comments, suggestions or complains by opening an issue.

The app comes with some included 3D models that have different licenses.

Whats next

  • Improve support for glTF standard format
  • VR without glasses (on hold)
  • Augmented reality

Features

  • Supports >= Android 4.1 (Ice Cream Sandwich) - Min API Level 16 -> Target API Level 31
  • OpenGL ES 2.0 API
  • Multiple Formats:
    • OBJ (wavefront)
    • STL (STereoLithography)
    • DAE (Collada-BETA)
    • GLTF (GL Transmission Format)
  • Vertex Normals support
  • Transformation support: scaling, rotation, translation, orientation
  • Colors support
  • Textures support
  • Lighting support
  • Multiple Rendering Modes
    • triangles
    • wireframe
    • point cloud
    • skeleton
  • camera support
    • perspective
    • orthographic
    • isometric views
    • free
  • skeletal animations (collada dae)
  • ray collision detection
  • stereoscopic 3D: anaglyph + cardboard
  • other:
    • Polygon with holes
    • Smoothing
    • Bounding box
    • Skybox
    • Object picking
    • file explorer
    • repository explorer
    • texture loader
    • lightweight: only 1.3 Megabyte (embedded models excluded)

Try it

You can install the application in either of these ways:

    export ANDROID_HOME=/home/$USER/Android/Sdk
    ./gradlew assembleDebug
    adb install -r app/build/outputs/apk/app-debug.apk
    adb shell am start -n org.andresoviedo.dddmodel2/org.the3deer.app.model3D.MainActivity

Open the application. You should see a menu. From there you can load models Once the model is rendered, pinch and rotate to see the 3D scene from another perspective.

Screenshots

Screenshot1 Screenshot2 Screenshot3 Screenshot4 Screenshot5 Screenshot6 cowboy.gif stormtrooper.gif Screenshot6

Emulator

You can run application in an emulator

// install some file provider (i.e. es file explorer)
adb devices -l
adb -s emulator-5554 install .\com.estrongs.android.pop_4.0.3.4-250_minAPI8(armeabi,x86)(nodpi).apk
// push some files to test file loading
adb -s emulator-5554 push .\app\src\main\assets\models /sdcard/download

Glasses

You may need one of this glasses to view models in 3D virtual reality.

Dependencies

Documentation

Working on it...

Acknowledgement

Licenses

The following copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

MIT License - Copyright (c) 2022 The 3Deer - https://github.com/the3deer
GNU LGPL v2.1 Copyright (c) 2001, 2002 Dipl. Ing. P. Szawlowski - STL Parser
MIT License - https://github.com/javagl/JglTF - GLTF Parser    
ISC License - Earcut - https://github.com/the3deer/earcut

Assets

android-3d-model-viewer's People

Contributors

andresoviedo avatar dilipkold avatar itslonua avatar izzysoft avatar mankinchung avatar niccokunzmann avatar sguinetti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-3d-model-viewer's Issues

Error loading model on Android 7.1.0

I try to load the Plane.obj model in examples on an Android device running API 25 Nougat 7.1.0 but I get this error.
There was a problem building the model: index=704643072 out of bounds (limit=1686)
alt text
This error happens only on this version of Android.

Here it is the Log:

04-20 13:03:18.539 1414-1863/org.andresoviedo.dddmodel2 E/Object3DBuilder: index=704643072 out of bounds (limit=1686)
                                                                           java.lang.IndexOutOfBoundsException: index=704643072 out of bounds (limit=1686)
                                                                               at java.nio.Buffer.checkIndex(Buffer.java:528)
                                                                               at java.nio.ByteBufferAsFloatBuffer.get(ByteBufferAsFloatBuffer.java:95)
                                                                               at org.andresoviedo.app.model3D.model.Object3DBuilder.generateArrays(Object3DBuilder.java:466)
                                                                               at org.andresoviedo.app.model3D.services.wavefront.WavefrontLoader2$1.build(WavefrontLoader2.java:106)
                                                                               at org.andresoviedo.app.model3D.controller.LoaderTask.doInBackground(LoaderTask.java:92)
                                                                               at org.andresoviedo.app.model3D.controller.LoaderTask.doInBackground(LoaderTask.java:22)
                                                                               at android.os.AsyncTask$2.call(AsyncTask.java:305)
                                                                               at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                               at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
                                                                               at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                               at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                               at java.lang.Thread.run(Thread.java:761)
04-20 13:03:18.559 1414-1429/org.andresoviedo.dddmodel2 E/EGL_emulation: tid 1429: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
04-20 13:03:18.559 1414-1429/org.andresoviedo.dddmodel2 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xcefd2aa0, error=EGL_BAD_MATCH
04-20 13:03:18.621 1414-1429/org.andresoviedo.dddmodel2 E/EGL_emulation: tid 1429: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
04-20 13:03:18.621 1414-1429/org.andresoviedo.dddmodel2 W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe427eb40, error=EGL_BAD_MATCH
                                                                          [ 04-20 13:03:18.844  1414: 1862 D/         ]
                                                                          HostConnection::get() New Host Connection established 0xd05ac340, tid 1862
04-20 13:03:18.988 1414-1862/org.andresoviedo.dddmodel2 D/org.andresoviedo.app.model3D.view.ModelRenderer: projection: [-0.6728972,0.6728972,-1,1]-near/far[1,10]
04-20 13:03:19.706 1414-1414/org.andresoviedo.dddmodel2 E/SceneLoader: index=704643072 out of bounds (limit=1686)
                                                                       java.lang.IndexOutOfBoundsException: index=704643072 out of bounds (limit=1686)
                                                                           at java.nio.Buffer.checkIndex(Buffer.java:528)
                                                                           at java.nio.ByteBufferAsFloatBuffer.get(ByteBufferAsFloatBuffer.java:95)
                                                                           at org.andresoviedo.app.model3D.model.Object3DBuilder.generateArrays(Object3DBuilder.java:466)
                                                                           at org.andresoviedo.app.model3D.services.wavefront.WavefrontLoader2$1.build(WavefrontLoader2.java:106)
                                                                           at org.andresoviedo.app.model3D.controller.LoaderTask.doInBackground(LoaderTask.java:92)
                                                                           at org.andresoviedo.app.model3D.controller.LoaderTask.doInBackground(LoaderTask.java:22)
                                                                           at android.os.AsyncTask$2.call(AsyncTask.java:305)
                                                                           at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                           at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
                                                                           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                           at java.lang.Thread.run(Thread.java:761)

Thanks for the help 😄

Rotate 3d model in its own Y axis

I would like to rotate a obj model in its own Y axis in 360 degree.
I tried camera.translateCamera(0.00010f, 0f); but rotation is not smooth.

how do a smooth animation by rotating the obj model.

How to translate 3D model in view?

I want to position a model on screen by specifying it's x position and y position on screen. I have attempted to apply Matrix.translateM on modelMatrix but the result turned out to be the model was rotated around the origin, not translated to a new x, y position on screen. May I know how to properly position the model on screen? How to translate the model on (x,y) plane with fixed view and projection?

Object3DImpl

public float[] getMMatrix(Object3DData obj) {
	// calculate object transformation
	Matrix.setIdentityM(mMatrix, 0);
	...
	if (obj.getPosition() != null) {
		Matrix.translateM(mMatrix, 0, obj.getPositionX(), obj.getPositionY(), obj.getPositionZ());
                // Line added to translate model
		Matrix.translateM(mMatrix, 0, -0.5f, 0, 0);
	}
	return mMatrix;
}

Thank you.

Alpha channel

Png image as textures with alpha channel don't work. Transparent area on image replace with black color.

IndexOutOfBounds loading normals

FATAL EXCEPTION: AsyncTask #1
   Process: org.andresoviedo.dddmodel, PID: 24065
   java.lang.RuntimeException: An error occurred while executing doInBackground()
       at android.os.AsyncTask$3.done(AsyncTask.java:309)
       at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
       at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
       at java.util.concurrent.FutureTask.run(FutureTask.java:242)
       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)
    Caused by: java.lang.IndexOutOfBoundsException: index=-3, limit=0
       at java.nio.Buffer.checkIndex(Buffer.java:150)
       at java.nio.ByteBufferAsFloatBuffer.get(ByteBufferAsFloatBuffer.java:94)
       at org.andresoviedo.app.model3D.model.Object3DBuilder.generateArrays(Object3DBuilder.java:484)
       at org.andresoviedo.app.model3D.model.LoaderTask.doInBackground(Object3DBuilder.java:801)
       at org.andresoviedo.app.model3D.model.LoaderTask.doInBackground(Object3DBuilder.java:732)
       at android.os.AsyncTask$2.call(AsyncTask.java:295)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
       at java.lang.Thread.run(Thread.java:818) 

How change Light color

I want to change the default white color of light object a different one, how can i change the color.
I tried setting color to lightPoint object but it doesn't change the color.

private static float[] LIGHT_COLOR = {1.0f, 0.0f, 0, 0.0f,};

private final Object3DData lightPoint = Object3DBuilder.buildPoint(lightPosition).setColor(LIGHT_COLOR).setId("light");

Thanks in Advance.

How to load multiple textures with dae file format for animation?

Hai iam analysing android-3d-model-viewer app collada loader classes in the app only load single texture with dae. if i load dae file with two or three textures the error came as "There was a problem loading model index=960,length=960".how can i load dae model with multiple textures?

zoom limit

hellow,how can make the model set the limits of the zoom maximum and minimum

Configuration options + Point Drawing + ByteBuffers thread safe

  • (f) Immersive mode is now configurable in the ModelActivity Intent: b.putString("immersiveMode", "false");
  • (f) Background color configurable in the MOdelActivity Intent: b.putString("backgroundColor", "0 0 0 1");
  • (f) Fixed vertex normals generation (vertices were missing): Fixes #11
  • (f) Scaling is now implemented in the ModelView Matrix with Object3DData.setScale(float[])
  • (f) Wireframe generation is now using the source data
  • (n) Implemented Point Drawing, like wireframe mode but only the points are drawn
  • (f) Removed trailing slash from parameter "assetDir"
  • (f) Access to ByteBuffers made absolute so there are thread safe (future fixes need this)

Limit Zoom

Is there a possibility to limit the max zoom in and out?

java.lang.RuntimeException: Error creating program.

06-07 17:22:48.006 4222-5030/org.andresoviedo.dddmodel2 E/GLUtil: Could not compile program: | const int MAX_JOINTS = 200; const int MAX_WEIGHTS = 3; uniform mat4 u_MVPMatrix; attribute vec4 a_Position; attribute vec3 in_jointIndices; attribute vec3 in_weights; uniform mat4 jointTransforms[MAX_JOINTS]; uniform mat4 u_MVMatrix; uniform vec3 u_LightPos; attribute vec3 a_Normal; uniform vec4 vColor; varying vec4 v_Color; attribute vec2 a_TexCoordinate;varying vec2 v_TexCoordinate;void main() { vec4 totalLocalPos = vec4(0.0); vec4 totalNormal = vec4(0.0); mat4 jointTransform = jointTransforms[int(in_jointIndices[0])]; vec4 posePosition = jointTransform * a_Position; totalLocalPos += posePosition * in_weights[0]; jointTransform = jointTransforms[int(in_jointIndices[1])]; posePosition = jointTransform * a_Position; totalLocalPos += posePosition * in_weights[1]; jointTransform = jointTransforms[int(in_jointIndices[2])]; posePosition = jointTransform * a_Position; totalLocalPos += posePosition * in_weights[2]; gl_Position = u_MVPMatrix * totalLocalPos; gl_PointSize = 2.5; vec3 modelViewVertex = vec3(u_MVMatrix * a_Position); vec3 lightVector = normalize(u_LightPos - modelViewVertex); vec3 modelViewNormal = vec3(u_MVMatrix * vec4(a_Normal, 0.0)); float diffuse = max(dot(modelViewNormal, lightVector), 0.1); float distance = length(u_LightPos - modelViewVertex); diffuse = diffuse * (1.0 / (1.0 + (0.05 * distance * distance))); diffuse = diffuse + 0.5; v_Color = vColor * diffuse; v_Color[3] = vColor[3]; v_TexCoordinate = a_TexCoordinate;} Error compiling program: L1003: Can't link program, because it does not contain a vertex shader 06-07 17:22:48.016 4222-5030/org.andresoviedo.dddmodel2 E/ModelRenderer: There was a problem rendering the object 'truck.obj':Error creating program. java.lang.RuntimeException: Error creating program. at org.andresoviedo.app.model3D.util.GLUtil.createAndLinkProgram(GLUtil.java:65) at org.andresoviedo.app.model3D.model.Object3DImpl.<init>(Object3DImpl.java:45) at org.andresoviedo.app.model3D.model.Object3DV9.<init>(Object3DImpl.java:963) at org.andresoviedo.app.model3D.model.Object3DBuilder.getDrawer(Object3DBuilder.java:430) at org.andresoviedo.app.model3D.view.ModelRenderer.onDrawFrame(ModelRenderer.java:176) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
Help! Getting error while loading texture.
Thanks in Advance

Sliding experience is not friendly.

Now sliding gesture experience is not very friendly, I compared the IOS side gestures, sliding gestures lack precision, now I want to slide back to initialize it is difficult to operate, can optimize the sliding interaction gestures

Performance problems with high vertex shapes

The rendering time for objects such as the truck (or objects I'm trying to render) is around 5 seconds or higher per frame. I'm not very familiar with your code or rendering algorithm yet, but if you have any ideas of how to speed things up let me know.

Problem parsing vertices with multiple spaces

I am trying to load the following template via "Load Model" option or add in the project assets. Both do not carry.
The 3d model have '.obj' and '.mtl' files.
When trying to check the error in logcat, the error is printed and quickly cleaned (since the app restarta) thus making verification impossible.
I have tried other several .obj files and none are being uploaded only the files that already come with the project.
Is there any implementation yet to be done?
I'm sorry that my knowledge of 3D object manipulation is extremely low.
Thanks for the comprehension.

Unable to use one finger functionality or zoom feature on API 24 & 25

It seems that every time I run the application on a VM or actual phone with API 24 or 25(Android 7 & 7.1)
Only the cube object files work as intended. The rest of the obj models (including imported ones) lost functionality with one finger touch functionality as well as zoom functionality.

When I attempt to touch the screen, this appears in the log :
10-05 00:57:11.961 25910-25910/org.andresoviedo.dddmodel2 D/Camera: Inside bounds of 'ToyPlane.obj'

Which I found the probable case scenario to be in line 201 of Camera.java
" Log.d("Camera", "Inside bounds of '" + objects.get(i).getId() + "'"); "
Inside the isOutOfBounds() function.

I am unsure if this is enough to try to identify the problem, but I think it's at least a start, haha.
Please help ! (:

PS: This is an awesome app

Code refactoring

I found it too hard to transplant and use your code .For example ,I just want to use some of your classes to display 3D models in my application,but I have to import many another classes as dependence. If I want to use SceneLoader ,but SceneLoader has reference to ModelActivity ,It isn't a good design as far as I am concerned.

In other words ,The coupling degree in your code may be very high.

Could you please make your classes into .jar files ?So that we can import your classes and use it easily.

Could you please upload your code to jCenter that we can import your code to our applications by adding dependence to build.gradle ?

Bug with textures

Click Load Model Item --> choose file .obj. In this folder with file .obj file .mtl exist. During building model I see error in logcat.
01-03 20:18:13.896 26400-27307/? E/GLUtil: Error compiling program: --From Vertex Shader: Error: uniform variables in vertex shader do not fit in 256 vectors. --From Fragment Shader: Error: uniform variables in vertex shader do not fit in 256 vectors. 01-03 20:18:13.901 26400-27307/? E/ModelRenderer: There was a problem rendering the object 'figurine_27201KM.obj':Error creating program. java.lang.RuntimeException: Error creating program. at org.andresoviedo.app.model3D.util.GLUtil.createAndLinkProgram(GLUtil.java:65) at org.andresoviedo.app.model3D.model.Object3DImpl.<init>(Object3DImpl.java:45) at org.andresoviedo.app.model3D.model.Object3DV9.<init>(Object3DImpl.java:995) at org.andresoviedo.app.model3D.model.Object3DBuilder.getDrawer(Object3DBuilder.java:426) at org.andresoviedo.app.model3D.view.ModelRenderer.onDrawFrame(ModelRenderer.java:175) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1535) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
And after building my 3d model without textures

Please help! Thanks

java.lang.RuntimeException: glGetUniformLocation: glError 1280

Hi Andres, I am new to OpenGL and I'm using your code for a school project. I want to load ship.obj. Object3DImpl.setMvpMatrix has raised error java.lang.RuntimeException: glGetUniformLocation: glError 1280. Can you give me some hints, what could have caused it to happen?

Error stack trace:

java.lang.RuntimeException: glGetUniformLocation: glError 1280
at com.myproject.model3D.util.GLUtil.checkGlError(GLUtil.java:162)
at com.myproject.model3D.model.Object3DImpl.setMvpMatrix(Object3DImpl.java:150)
at com.myproject.model3D.model.Object3DImpl.draw(Object3DImpl.java:64)
at com.myproject.model3D.model.Object3DImpl.draw(Object3DImpl.java:48)
at com.myproject.ModelRenderer.onDrawFrame(ModelRenderer.java:133)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)

Thank you.

how to select the Object3DData in the scene?

public void processTouch(float x, float y) {
	Object3DData objectToSelect = CollisionDetection.getBoxIntersection(getObjects(), parent.getgLView().getModelRenderer(), x, y);
	if (objectToSelect != null) {
		if (getSelectedObject() == objectToSelect) {
			Log.i("SceneLoader", "Unselected object " + objectToSelect.getId());
			setSelectedObject(null);
		} else {
			Log.i("SceneLoader", "Selected object " + objectToSelect.getId());
			setSelectedObject(objectToSelect);
		}
		float[] point = CollisionDetection.getTriangleIntersection2(getObjects(), parent.getgLView().getModelRenderer(), x, y);
		if (point != null) {
			addObject(Object3DBuilder.buildPoint(point).setColor(new float[]{1.0f,0f,0f,1f}));
		}
	}
}

why the objectToSelect is always null?

column '_data' does not exist

When I compile the app and execute in my tablet and I try to load an .obj object, it throws this error:


02-23 21:46:19.199 29517-29517/org.andresoviedo.dddmodel2 I/Menu: Loading 'content://com.huawei.hidisk.fileprovider/root/storage/emulated/0/Biotech3D/ScanFace/Output/2018.02.23.21.32.13/Output_hd/head3d.obj'
02-23 21:46:19.204 29517-29517/org.andresoviedo.dddmodel2 E/AndroidRuntime: FATAL EXCEPTION: main
                                                                            Process: org.andresoviedo.dddmodel2, PID: 29517
                                                                            java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1000, result=-1, data=Intent { dat=content://com.huawei.hidisk.fileprovider/root/storage/emulated/0/Biotech3D/ScanFace/Output/2018.02.23.21.32.13/Output_hd/head3d.obj flg=0x3 }} to activity {org.andresoviedo.dddmodel2/org.andresoviedo.app.model3D.view.MenuActivity}: java.lang.IllegalArgumentException: column '_data' does not exist
                                                                                at android.app.ActivityThread.deliverResults(ActivityThread.java:4284)
                                                                                at android.app.ActivityThread.handleSendResult(ActivityThread.java:4327)
                                                                                at android.app.ActivityThread.-wrap22(ActivityThread.java)
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1624)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:105)
                                                                                at android.os.Looper.loop(Looper.java:156)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6523)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
                                                                             Caused by: java.lang.IllegalArgumentException: column '_data' does not exist
                                                                                at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:333)
                                                                                at android.database.CursorWrapper.getColumnIndexOrThrow(CursorWrapper.java:87)
                                                                                at org.andresoviedo.app.util.content.ContentUtils.getDataColumn(ContentUtils.java:128)
                                                                                at org.andresoviedo.app.util.content.ContentUtils.getPathLegacy(ContentUtils.java:49)
                                                                                at org.andresoviedo.app.util.content.ContentUtils.getPath(ContentUtils.java:34)
                                                                                at org.andresoviedo.app.model3D.view.MenuActivity.onActivityResult(MenuActivity.java:124)
                                                                                at android.app.Activity.dispatchActivityResult(Activity.java:7193)
                                                                                at android.app.ActivityThread.deliverResults(ActivityThread.java:4280)
                                                                                at android.app.ActivityThread.handleSendResult(ActivityThread.java:4327) 
                                                                                at android.app.ActivityThread.-wrap22(ActivityThread.java) 
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1624) 
                                                                                at android.os.Handler.dispatchMessage(Handler.java:105) 
                                                                                at android.os.Looper.loop(Looper.java:156) 
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6523) 
                                                                                at java.lang.reflect.Method.invoke(Native Method) 
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942) 
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832) 
02-23 21:46:19.223 29517-29517/org.andresoviedo.dddmodel2 I/Process: Sending signal. PID: 29517 SIG: 9

This is the part of the code responsible of this:

public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {

		Cursor cursor = null;
		final String column = "_data";
		final String[] projection = { column };

		try {
			cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
			if (cursor != null && cursor.moveToFirst()) {
				final int index = cursor.getColumnIndexOrThrow(column);
				return cursor.getString(index);
			}
		} finally {
			if (cursor != null)
				cursor.close();
		}
		return null;
	}

Any idea how to solve this?

Thanks

Transparent Background

How can make the ModelSurfaceView background transparent. now it displays all models in a dark background. i have tried using

    setZOrderOnTop(true);
    setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    getHolder().setFormat(PixelFormat.TRANSPARENT);

nothing works.

please guide me to make the ModelSurfaceView background as transparent.

Bug in demo option: App crashes

Expected behavior

After launching the app which am not really used to, I needed a tutorial for it's usage but I luckily found a demo of how to design the model. But unfortunately none of the demos was able to play.

Actual behavior

The app keeps crashing everytime I click on a demo to play for how to use it.

How to reproduce

Open the android 3D model viewer app if already installed or download from Google Play Store if not, after launching it go-to demo and after it loads, click any of the demo you wish to view, immediately the app crashes.

  • Browser: infinix note 4
  • Operating system: android 7

Recording Of The Bug

Here is a video to record the bug.
https://youtu.be/ycGrLlv1Vlg



Posted on <a href="https://utopian.io/utopian-io/@onos/bug-found-in-pla%22%3EUtopian.io - Rewarding Open Source Contributors

Fix draw wireframe performance

The idea is to draw 3 lines for all triangles by using the index buffer. A new model should be created with the current model data but with the new index buffer containing the wireframe lines.

Allow stopping the light rotation

  • The light now has 3 states: rotating-light, static-light, no-light
    • The new state (static-light) can be activated with the same toggle light button
  • The wireframe was using a static drawer. Now it uses the current object drawer
  • More changes:
    • Toggle lights menu has been moved to 2nd place after the wireframe
    • Menu hide timeout set from 3 to 5 secs

touch control

6/org.andresoviedo.dddmodel2 E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
01-31 15:03:35.097 11356-11356/org.andresoviedo.dddmodel2 E/MessageQueue-JNI: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at org.andresoviedo.app.model3D.collision.CollisionDetection.getBoxIntersection(CollisionDetection.java:52)
at org.andresoviedo.app.model3D.collision.CollisionDetection.getBoxIntersection(CollisionDetection.java:37)
at org.andresoviedo.app.model3D.services.SceneLoader.processTouch(SceneLoader.java:323)
at org.andresoviedo.app.model3D.controller.TouchController.onTouchEvent(TouchController.java:189)
at org.andresoviedo.app.model3D.view.ModelSurfaceView.onTouchEvent(ModelSurfaceView.java:42)
at android.view.View.dispatchTouchEvent(View.java:9993)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2831)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1863)
at android.app.Activity.dispatchTouchEvent(Activity.java:3046)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2792)
at android.view.View.dispatchPointerEvent(View.java:10228)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5344)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5180)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4620)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4673)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4639)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4781)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4647)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4838)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4620)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4673)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4639)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4647)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4620)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7306)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7184)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7145)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7416)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
01-31 15:03:35.097 11356-11356/org.andresoviedo.dddmodel2 E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.andresoviedo.dddmodel2, PID: 11356
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at org.andresoviedo.app.model3D.collision.CollisionDetection.getBoxIntersection(CollisionDetection.java:52)
at org.andresoviedo.app.model3D.collision.CollisionDetection.getBoxIntersection(CollisionDetection.java:37)
at org.andresoviedo.app.model3D.services.SceneLoader.processTouch(SceneLoader.java:323)
at org.andresoviedo.app.model3D.controller.TouchController.onTouchEvent(TouchController.java:189)
at org.andresoviedo.app.model3D.view.ModelSurfaceView.onTouchEvent(ModelSurfaceView.java:42)
at android.view.View.dispatchTouchEvent(View.java:9993)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2831)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1863)
at android.app.Activity.dispatchTouchEvent(Activity.java:3046)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2792)
at android.view.View.dispatchPointerEvent(View.java:10228)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5344)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5180)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4620)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4673)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4639)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4781)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4647)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4838)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4620)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4673)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4639)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4647)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4620)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7306)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7184)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7145)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7416)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Add support for multiple bitmaps

Thanks a lot for this software at first. Now I meet with one problem.I want to add different texture mapping bitmap in one cube. I search all codes many times. I choose Object3DBuilder .java.
Now it only support one bitmap. Can you help us realize add different texture mapping bitmap in one cube. (
bitmap[] bm.
bmp[0] = BitmapFactory.decodeResource(context.getResources(), R.drawable.aa);
bmp[1] = BitmapFactory.decodeResource(context.getResources(), R.drawable.bb);
bmp[2] = BitmapFactory.decodeResource(context.getResources(), R.drawable.cc);
bmp[3] = BitmapFactory.decodeResource(context.getResources(), R.drawable.dd);
bmp[4] = BitmapFactory.decodeResource(context.getResources(), R.drawable.ee);
bmp[5] = BitmapFactory.decodeResource(context.getResources(), R.drawable.ff)
not byte[] textureData and I want to change it to bimtap[]
)

file : Object3DBuilder.java
org.andresoviedo.app.model3D.model;public final class Object3DBuilder
public static Object3DData buildCubeV3(byte[] textureData) {
return new Object3DData(
createNativeByteBuffer(cubePositionData.length * 4).asFloatBuffer().put(cubePositionData),
createNativeByteBuffer(cubeTextureCoordinateData.length * 4).asFloatBuffer()
.put(cubeTextureCoordinateData).asReadOnlyBuffer(),
textureData).setDrawMode(GLES20.GL_TRIANGLES).setId("cubeV3").centerAndScale(1.0f);
}

Model is displayed with yellow over it's texture.

Hey,

I've been using some different models through the application.
This doesn't happen with all of the models, but with some of them, they appear to have a sort of yellow filter over their texture. I'm not sure why this happens or where to go about trying to fix it. I've been messing around the Object3DBuilder or sometimes mess with the mtl file but to no avail.
my logger will be something like :

...myapp I/Object3DBuilder: Processing face materials...
...myapp I/Object3DBuilder: Using single color.
...myapp I/Object3DBuilder: Loading that texture 'Octopus_Sushi.jpg'...
...myapp I/Object3DBuilder: Loading fis'java.io.FileInputStream@a7d552d'...
...myapp I/Object3DBuilder: Length of jpg bytes:'1273459'...[B@51f2a62
...myapp I/Object3DBuilder: Allocating/populating texture buffer...
...myapp I/Object3DBuilder: Populating texture array buffer...
...myapp I/Object3DBuilder: Populating texture array buffer...
...myapp I/Object3DBuilder: Texture is wrong. Applying global texture
...myapp I/GLUtil: Handler: 1

This issue only happens with a few of the models i'm tryng to display.
This is a link that provides a download to a zip file containing the models:
https://ufile.io/rx8fr

If anyone could help out, that'd be great !

Works: FishFilet
Yellow filter: TheRyanBurger
Yellow filter: octopus_sushi

Multiple texture images from MTL file not reflecting in 3D Modal

First of all I want to thank you for your wonderful work. This project help me to learn a lots of thing related Wavefront/STL Parsing and OpenGL rendering in Android application.

By using the source code , I can able to parse Wavefront and STL files successfully and able to create the 3D model.

Here I have a question under Rendering Texture on 3D model part, I tried to render the texture on top of 3D model, it failed due to multiple texture images present in the MTL file.

MTL file,

  • Contain one texture image, rendering texture is success.
  • Contain more than one texture image, rendering went failed. First texture image is rendered on top of 3D Modal object.

Please give some input to solve this issue.

Fix Camera rotation and Zoom

  • Fix camera to use only 1 vector to translate POV
  • Fix camera z movement (zoom) so the camera stays between the Scene bounds
  • Fix camera z movement (zoom) so it's not zooming beyond the Scene center (0,0,0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.