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

PerspectiveCamera usage. #6

Closed
vkornii opened this issue Mar 13, 2014 · 1 comment
Closed

PerspectiveCamera usage. #6

vkornii opened this issue Mar 13, 2014 · 1 comment

Comments

@vkornii
Copy link

vkornii commented Mar 13, 2014

How can I draw trails with perspective camera?
I tried to add next lines to SwipeTriStrip draw() method :

       Vector2 point = tristrip.get(i);
            Vector2 tc = texcoord.get(i);
           point3.set(point.x, point.y, 0f);
            cam.unproject(point3);
            tc3.set(tc, 0f);
            cam.unproject(tc3);
            gl20.color(color.r, color.g, color.b, color.a);
            gl20.texCoord(tc3.x, tc3.z);
            gl20.vertex(point3.x, point3.y, point3.z);

But it not working.
Thanks in advance

@mattdesl
Copy link
Owner

Where are you getting the PerapectiveCamera class from? Usually you use camera.project() to go from world space to screen space.

That function is more useful for software rendering and hit testing, though.

If you are using GL, then you would pass the "combined" camera matrix to the vertex shader as a uniform, and do something like:

gl_Position = mvp_matrix * vec4(a_position.xyz, 1.0);

If you're using LibGDX, you should just pass the combined matrix to it the ImmediateModeRenderer. Then, you can pass 3D points to vertex() and it will transform them in the shader for you.

Sent from my iPhone

On Mar 13, 2014, at 6:06 AM, vkornienko [email protected] wrote:

How can I draw trails with perspective camera?
I tried to add next lines to SwipeTriStrip draw() method :

   Vector2 point = tristrip.get(i);
        Vector2 tc = texcoord.get(i);
       point3.set(point.x, point.y, 0f);
        cam.unproject(point3);
        tc3.set(tc, 0f);
        cam.unproject(tc3);
        gl20.color(color.r, color.g, color.b, color.a);
        gl20.texCoord(tc3.x, tc3.z);
        gl20.vertex(point3.x, point3.y, point3.z);

But it not working.
Thanks in advance


Reply to this email directly

or view it on GitHub.

@vkornii vkornii closed this as completed Aug 18, 2021
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