当前位置: 首页>>代码示例>>C++>>正文


C++ Any::containsKey方法代码示例

本文整理汇总了C++中Any::containsKey方法的典型用法代码示例。如果您正苦于以下问题:C++ Any::containsKey方法的具体用法?C++ Any::containsKey怎么用?C++ Any::containsKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Any的用法示例。


在下文中一共展示了Any::containsKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: r

Texture::Specification::Specification(const Any& any, bool assumesRGBForAuto, Dimension defaultDimension) {
    *this = Specification();
    assumeSRGBSpaceForAuto = assumesRGBForAuto;
    dimension              = defaultDimension;

    if (any.type() == Any::STRING) {
        filename = any.string();
        if (filename == "<whiteCube>") {
            filename = "<white>";
            dimension = Texture::DIM_CUBE_MAP;
        }

        if (! beginsWith(filename, "<")) {
            filename = any.resolveStringAsFilename();
            if (FilePath::containsWildcards(filename)) {

                // Assume this is a cube map
                dimension = Texture::DIM_CUBE_MAP;
            }
        }
    } else if ((any.type() == Any::NUMBER) ||
               any.nameBeginsWith("Color4") || 
			   anyNameIsColor3Variant(any)) {
        filename = "<white>";
        encoding.readMultiplyFirst = Color4(any);
    } else {

        any.verifyNameBeginsWith("Texture::Specification");
        AnyTableReader r(any);
        r.getFilenameIfPresent("filename", filename);
        r.getFilenameIfPresent("alphaFilename", alphaFilename);
        r.getIfPresent("encoding", encoding);
        r.getIfPresent("assumeSRGBSpaceForAuto", assumeSRGBSpaceForAuto);
        {
            Any a;
            if (r.getIfPresent("dimension", a)) {
                dimension = toDimension(a);
            }
        }
        r.getIfPresent("generateMipMaps", generateMipMaps);
        r.getIfPresent("preprocess", preprocess);
        r.getIfPresent("visualization", visualization);
        r.getIfPresent("cachable", cachable);
        r.verifyDone();

        if (! any.containsKey("dimension") && FilePath::containsWildcards(filename)) {
            // Assume this is a cube map
            dimension = Texture::DIM_CUBE_MAP;
        }
    }
}
开发者ID:elfprince13,项目名称:G3D10,代码行数:51,代码来源:Texture_Specification.cpp

示例2: load

Any Scene::load(const std::string& scene) {
    std::string filename;
    clear();
    m_modelTable.clear();
    m_name = scene;

    bool isFilename = endsWith(toLower(scene), ".scn.any") || endsWith(toLower(scene), ".Scene.Any");

    if (isFilename) {
        filename = scene;
    } else {
        const std::string* f = filenameTable().getPointer(scene);
        if (f == NULL) {
            throw "No scene with name '" + scene + "' found in (" + 
                stringJoin(filenameTable().getKeys(), ", ") + ")";
        }

        filename = *f;
    }

    Any any;
    any.load(filename);

    {
        const std::string& n = any.get("name", filename);

        // Ensure that this name appears in the filename table if it does not already,
        // so that it can be loaded by name in the future.
        if (! filenameTable().containsKey(n)) {
            filenameTable().set(n, filename);
        }
    }

    m_sourceAny = any;

    // Load the lighting environment (do this before loading entities, since some of them may
    // be lights that will enter this array)
    bool hasEnvironmentMap = false;
    if (any.containsKey("localLightingEnvironment")) {
         m_localLightingEnvironment = any["localLightingEnvironment"];
         hasEnvironmentMap = any["localLightingEnvironment"].containsKey("environmentMap");
    }
        

    // Load the models
    if (any.containsKey("models")) {
        Any models = any["models"];
        if (models.size() > 0) {
            for (Any::AnyTable::Iterator it = models.table().begin(); it.isValid(); ++it) {
                const std::string name = it->key;
                Any v = it->value;
                createModel(v, name);
            }
        }
    }

    // Instance the models
    if (any.containsKey("entities")) { 
        Any entities = any["entities"];
        if (entities.size() > 0) {
            for (Table<std::string, Any>::Iterator it = entities.table().begin(); it.isValid(); ++it) {
                const std::string& name = it->key;
                const std::string& entityType = it->value.name();

                createEntity(entityType, name, it->value);
            }
        }
    }
    
    shared_ptr<Texture> skyboxTexture = Texture::whiteCube();

    Any skyAny;

    // Use the environment map as a skybox if there isn't one already, and vice versa
    Array<shared_ptr<Skybox> > skyboxes;
    getTypedEntityArray<Skybox>(skyboxes);
    if ( skyboxes.size() == 0 ) {
        if (any.containsKey("skybox")) {
            createEntity("Skybox", "skybox", any["skybox"]);
            m_skybox = typedEntity<Skybox>("skybox");
        } else if (hasEnvironmentMap) {
            m_skybox = Skybox::create("skybox", this, Array<ScaledTexture>(m_localLightingEnvironment.environmentMapArray[0]), Array<SimTime>(0.0), 0, SplineExtrapolationMode::CLAMP, false, false);
            insert(m_skybox);
        } else {
            m_skybox = Skybox::create("skybox", this, Array<ScaledTexture>(ScaledTexture(Texture::whiteCube(), 1.0f)), Array<SimTime>(0.0), 0, SplineExtrapolationMode::CLAMP, false, false);
            insert(m_skybox);
        }
    }

    if (any.containsKey("environmentMap")) {
        throw std::string("environmentMap field has been replaced with localLightingEnvironment");
    }


    // Default to using the skybox as an environment map if none is specified.
    if (! hasEnvironmentMap) {
        m_localLightingEnvironment.environmentMapArray.append(ScaledTexture(m_skybox->keyframeArray()[0].texture, m_skybox->keyframeArray()[0].constant));
    }


//.........这里部分代码省略.........
开发者ID:jackpoz,项目名称:G3D-backup,代码行数:101,代码来源:Scene.cpp

示例3: create

Scene::Ref Scene::create(const std::string& scene, GCamera& camera) 
{
	if (scene == "") 
	{
		return NULL;
	}

	Scene::Ref s = new Scene();

	const std::string* f = filenameTable().getPointer(scene);
	if (f == NULL) 
	{
		throw "No scene with name '" + scene + "' found in (" + 
			stringJoin(filenameTable().getKeys(), ", ") + ")";
	}
	const std::string& filename = *f;

	Any any;
	any.load(filename);

	// Load the lighting
	s->m_lighting = Lighting::create(any.get("lighting", Lighting::Specification()));

	// Load the models
	Any models = any["models"];
	typedef ReferenceCountedPointer<ReferenceCountedObject> ModelRef;
	Table< std::string, ModelRef > modelTable;
	for (Any::AnyTable::Iterator it = models.table().begin(); it.hasMore(); ++it) {
		ModelRef m;
		Any v = it->value;
		if (v.nameBeginsWith("ArticulatedModel")) {
			m = ArticulatedModel::create(v);
		} else if (v.nameBeginsWith("MD2Model")) {
			m = MD2Model::create(v);
		} else if (v.nameBeginsWith("MD3Model")) {
			m = MD3Model::create(v);
		} else {
			debugAssertM(false, "Unrecognized model type: " + v.name());
		}

		modelTable.set(it->key, m);        
	}

	// Instance the models
	Any entities = any["entities"];
	for (Table<std::string, Any>::Iterator it = entities.table().begin(); it.hasMore(); ++it) {
		const std::string& name = it->key;
		const Any& modelArgs = it->value;

		modelArgs.verifyType(Any::ARRAY);
		const ModelRef* model = modelTable.getPointer(modelArgs.name());
		modelArgs.verify((model != NULL), 
			"Can't instantiate undefined model named " + modelArgs.name() + ".");

		PhysicsFrameSpline frameSpline;
		ArticulatedModel::PoseSpline poseSpline;
		if (modelArgs.size() >= 1) {
			frameSpline = modelArgs[0];
			if (modelArgs.size() >= 2) {
				// Poses 
				poseSpline = modelArgs[1];
			}
		}

		ArticulatedModel::Ref artModel = model->downcast<ArticulatedModel>();
		MD2Model::Ref         md2Model = model->downcast<MD2Model>();
		MD3Model::Ref         md3Model = model->downcast<MD3Model>();

		if (artModel.notNull()) {
			s->m_entityArray.append(Entity::create(name, frameSpline, artModel, poseSpline));
		} else if (md2Model.notNull()) {
			s->m_entityArray.append(Entity::create(name, frameSpline, md2Model));
		} else if (md3Model.notNull()) {
			s->m_entityArray.append(Entity::create(name, frameSpline, md3Model));
		}
	}

	// Load the camera
	camera = any["camera"];

	if (any.containsKey("skybox")) {
		Any sky = any["skyBox"];
		s->m_skyBoxConstant = sky.get("constant", 1.0f);
		if (sky.containsKey("texture")) {
			s->m_skyBoxTexture = Texture::create(sky["texture"]);
		}
	} else {
		s->m_skyBoxTexture = s->m_lighting->environmentMapTexture;
		s->m_skyBoxConstant = s->m_lighting->environmentMapConstant;
	}

	// Default to using the skybox as an environment map if none is specified.
	if (s->m_skyBoxTexture.notNull() && s->m_lighting->environmentMapTexture.isNull()) {
		s->m_lighting->environmentMapTexture  = s->m_skyBoxTexture;
		s->m_lighting->environmentMapConstant = s->m_skyBoxConstant;
	}

	return s;
}
开发者ID:chuckiesmals,项目名称:Thesis,代码行数:99,代码来源:Scene.cpp


注:本文中的Any::containsKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。