Example #1
0
    BitmapTexture(Stream *stream, InstanceManager *manager)
        : Texture2D(stream, manager) {
        m_filename = stream->readString();
        Log(EInfo, "Unserializing texture \"%s\"", m_filename.leaf().c_str());
        m_gamma = stream->readFloat();
        m_format = static_cast<Bitmap::EFileFormat>(stream->readInt());
        m_filterType = (MIPMap::EFilterType) stream->readInt();
        m_wrapMode = (MIPMap::EWrapMode) stream->readUInt();
        m_maxAnisotropy = stream->readFloat();
        uint32_t size = stream->readUInt();
        ref<MemoryStream> mStream = new MemoryStream(size);
        stream->copyTo(mStream, size);
        mStream->setPos(0);
        ref<Bitmap> bitmap = new Bitmap(m_format, mStream);
        initializeFrom(bitmap);

        if (Scheduler::getInstance()->hasRemoteWorkers()
                && !fs::exists(m_filename)) {
            /* This code is running on a machine different from
               the one that created the stream. Because we might
               later have to handle a call to serialize(), the
               whole bitmap must be kept in memory */
            m_stream = mStream;
            m_stream->setPos(0);
        }
    }
Example #2
0
    BitmapTexture(const Properties &props) : Texture2D(props) {
        m_filename = Thread::getThread()->getFileResolver()->resolve(
                         props.getString("filename"));

        /* -1 means sRGB. Gamma is ignored when loading EXR files */
        m_gamma = props.getFloat("gamma", -1);
        Log(EInfo, "Loading texture \"%s\"", m_filename.leaf().c_str());

        ref<FileStream> fs = new FileStream(m_filename, FileStream::EReadOnly);
        std::string extension = boost::to_lower_copy(m_filename.extension());
        std::string filterType = boost::to_lower_copy(props.getString("filterType", "ewa"));
        std::string wrapMode = boost::to_lower_copy(props.getString("wrapMode", "repeat"));

        if (filterType == "ewa")
            m_filterType = MIPMap::EEWA;
        else if (filterType == "trilinear")
            m_filterType = MIPMap::ETrilinear;
        else if (filterType == "none")
            m_filterType = MIPMap::ENone;
        else
            Log(EError, "Unknown filter type '%s' -- must be "
                "'ewa', 'isotropic', or 'none'!", filterType.c_str());

        if (wrapMode == "repeat")
            m_wrapMode = MIPMap::ERepeat;
        else if (wrapMode == "clamp")
            m_wrapMode = MIPMap::EClamp;
        else if (wrapMode == "black")
            m_wrapMode = MIPMap::EBlack;
        else if (wrapMode == "white")
            m_wrapMode = MIPMap::EWhite;
        else
            Log(EError, "Unknown wrap mode '%s' -- must be "
                "'repeat', 'clamp', 'black', or 'white'!", filterType.c_str());

        m_maxAnisotropy = props.getFloat("maxAnisotropy", 8);

        if (extension == ".exr")
            m_format = Bitmap::EEXR;
        else if (extension == ".jpg" || extension == ".jpeg")
            m_format = Bitmap::EJPEG;
        else if (extension == ".png")
            m_format = Bitmap::EPNG;
        else if (extension == ".tga")
            m_format = Bitmap::ETGA;
        else if (extension == ".bmp")
            m_format = Bitmap::EBMP;
        else
            Log(EError, "Cannot deduce the file type of '%s'!", m_filename.file_string().c_str());

        ref<Bitmap> bitmap = new Bitmap(m_format, fs);
        initializeFrom(bitmap);
    }
	DiffusionTexture(Stream *stream, InstanceManager *manager) 
	 : Texture2D(stream, manager) {
		m_filename = stream->readString();
		Log(EInfo, "Unserializing texture \"%s\"", m_filename.leaf().c_str());
		stream->writeInt(m_filterType);
		stream->writeUInt(m_wrapMode);
		stream->writeFloat(m_maxAnisotropy);
		int size = stream->readInt();
		ref<MemoryStream> mStream = new MemoryStream(size);
		stream->copyTo(mStream, size);
		mStream->setPos(0);
		ref<Bitmap> bitmap = new Bitmap(Bitmap::EEXR, mStream);
        initializeFrom(bitmap, false);
	}
	DiffusionTexture(const Properties &props) : Texture2D(props) {
		std::string filterType = props.getString("filterType", "ewa");
		std::string wrapMode = props.getString("wrapMode", "repeat");

		if (filterType == "ewa")
			m_filterType = MIPMap::EEWA;
		else if (filterType == "trilinear")
			m_filterType = MIPMap::ETrilinear;
		else if (filterType == "none")
			m_filterType = MIPMap::ENone;
		else
			Log(EError, "Unknown filter type '%s' -- must be "
				"'ewa', 'isotropic', or 'none'!", filterType.c_str());

		if (wrapMode == "repeat")
			m_wrapMode = MIPMap::ERepeat;
		else if (wrapMode == "clamp")
			m_wrapMode = MIPMap::EClamp;
		else if (wrapMode == "black")
			m_wrapMode = MIPMap::EBlack;
		else if (wrapMode == "white")
			m_wrapMode = MIPMap::EWhite;
		else
			Log(EError, "Unknown wrap mode '%s' -- must be "
				"'repeat', 'clamp', 'black', or 'white'!", filterType.c_str());

		m_maxAnisotropy = props.getFloat("maxAnisotropy", 8);

        bool loadDataManually = props.getBoolean("loadDataManually", false);

        if (!loadDataManually) {
            m_filename = Thread::getThread()->getFileResolver()->resolve(
                props.getString("filename"));
            Log(EInfo, "Loading texture \"%s\"", m_filename.leaf().c_str());

            ref<FileStream> fs = new FileStream(m_filename, FileStream::EReadOnly);
        
            ref<Bitmap> bitmap = new Bitmap(Bitmap::EEXR, fs);
            initializeFrom(bitmap, false);
        }
	}
Example #5
0
IRResultType
LoadTimeFunction :: initializeFrom(InputRecord *ir, DataReader *dr)
{
    return initializeFrom(ir);
}
Example #6
0
void
UndoDependentData::initializeFrom(const CReaction* pObject)
{
  initializeFrom(pObject->getDeletedObjects());
}
Example #7
0
void
UndoDependentData::initializeFrom(const CModelEntity* pObject)
{
  initializeFrom(pObject->getDeletedObjects());
}