Saturday, July 12, 2014

Interesting Times

Usually I keep away from political and economic topics on my blog, however I think the time has come to make an exception. I need to mention, that for the record, in the past 6 months to a year, something has gone wrong in this country, and I do not know what it is.

Suddenly, consumer products have become a lot more expensive. They have not become more expensive in the normal sense of inflation, but in the sense of hyper-inflation. And this is a bad thing. A very large percentage of the population lives in poverty: The world bank puts the figure at around 23% (see http://data.worldbank.org/country/south-africa) I do not know how these people will cope with this increase in prices.

As to what caused this, I can only speculate. In the last year, the following notable things happened:
  • We had an election
  • The e-Toll system was activated
  • There was general strikes in our mining industry
What I don't understand is how these factors could have such a huge impact on prices. Other countries also have elections and toll systems but do not undergo hikes in prices. We had strikes in South Africa for years, but not price increases on the scale what we are seeing them now. 

So I am out of ideas. If I have to speculate, I would have to guess that some large organization somewhere has made a decision that had a massive impact on our economy.

Sunday, May 25, 2014

Loading and displaying a Blender model in Three JS

I recently had this strange urge to create a web based strategy game. So I decided to check out Three JS and scrape together some code from all over the Internet to render a 3D box. (Yes, the one you see right after installing blender ... :-)

I uploaded the results of my efforts here: http://www.coffee-smudge.com/strategy1/

The end result looks like this:

End result of my rendering efforts. Not quite a strategy game yet ... 

In order to make this I had to follow these steps: (after browsing the references and examples ... see code sample)
  1. Download Blender version 2.67
  2. Get the Three JS git repository. It is here: https://github.com/mrdoob/three.js/
  3. The git repository contains a Blender Exporter with some installation instructions. Get it here: https://github.com/mrdoob/three.js/tree/master/utils/exporters/blender
  4. Export the 3D model. This will give you a JSON file that can be loaded using Three JS. As far as I can tell it must be hosted to be loadable.
  5. Load it: I used this JavaScipt Code:
    //References:
    // $(Github)\three.js\three.js-master\three.js-master\examples\misc_controls_orbit.html
    // http://math.hws.edu/eck/cs424/notes2013/threejs/json-loader-demo.html
    
    var container, stats;
    var camera, controls, scene, renderer;
    
    
    var render = function render() {
    
      // NB: Uncommenting this makes it slow
      //requestAnimationFrame(render);
    
      renderer.render(scene, camera);
      stats.update(); 
    }
    
    var resize = function () {
      camera.aspect = window.innerWidth / window.innerHeight;
      camera.updateProjectionMatrix();
      renderer.setSize(window.innerWidth, window.innerHeight);
      render();
    }
    
    var modelLoadedCallback = function (geometry, materials) {
      try {
        for (var x = -20; x < 20; x++) {
          for (var z = -20; z < 20; z++) {
            var object = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
            object.position.set(x * 5, -5, z * 5);
            scene.add(object);
          }
        }
        render();
      }
      catch (err) {
        alert(err);
      }
    }
    
    var loadModel = function () {
      var loader = new THREE.JSONLoader();
      loader.load("model/cube.js", modelLoadedCallback);
    }
    
    var loadLight = function () {
      // Specular + diffuse
      light = new THREE.DirectionalLight(0xffffff);
      light.position.set(0, 5, 0);
      scene.add(light);
      // Ambient
      light = new THREE.AmbientLight(0x222222);
      scene.add(light);
    }
    
    var init = function () {
      if (!Detector.webgl) {
        Detector.addGetWebGLMessage();
        throw "No WebGL detected!"
      }
    
      renderer = new THREE.WebGLRenderer({ antialias: true });
      renderer.setClearColor(0x000022, 1);
      renderer.setSize(window.innerWidth, window.innerHeight);
    
      // Load content
      scene = new THREE.Scene();
      loadLight();
      loadModel();
    
      container = document.getElementById( 'container' );
      container.appendChild( renderer.domElement );
        
      camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 1, 1000);
      camera.position.z = 5;
    
      controls = new THREE.OrbitControls(camera);
      controls.addEventListener('change', render);
    
      stats = new Stats();
      stats.domElement.style.position = 'absolute';
      stats.domElement.style.top = '0px';
      stats.domElement.style.zIndex = 100;
      container.appendChild(stats.domElement);
    
      window.addEventListener('resize', resize, false);
      window.addEventListener('error', function () {
        alert("error!");
      }, false);
    
      render();
    }
    
    window.addEventListener('load', init, false);
    

Monday, December 16, 2013

Is the XBox One or Playstation 4 worth buying?

I've been wondering if it is worthwhile spending thousands of Rands (or hundreds of Dollars ...) on a next generation console, and I came to the conclusion that it may not currently be worth the money. The reasons for this, in my opinion, are:
  • The price of games: Is a computer game really worth R800?s think about this ... R800 is more or less equal to a month of DSTV, if you still waste your money on that (Yes Naspers, I am looking at you ...). If you are lucky it will cover a large part of an electricity bill. And then there is food: depending on what you buy this could be a week of groceries or petrol. Worst of all: buy 5 and you have spent R 4000!
  • Single player games tend to be linear: Is it really worth playing something that is pretty much on rails? If everyone will have the same experience, it makes more sense to just watch a game playthrough on YouTube. Multiplayer is about the only real usage scenario for me here because of the replay-ability.
  • It's a single purpose device: In the USA, you could use your XBox One to watch TV, as well as play games. But in SA it is just a gaming device. This happens even though it is a full PC and can probably run a full version of Windows 8.1. I don't want to spend between six and eight thousand Rand on something I will only ever use for computer games. It is also a DVD player, but if you want a DVD player there are cheaper options. This is also true for browsing the web.
  • Locked in ecosystems: I guess it could be argued that this is not a problem: most major games get released on most platforms. The thing that bothers me, however, is that the console manufacturer controls the distribution channel and can cut you off at any time. If you publish via this channel they will take a chunk of your money.
  • The price of the device, and getting ripped off because we do not live in North America: The PS4 has a recommended retail price in South Africa of R 6300. This is US$ 609 at current exchange rates!!! Overseas it costs US$ 400, or about R 4150. Someone is making a cool two thousand Rand per sale.
I may eventually get an XBox One due to its ties with the Windows operating system. Be that as it may, the price will have to come down to about R 3000 before I will even consider buying it. Game prices will also have to come down to a maximum of R400 per game.

Referenced Links

http://www.ign.com/wikis/xbox-one/Xbox_One_Hardware_Specs
http://www.ign.com/wikis/playstation-4/PlayStation_4_Hardware_Specs
http://mybroadband.co.za/news/gadgets/93691-playstation-4-launched-in-south-africa-price-details.html
http://www.pcmag.com/article2/0,2817,2419594,00.asp