Tuesday, April 29, 2008

Why reinvent the wheel again and again?

Reading this post "Get that job at Google" on Stevey blog's made me wonder why we always reinvent the wheel in the software industry.

At one point he says the interviewers usually ask to implement a well known basic algorithm (tree, sorting, ...). Why?

Do they expect that rooting learning existing algorithms makes a good programmer?


Said differently: Do you really ask a Chief how to build pans, knifes or an oven? Wouldn't it be better to test if he is able to select appropriate ingredients or use bad ingredients to make tasty dishes?

As most of us I studied how sorting, hashtable, trees and other statistics methods where implemented. And I quickly realised that only very few mathematical genius would be able to ameliorate them hence I forgot how to code them as soon as possible to leave place for useful stuff.

Such as which of the available implementations (Boost::graph, Poco, std,...) is the best in a cross-platform implementation, which one is thread-safe, which one is fastest, etc.

Anyway very informative post.
I wonder how much time he uses to write those rants :)

PS: If I made interviews one of my question would be to use so-called "advanced" statistical methods to prove a relationship among data then change the chosen method parameters to disprove it!

Cpu usage going to 100% when pc idle


Since months each time I let my pc idle it would go in idle mode. Nothing special here.

However some process was doing something in the background when my pc should have been idle. This didn't bothered me because each time I used my pc again this process would stop. Hence I thought it was a "normal" Windows process doing some small maintenance.

Recently I began to have doubts.

To pinpoint the problem I used the excellent free must-have tool ProcessExplorer. (At least grab it before Macro$ begins to charge for it ;)

After lauching ProcessExplorer I waited until my pc got idle and this mysterious process began (= gone taking a cup of coffee). When I cam back it was running so I looked at ProcessExplorer and saw that it was a SVCHOST.exe running at 80-100% cpu!! Ouch!

That's much badder than I thought but strangely the pc didn't seem to heat so much - hence the fan didn't turn like mad and the reason it didn't realise the problem sooner.

ProcessExplorer told me numerous services are associated with this SVCHOST and my suspicion quickly turned to the "System Restore Service".

Some browsing helped me found this trick which indicate that some infinite loop was happening:

http://cboard.cprogramming.com/showthread.php?t=81209

  • Open a dos shell window. By clicking “Start/Run”, type in “cmd.exe” and hit enter.
  • Stop the Windows Management service: "net stop winmgmt"
  • Delete the Repository folder: "rd /s /q c:\windows\system32\wbem\Repository\"
  • Restart the Windows Management service: "net start winmgmt"
  • Recompile all the "Managed Object Format" files (*.mof,*.mfl):
  • a - "cd /d c:\windows\system32\wbem\"
  • b - "for %i in (*.mof,*.mfl) do Mofcomp.exe %i"
  • Verify the folder "c:\windows\system32\wbem\Repository\" has been recreated. If not, restore your system and try again or look for another solution. :-)

This trick worked for me.
I should have done this a long time ago.


I didn't need to try this other trick: "Problem with High CPU Usage with SVCHost.EXE : cpu, usage, high".

If none work for you you will probably need to use ProcessExplorer and stop one-by-one the programs linked to the SVCHOST.exe to find the culprit and decide either to leave it stopped or correct it by reinstalling it.

Also don't forget to update you anti-virus, spyware etc as it could be a corrupt service.

Good luck

Tuesday, April 8, 2008

Open source 3D printer !

Rahh... this is such a cool project I can't resist making some publicity for it.

RepRap is short for Replicating Rapid-prototyper. It is the practical self-copying 3D printer shown on the right - a self-replicating machine.

I hope I find time to build it with my children :D

Friday, March 28, 2008

A Legal Issues Primer for Open Source and Free Software Projects

For those of us who are not lawyer here are two nice primer useful for open source projects:

In the last don't forget the point 7 about "Contributor License Agreement".

Saturday, March 1, 2008

My first mesh... and a comment from my son

Half a day to create my first mesh it should be a wagon... and I have no idea if this is a good performance or not :D

So that I can remember how I did it, here is a short description of the steps needed to create this image with Ogre, Blender and visualise the result in OGEd:

  1. Launch Blender and try to use it.
  2. Search online Blender tutorial to understand the most basic commands: Blender User Interface Tutorial, Modelling A Cube, Selecting Meshes and Using Textures.
  3. Struggling like hell to select faces, rescaling, subdividing to create more faces, destroy some faces to create doors and windows, ...
  4. Repeating step 3 several times.
  5. Reread 'Using Textures' to understand how to apply textures.
  6. Save and repeat steps 3-5 until you get this wagon. Forget about making a complex multiple windows wagons.
  7. Using the steps on "Blender to Ogre" to determine how to export the mesh:
    1. Copy the Pyhton script from ogrenew/tools/BlenderExport to the blender folder
    2. Read the documentation in BlenderExport/ogrehelp/ogremeshesexporter.html
    3. Realise that Blender must have a version newer than 2.44 (mine is 2.43)
    4. Download Blender, reinstall it, reload the mesh.
    5. Realise that I didn't compile OgreXmlConverter (/ogrenew/tools/XMLConverter)
    6. Install OgreXmlConverter and set up the mesh exporter correctly.
    7. I said correctly.
    8. .... no mesh appear in the exporter.... lose time to understand that you need to select the object and click Update if you want the mesh to be exported.
  8. (Repeat from step 5 because there was no textures on some faces...)
  9. At last the export works and here are:
    1. MyMesh.mesh.xml and
    2. MyMesh.material
  10. Now you must convert it to a .mesh so that Ogre can understand it. So you search the doc to find that you need XMLConverter again.
  11. In a console you type "OgreXmlConverter MyMesh.mesh.xml" and you get MyMesh.xml
  12. You load the mesh, material and texture in a mesh viewer (OGEd for example).
  13. .... and you see that the mesh is turned 90 degree on its x axis.... Bags!
  14. You find that the ogre addons MeshMagick can rotate a mesh.
  15. You try to compile it and stumbles on a compile error...
    1. You check the code and see that this can't compile.
    2. So you make a quick fix (who needs to convert mesh skeleton anyway... humpf... I will need to compile this correctly at one time).
    3. You type a bug report about this skeleton bug.
  16. You rotate it... in the wrong direction... redo it.
  17. Reload all in OGEd and... yes it shows correctly.
That was easy - I will watch a movie now.

Comment from my son (3.5 years old) "Dady doesn't even know how to make wheels!". I will disinherit him...

Tuesday, February 12, 2008

OGEd - Open Game Editor (aka Ogre/OGE Editor) open sourced!

OGEd is now open-source :)

OGEd stands for Open Game Editor but at this stage it is more an Ogre Resource Editor and will evolve into an OGE Editor before becoming a true versatile Open Game Editor :D

You can get it on the OGE sourceforge as code or binary.

Of course there are still lots to do and any help would be great.
If you are interested you can look on the oge wiki for more information like todo list, planned features, how to compile, etc.
http://www.opengameengine.org/wiki

Originally I took inspiration from the Ogre project name "Material Editor" and 5 files that allowed Ogre script edition were really interesting.
So I proposed to the Ogre owner -Sinbad- that we exchange some code so that both could benefit - I thought it was a win-win proposal. I was wrong.

His answer disappointed me. As I want to be able to distribute OGEd under our OGE unlimited license -which I can't if I must keep Ogre license and copyright- I was obliged to remove ANY code that could be interpreted as being originally from the Material Editor :(

This attitude is bit to near to the "SCO versus Linux" for my taste. This is not how I idealise the open source movement. For me if someone is willing to exchange worthwhile code I am more than happy to give mine. Saving time is the most important thing in live! I am not immortal! In my opinion copyrights and licenses are primarily a way to protect my work from people patenting it and then trying to stop me using my code or even making me pay for the work I did! I use them to protect me against crooks and felons.


This lead me to read some legal texts about using existing code without infringing copyright & license. And I found this legal review from the ReactOS project: http://www.reactos.org/en/dev_legalreview.html (ReactOS is a nice project btw I hope it will reach the stage where VC runs on it).

This point is fairly obvious but IMO hard to achieve as C++ programmers are increasingly using the same coding style:

Developers are encouraged to NOT attempt to copy the coding style of non-free code. While coding style may not covered by copyright, a similar or identical coding style to a piece of non-free code casts suspicion on the new code.


This experience made me realise that the "Tainted Developers" theory is nearly unavoidable and I was not able to explain my position to Sinbad. So to avoid again a "SCO versus linux" issue I will avoid reading ANY copyrighted code from now on.

"Tainted Developers". There is a legal theory that is occasionally cited in the context of producing a work-alike implementation of a published copyrighted work. There is concern that, if the creators of the new work have seen the original work, they will be unable to create a similar work without infringing the copyright of the original. It is the position of the Project that this theory is invalid for a number of reasons. As a general rule, there is no reason that a developer who has seen non-free code cannot write logically similar code for ReactOS.

What a lose of time and effort - I hate to reinvent the wheel.

Wednesday, January 9, 2008

Shadows added


New screenshot of my engine where shadows were added.

Shadows techniques are cpu-expensive I will need to find how to limit them and make them lod dependent.

Any way it is progressing well.