Saturday, November 14, 2009

My Vista OGRE, Part II

A little more today on my trials and tribulations of using OGRE. :-)

To better explain a couple of things from my previous post:
The OGRE App Wizard works well with VS 2008. Creating a new C++ project will show the option to create a new OGRE application. After assigning a name, the "next" button will open the app wizard. The defaults for this are probably suitable for anyone, unless options such as CEGUI support are needed. The one thing to be careful about is copying files/folders from the OgreSDK location to your project (as needed). One specific issue with this is the OgreMain.lib and OgreMain_d.lib files. If a project is created in a directory other than the OgreSDK directory, these files will not be automatically found and the app will crash. These can be added to the project by copying the 'OgreSDK\lib' folder to the project directory, by opening the executable from the 'OgreSDK\bin\debug' folder, or making appropriate changes in VS to point to the right path.
Secondly, I didn't elaborate on setting the environmental variable for OGRE (in Vista) originally, but will so now:
- As an administrator, this can be done through the GUI: System Control Panel, Advanced Settings, Environmental Variables
- As a regular user: from the command line, enter: setx OGRE_HOME c:\OgreSDK.
Lastly, OGRE is not fond of spaces in file/folder names, so do so with caution.

So, now onto where I am in this journey:
After searching around Google's 3D Warehouse for the "perfect" city to use, I ultimately decided to create my own. Had I fully envisioned the amount of time this would take, I would not have been so picky. Creating my own street layout took two attempts. I took a more Agile approach and just "dove right in." Had I read a little first, I would have found out about connecting pieces (by endpoint in my case), rotating pieces, and filling in areas. The second attempt, with about three hours of work, produced a street map were X = [-1300, 1300], Y = 0, and Z = [-1120, 1100], with 40 intersections of different types (90 deg. intersections, 3-way', and 4-ways). I was really impressed with myself when I finished this, exported it, and used it in my OGRE application test.

However, what I didn't account for was initially was that, in order to script the movement of vehicles, I needed to know where each car would be when it entered an intersection, and where it would be when it left (depending on direction of turn), including yaw and turn translation. Thus began a LOT of trial and error for identifying where each position was. It didn't help that the road models I used, including the pieces of straight section of road, where slightly skewed. I know that there is a way in the OGRE API to use the mouse to identify a point on a mesh. However, I dove into my trial/error method thinking it would be a lot faster than it was (12 hours to identify entry and exit positions for 22 of the 40 intersections).

After deciding that I had enough intersection information for multiple paths, I decided it was time to test the movement of my camaro from/through intersections. I used the OGRE Intermediate Tutorial #1 as a guide. If my camaro would would have had animation defined, then the tutorial as it was written would have been perfect. But, I din't have animation defined, so out of luck there! What I did was use this same tutorial and make some minor changes:
- deleted the "Knot" entities and Robot entity
- Added my city.mesh
- Added my camaro.mesh
- commented out (for now) the mAnimationState lines from inside the if/else's that are inside the MoveDemoListener::frameStarted function
- changed the return to 'true'.

All of this worked well, except my car is facing sideways as it drives :-), which I will work on later tonight.

3 comments:

  1. a pointer on the car you could manually divert it by going to the axis on sketch up and start twisting and turning that is the fastest way to redirect the front end point of the car. Some trail and error will be done but identified easily and fast and don't forget te reexport it in mesh format.. Good Luck

    ReplyDelete
  2. Thank you. I haven't had much time to update this, but shortly after I posted this, I realized much the same thing.
    The bottom line: The solid lines in Sketchup are the positive sections of each axis. Deciding which direction is the "default" direction is all that is really needed. Once this is decided, on object in sketchup can be rotated (twisted, turned, etc) to point in the "defaul" direction.

    DW

    ReplyDelete
  3. hi there. i just stumbled onto your blog post. i am a graduate student at the university of illinois at chicago. i recently wrote a simple first-person driving simulator to support my dissertation research (which involves sleep and spee apnea). i also chose to use Ogre. i am now using my simulator in a couple research studies and it appears to be sufficient to accomplish my basic goals. however, since game programming (and everything it entails) is not my area of expertise, i am sure my simulator could be greatly improved in the future. i am curious about how much progress you have made on your project and whether you would be willing to share what you have accomplished. thanks!

    ReplyDelete