Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to get part name of 3D Object? #7

Closed
braver-tool opened this issue Apr 4, 2019 · 2 comments
Closed

Is it possible to get part name of 3D Object? #7

braver-tool opened this issue Apr 4, 2019 · 2 comments

Comments

@braver-tool
Copy link

Ques 1:
I have to added Human 3D object file using your excellent Renderer code,and the 3D object have multiple body parts(Head,Leg,etc..).So,Using OnTouch event can i have selected 3D model part name??

Ques 2:
Is it possible to load more than one Obj file at same time in a SurfaceView??

Thanks in Advance

@dbrant
Copy link
Owner

dbrant commented Apr 4, 2019

Using OnTouch event can i have selected 3D model part name?

You would have to implement a "picking" algorithm to transform your touch coordinates into the world space of the model and detect which portion of the model is picked.

Is it possible to load more than one Obj file at same time in a SurfaceView?

Sure, right now the model is stored as a global field in ModelViewerApplication.java. You can change this to be a List of models, and then render all of them in ModelRenderer.onDrawFrame().

@braver-tool
Copy link
Author

I have to try with your tips for load more than one object file at same time in a surfaceview.But its not working for me.
Please help me!,If you have sample source pls share the link.
Please find below my Source

Step 1: Application class
   @Nullable
private List<Model> currentModel;

public static ModelViewerApplication getInstance() {
    return INSTANCE;
}

@Nullable
public List<Model> getCurrentModel() {
    return currentModel;
}

public void setCurrentModel(@Nullable List<Model> model) {
    currentModel = model;
}

Step 2: MainActivity
    List<Model> modelList = new ArrayList<>();
    try {
        InputStream stream = getApplicationContext().getAssets().open(SAMPLE_MODELS[0]);
        Model model = new ObjModel(stream);
        stream.close();
        modelList.add(model);

        InputStream stream1 = getApplicationContext().getAssets().open(SAMPLE_MODELS[1]);
        Model model1 = new ObjModel(stream1);
        stream1.close();
        modelList.add(model1);

        setCurrentModel(modelList);
    } catch (IOException e) {
        e.printStackTrace();
    }

Step 3: Rederer class

@OverRide
public void onDrawFrame(GL10 unused) {
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    floor.draw(viewMatrix, projectionMatrix, light);
    if (model != null) {
        for (int i = 0; i < model.size(); i++) {
            model.get(i).draw(viewMatrix, projectionMatrix, light);
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants