Iterating through an NxOgre::List?

danharibo

17-11-2007 22:58:54

I want to iterate through an NxOgre list (Or Wheels to be more precise) but ::iterator doesn't exist? So how can i do this?

betajaen

17-11-2007 23:12:12

I'm pretty sure it works like the Container iterator.

List<Class*> classes;
for(Class* x = classes.begin();x = classes.next();) {
x->doSomething();
}

danharibo

17-11-2007 23:20:51

thanks! but now i get this error:
.\Vehicle.cpp(249) : error C2440: 'initializing' : cannot convert from 'void' to 'NxOgre::Wheel *'

betajaen

18-11-2007 10:36:19

What is line 249 of Vehicle.cpp?

danharibo

18-11-2007 11:58:09

NxOgre::Wheels mWheelList = mWheelSet->mWheels;
for(NxOgre::Wheel* x = mWheelList.begin();x = mWheelList.next();) {
x.setSteeringAngle(Angle);

249 is in the middle

betajaen

18-11-2007 12:31:27

Just do this then:

for(Wheels::Iterator i = mWheelList.items.begin();i != mWheelList.items.end();++i)
(*i)->setSteeringAngle(angle);

danharibo

18-11-2007 12:52:58

thank you!