How to change the camera's offset in C++

Have a question about using Celestia? Check here first for FAQs and helpful advice.
Forum rules
Please help to make this forum more useful by checking the FAQs before posting! Keep it clean, keep it civil, keep it truthful, stay on topic, be responsible, share your knowledge.
Topic author
su27
Posts: 10
Joined: 26.08.2010
With us: 14 years 3 months

How to change the camera's offset in C++

Post #1by su27 » 24.09.2010, 11:44

Imagine now the resolution of the screen is 1024x768, and the display content is from (0,0) to (1024,768)

I want to display the content of (-1024,0) to (0,768)

thus I can merge 3 screens together horizontally (simply rotate the camera horizontally is not right)

How to do this? thx :mrgreen:
or where can I modify it in the source code of Celestia.

By the way, I've just put my LAN time synchonize code here, :mrgreen:
http://www.celestiaproject.net/forum/viewtopic.php?f=4&t=16136
Last edited by su27 on 25.09.2010, 15:35, edited 1 time in total.

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Re: How to change the camera's offset in C++

Post #2by selden » 24.09.2010, 19:00

Unfortunately, Celestia is currently limited to exporting images which are the size of the display device.

I'm not at all certain where that code is located. I agree that it would be great if Celestia could render to a buffer that's much larger than the screen size. My understanding is that larger image buffers are supported by OpenGL.
Selden

Topic author
su27
Posts: 10
Joined: 26.08.2010
With us: 14 years 3 months

Re: How to change the camera's offset in C++

Post #3by su27 » 25.09.2010, 02:19

I've examined it selden

maybe it does not need to be done by render to a large buffer.

It can be done by rotate the camera, and change the "Frustum" parameter.

But it's hard to examine where to change the code. :cry:

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: How to change the camera's offset in C++

Post #4by chris » 27.09.2010, 04:02

Su27,

How large an image do you want to generate? There are two possible approaches, both of which require modifying the Celestia code:

1. Make Celestia render to an offscreen buffer. The size of the buffer can be larger than your monitor, but it's still limited by hardware capabilities and available graphics memory. This is practical for images as large as about 8000x4000 if you have a recently graphics card with 512M of memory. Celestia would have to be modified to draw into the offscreen buffer. This should just be a matter of creating an OpenGL framebuffer object and setting it as the current render target. The Celestia rendering engine wouldn't need to be changed, so it's probably the easiest option.

2. This is what you are proposing: render multiple views with different frustums, save the image files, and merge them together in Photoshop, GIMP, or some other software. The problem is that this requires asymmetric frusta, but Celestia only supports symmetric frusta. Celestia's rendering engine would have to be modified in a few places. The Frustum class would have to be modified, and some of the culling code changed. I don't think the modifications are too drastic, but if you're not familiar with the code, it's not obvious what needs to change. Adding support for asymmetric projections would have additional benefits, as it would enable stereo and multiwall projections.

So... how big do you need the images to be?

--Chris

Topic author
su27
Posts: 10
Joined: 26.08.2010
With us: 14 years 3 months

Re: How to change the camera's offset in C++

Post #5by su27 » 27.09.2010, 07:50

Thank you very much Chris,
I've read your reply and post. My image may not be very large,just 2 times of the screen,such as the resolution of 2560x1024.

My idea is first to use the function
void Frustum::transform(const Mat4f& m)
use a 4x4 matrix to cut the current frustum.

Thus, with certain matrix, the frustum will only be the left part of the original, and it's FOV will only be half of the original one.
But that's all right, when they merge together, it will also be a full screen image.

But it will not be a symmetric frustum, as you have said.
Can it be displayed properly? Or what other files shall I modify.

Thank you very much:D


Return to “Help Central”