Tuesday, 7 June 2011

Developer Journal 93

Grr. I just spent my morning goofing off on comics and my afternoon goofing off on YouTube.

The simulation crashed because there was a lot of reproducing and I ran out of view ports. I still can't get the default UI that comes with Ogre to work. I did get it to work when I first started with Ogre. A quick look in the Ogre log reveals the following.

18:06:33: OGRE EXCEPTION(5:ItemIdentityException): OverlayElement with name SdkTrays/Cursor not found. in OverlayManager::getOverlayElementImpl at ../../../../../OgreMain/src/OgreOverlayManager.cpp (line 621)

I don't know what it means. I had a search around and there is a /media/packs/SdkTrays.zip. Hmm, in dist/bin/resources.cfg there is the following line,


My code at the moment does not use resources.cfg and instead does it in code. I copied SdkTrays.zip into /media/packs and added the following line to my code.

    "../../media/packs/SdkTrays.zip", "Zip", "General" );

Worked! I had a look at SdkTrays.h to find a way to make the cursor visible and found two useful functions.

  | Converts a 2D screen coordinate (in pixels) to a 3D ray into the scene.
  static Ogre::Ray screenToScene(Ogre::Camera* cam, const Ogre::Vector2& pt)
   return cam->getCameraToViewportRay(pt.x, pt.y);

  | Converts a 3D scene position to a 2D screen coordinate (in pixels).
  static Ogre::Vector2 sceneToScreen(Ogre::Camera* cam, const Ogre::Vector3& pt)
   Ogre::Vector3 result = cam->getProjectionMatrix() * cam->getViewMatrix() * pt;
   return Ogre::Vector2((result.x + 1) / 2, -(result.y + 1) / 2);

Unfortunately, the new UI stuff I'm displaying is also turning up in the smaller view ports and there are no frames per second numbers. To get the numbers to display you have to call SdkTrayManager::frameRenderingQueued(). Unfortunately, the text is not quite right. Where it says Average FPS it then says FPS: 50 and the words FPS overlap.

To show the cursor jut call SdkTrayManager::showCursor().

Grr, the mouse can only move in a small fraction of space in the screen. I suspect the problem with the mouse and the problem with they UI stuff being in all view ports is due to the z order. The z order was 200 by default. Nope, nothing to do with z order. Each view port has a toggle to display overlays or not.

The last problem is getting the cursor to be able to move more than a small square in the top left hand corner.

Ogre graphics and Bullet physics have both been a pleasure to work with.


The following are the results of my afternoon of goofing off on YouTube.

Teyla and John Sparring One

Teyla and John Sparring Two

Teyla and Ronon Sparring

Teyla and Michael Sparring

Ronan and Rodney Sparring

Teal'c Talking

Teal'c Fighting

Teal'c Playing Table Tennis

Stargate Trek

Teyla and Ronon learn about television

The best Stargate commercial ever!

10 burpees
10 mountain climbers
10 squat jumps
10 burpees
10 mountain climbers
10 squat jumps
10 burpees
10 mountain climbers
10 squat jumps
10 burpees


No comments:

Post a Comment