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

render plane on top of rectangle in rajawali #1608

Closed
shripadashtekar opened this issue Mar 13, 2016 · 10 comments
Closed

render plane on top of rectangle in rajawali #1608

shripadashtekar opened this issue Mar 13, 2016 · 10 comments
Labels

Comments

@shripadashtekar
Copy link

I have an image in android with a rectangle on it. I have found the coordinates of that rectangle which is in the following format.

rect(left,top,right,bottom)
I have created a plane in rajawali and I want to render/draw the plane exactly on top of the original rectangle.

How do I render the plane, because rect method gives coordinates in different coordinate system and rajawali uses different coordinate system to render objects.

How do I map the rect coordinates to rajawali coordinates?

@jwoolston
Copy link
Member

This sounds like you want to render over a section of an android native view. Is this correct?

@shripadashtekar
Copy link
Author

Yes . I want to render it on android surface view.
I am not getting how to map those rect coordinates which are in android screen coordinate system to rajawali coordinate system. I have searched a lot but no success.

@jwoolston
Copy link
Member

Well you have a few options. You could either use android's layout system to confine the surface view to the area you wish to render, or you can do an inverse projection to map the screen coordinates to GL coordinates. Similar to how Object3D#setScreenCoordinates() works. Note that that method works on the object's centroid location only and not the bounds like you are discussing, so you will need to do some work to do it for the 4 corners you are interest in and determine how to use that to adjust your render objects.

@shripadashtekar
Copy link
Author

Thanks for your reply. But I am using Rajawali for the first time.
Can you give me some link where i can learn how to do inverse projection in Rajawali?

@jwoolston
Copy link
Member

We do not have a tutorial or example of this. Google "GLU unproject" or look at how the method I pointed out works. You don't need to understand how Rajawali or the GLU unproject methods work to be able to use them.

@shripadashtekar
Copy link
Author

I tried to use setScreenCoordinates() method like this

front.setScreenCoordinates(0.205f,0.045f,720,1280,0f); // front is a plane which i want to render on top of rectangle

but it gives me following errors

java.lang.IllegalArgumentException: array == null
at android.opengl.Matrix.multiplyMM(Native Method)
at android.opengl.GLU.gluUnProject(GLU.java:221)

Do I need to find those "model view projection" matrices by myself or are those calculated internally?

@jwoolston
Copy link
Member

What version of rajawali are you using? Looking at the current
code, there is no possible way for a null array to be passed in.

@shripadashtekar
Copy link
Author

I am using version 0.9.
Do i need to perform any more operations before using setScreenCoordinates() method ?
I am stuck at this point. This is the last thing which I need to do. Please help me at this point.

@shripadashtekar
Copy link
Author

Here is the link to the code.
https://github.com/Sher-lock/IndiAR/blob/master/app/src/main/java/rocks/rishi/iar/Renderer.java

please tell me how to integrate setScreenCoordinates() method in the above code.

@jwoolston
Copy link
Member

Version 0.9 has been unsupported for some time now. To be honest I can't even remember how some of it worked. The Google Plus community will have users who are more familiar with the 0.9 version than I am at this point. Since this issue is related to an unsupported version, I am closing the ticket.

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

No branches or pull requests

2 participants