Hi Monster,
How do I make multiple instances of the Subaru vehicle?
Making more than one "as is" using the DemoOgreOde_GranTurismOgre as a basis, I get errors because it tries to create multiple entities all named "Subaru_Entity".
If I change the name(s) passed to OgreOde_Prefab::Vehicle (to something like Subaru0, Subaru1, etc) then I get basically nothing because from OgreOde_Prefab::Vehicle::load cause it can't find a definition for "Subaru0".
I suppose I could just duplicate the entries in the SimpleScenes.ogreode file, but this seems ineffecient, and not exactly the intention.
Any suggestions?
OgreOde - how to make multiple Subarus?
-
- Goblin
- Posts: 215
- Joined: Tue Jul 08, 2003 4:41 pm
- Location: 0,0,0
-
- OGRE Expert User
- Posts: 829
- Joined: Sat Oct 02, 2004 2:20 pm
- Location: California, USA
nono, just change the line where it created the Entity. you might want to add a static member to the class called "static int mSubaruCount"
then, do something like this:
ent = mSceneMgr->createEntity( "Subaru"+Ogre::StringConvertor::toString(mSubaruCount++), "whatever.mesh" );
something like that should fix the problem.
then, do something like this:
ent = mSceneMgr->createEntity( "Subaru"+Ogre::StringConvertor::toString(mSubaruCount++), "whatever.mesh" );
something like that should fix the problem.
-
- OGRE Community Helper
- Posts: 1098
- Joined: Mon Sep 22, 2003 2:40 am
- Location: Melbourne, Australia
Hmm yeah, fair enough. At the moment the vehicle definition is loaded based on it's name. What you need to do is;
Change the declaration of Vehicle::load to be;
In the body of Vehicle::load, change the top bit to be;
And then change line 565 of OgreOdeVehicle to be;
Then you can do something like;
But note that you'll have to add extra code to delete your vehicles properly.
Or, like walaber says, create your vehicles programmatically with different names rather than by loading them from the config file.
Change the declaration of Vehicle::load to be;
Code: Select all
void load(const String &filename,const String &definition_name = StringUtil::BLANK);
Code: Select all
void Vehicle::load(const String &filename,const String &definition_name)
{
String my_name = definition_name;
if(my_name == StringUtil::BLANK) my_name = _name;
...
Code: Select all
if(vehicle->Attribute("name") && (!strcmp(vehicle->Attribute("name"),my_name.c_str())))
Code: Select all
for(int i = 0;i < 5;++i)
{
// Create the vehicle from the config file
vehicle = new OgreOde_Prefab::Vehicle("Subaru" + StringConverter::toString(i));
vehicle->load("SimpleScenes.ogreode","Subaru");
// Move the vehicle
vehicle->setPosition(Vector3(-7.5 + (3.0 * (Real)i),0.82898,0));
}
But note that you'll have to add extra code to delete your vehicles properly.
Or, like walaber says, create your vehicles programmatically with different names rather than by loading them from the config file.