00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "CaelumPrecompiled.h"
00022 #include "CaelumPrerequisites.h"
00023
00024 #if CAELUM_SCRIPT_SUPPORT
00025
00026 #include "CaelumScriptTranslator.h"
00027 #include "CaelumSystem.h"
00028 #include "CaelumExceptions.h"
00029
00030 using namespace Ogre;
00031
00032 namespace Caelum
00033 {
00034 PropScriptResource::PropScriptResource
00035 (
00036 Ogre::ResourceManager* creator, const Ogre::String& name, Ogre::ResourceHandle handle,
00037 const Ogre::String& group, bool isManual, Ogre::ManualResourceLoader* loader
00038 ):
00039 Ogre::Resource (creator, name, handle, group, isManual, loader)
00040 {
00041
00042
00043 }
00044
00045 PropScriptResource::~PropScriptResource() {
00046
00047
00048 }
00049
00050 PropScriptResourceManager::PropScriptResourceManager() {
00051 mLoadOrder = 1000;
00052 mResourceType = "PropertyScript";
00053 }
00054
00055 PropScriptResource* PropScriptResourceManager::createImpl(
00056 const String& name, ResourceHandle handle, const String& group,
00057 bool isManual, ManualResourceLoader* loader, const NameValuePairList* createParams)
00058 {
00059
00060
00061 return new PropScriptResource (this, name, handle, group, isManual, loader);
00062 }
00063
00064 TypeDescriptorScriptTranslator::TypeDescriptorScriptTranslator (TypeDescriptor* typeDescriptor):
00065 mTypeDescriptor(typeDescriptor)
00066 {
00067 }
00068
00069 bool TypeDescriptorScriptTranslator::getPropValueOrAddError (
00070 ScriptCompiler* compiler,
00071 PropertyAbstractNode* prop,
00072 bool& value)
00073 {
00074 if (prop->values.empty ()) {
00075 compiler->addError (ScriptCompiler::CE_STRINGEXPECTED, prop->file, prop->line);
00076 return false;
00077 }
00078 if (prop->values.size () > 1) {
00079 compiler->addError (ScriptCompiler::CE_FEWERPARAMETERSEXPECTED, prop->file, prop->line,
00080 prop->name + " must have at most 1 argument");
00081 return false;
00082 }
00083 if (!Ogre::ScriptTranslator::getBoolean(prop->values.front(), &value)) {
00084 compiler->addError (ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line,
00085 prop->values.front()->getValue() + " is not a valid number");
00086 return false;
00087 }
00088 return true;
00089 }
00090
00091 bool TypeDescriptorScriptTranslator::getPropValueOrAddError (
00092 ScriptCompiler* compiler,
00093 PropertyAbstractNode* prop,
00094 ColourValue& value)
00095 {
00096 if (prop->values.empty ()) {
00097 compiler->addError (ScriptCompiler::CE_STRINGEXPECTED, prop->file, prop->line);
00098 return false;
00099 }
00100 if (prop->values.size () > 4) {
00101 compiler->addError (ScriptCompiler::CE_FEWERPARAMETERSEXPECTED, prop->file, prop->line,
00102 prop->name + " must have at most 4 arguments");
00103 return false;
00104 }
00105 if (prop->values.size () < 3) {
00106 compiler->addError (ScriptCompiler::CE_FEWERPARAMETERSEXPECTED, prop->file, prop->line,
00107 prop->name + " must have at least 3 arguments");
00108 }
00109 if (!getColour(prop->values.begin(), prop->values.end(), &value)) {
00110 compiler->addError (ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line,
00111 prop->name + " requires a colour argument");
00112 }
00113 return true;
00114 }
00115
00116 bool TypeDescriptorScriptTranslator::getPropValueOrAddError (
00117 ScriptCompiler* compiler,
00118 PropertyAbstractNode* prop,
00119 float& value)
00120 {
00121 if (prop->values.empty ()) {
00122 compiler->addError (ScriptCompiler::CE_STRINGEXPECTED, prop->file, prop->line);
00123 return false;
00124 }
00125 if (prop->values.size () > 1) {
00126 compiler->addError (ScriptCompiler::CE_FEWERPARAMETERSEXPECTED, prop->file, prop->line,
00127 prop->name + " must have at most 1 argument");
00128 return false;
00129 }
00130 if (!Ogre::ScriptTranslator::getFloat(prop->values.front(), &value)) {
00131 compiler->addError (ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line,
00132 prop->values.front()->getValue() + " is not a valid number");
00133 return false;
00134 }
00135 return true;
00136 }
00137
00138 bool TypeDescriptorScriptTranslator::getPropValueOrAddError (
00139 ScriptCompiler* compiler,
00140 PropertyAbstractNode* prop,
00141 int& value)
00142 {
00143 if (prop->values.empty ()) {
00144 compiler->addError (ScriptCompiler::CE_STRINGEXPECTED, prop->file, prop->line);
00145 return false;
00146 }
00147 if (prop->values.size () > 1) {
00148 compiler->addError (ScriptCompiler::CE_FEWERPARAMETERSEXPECTED, prop->file, prop->line,
00149 prop->name + " must have at most 1 argument");
00150 return false;
00151 }
00152 if (!Ogre::ScriptTranslator::getInt(prop->values.front(), &value)) {
00153 compiler->addError (ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line,
00154 prop->values.front()->getValue() + " is not a valid integer");
00155 return false;
00156 }
00157 return true;
00158 }
00159
00160 bool TypeDescriptorScriptTranslator::getPropValueOrAddError (
00161 ScriptCompiler* compiler,
00162 PropertyAbstractNode* prop,
00163 double& value)
00164 {
00165 if (prop->values.empty ()) {
00166 compiler->addError (ScriptCompiler::CE_STRINGEXPECTED, prop->file, prop->line);
00167 return false;
00168 }
00169 if (prop->values.size () > 1) {
00170 compiler->addError (ScriptCompiler::CE_FEWERPARAMETERSEXPECTED, prop->file, prop->line,
00171 prop->name + " must have at most 1 argument");
00172 return false;
00173 }
00174
00175 std::stringstream strStream (std::string(prop->values.front()->getValue()));
00176 strStream >> value;
00177 if (strStream.fail()) {
00178 compiler->addError (ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line,
00179 prop->values.front()->getValue() + " is not a valid number");
00180 return false;
00181 }
00182 return true;
00183 }
00184
00185 bool TypeDescriptorScriptTranslator::getPropValueOrAddError (
00186 ScriptCompiler* compiler,
00187 PropertyAbstractNode* prop,
00188 Ogre::Degree& value)
00189 {
00190 if (prop->values.size () == 0) {
00191 compiler->addError (ScriptCompiler::CE_STRINGEXPECTED, prop->file, prop->line);
00192 return false;
00193 }
00194 if (prop->values.size () > 3) {
00195 compiler->addError (ScriptCompiler::CE_FEWERPARAMETERSEXPECTED, prop->file, prop->line,
00196 prop->name + " must have at most 3 arguments");
00197 return false;
00198 }
00199
00200 float degMinSec[3] = { 0, 0, 0 };
00201 int k = 0;
00202 for (AbstractNodeList::const_iterator it = prop->values.begin(), endIt = prop->values.end(); it != endIt; ++it, ++k) {
00203 if (!Ogre::ScriptTranslator::getFloat(*it, °MinSec[k])) {
00204 compiler->addError (ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line,
00205 (*it)->getValue () + " is not a valid number");
00206 return false;
00207 }
00208 }
00209 value = Ogre::Degree(degMinSec[0] + degMinSec[1] / 60.0 + degMinSec[2] / 3600);
00210 return true;
00211 }
00212
00213 bool TypeDescriptorScriptTranslator::getPropValueOrAddError (
00214 ScriptCompiler* compiler,
00215 PropertyAbstractNode* prop,
00216 Ogre::String& value)
00217 {
00218 if (prop->values.size () == 0) {
00219 compiler->addError (ScriptCompiler::CE_STRINGEXPECTED, prop->file, prop->line);
00220 return false;
00221 }
00222 if (prop->values.size () > 1) {
00223 compiler->addError (ScriptCompiler::CE_FEWERPARAMETERSEXPECTED, prop->file, prop->line,
00224 prop->name + " must have at most 1 arguments");
00225 return false;
00226 }
00227 if (!Ogre::ScriptTranslator::getString(prop->values.front(), &value)) {
00228 compiler->addError (ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line,
00229 prop->values.front()->getValue() + " is not a valid string");
00230 return false;
00231 }
00232 return true;
00233 }
00234
00235 bool TypeDescriptorScriptTranslator::getPropValueOrAddError (
00236 ScriptCompiler* compiler,
00237 PropertyAbstractNode* prop,
00238 Ogre::Vector3& value)
00239 {
00240 if (prop->values.size () == 0) {
00241 compiler->addError (ScriptCompiler::CE_STRINGEXPECTED, prop->file, prop->line);
00242 return false;
00243 }
00244 if (prop->values.size () > 3) {
00245 compiler->addError (ScriptCompiler::CE_FEWERPARAMETERSEXPECTED, prop->file, prop->line,
00246 prop->name + " must have at most 3 arguments");
00247 return false;
00248 }
00249 float floats[3];
00250 if (!Ogre::ScriptTranslator::getFloats(prop->values.begin(), prop->values.end(), floats, 3)) {
00251 compiler->addError (ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line,
00252 "incorrect vector parameters.");
00253 return false;
00254 }
00255 value.x = floats[0];
00256 value.y = floats[1];
00257 value.z = floats[2];
00258 return true;
00259 }
00260
00261 bool TypeDescriptorScriptTranslator::getPropValueOrAddError (
00262 ScriptCompiler* compiler,
00263 PropertyAbstractNode* prop,
00264 Ogre::Vector2& value)
00265 {
00266 if (prop->values.size () == 0) {
00267 compiler->addError (ScriptCompiler::CE_STRINGEXPECTED, prop->file, prop->line);
00268 return false;
00269 }
00270 if (prop->values.size () > 2) {
00271 compiler->addError (ScriptCompiler::CE_FEWERPARAMETERSEXPECTED, prop->file, prop->line,
00272 prop->name + " must have at most 3 arguments");
00273 return false;
00274 }
00275 float floats[2];
00276 if (!Ogre::ScriptTranslator::getFloats(prop->values.begin(), prop->values.end(), floats, 2)) {
00277 compiler->addError (ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line,
00278 "incorrect vector parameters.");
00279 return false;
00280 }
00281 value.x = floats[0];
00282 value.y = floats[1];
00283 return true;
00284 }
00285
00286 template<class T>
00287 static bool tryHandlePropertyType (
00288 ScriptCompiler* compiler, PropertyAbstractNode* propNode,
00289 void* targetObject, const ValuePropertyDescriptor* propDesc)
00290 {
00291 if (propDesc->getValueTypeId () == typeid(T)) {
00292 T val;
00293 if (TypeDescriptorScriptTranslator::getPropValueOrAddError (compiler, propNode, val)) {
00294 propDesc->setValue (targetObject, Ogre::Any(val));
00295 }
00296 return true;
00297 }
00298 return false;
00299 }
00300
00301 void TypeDescriptorScriptTranslator::translateProperty (
00302 ScriptCompiler* compiler,
00303 PropertyAbstractNode* prop,
00304 void* targetObject,
00305 const TypeDescriptor* typeDescriptor)
00306 {
00307 const ValuePropertyDescriptor* propDesc = typeDescriptor->getPropertyDescriptor (prop->name);
00308 if (!propDesc) {
00309 compiler->addError (ScriptCompiler::CE_UNEXPECTEDTOKEN, prop->file, prop->line,
00310 "property \"" + prop->name + "\" not recognized; missing from type descriptor.");
00311 return;
00312 }
00313 if (!propDesc->canSetValue ()) {
00314 compiler->addError (ScriptCompiler::CE_UNEXPECTEDTOKEN, prop->file, prop->line,
00315 "property \"" + prop->name + "\" is read-only and can't be set from a script.");
00316 return;
00317 }
00318
00319
00320
00321
00322 bool handled = false
00323 || tryHandlePropertyType<int> (compiler, prop, targetObject, propDesc)
00324 || tryHandlePropertyType<float> (compiler, prop, targetObject, propDesc)
00325 || tryHandlePropertyType<double> (compiler, prop, targetObject, propDesc)
00326 || tryHandlePropertyType<bool> (compiler, prop, targetObject, propDesc)
00327 || tryHandlePropertyType<Ogre::Degree> (compiler, prop, targetObject, propDesc)
00328 || tryHandlePropertyType<Ogre::String> (compiler, prop, targetObject, propDesc)
00329 || tryHandlePropertyType<Ogre::Vector3> (compiler, prop, targetObject, propDesc)
00330 || tryHandlePropertyType<Ogre::Vector2> (compiler, prop, targetObject, propDesc)
00331 || tryHandlePropertyType<Ogre::ColourValue> (compiler, prop, targetObject, propDesc);
00332
00333 if (!handled) {
00334 compiler->addError (ScriptCompiler::CE_UNEXPECTEDTOKEN, prop->file, prop->line,
00335 "property \"" + prop->name + "\" is found in type descriptor but has "
00336 "unsupported type. Mangled typeid is '" + propDesc->getValueTypeId().name() + "'");
00337 }
00338 }
00339
00340 void TypeDescriptorScriptTranslator::translate (ScriptCompiler* compiler, const AbstractNodePtr& node)
00341 {
00342
00343
00344
00345 assert (getTypeDescriptor () && "Type descriptor must be set before we can translate.");
00346
00347
00348 ObjectAbstractNode *objNode = reinterpret_cast<ObjectAbstractNode*>(node.get());
00349 assert (!objNode->context.isEmpty ());
00350 void* targetObject = any_cast<void*> (objNode->context);
00351 assert (targetObject);
00352
00353 for (AbstractNodeList::iterator i = objNode->children.begin(); i != objNode->children.end(); ++i)
00354 {
00355 if ((*i)->type == ANT_PROPERTY)
00356 {
00357 PropertyAbstractNode *prop = reinterpret_cast<PropertyAbstractNode*>((*i).get());
00358
00359 translateProperty (compiler, prop, targetObject, getTypeDescriptor());
00360 }
00361 else if((*i)->type == ANT_OBJECT)
00362 {
00363 compiler->addError (ScriptCompiler::CE_INVALIDPARAMETERS, (*i)->file, (*i)->line);
00364 }
00365 }
00366
00367
00368 }
00369
00370 CaelumSystemScriptTranslator::CaelumSystemScriptTranslator ():
00371 mResourceManager(false),
00372 mTranslationTarget(0),
00373 mTranslationTargetFound(false),
00374 mTypeDescriptor(0)
00375 {
00376 }
00377
00378 void CaelumSystemScriptTranslator::setTranslationTarget (CaelumSystem* target, const Ogre::String& name)
00379 {
00380 assert (target != 0);
00381 this->mTranslationTarget = target;
00382 this->mTranslationTargetName = name;
00383 this->mTranslationTargetFound = false;
00384 }
00385
00386 void CaelumSystemScriptTranslator::clearTranslationTarget () {
00387 this->mTranslationTarget = 0;
00388 this->mTranslationTargetName.clear();
00389 this->mTranslationTargetFound = false;
00390 }
00391
00392 void CaelumSystemScriptTranslator::translate (ScriptCompiler* compiler, const AbstractNodePtr& node)
00393 {
00394
00395
00396 ObjectAbstractNode *objNode = reinterpret_cast<ObjectAbstractNode*>(node.get());
00397
00398 CaelumSystem* sys = 0;
00399
00400
00401 if (this->getTranslationTarget ()) {
00402 sys = this->getTranslationTarget ();
00403
00404
00405 if (this->getTranslationTargetName () != objNode->name) {
00406
00407
00408 return;
00409 }
00410
00411
00412
00413
00414
00415 sys->clear();
00416
00417
00418
00419 mTranslationTargetFound = true;
00420 } else if (this->getResourceManager ()) {
00421
00422
00423
00424 PropScriptResourceManager* mgr = this->getResourceManager ();
00425 ResourcePtr resource = mgr->create (objNode->name, compiler->getResourceGroup());
00426 resource->_notifyOrigin (objNode->file);
00427 return;
00428 }
00429
00430 objNode->context = sys;
00431
00432 for (AbstractNodeList::iterator i = objNode->children.begin(); i != objNode->children.end(); ++i)
00433 {
00434 if ((*i)->type == ANT_PROPERTY)
00435 {
00436 PropertyAbstractNode *prop = reinterpret_cast<PropertyAbstractNode*>((*i).get());
00437
00438
00439 TypeDescriptorScriptTranslator::translateProperty(
00440 compiler, prop,
00441 static_cast<void*>(sys),
00442 getTypeDescriptor ());
00443 }
00444 else if((*i)->type == ANT_OBJECT)
00445 {
00446 ObjectAbstractNode *childObjNode = reinterpret_cast<ObjectAbstractNode*>((*i).get());
00447
00448
00449
00450
00451
00452
00453
00454
00455 #if OGRE_VERSION < 0x010700
00456 if (childObjNode->name.empty () == false || childObjNode->base.empty () == false) {
00457 #else
00458 if (childObjNode->name.empty () == false || childObjNode->bases.size () != 0) {
00459 #endif
00460 compiler->addError (
00461 ScriptCompiler::CE_FEWERPARAMETERSEXPECTED,
00462 childObjNode->file, childObjNode->line,
00463 "caelum_sky_system components can't have names or bases");
00464 continue;
00465 }
00466 const String& className = childObjNode->cls;
00467
00468 try {
00469 if (className == "sun") {
00470 sys->setSun (new Sun (sys->getSceneMgr (), sys->getCaelumCameraNode ()));
00471 childObjNode->context = static_cast<void*> (sys->getSun ());
00472 } else if (className == "sky_dome") {
00473 sys->setSkyDome (new SkyDome (sys->getSceneMgr (), sys->getCaelumCameraNode ()));
00474 childObjNode->context = static_cast<void*>(sys->getSkyDome ());
00475 } else if (className == "moon") {
00476 sys->setMoon (new Moon (sys->getSceneMgr (), sys->getCaelumCameraNode ()));
00477 childObjNode->context = static_cast<void*>(sys->getMoon ());
00478 } else if (className == "ground_fog") {
00479 sys->setGroundFog (new GroundFog (sys->getSceneMgr (), sys->getCaelumCameraNode ()));
00480 childObjNode->context = static_cast<void*>(sys->getGroundFog ());
00481 } else if (className == "depth_composer") {
00482 sys->setDepthComposer (new DepthComposer (sys->getSceneMgr ()));
00483 childObjNode->context = static_cast<void*>(sys->getDepthComposer ());
00484 } else if (className == "point_starfield") {
00485 sys->setPointStarfield (new PointStarfield (sys->getSceneMgr (), sys->getCaelumCameraNode()));
00486 childObjNode->context = static_cast<void*>(sys->getPointStarfield ());
00487 } else if (className == "precipitation") {
00488 sys->setPrecipitationController (new PrecipitationController (sys->getSceneMgr ()));
00489 childObjNode->context = static_cast<void*>(sys->getPrecipitationController ());
00490 } else if (className == "cloud_system") {
00491 sys->setCloudSystem (new CloudSystem (sys->getSceneMgr (), sys->getCaelumGroundNode ()));
00492 childObjNode->context = static_cast<void*>(sys->getCloudSystem ());
00493 } else {
00494 LogManager::getSingleton ().logMessage ("CaelumSystemScriptTranslator::translate "
00495 "unknown child object class '" + className + "'");
00496 }
00497 } catch (Caelum::UnsupportedException& ex) {
00498
00499
00500
00501
00502 compiler->addError (
00503 ScriptCompiler::CE_UNSUPPORTEDBYRENDERSYSTEM,
00504 childObjNode->file, childObjNode->line,
00505 "Failed to create component \"" + className + "\": " + ex.getFullDescription ());
00506 continue;
00507 }
00508 processNode (compiler, *i);
00509 }
00510 }
00511
00512
00513 }
00514
00515 void CloudSystemScriptTranslator::translate (ScriptCompiler* compiler, const AbstractNodePtr& node)
00516 {
00517
00518
00519 ObjectAbstractNode *objNode = reinterpret_cast<ObjectAbstractNode*>(node.get());
00520 assert (!objNode->context.isEmpty ());
00521 void* rawTargetObject = any_cast<void*> (objNode->context);
00522 assert (rawTargetObject);
00523
00524 CloudSystem* target = static_cast<CloudSystem*>(rawTargetObject);
00525
00526 for (AbstractNodeList::iterator i = objNode->children.begin(); i != objNode->children.end(); ++i)
00527 {
00528 if ((*i)->type == ANT_PROPERTY)
00529 {
00530 compiler->addError (
00531 ScriptCompiler::CE_INVALIDPARAMETERS,
00532 objNode->file, objNode->line,
00533 "cloud_system doesn't have any properties");
00534 }
00535 else if((*i)->type == ANT_OBJECT)
00536 {
00537 ObjectAbstractNode *childObjNode = reinterpret_cast<ObjectAbstractNode*>((*i).get());
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547 const Ogre::String& className = childObjNode->cls;
00548
00549 if (className == "cloud_layer") {
00550
00551 #if OGRE_VERSION < 0x010700
00552 if (childObjNode->base.empty () == false) {
00553 #else
00554 if (childObjNode->bases.size () != 0) {
00555 #endif
00556 compiler->addError (
00557 ScriptCompiler::CE_FEWERPARAMETERSEXPECTED,
00558 childObjNode->file, childObjNode->line,
00559 "cloud_layer can't have a base");
00560 continue;
00561 }
00562
00563 target->createLayerAtHeight (0);
00564 FlatCloudLayer* layer = target->getLayer (target->getLayerCount () - 1);
00565
00566
00567
00568 childObjNode->context = static_cast<void*>(layer);
00569 } else {
00570 LogManager::getSingleton ().logMessage ("CloudSystemScriptTranslator::translate "
00571 "unknown child object class '" + className + "'");
00572 }
00573 processNode (compiler, *i);
00574 }
00575 }
00576
00577
00578 }
00579
00580 CaelumScriptTranslatorManager::CaelumScriptTranslatorManager
00581 (
00582 CaelumDefaultTypeDescriptorData* typeData
00583 ):
00584 mCaelumSystemTranslator(),
00585 mCloudSystemTranslator(),
00586 mFlatCloudLayerTranslator(typeData->FlatCloudLayerTypeDescriptor),
00587 mSunTranslator(typeData->BaseSkyLightTypeDescriptor),
00588 mMoonTranslator(typeData->BaseSkyLightTypeDescriptor),
00589 mPointStarfieldTranslator(typeData->PointStarfieldTypeDescriptor),
00590 mGroundFogTranslator(typeData->GroundFogTypeDescriptor),
00591 mDepthComposerTranslator(typeData->DepthComposerTypeDescriptor),
00592 mPrecipitationTranslator(typeData->PrecipitationTypeDescriptor),
00593 mSkyDomeTranslator(typeData->SkyDomeTypeDescriptor)
00594 {
00595 mCaelumSystemTranslator.setTypeDescriptor(typeData->CaelumSystemTypeDescriptor);
00596
00597
00598 mTranslatorMap.insert (std::make_pair ("caelum_sky_system", &mCaelumSystemTranslator));
00599 mTranslatorMap.insert (std::make_pair ("cloud_system", &mCloudSystemTranslator));
00600 mTranslatorMap.insert (std::make_pair ("cloud_layer", &mFlatCloudLayerTranslator));
00601 mTranslatorMap.insert (std::make_pair ("sun", &mSunTranslator));
00602 mTranslatorMap.insert (std::make_pair ("moon", &mMoonTranslator));
00603 mTranslatorMap.insert (std::make_pair ("point_starfield", &mPointStarfieldTranslator));
00604 mTranslatorMap.insert (std::make_pair ("ground_fog", &mGroundFogTranslator));
00605 mTranslatorMap.insert (std::make_pair ("depth_composer", &mDepthComposerTranslator));
00606 mTranslatorMap.insert (std::make_pair ("precipitation", &mPrecipitationTranslator));
00607 mTranslatorMap.insert (std::make_pair ("sky_dome", &mSkyDomeTranslator));
00608 }
00609
00610 size_t CaelumScriptTranslatorManager::getNumTranslators () const {
00611
00612 assert(0 && "This method should be removed from Ogre::ScriptTranslatorManager");
00613 return mTranslatorMap.size ();
00614 }
00615
00616 void CaelumScriptTranslatorManager::_setPropScriptResourceManager (PropScriptResourceManager* mgr)
00617 {
00618 mCaelumSystemTranslator.setResourceManager (mgr);
00619 }
00620
00621 ScriptTranslator* CaelumScriptTranslatorManager::getTranslator (const AbstractNodePtr& node)
00622 {
00623
00624 if (node->type == ANT_ATOM) {
00625
00626
00627 } else if (node->type == ANT_OBJECT) {
00628 ObjectAbstractNode* objNode = reinterpret_cast<ObjectAbstractNode*>(node.get());
00629
00630
00631
00632 ScriptTranslatorMap::const_iterator it = mTranslatorMap.find(objNode->cls);
00633 if (it != mTranslatorMap.end()) {
00634 return it->second;
00635 }
00636 }
00637
00638
00639 return 0;
00640 }
00641 }
00642
00643 #endif // CAELUM_SCRIPT_SUPPORT