Rain, Rain and More Rain...

The last week has been pretty surreal. I was in work on Monday getting a bit of work done when we had some really heavy rain. The commute home was a nightmare and I was glad I left early. It seems that I had a lucky escape though as in Sheffield (where I live and work) we have had some of the worst floods I have ever known. Rivers have burst their banks and literally washed cars down the road.

Unfortunately a few people have also died in the midst of the floods. A nearby dam has also developed cracks in its walls which led to sections of the M1 being closed along with nearby homes getting evacuated. Rolling power cuts and the threat of more rain this weekend make life in Sheffield pretty difficult. We have been fortunate to have escaped most of the problems where we live and have not had any flooding or power cuts. A recent article on events shows some of the problems faced by our city.

Avogadro Videos: Transparent Molecules, Rotation and Geometry Optimisation

I already wrote this post once, but the bit bucket ate it when my browser crashed... Carsten and I were talking on IRC yesterday about the last post I made and progress with my project in general. He asked if I would try making a few videos demonstrating new features as his system has trouble capturing videos without dropping frames. I am new to the whole video capture scene and have always found screen shots to be enough in the past. He told me about xvidcap and so I emerged it. What else do people use for this kind of thing?

After some trial and error (I found xdamage prevented the OpenGL window from being recorded properly) I recorded a video. The above video is my first successful one, as uploaded to YouTube by Carsten. I don't know about you but I find flash very unreliable on my 64 bit system in my 64 bit browser as there is still no decent 64 bit flash plugin. You can get the original video here (~17MB) and my second attempt here (~14MB) which I think is a little better personally.

I made a new video this morning that is shown above and also available for download here (~5MB) showing some recent changes in Avogadro implemented by Donald - geometry optimisation now takes place in a separate thread. This was on my list of features to implement and I had done some reading and initial code (nothing that worked right). It is a great feature to have implemented as geometry optimisation can take quite some time. My research, reading and coding haven't been in vain either - I learned a lot about how Avogadro, OpenBabel and Qt interact as well as learning quite a bit about threads (never used them before). There are other things that will benefit from threading too, so I hope I will be able to do some coding with threads soon :-)

I would love to hear what you think about the videos, if they are useful demonstrations of new features in Avogadro. Most of this stuff is actually in libavogadro which is used by Avogadro. Kalzium uses a snapshot of libavogadro right now, in KDE 4.1 it should be possible to switch to the system copy of libavogadro. It is a great demonstration of how easy it is to add molecular visualisation capabilities to a program by using libavogadro. I am still learning lots of new stuff and thankfully the development team don't mind me asking questions, even when some of the questions are really stupid... I am still having a great time working on the code pushing the boundaries of what we can accomplish and hope that you find these posts informative.

Avogadro Transparent Rendering and Engine Updates

When I initially implemented the transparent VdW engine for Avogadro I had the problem that any rendering of transparent objects must be done after the internal opaque objects have been rendered. So at the time I just implemented a ball and stick engine inside the VdW engine that was basically a copy of the ball and stick engine. I also mentioned that if we could set render order that would allow me to use any other engine if there was a way to ensure this engine was called after the others. The need for this had already been mentioned with respect to label rendering too.

Avogadro rendering of a functionalised C60 molecule using a transparent VdW engine with a stick backbone

Yesterday we discussed the engine rendering order needs on IRC and hashed out some ideas. Then my IRC connection went crazy (I think it was Freenode or the server I was connected to at least). Donald made some commits late last night (my time at least) and implemented flags for the engines to declare their roles and their transparency depth to order within particular roles. We now have a renderOpaque and renderTransparent function in each engine which should improve transparency rendering when combined with the rendering order enhancements.

The above image shows a rendered functionalised C60 molecule (one I worked with during my PhD research) using the transparent VdW engine with the stick engine rendering its backbone. It has allowed me to simplify the VdW engine whilst making it far more powerful as it can now use the ball and sick, stick or wire frame engine to render the structure inside the VdW surface. As we add more engines they can also be used with no further modification to this engine.

I am really pleased with the result and this particular visualisation shows the structure of the molecule very well. Lots more to do but I thought it would be nice to show how this display engine had progressed. Back to coding now - next challenge is getting to grips with threads!

GSoC Progress: Avogadro 3D Molecular Visualisation

I have had a really productive week. I have been doing lots of reading to learn the finer points of the Qt plug in system, OpenGL projections and transformations. I have also found and hunted down a few bugs and added some really cool visualisations to Avogadro.

Avogadro transparent VdW view

I am especially pleased with the transparent Van der Waals view with the molecular backbone. I am not sure if I am rendering it in an optimal way right now as it requires three passes - one to render the molecular backbone, one to render totally transparent VdW spheres and a final pass to render the VdW spheres with the specified transparency. I hope you agree that the result is certainly very pleasing visually and I think it gives a good sense of both the molecular structure and how much space it fills.

I have done lots of other things this week. Bond labels have been added as an option for the label engine along with improvements to the rendering engines to actually return a valid bond radius. I added a setAlpha function to the Color class so that the alpha value of a colour can be altered without affecting its colour.

There is a new axes engine that renders the x, y and z axes to the screen. It works reasonably well but still needs several improvements to be implemented. Our text drawing routines don't draw into the current OpenGL projection matrix and so I couldn't label the axes. The vectors I get for the x, y and z axes are also not of uniform length as I wanted - if you have a rectangular view of the molecule the axes are rendered at different lengths. It is certainly helpful having the axes available even in their current form but I need to figure out a few more features before I will be happy with them.

I added a new auto rotation tool this week too. It allows you to rotate the molecule about the views x, y and/or z axes at variable speeds in order to get a complete view of the molecule. I have already tweaked the configuration quite a bit. I did want to make a derived QWidget to have a little more control over the configuration widget, but every time I linked to my derived QWidget class the tool failed to load - still not figured out why and it has been insanely frustrating. If you know why I would love to know! Probably a gap in my Qt skill set - I have a book on the way that promises to teach me the finer points of Qt 4 and am very good friends with the docs bundled with Qt ;-)

I also added a couple of higher detail levels and have used the highest in the screenshot above. It produces really nice spheres but there is quite a performance hit and I don't think it would perform well with lots of atoms or on unaccelerated graphics cards. Hopefully ATI/AMD will be releasing a nice open source accelerated driver soon. Next week I will be focusing on threads and have already done quite a bit of reading on the subject. Wish me luck.