I thought I would mention here that OGRE3D has a new, stable release. OGRE is an open source 3D graphics engine. I have written about OGRE before and I believe it to be an awesome tool that is well supported and has many great third-party enhancements. An interesting point here is that my last posting on here was five days before the most recent OGRE release (Feb 28, 2010).
From www.ogre3d.org:
"We’re very pleased to announce that OGRE 1.7.0 (Cthugha) has now been released, this version is now considered to be our stable release branch."
If you develop ANYTHING for 3D applications and you haven't checked out OGRE (no pun inteded), I think you are seriously missing something.
I had a project last year that involved using OGRE to create a driving simulator that incorporated a collision-avoidance algorithm. The project was 80% of where I wanted it, I got a great grade on it, and plan to extend it. The continued support of OGRE, and its newest release mean that, after I finish this semester, it should be relatively painless to get back on this project. In short, I am just excited to find that OGRE3D is alive and well, and moving forward!
Showing posts with label OGRE. Show all posts
Showing posts with label OGRE. Show all posts
Friday, March 19, 2010
Sunday, January 10, 2010
My Vista OGRE, Part III
It has been awhile since I have had time to update my blog. Life has a funny way of getting in the way of best laid plans. :-)
In any event, I figured I would update (finalize, for now), my comments on using OGRE. The real bottom line on this project is that the requirements changing drastically coupled with only ~10 weeks to do this (in addition to work, my other graduate class, family, Michigan Football, and sleep) really was not enough time to do this properly. I guess I should add that trying to just "dive-in" into this was definitely the wrong approach. With this in mind, my summary here may be updated as I "remember" more of what I did to finish this project. It might be pertinent to add that I did finish the class with an "A," although I don't know my project grade. However, with the weight it carried, it had to have been at least a "B." :-)
If anyone is actually reading this blog and is interested, I did produce a write-up on the project, design decisions, and thoughts on how to make it better. Plus, I have the source code still. Can't ever seem to delete source code. :-)
FINISHED PROTOTYPE:
In the submitted prototype, I ended up using two different data structures (standard Linked List and standard deque) and a couple of algorithms used during each frame updates.
Entry, Exit, and Curve Vectors were all stored in a standard linked list (as IntersectionNodes). While I believe that there are other methods to account for these coordinates, and the actions that need to happen at each one in a scripted world of traffic, I decided that a linked list would be the easiest to maintain and use for these vectors.
The IntersectionNodes themselves stored not only the Vector3 types, but also Ints and Chars to indicate:
- The implicit direction of travel that a car must be facing.
- for example, Intersection 1 is a four-way stop. An entry Vector3 facing North would indicate a stopping point for the car facing North and an corresponding exit Vector3 with the car facing South.
- The number of the intersection.
The deque was used for scripting individual car routes (I have 5 vehicles that are mix of cars, trucks, and a school bus). Initially, it was a simple matter of adding each entry and exit point to the route deque's. During each frame update, the current position (Vector3) is compared to the list of Entry Vectors, which indicates a stopping point for the vehicle (curves were seperated from Entry and Exit Vector lists) and an algorithm for slowing the car was used (below). The hard part of the deque's (made hard by my own inability to just do some research first), and something I think I mentioned already, was calculating the turns through intersections and curves. The algorithms I attempted based on some math (sin, cosine, etc), never "quite" worked right. I ended up calculating manually a minumum number of points of a turn and adjusting the Vector3's x and z values. I added no less than seven Vector3's to between each Entry and Exit point on the deque's.
The stopping and restarting of the vehicles was fairly simple to transform into an algorithm to use during each frame update (I did not seperate this out into another class as I think it would have added more coupling than neccessary). Basically, what I did at each frame update was take the precent of change in distance to the stopping point (<=30 from Entry Vector3), and slowed the car by the same delta. To prevent any negative values in direction (makes the car go backwards), I tested for any distance <= 0.5. If distance was <= 0.5, the algorithm automatically set the wait timer to 30, distance to 0.0, and current position = destination (Entry Vector). This basically "snapped" a car to the stopping point and initiated the stop wait timer.
The Camera views, and toggling them, was a little difficult and time did not allow me to finish this aspect. The current prototype has one camera (movable) that overlooks the "city" I created.
Futre Plans/Increments:
As time permits, I would like to do more with this project, if only for myself. There is an OGRE physics engine that I have seen used for car movements and I would like to incoporate this. I also plan to revisit not only the multiple (toggling) cameras, but a more dynamic way to script out the movements of the cars that are not being "driven" by the user.
OGRE provides support for peripherals suchs as joysticks and I may be interested enough in the future to play with this for the driving simulator. However, right now, the actual "driving" of the car will actually be "camera view."
I also want to look at how storing Vector3's for a turn compares to a more dynamic approach of using a turning algorithm/function. I am curious as to the comparison of:
- storing and popping a turn algorithm as compared to a method that calculates the Vector3 of a set number of points on a turn. It is the memory used versus the processor time used that I am curious about.
The bottom line is that I really want to find some extra time to create the next increment on this prototype. I realized too late that there are some definite improvements I could implement to make this simulator: more realistic, more efficient, and more fun. The OGRE API, and the additional physics engine, definitely provide all the means to transform this prototype into what I want it to be. My middle daughter is only 8 years old, so I have at least seven years to perfect this program. :-)
In any event, I figured I would update (finalize, for now), my comments on using OGRE. The real bottom line on this project is that the requirements changing drastically coupled with only ~10 weeks to do this (in addition to work, my other graduate class, family, Michigan Football, and sleep) really was not enough time to do this properly. I guess I should add that trying to just "dive-in" into this was definitely the wrong approach. With this in mind, my summary here may be updated as I "remember" more of what I did to finish this project. It might be pertinent to add that I did finish the class with an "A," although I don't know my project grade. However, with the weight it carried, it had to have been at least a "B." :-)
If anyone is actually reading this blog and is interested, I did produce a write-up on the project, design decisions, and thoughts on how to make it better. Plus, I have the source code still. Can't ever seem to delete source code. :-)
FINISHED PROTOTYPE:
In the submitted prototype, I ended up using two different data structures (standard Linked List and standard deque) and a couple of algorithms used during each frame updates.
Entry, Exit, and Curve Vectors were all stored in a standard linked list (as IntersectionNodes). While I believe that there are other methods to account for these coordinates, and the actions that need to happen at each one in a scripted world of traffic, I decided that a linked list would be the easiest to maintain and use for these vectors.
The IntersectionNodes themselves stored not only the Vector3 types, but also Ints and Chars to indicate:
- The implicit direction of travel that a car must be facing.
- for example, Intersection 1 is a four-way stop. An entry Vector3 facing North would indicate a stopping point for the car facing North and an corresponding exit Vector3 with the car facing South.
- The number of the intersection.
The deque was used for scripting individual car routes (I have 5 vehicles that are mix of cars, trucks, and a school bus). Initially, it was a simple matter of adding each entry and exit point to the route deque's. During each frame update, the current position (Vector3) is compared to the list of Entry Vectors, which indicates a stopping point for the vehicle (curves were seperated from Entry and Exit Vector lists) and an algorithm for slowing the car was used (below). The hard part of the deque's (made hard by my own inability to just do some research first), and something I think I mentioned already, was calculating the turns through intersections and curves. The algorithms I attempted based on some math (sin, cosine, etc), never "quite" worked right. I ended up calculating manually a minumum number of points of a turn and adjusting the Vector3's x and z values. I added no less than seven Vector3's to between each Entry and Exit point on the deque's.
The stopping and restarting of the vehicles was fairly simple to transform into an algorithm to use during each frame update (I did not seperate this out into another class as I think it would have added more coupling than neccessary). Basically, what I did at each frame update was take the precent of change in distance to the stopping point (<=30 from Entry Vector3), and slowed the car by the same delta. To prevent any negative values in direction (makes the car go backwards), I tested for any distance <= 0.5. If distance was <= 0.5, the algorithm automatically set the wait timer to 30, distance to 0.0, and current position = destination (Entry Vector). This basically "snapped" a car to the stopping point and initiated the stop wait timer.
The Camera views, and toggling them, was a little difficult and time did not allow me to finish this aspect. The current prototype has one camera (movable) that overlooks the "city" I created.
Futre Plans/Increments:
As time permits, I would like to do more with this project, if only for myself. There is an OGRE physics engine that I have seen used for car movements and I would like to incoporate this. I also plan to revisit not only the multiple (toggling) cameras, but a more dynamic way to script out the movements of the cars that are not being "driven" by the user.
OGRE provides support for peripherals suchs as joysticks and I may be interested enough in the future to play with this for the driving simulator. However, right now, the actual "driving" of the car will actually be "camera view."
I also want to look at how storing Vector3's for a turn compares to a more dynamic approach of using a turning algorithm/function. I am curious as to the comparison of:
- storing and popping a turn algorithm as compared to a method that calculates the Vector3 of a set number of points on a turn. It is the memory used versus the processor time used that I am curious about.
The bottom line is that I really want to find some extra time to create the next increment on this prototype. I realized too late that there are some definite improvements I could implement to make this simulator: more realistic, more efficient, and more fun. The OGRE API, and the additional physics engine, definitely provide all the means to transform this prototype into what I want it to be. My middle daughter is only 8 years old, so I have at least seven years to perfect this program. :-)
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.
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.
Sunday, November 8, 2009
My Vista OGRE
The classes for my Masters that I am taking right now are definitely difficult. In one class, we have a group project to create a real-time version of YouTube. That one has been fun (after moving quickly away from ffmpeg into the Red5 framework) and educational.
My other class is an individual project to create a 3D driving simulator with a focus not only on the data structures, but on a "collision-avoidance" algorithm. I should add that, like in real life, the requirements have changed slightly each week. However, the project has so far been a fun challenge. The biggest change is that we are to create it from the ground up, whereas initially we were going to be given the underlying model and were to just focus on the avoidance of collisions. This change brings me to the point of this post: OGRE and installing it on Vista.
In order to meet the requirements of this project without digging into my wallet, I decided to use the following:
- OGRE 1.6.4 (for Visual C++.NET 2008) Prebuilt SKD: https://sourceforge.net/projects/ogre/files/ogre/1.6.4/OgreSDKSetup1.6.4_VC90.exe/download
- Google Sketchup 7 (free version): http://sketchup.google.com/download/gsu.html
- Ogremeshexporter:
http://cid-ea0e1d9f19828aa4.skydrive.live.com/self.aspx/.Public/Sketchup%20exporter%20to%20realXtend/ogremeshexporter.msi
- DirectX or OpenGL (personal preference)
- OGRECommandLineTools (needed for OgreXMLConverter, which allows for conversions to the mesh format): https://sourceforge.net/projects/ogre/files/ogre-tools/1.6.3/OgreCommandLineTools_1.6.3.msi/download
The reason I went with the prebuilt instead of building OGRE from source was more of a time concern than anything, although I will say that as of a month ago, the source as downloaded from soureforge was buggy.
The installation of the three products was as easy as double-clicking the installer for each one, in the order I have above, setting/verifying the OGRE_HOME environmental variable is set to "c:\OgreSDK", and restarting (not required, but I prefered). To verify that OGRE was correctly installed, the following folder structure should exist:
[root]\OgreSDK\
----\bin
----\include
----\media
----\docs
----\lib (should have "OgreMain.lib" and "OgreMain_d.lib")
----\samples
Outside of the OGRE examples, Google Sketchup can be used to create a new mesh for OGRE. Sketchup can import directly from 3D Warehouse. Once a model has been imported, it can be exported to OGRE mesh format (tools->Export to Ogre Mesh). The Sketchup exporter will have its own directory ([root]\SketchupExporter) in which the exported .mesh, .material, etc. files will be saved to by defualt.
I intend to keep the OGRE thread going for awhile as I work through it, so I am not going to write directly about creating OGRE projects, as it can be a pain in the rear. There is some excellent information on the OGRE Wiki for this information. The last thing I wanted to add to this is that there are AppWizards for automatically creating a new VC++ project and it can be found here: http://www.jacmoe.dk/forum/index.php?PHPSESSID=5bc2de1bec215099e2d76cba08f9a815&topic=3.0
A lot of the links at this page go back to sourceforge, but apparently (I didn't use the wizard) these tools are good for each IDE for which they were written.
My other class is an individual project to create a 3D driving simulator with a focus not only on the data structures, but on a "collision-avoidance" algorithm. I should add that, like in real life, the requirements have changed slightly each week. However, the project has so far been a fun challenge. The biggest change is that we are to create it from the ground up, whereas initially we were going to be given the underlying model and were to just focus on the avoidance of collisions. This change brings me to the point of this post: OGRE and installing it on Vista.
In order to meet the requirements of this project without digging into my wallet, I decided to use the following:
- OGRE 1.6.4 (for Visual C++.NET 2008) Prebuilt SKD: https://sourceforge.net/projects/ogre/files/ogre/1.6.4/OgreSDKSetup1.6.4_VC90.exe/download
- Google Sketchup 7 (free version): http://sketchup.google.com/download/gsu.html
- Ogremeshexporter:
http://cid-ea0e1d9f19828aa4.skydrive.live.com/self.aspx/.Public/Sketchup%20exporter%20to%20realXtend/ogremeshexporter.msi
- DirectX or OpenGL (personal preference)
- OGRECommandLineTools (needed for OgreXMLConverter, which allows for conversions to the mesh format): https://sourceforge.net/projects/ogre/files/ogre-tools/1.6.3/OgreCommandLineTools_1.6.3.msi/download
The reason I went with the prebuilt instead of building OGRE from source was more of a time concern than anything, although I will say that as of a month ago, the source as downloaded from soureforge was buggy.
The installation of the three products was as easy as double-clicking the installer for each one, in the order I have above, setting/verifying the OGRE_HOME environmental variable is set to "c:\OgreSDK", and restarting (not required, but I prefered). To verify that OGRE was correctly installed, the following folder structure should exist:
[root]\OgreSDK\
----\bin
----\include
----\media
----\docs
----\lib (should have "OgreMain.lib" and "OgreMain_d.lib")
----\samples
Outside of the OGRE examples, Google Sketchup can be used to create a new mesh for OGRE. Sketchup can import directly from 3D Warehouse. Once a model has been imported, it can be exported to OGRE mesh format (tools->Export to Ogre Mesh). The Sketchup exporter will have its own directory ([root]\SketchupExporter) in which the exported .mesh, .material, etc. files will be saved to by defualt.
I intend to keep the OGRE thread going for awhile as I work through it, so I am not going to write directly about creating OGRE projects, as it can be a pain in the rear. There is some excellent information on the OGRE Wiki for this information. The last thing I wanted to add to this is that there are AppWizards for automatically creating a new VC++ project and it can be found here: http://www.jacmoe.dk/forum/index.php?PHPSESSID=5bc2de1bec215099e2d76cba08f9a815&topic=3.0
A lot of the links at this page go back to sourceforge, but apparently (I didn't use the wizard) these tools are good for each IDE for which they were written.
Subscribe to:
Posts (Atom)