Ejemplo n.º 1
0
void LodComponent::Deserialize(KeyedArchive *archive, SceneFileV2 *sceneFile)
{
	if(NULL != archive)
	{
		if(archive->IsKeyExists("lc.flags")) flags = archive->GetUInt32("lc.flags");
		if(archive->IsKeyExists("lc.forceDistance")) forceDistance = archive->GetFloat("lc.forceDistance");
		if(archive->IsKeyExists("lc.forceDistanceSq")) forceDistanceSq = archive->GetFloat("lc.forceDistanceSq");
		if(archive->IsKeyExists("lc.forceLodLayer")) forceLodLayer = archive->GetInt32("lc.forceLodLayer");

		KeyedArchive *lodDistArch = archive->GetArchive("lc.loddist");
		if(NULL != lodDistArch)
		{
			for(uint32 i = 0; i < MAX_LOD_LAYERS; ++i)
			{
				KeyedArchive *lodDistValuesArch = lodDistArch->GetArchive(KeyedArchive::GenKeyFromIndex(i));
				if(NULL != lodDistValuesArch)
				{
					lodLayersArray[i].distance = lodDistValuesArch->GetFloat("ld.distance");
					lodLayersArray[i].nearDistance = lodDistValuesArch->GetFloat("ld.neardist");
					lodLayersArray[i].farDistance = lodDistValuesArch->GetFloat("ld.fardist");
					lodLayersArray[i].nearDistanceSq = lodDistValuesArch->GetFloat("ld.neardistsq");
					lodLayersArray[i].farDistanceSq = lodDistValuesArch->GetFloat("ld.fardistsq");
				}
			}
		}

		KeyedArchive *lodDataArch = archive->GetArchive("lc.loddata");
		if(NULL != lodDataArch)
		{
			for(uint32 i = 0; i < archive->GetUInt32("lc.loddatacount"); ++i)
			{
				KeyedArchive *lodDataValuesArch = lodDataArch->GetArchive(KeyedArchive::GenKeyFromIndex(i));
				if(NULL != lodDataValuesArch)
				{
					LodData data;

					if(lodDataValuesArch->IsKeyExists("layer")) data.layer = lodDataValuesArch->GetInt32("layer");
					if(lodDataValuesArch->IsKeyExists("isdummy")) data.isDummy = lodDataValuesArch->GetBool("isdummy");

					KeyedArchive *lodDataIndexesArch = lodDataValuesArch->GetArchive("indexes");
					if(NULL != lodDataIndexesArch)
					{
						for(uint32 j = 0; j < lodDataValuesArch->GetUInt32("indexescount"); ++j)
						{
							data.indexes.push_back(lodDataIndexesArch->GetInt32(KeyedArchive::GenKeyFromIndex(j)));
						}
					}

					lodLayers.push_back(data);
				}
			}
		}
	}

	flags |= NEED_UPDATE_AFTER_LOAD;
	Component::Deserialize(archive, sceneFile);
}
Ejemplo n.º 2
0
void RenderObject::Load(KeyedArchive * archive, SceneFileV2 *sceneFile)
{
    if(NULL != archive)
    {
        if(archive->IsKeyExists("ro.type")) type = archive->GetUInt32("ro.type");
        if(archive->IsKeyExists("ro.flags")) flags = archive->GetUInt32("ro.flags");
        if(archive->IsKeyExists("ro.debugflags")) debugFlags = archive->GetUInt32("ro.debugflags");

        if(archive->IsKeyExists("ro.batchCount"))
        {
            KeyedArchive *batchesArch = archive->GetArchive("ro.batches");
            for(uint32 i = 0; i < archive->GetUInt32("ro.batchCount"); ++i)
            {
                KeyedArchive *batchArch = batchesArch->GetArchive(KeyedArchive::GenKeyFromIndex(i));
                if(NULL != batchArch)
                {
                    RenderBatch *batch = (RenderBatch *) ObjectFactory::Instance()->New(batchArch->GetString("rb.classname"));
                    if(NULL != batch)
                    {
                        batch->Load(batchArch, sceneFile);
                        AddRenderBatch(batch);
                        batch->Release();
                    }
                }
            }
        }
    }

    AnimatedObject::Load(archive);
}