How to preserve objects size when moving camera

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to preserve objects size when moving camera

Andrey Ivanov
Hello!

I am trying to draw a lot of objects with the same shape for CAD system. Let it be stars or circles for example.
The number of such circles can be about 1000-10000.
I would like to *preserve their size* when moving the camera, scaling frustrum and changing distance to objects.

For now I found two approaches:

1. Use vtkDistanceToCamera
An example from https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/DistanceToCamera/ is great
for low number of objects, however when their numer grows, the interface starts to freeze due to
rescaling of shapes on each interaction with camera.

2. Use points (squares with width equal to 4 pixels).
It works fast and points size is fixed, but I would like to have more complex shapes, like triangles and circles.


Is there another approach to solve this problem? It seems that with pure OpenGL this can be implemented rather efficiently,
so I am looking for a way to do it in VTK.

Best regards,
Andrey Ivanov

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: How to preserve objects size when moving camera

David E DeMarle via vtkusers
Will turning off perspective do what you want?
void vtkCamera::SetParallelProjection(vtkTypeBool flag)

David E DeMarle
Kitware, Inc.
Principal Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Fri, Dec 14, 2018 at 10:55 AM Andrey Ivanov <[hidden email]> wrote:
Hello!

I am trying to draw a lot of objects with the same shape for CAD system. Let it be stars or circles for example.
The number of such circles can be about 1000-10000.
I would like to *preserve their size* when moving the camera, scaling frustrum and changing distance to objects.

For now I found two approaches:

1. Use vtkDistanceToCamera
An example from https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/DistanceToCamera/ is great
for low number of objects, however when their numer grows, the interface starts to freeze due to
rescaling of shapes on each interaction with camera.

2. Use points (squares with width equal to 4 pixels).
It works fast and points size is fixed, but I would like to have more complex shapes, like triangles and circles.


Is there another approach to solve this problem? It seems that with pure OpenGL this can be implemented rather efficiently,
so I am looking for a way to do it in VTK.

Best regards,
Andrey Ivanov
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: How to preserve objects size when moving camera

Andrey Ivanov
I forgot to mention that I am already working with orthogonal projection. The problem is not with preserving shapes and avoiding perspective deformations. I would like to fix screen size of objects, so when I increase height and width of camera frustum they will occupy the same number of pixels.

Best regards,
Andrey Ivanov


On Fri, 14 Dec 2018 at 19:41, David E DeMarle <[hidden email]> wrote:
Will turning off perspective do what you want?
void vtkCamera::SetParallelProjection(vtkTypeBool flag)

David E DeMarle
Kitware, Inc.
Principal Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Fri, Dec 14, 2018 at 10:55 AM Andrey Ivanov <[hidden email]> wrote:
Hello!

I am trying to draw a lot of objects with the same shape for CAD system. Let it be stars or circles for example.
The number of such circles can be about 1000-10000.
I would like to *preserve their size* when moving the camera, scaling frustrum and changing distance to objects.

For now I found two approaches:

1. Use vtkDistanceToCamera
An example from https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/DistanceToCamera/ is great
for low number of objects, however when their numer grows, the interface starts to freeze due to
rescaling of shapes on each interaction with camera.

2. Use points (squares with width equal to 4 pixels).
It works fast and points size is fixed, but I would like to have more complex shapes, like triangles and circles.


Is there another approach to solve this problem? It seems that with pure OpenGL this can be implemented rather efficiently,
so I am looking for a way to do it in VTK.

Best regards,
Andrey Ivanov
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: How to preserve objects size when moving camera

David E DeMarle via vtkusers
You could probably do what you want by drawing points using a custom shader to create different shapes. 
Something like this: https://stackoverflow.com/questions/27098315/render-large-circular-points-in-modern-opengl
I'm not sure how to do this in VTK, however.

On Fri, Dec 14, 2018 at 12:08 PM Andrey Ivanov <[hidden email]> wrote:
I forgot to mention that I am already working with orthogonal projection. The problem is not with preserving shapes and avoiding perspective deformations. I would like to fix screen size of objects, so when I increase height and width of camera frustum they will occupy the same number of pixels.

Best regards,
Andrey Ivanov


On Fri, 14 Dec 2018 at 19:41, David E DeMarle <[hidden email]> wrote:
Will turning off perspective do what you want?
void vtkCamera::SetParallelProjection(vtkTypeBool flag)

David E DeMarle
Kitware, Inc.
Principal Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Fri, Dec 14, 2018 at 10:55 AM Andrey Ivanov <[hidden email]> wrote:
Hello!

I am trying to draw a lot of objects with the same shape for CAD system. Let it be stars or circles for example.
The number of such circles can be about 1000-10000.
I would like to *preserve their size* when moving the camera, scaling frustrum and changing distance to objects.

For now I found two approaches:

1. Use vtkDistanceToCamera
An example from https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/DistanceToCamera/ is great
for low number of objects, however when their numer grows, the interface starts to freeze due to
rescaling of shapes on each interaction with camera.

2. Use points (squares with width equal to 4 pixels).
It works fast and points size is fixed, but I would like to have more complex shapes, like triangles and circles.


Is there another approach to solve this problem? It seems that with pure OpenGL this can be implemented rather efficiently,
so I am looking for a way to do it in VTK.

Best regards,
Andrey Ivanov
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: How to preserve objects size when moving camera

Patricio Sandana
In reply to this post by Andrey Ivanov
Hi Andrey,

What I would do in your case, is to have two renderers and two cameras. One renderer with a fixed camera with all your circles and polygons you want to preserve in your screen and another to deal with the 3D world objects. You can attach more than one renderer to the Render Window.

Cheers,
Pato

Message: 1
Date: Fri, 14 Dec 2018 20:07:33 +0300
From: Andrey Ivanov <[hidden email]>
To: David E DeMarle <[hidden email]>
Cc: [hidden email]
Subject: Re: [vtkusers] How to preserve objects size when moving
        camera
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset="utf-8"

I forgot to mention that I am already working with orthogonal projection.
The problem is not with preserving shapes and avoiding perspective deformations. I would like to fix screen size of objects, so when I increase height and width of camera frustum they will occupy the same number of pixels.

Best regards,
Andrey Ivanov

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers