OpenGL and Qt: part III Ray casting

An update. I found that the camera doesnt really act the way I wanted it to; it seems to just rotate objects around the y-axis regardless of where i pan and ive been stuck for a week now trying to implement a camera that works the way I want it to.


I have connected up the viewer to the raytracer so you can just move the camera into place and press a render button to render the scene with the current view, it is on a separate thread so it doesnt block the GUI.

Also, I have implemented ray casting which is usually used for selecting things. It works pretty much like when shooting rays out from the camera in ray tracing. Its useful for debugging the bounding volume hierarchy data structure you can press keys to change the depth at which to draw the bounding boxes and to check that the intersection routines actually work.

You can see below the red dot representing the intersection point and the green line the ray. The blue boxes are the bounding volumes for the mesh.


Ray casting





OpenGL and Qt: part II Cameras and Transformations

I have continued to develop my previous application here by making a camera class. This makes it easy to have multiple cameras, switch between them in the scene and move them about in world space.

The link below goes into details about the transformations used in computer graphics, specifically opengl, and uses the old fixed function pipeline depreciated opengl, but it is still very useful:

Another awesome resource for learning linear algebra is a website called immersive math.


Cameras and Transformations

Revision: Bézier curves

Revision for computer graphics course. I created a simple program to play around with bézier curves. I am currently just evaluating the Bernstein basis polynomials directly for the quadratic and cubic bézier curves to determine a point.

I will probably revisit this next week for review and implement De Casteljau’s algorithm since it seems like that is what is being shown on the lecture slides.

The program is written with OpenGL and Qt. The current features include inserting, deleting, selecting, and moving control/anchor points.


Left Quadratic and Right Cubic


OpenGL and Qt

I have been learning Qt ( a cross platform gui library and OpenGL ( a graphics API the past two weeks. Its kind of an aside as I am still thinking/procrastinating on how to proceed with the ray tracer and i need to spend time revising for exams.

I am trying to implement a simple viewer application to manipulate the scene, currently, I have four views; the front, left, top, which are orthographic views and a perspective view at the bottom right. Each view has the ability to rotate, pan and zoom in.

Some technicalities, each viewport is a QOpenGLWidget ( each sharing a main context, which allows the shader programs, textures, and vertex buffer objects to be shared, one problem however is that the vertex array objects are not shared, as seen below the teapot’s colours have made it into the grid since there is only one VAO used at the moment so the attribute is still active and bound to its teapot’s colour VBO. Another problem is that each context of each view is intialized only when it is needed to be drawn and therefore you cannot create/bind any VBOs outside of the class.

The next step is to implement a scene graph to organize the objects within the scene to apply transformations, and render more easily. I still need a way to use VAOs across the different contexts and then I can think about abstracting things into classes since I am just experimenting and learning things are just written so that they work.

Many Viewports