Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions f3d/src/main/java/app/f3d/F3D/android/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import java.util.Objects;

import app.f3d.F3D.android.Utils.FileInteractionContract;
import app.f3d.F3D.android.Utils.FileType;
import app.f3d.F3D.android.Utils.FileUtils;

public class MainActivity extends AppCompatActivity {

Expand Down Expand Up @@ -49,8 +47,7 @@ protected void onCreate(Bundle savedInstanceState) {
}

private void handleSelectedFile(Uri uri) {
String filePath = FileUtils.createTempFileFromUri(this,uri);
mView.updateFilePath(filePath);
mView.updateActiveUri(uri);
}

private void handleSelectedFileAppNotOpen(){
Expand Down
22 changes: 17 additions & 5 deletions f3d/src/main/java/app/f3d/F3D/android/MainView.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package app.f3d.F3D.android;

import android.content.Context;
import android.net.Uri;
import android.opengl.GLSurfaceView;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;

import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;

import javax.microedition.khronos.egl.EGLConfig;
Expand All @@ -19,7 +22,7 @@ public class MainView extends GLSurfaceView {
final private ScaleGestureDetector mScaleDetector;
final private PanGestureDetector mPanDetector;
final private RotateGestureDetector mRotateDetector;
private String internalCachePath = "";
private Uri mActiveUri = Uri.EMPTY;

public MainView(Context context) {
super(context);
Expand Down Expand Up @@ -66,14 +69,23 @@ public void onSurfaceCreated(GL10 gl, EGLConfig config) {
MainView.this.mEngine.getOptions().toggle("ui.loader_progress");
// MainView.this.mEngine.getOptions().toggle("model.volume.enable");

if(!Objects.equals(internalCachePath, "")) {
MainView.this.mEngine.getScene().add(internalCachePath);
if(!Objects.equals(mActiveUri, Uri.EMPTY)) {
try (InputStream inputStream = MainView.this.getContext().getContentResolver().openInputStream(mActiveUri)) {
if (inputStream != null) {
byte[] fileBytes = new byte[inputStream.available()];
inputStream.read(fileBytes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i suppose this copy is unavoidable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the best way I could find.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hat some point I considered adding a vtkIStreamResourceStream, would that help ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe? Hard to tell at the moment but we'll most likely need a f3d::scene::add(std::istream& stream) api

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well of course, thats the easy part though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So yeah, I think that'd help here too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets open an issue about it


MainView.this.mEngine.getScene().addBuffer(fileBytes, fileBytes.length);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public void updateFilePath(String newFilePath) {
public void updateActiveUri(Uri uri) {
// Use the new file path as needed in MainView
internalCachePath = newFilePath;
mActiveUri = uri;
}

private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
Expand Down
91 changes: 0 additions & 91 deletions f3d/src/main/java/app/f3d/F3D/android/Utils/FileUtils.java

This file was deleted.