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,

Zip=../../media/packs/SdkTrays.zip

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.

Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
    "../../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.



RELATED



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

Teyla and John Sparring One
http://www.youtube.com/watch?v=WwfZ92N6o6U

Teyla and John Sparring Two
http://www.youtube.com/watch?v=K1w4f3gBg-k

Teyla and Ronon Sparring
http://www.youtube.com/watch?v=-daxpuA5Ypo
http://www.youtube.com/watch?v=HqMlM3XF3pY

Teyla and Michael Sparring
http://www.youtube.com/watch?v=Bty2-qUat9I

Ronan and Rodney Sparring
http://www.youtube.com/watch?v=slxnETx06JQ

Teal'c Talking
http://www.youtube.com/watch?v=HTzuxhOh80M

Teal'c Fighting
http://www.youtube.com/watch?v=dUZVrbV7Zx8

Teal'c Playing Table Tennis
http://www.youtube.com/watch?v=kMfzfMpkTJ4

Stargate Trek
http://www.youtube.com/watch?v=XohUsJSrAOk

Teyla and Ronon learn about television
http://www.youtube.com/watch?v=sYiJlp6BXY4&NR=1

The best Stargate commercial ever!
http://www.youtube.com/watch?v=EieL13mwGV0

http://www.youtube.com/watch?v=q7gRB34DzZc
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

http://www.youtube.com/watch?v=ayLfvDtnPAY&feature=related

No comments:

Post a Comment