|
From: <a_r...@gm...> - 2007-09-20 09:01:44
|
Hi!
Jan asked me to post over here, since he was uncertain, if Jens reads the
yahoogroup...
Some minor modifications to the former posting to reflect the current
status...
As some of you might know, I'm working on the integration of helis in CRRC-Sim.
I'm currently working on the parsing of the T-Rex XML file. Our current draft
of the engine part looks like this:
=================
<power units="1">
<battery filename="nimh7_kan1050" throttle_min="0">
<shaft J="0" brake="1">
<gearing i="0.08667" J="0" eta="0.98"> <!-- SE V2 main gear 150T with 13T pinion -->
<rotor TYPE="MAIN" D="0.7" CHORD="0.05" MIN_PITCH="-10" MAX_PITCH="10" J="0" SPIN_DIR="RIGHT" x="0" y="0" z="-0.38" dir_x="0" dir_y="0" dir_z="-1"/>
</gearing>
<gearing i="0.42941" J="0" eta="0.98"> <!-- Old tail gearing 109/22 -->
<rotor TYPE="TAIL" D="0.15" CHORD="0.016" MIN_PITCH="-5" MAX_PITCH="15" J="0" SPIN_DIR="LEFT" x="-1.34" y="0" z="0.02" dir_x="0" dir_y="1" dir_z="0"/>
</gearing>
<engine filename="Mabuchi_380_FR" />
</shaft>
</battery>
</power>
=================
So we have the engine with 2 gearings for the main and the tail rotor.
It seems, Jens already had such a solution in mind, since a shaft contains
a vector with gearings, attached to it.
Problem: in shaft.cpp, there's code like:
=================
p = new Propeller();
p->automagic(xml);
gear.push_back(p);
=================
, and in the propeller automagic, there's code like:
=================
void Power::Propeller::automagic(SimpleXMLTransfer* xml)
{
SimpleXMLTransfer* p = xml->getChild("battery.shaft.propeller");
...
=================
But what happens, if there's more than one propeller in the XML? Imagine
a plane with a pulling and a pusher prop with different diameters, or so?
As I see it, a prop will always parse the first prop in the xml, when it
looks for a propeller child.
My proposal currently looks like this:
In shaft.cpp, those few lines become:
=================
// Get all the propellers and rotors attached to this shaft...
SimpleXMLTransfer* shaft = xml->getChild("battery.shaft");
int nChilds = shaft->getChildCount();
for( int currentChildIndex = 0; currentChildIndex < nChilds; currentChildIndex++) {
SimpleXMLTransfer* currentChild = shaft->getChildAt( currentChildIndex);
std::string childName = currentChild->getName();
if( childName.compare( "propeller") == 0)
{
Propeller* p = new Propeller();
p->automagic( currentChild);
gear.push_back( p);
}
else if( childName.compare( "rotor") == 0)
{
Rotor* r = new Rotor();
r->automagic( currentChild);
gear.push_back( r);
}
}
=================
So we pass the exact child with the propeller or the rotor data to the
constructor of these objects. This way, we could parse several different
propellers and rotors in the file.
Am I wrong? Or do you have any suggestions for improvement?
Ciao,
Andreas
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
|