I'm trying to get up to speed on using Pangolin. I'm starting with the first example:
https://github.com/stevenlovegrove/Pangolin/blob/master/examples/HelloPangolin/main.cpp
which I'll reproduce here for convenience:
#include <pangolin/pangolin.h>
int main( int /*argc*/, char** /*argv*/ )
{
pangolin::CreateWindowAndBind("Main",640,480);
glEnable(GL_DEPTH_TEST);
// Define Projection and initial ModelView matrix
pangolin::OpenGlRenderState s_cam(
pangolin::ProjectionMatrix(640,480,420,420,320,240,0.2,100),
pangolin::ModelViewLookAt(-2,2,-2, 0,0,0, pangolin::AxisY)
);
// Create Interactive View in window
pangolin::Handler3D handler(s_cam);
pangolin::View& d_cam = pangolin::CreateDisplay()
.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0f/480.0f)
.SetHandler(&handler);
while( !pangolin::ShouldQuit() )
{
// Clear screen and activate view to render into
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
d_cam.Activate(s_cam);
// Render OpenGL Cube
pangolin::glDrawColouredCube();
// Swap frames and Process Events
pangolin::FinishFrame();
}
return 0;
}
Having a background in related topics I can understand most of this code is doing, however I'm unclear on what s_cam and d_cam are, can anybody who is familiar with Pangolin explain this?
Before somebody says "read the documentation", I did build the Pangolin documentation but that basically just lists the functions and didn't help much.
Also I should mention this is a difficult thing to Google on due to Pangolin being the same name as the animal, and also there is a company that makes laser products with the same name.
You may look at s_cam as the State of the camera. It defines the relationship between the camera and world. It's defined by the Projection Matrix which is defined as
and ModelViewLookAt which is defined as
In Summary, the ModelViewLookAt takes in 3 types of parameters: Where the Camera is? (3 params), Where the Object is? (3 params) and Where is the camera Looking? (3 Params).
On the other hand, d_cam is the through which you are going to see. Basically, Display configuration by Bounds, Aspect Ratios, and Handler.
Bounds can be seen as Upper and Lower bounds in 2 Axis (Bottom-Up, Left-Right). Bounds also include aspect ratio.
Handler helps us create an Interactive View in Windows.
SetBounds definition
SetHandler Definition
I hope this helps you in some way.