Beispiel #1
0
	void MetaBall::write( StreamSerialiser & output ) const
	{
		const Real nRadius = _sphere.getRadius();
		MetaObject::write(output);
		output.write(&_fExcavating);
		output.write(&nRadius);
	}
	//---------------------------------------------------------------------
	void SimplePageContentCollection::save(StreamSerialiser& stream)
	{
		stream.writeChunkBegin(SUBCLASS_CHUNK_ID, SUBCLASS_CHUNK_VERSION);

		for (ContentList::iterator i = mContentList.begin(); i != mContentList.end(); ++i)
			(*i)->save(stream);

		stream.writeChunkEnd(SUBCLASS_CHUNK_ID);
	}
Beispiel #3
0
	void MetaBall::read( StreamSerialiser & input )
	{
		Real nRadius;

		MetaObject::read(input);
		input.read(&_fExcavating);
		input.read(&nRadius);

		_sphere.setRadius(nRadius);
		_sphere.setCenter(_pos);
	}
	//---------------------------------------------------------------------
	bool SimplePageContentCollection::prepare(StreamSerialiser& stream)
	{
		if (!stream.readChunkBegin(SUBCLASS_CHUNK_ID, SUBCLASS_CHUNK_VERSION, "SimplePageContentCollection"))
			return false;

		bool ret = true;
		for (ContentList::iterator i = mContentList.begin(); i != mContentList.end(); ++i)
			ret = (*i)->prepare(stream) && ret;


		stream.readChunkEnd(SUBCLASS_CHUNK_ID);

		return ret;

	}
	//---------------------------------------------------------------------
	bool Page::prepareImpl(StreamSerialiser& stream, PageData* dataToPopulate)
	{

		// Now do the real loading
		if (!stream.readChunkBegin(CHUNK_ID, CHUNK_VERSION, "Page"))
			return false;

		// pageID check (we should know the ID we're expecting)
		uint32 storedID;
		stream.read(&storedID);
		if (mID != storedID)
		{
			LogManager::getSingleton().stream() << "Error: Tried to populate Page ID " << mID
				<< " with data corresponding to page ID " << storedID;
			stream.undoReadChunk(CHUNK_ID);
			return false;
		}

		PageManager* mgr = getManager();
		
		while(stream.peekNextChunkID() == CHUNK_CONTENTCOLLECTION_DECLARATION_ID)
		{
			const StreamSerialiser::Chunk* collChunk = stream.readChunkBegin();
			String factoryName;
			stream.read(&factoryName);
			stream.readChunkEnd(CHUNK_CONTENTCOLLECTION_DECLARATION_ID);
			// Supported type?
			PageContentCollectionFactory* collFact = mgr->getContentCollectionFactory(factoryName);
			if (collFact)
			{
				PageContentCollection* collInst = collFact->createInstance();
				if (collInst->prepare(stream)) // read type-specific data
				{
					dataToPopulate->collectionsToAdd.push_back(collInst);
				}
				else
				{
					LogManager::getSingleton().stream() << "Error preparing PageContentCollection type: " 
						<< factoryName << " in " << *this;
					collFact->destroyInstance(collInst);
				}
			}
			else
			{
				LogManager::getSingleton().stream() << "Unsupported PageContentCollection type: " 
					<< factoryName << " in " << *this;
				// skip
				stream.readChunkEnd(collChunk->id);
			}

		}


		mModified = false;

		return true;
	}
	//---------------------------------------------------------------------
	bool PagedWorld::load(StreamSerialiser& ser)
	{
		if (!ser.readChunkBegin(CHUNK_ID, CHUNK_VERSION, "PagedWorld"))
			return false;

		// Name
		ser.read(&mName);
		// Sections
		while(ser.peekNextChunkID() == CHUNK_SECTIONDECLARATION_ID)
		{
			ser.readChunkBegin();
			String sectionType, sectionName;
			ser.read(&sectionType);
			ser.read(&sectionName);
			ser.readChunkEnd(CHUNK_SECTIONDECLARATION_ID);
			// Scene manager will be loaded
			PagedWorldSection* sec = createSection(0, sectionType, sectionName);
			bool sectionsOk = sec->load(ser);
			if (!sectionsOk)
				destroySection(sec);
		}

		ser.readChunkEnd(CHUNK_ID);

		return true;

	}
Beispiel #7
0
//---------------------------------------------------------------------
void PagedWorldSection::save(StreamSerialiser& ser)
{
    ser.writeChunkBegin(CHUNK_ID, CHUNK_VERSION);

    // Name
    ser.write(&mName);
    // AABB
    ser.write(&mAABB);
    // SceneManager type & name
    ser.write(&mSceneMgr->getTypeName());
    ser.write(&mSceneMgr->getName());
    // Page Strategy Name
    ser.write(&mStrategy->getName());
    // Page Strategy Data
    mStrategyData->save(ser);

    /// Save any data specific to a subtype of this class
    saveSubtypeData(ser);

    ser.writeChunkEnd(CHUNK_ID);

    // save all pages (in separate files)
    for (PageMap::iterator i = mPages.begin(); i != mPages.end(); ++i)
    {
        i->second->save();
    }


}
    //---------------------------------------------------------------------
    void Grid3DPageStrategyData::save(StreamSerialiser& ser)
    {
        ser.writeChunkBegin(CHUNK_ID, CHUNK_VERSION);

        ser.write(&mWorldOrigin);
        ser.write(&mCellSize);
        ser.write(&mLoadRadius);
        ser.write(&mHoldRadius);
        ser.write(&mMinCellX);
        ser.write(&mMaxCellX);
        ser.write(&mMinCellY);
        ser.write(&mMaxCellY);
        ser.write(&mMinCellZ);
        ser.write(&mMaxCellZ);

        ser.writeChunkEnd(CHUNK_ID);
    }
    //---------------------------------------------------------------------
    bool Grid3DPageStrategyData::load(StreamSerialiser& ser)
    {
        if (!ser.readChunkBegin(CHUNK_ID, CHUNK_VERSION, "Grid3DPageStrategyData"))
            return false;

        ser.read(&mOrigin);
        ser.read(&mCellSize);
        ser.read(&mLoadRadius);
        ser.read(&mHoldRadius);
        ser.read(&mMinCellX);
        ser.read(&mMaxCellX);
        ser.read(&mMinCellY);
        ser.read(&mMaxCellY);
        ser.read(&mMinCellZ);
        ser.read(&mMaxCellZ);

        ser.readChunkEnd(CHUNK_ID);

        return true;
    }
Beispiel #10
0
//---------------------------------------------------------------------
bool PagedWorldSection::load(StreamSerialiser& ser)
{
    if (!ser.readChunkBegin(CHUNK_ID, CHUNK_VERSION, "PagedWorldSection"))
        return false;

    // Name
    ser.read(&mName);
    // AABB
    ser.read(&mAABB);
    // SceneManager type
    String smType, smInstanceName;
    SceneManager* sm = 0;
    ser.read(&smType);
    ser.read(&smInstanceName);
    Root& root = Root::getSingleton();
    if (root.hasSceneManager(smInstanceName))
        sm = root.getSceneManager(smInstanceName);
    else
        sm = root.createSceneManager(smType, smInstanceName);
    setSceneManager(sm);
    // Page Strategy Name
    String stratname;
    ser.read(&stratname);
    setStrategy(stratname);
    // Page Strategy Data
    bool strategyDataOk = mStrategyData->load(ser);
    if (!strategyDataOk)
        LogManager::getSingleton().stream() << "Error: PageStrategyData for section '"
                                            << mName << "' was not loaded correctly, check file contents";

    /// Load any data specific to a subtype of this class
    loadSubtypeData(ser);

    ser.readChunkEnd(CHUNK_ID);

    return true;

}
	//---------------------------------------------------------------------
	void PagedWorld::save(StreamSerialiser& ser)
	{
		ser.writeChunkBegin(CHUNK_ID, CHUNK_VERSION);

		// Name
		ser.write(&mName);
		// Sections
		for (SectionMap::iterator i = mSections.begin(); i != mSections.end(); ++i)
		{
			PagedWorldSection* sec = i->second;
			// declaration
			ser.writeChunkBegin(CHUNK_SECTIONDECLARATION_ID);
			ser.write(&sec->getType());
			ser.write(&sec->getName());
			ser.writeChunkEnd(CHUNK_SECTIONDECLARATION_ID);
			// data
			i->second->save(ser);
		}

		ser.writeChunkEnd(CHUNK_ID);
	}
Beispiel #12
0
	//---------------------------------------------------------------------
	void Page::save(StreamSerialiser& stream)
	{
		stream.writeChunkBegin(CHUNK_ID, CHUNK_VERSION);

		// page id
		stream.write(&mID);

		// content collections
		for (ContentCollectionList::iterator i = mContentCollections.begin();
			i != mContentCollections.end(); ++i)
		{
			// declaration
			stream.writeChunkBegin(CHUNK_CONTENTCOLLECTION_DECLARATION_ID);
			stream.write(&(*i)->getType());
			stream.writeChunkEnd(CHUNK_CONTENTCOLLECTION_DECLARATION_ID);
			// data
			(*i)->save(stream);
		}

		stream.writeChunkEnd(CHUNK_ID);

		mModified = false;
	}