//----------------------------------------------------------------------------//
void OgreResourceProvider::loadRawDataContainer(const String& filename,
                                                RawDataContainer& output,
                                                const String& resourceGroup)
{
    String orpGroup;
    if (resourceGroup.empty())
        orpGroup = d_defaultResourceGroup.empty() ?
            Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME.c_str() :
            d_defaultResourceGroup;
    else
        orpGroup = resourceGroup;

    Ogre::DataStreamPtr input = Ogre::ResourceGroupManager::getSingleton().
        openResource(filename.c_str(), orpGroup.c_str());

    if (input.isNull())
        CEGUI_THROW(InvalidRequestException(
            "Unable to open resource file '" + filename +
            "' in resource group '" + orpGroup + "'."));

    Ogre::String buf = input->getAsString();
    const size_t memBuffSize = buf.length();

    unsigned char* mem = new unsigned char[memBuffSize];
    memcpy(mem, buf.c_str(), memBuffSize);

    output.setData(mem);
    output.setSize(memBuffSize);
}
예제 #2
0
	virtual Ogre::GpuProgramPtr generateFragmentShader(Perm permutation)
	{
		/// Create shader
		if (mMasterSource.empty())
		{
			Ogre::DataStreamPtr ptrMasterSource = Ogre::ResourceGroupManager::getSingleton().openResource(
				 "DeferredShading/post/LightMaterial_ps.cg"
				, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
			assert(ptrMasterSource.isNull()==false);
			mMasterSource = ptrMasterSource->getAsString();
		}

		assert(mMasterSource.empty()==false);

		// Create name
		Ogre::String name = mBaseName+Ogre::StringConverter::toString(permutation)+"_ps";		

		// Create shader object
		Ogre::HighLevelGpuProgramPtr ptrProgram = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram(
			name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
			"cg", Ogre::GPT_FRAGMENT_PROGRAM);
		ptrProgram->setSource(mMasterSource);
		ptrProgram->setParameter("entry_point","main");
	    ptrProgram->setParameter("profiles","ps_2_x arbfp1");
		// set up the preprocessor defines
		// Important to do this before any call to get parameters, i.e. before the program gets loaded
		ptrProgram->setParameter("compile_arguments", getPPDefines(permutation));

		setUpBaseParameters(ptrProgram->getDefaultParameters());

		return Ogre::GpuProgramPtr(ptrProgram);
	}
void OgreNetworkReply::abort()
{
    if (!mDataStream.isNull()) {
        mDataStream->close();
        mDataStream.setNull();
    }
}
예제 #4
0
bool gkAndroidApp::setup(void) {
    AAssetManager* assetMgr = m_state->activity->assetManager;
    if (assetMgr) {
        Ogre::ArchiveManager::getSingleton().addArchiveFactory(new Ogre::APKFileSystemArchiveFactory(assetMgr));
        Ogre::ArchiveManager::getSingleton().addArchiveFactory(new Ogre::APKZipArchiveFactory(assetMgr));
        Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/", "APKFileSystem",
                Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    }

    Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().
            openResource(m_blend, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    if (stream.isNull()) {
        gkPrintf("Error: Can't open file %s.\n", m_blend.c_str());
        return false;
    }

    size_t size = stream->size();
    char* buf = new char[size];
    stream->read(buf, size);

    gkBlendFile* blend = gkBlendLoader::getSingleton().loadFromMemory(buf,size,gkBlendLoader::LO_ALL_SCENES);
    gkScene* scene = blend->getMainScene();
    if (!scene) {
        gkPrintf("No usable scenes found in blend.\n");
        return false;
    }

    scene->createInstance();
    scene->getMainCamera()->getCamera()->setAutoAspectRatio(true);

    return true;
}
예제 #5
0
// OgreScriptBuilder
int OgreScriptBuilder::LoadScriptSection(const char* full_path_cstr)
{
    // Get filename - required to retrieve file from OGRe's resource system.
    //  This function received filename in older AngelScript versions, but now receives full path
    //      (reconstructed wrong by CScriptBuilder because it doesn't know about OGRE's ZIP files).
    //  TODO: Refactor the entire script building logic 
    //      - create fully RoR-custom builder instead of hacked stock CScriptBuilder + our overload. ~ only_a_ptr, 08/2017

    std::string full_path(full_path_cstr);
    std::string filename;
    size_t slash_pos = full_path.rfind('/'); // AngelScript always uses forward slashes in paths.
    if (slash_pos != std::string::npos)
    {
        filename = full_path.substr(slash_pos+1);
    }
    else
    {
        filename = full_path;
    }

    Ogre::DataStreamPtr ds;
    try
    {
        ds = Ogre::ResourceGroupManager::getSingleton().openResource(filename, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
                 //TODO: do not use `AUTODETECT_RESOURCE_GROUP_NAME`, use specific group, lookups are slow!
                 //see also https://github.com/OGRECave/ogre/blob/master/Docs/1.10-Notes.md#resourcemanager-strict-mode ~ only_a_ptr, 08/2017
    }
    catch (Ogre::Exception e)
    {
        LOG("[RoR|Scripting] exception upon loading script file '"+filename+"', message: " + e.getFullDescription());
        return -1;
    }
    // In some cases (i.e. when fed a full path with '/'-s on Windows), `openResource()` will silently return NULL for datastream. ~ only_a_ptr, 08/2017
    if (ds.isNull())
    {
        LOG("[RoR|Scripting] Failed to load file '"+filename+"', reason unknown.");
        return -1;
    }

    // Read the entire file
    std::string code;
    code.resize(ds->size());
    ds->read(&code[0], ds->size());

    // hash it
    {
        char hash_result[250];
        memset(hash_result, 0, 249);
        RoR::CSHA1 sha1;
        sha1.UpdateHash((uint8_t *)code.c_str(), (uint32_t)code.size());
        sha1.Final();
        sha1.ReportHash(hash_result, RoR::CSHA1::REPORT_HEX_SHORT);
        hash = Ogre::String(hash_result);
    }

    return ProcessScriptSection(code.c_str(), code.length(), filename.c_str(), 0);
}
예제 #6
0
	Ogre::DataStreamPtr Utf8Archive::open(const String& _filename, bool _readOnly) const
    {
		String filename2 = _filename;
		StringUtil::utf8ToAnsi(filename2);
		Ogre::DataStreamPtr stream = mBaseArchive->open(filename2, _readOnly);
		if(!stream.isNull())
			static_cast<DataStream_NameHelper*>(stream.get())->setName(_filename);
		return stream;
    }
예제 #7
0
Rocket::Core::FileHandle RocketInterface::Open(const Rocket::Core::String& path)
{
    Ogre::DataStreamPtr stream =
        Ogre::ResourceGroupManager::getSingleton().openResource(path.CString());

    if (stream.isNull())
        return 0;

    return reinterpret_cast<Rocket::Core::FileHandle>(new Ogre::DataStreamPtr(stream));
}
예제 #8
0
	virtual Ogre::GpuProgramPtr generateFragmentShader(Perm permutation)
	{
		/// Create shader
		if (mMasterSource.empty())
		{
			Ogre::DataStreamPtr ptrMasterSource;
            if(Ogre::GpuProgramManager::getSingleton().isSyntaxSupported("glsles"))
                ptrMasterSource = Ogre::ResourceGroupManager::getSingleton().openResource("DeferredShading/post/LightMaterial_ps.glsles",
                                                                                    Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
            else
                ptrMasterSource = Ogre::ResourceGroupManager::getSingleton().openResource("DeferredShading/post/LightMaterial_ps.glsl",
                                                                                    Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

			assert(ptrMasterSource.isNull()==false);
			mMasterSource = ptrMasterSource->getAsString();
		}

		assert(mMasterSource.empty()==false);

		// Create name
		Ogre::String name = mBaseName+Ogre::StringConverter::toString(permutation)+"_ps";

		// Create shader object
		Ogre::HighLevelGpuProgramPtr ptrProgram;
        if(Ogre::GpuProgramManager::getSingleton().isSyntaxSupported("glsles"))
        {
            ptrProgram = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram(name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                                                                                  "glsles", Ogre::GPT_FRAGMENT_PROGRAM);
            ptrProgram->setParameter("profiles", "glsles");
        }
        else
        {
            ptrProgram = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram(name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                                                                                  "glsl", Ogre::GPT_FRAGMENT_PROGRAM);
            ptrProgram->setParameter("profiles", "glsl150");
        }
        ptrProgram->setSource(mMasterSource);
		// set up the preprocessor defines
		// Important to do this before any call to get parameters, i.e. before the program gets loaded
		ptrProgram->setParameter("preprocessor_defines", getPPDefines(permutation));

		setUpBaseParameters(ptrProgram->getDefaultParameters());

        // Bind samplers
		Ogre::GpuProgramParametersSharedPtr params = ptrProgram->getDefaultParameters();
        int numSamplers = 0;
        params->setNamedConstant("Tex0", (int)numSamplers++);
        params->setNamedConstant("Tex1", (int)numSamplers++);

        if(permutation & LightMaterialGenerator::MI_SHADOW_CASTER)
            params->setNamedConstant("ShadowTex", (int)numSamplers++);

		return Ogre::GpuProgramPtr(ptrProgram);
	}
qint64 OgreNetworkReply::readData(char *data, qint64 maxSize)
{
    if (mDataStream.isNull()) {
        setErrorString("This network request is closed.");
        return -1;
    }

    if (mDataStream->eof())
        return -1;

    return mDataStream->read(data, maxSize);
}
예제 #10
0
void UnloadMaterials(const std::string& filename)
{
    if (filename.empty())
    {
        Ogre::LogManager::getSingleton().logMessage("Filename is empty.");
        return;
    }
 
    Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(filename);
    if(!stream.isNull())
    {
        try
        {
            while(!stream->eof())
            {
                std::string line = stream->getLine();
                StringUtil::trim(line);
 
                ///
                /// UNLOAD MATERIALS
                ///
                if (StringUtil::startsWith(line, "material"))
                {
                    Ogre::vector<Ogre::String>::type vec = StringUtil::split(line," \t:");
                    bool skipFirst = true;
                    for (Ogre::vector<Ogre::String>::type::iterator it = vec.begin(); it < vec.end(); ++it)
                    {
                        if (skipFirst)
                        {
                            skipFirst = false;
                            continue;
                        }
                        std::string match = (*it);
                        StringUtil::trim(match);
                        if (!match.empty())
                        {
                            UnloadResource(Ogre::MaterialManager::getSingletonPtr(), match);
                            break;
                        }
                    }
                }
            }
        }
        catch (Ogre::Exception &e)
        {
            StringUtil::StrStreamType msg;
            msg << "Exception: FILE: " << __FILE__ << " LINE: " << __LINE__ << " DESC: " << e.getFullDescription() << std::endl;
            Ogre::LogManager::getSingleton().logMessage(msg.str());
        }
    }
    stream->close();
}
예제 #11
0
ResourceWrapper OgreResourceProvider::getResource(const std::string& name)
{
  Ogre::DataStreamPtr input = Ogre::ResourceGroupManager::getSingleton().openResource(name, mGroupName);

  if (input.isNull()) {
    throw Exception("Unable to open resource file '" + name + "' in resource group '" + name + "'.");
  }
  OgreResourceWrapper* wrapper = new OgreResourceWrapper(input);
  input->close();
  return ResourceWrapper(wrapper, name);

// 	Ogre::String buf = input->getAsString();
// 	const size_t memBuffSize = buf.length();
//
// 	unsigned char* mem = new unsigned char[memBuffSize];
// 	memcpy(mem, buf.c_str(), memBuffSize);
//
// 	output.setData(mem);
// 	output.setSize(memBuffSize);
}
예제 #12
0
void ReloadMaterial(const std::string& materialName, const std::string& groupName, const std::string& filename, bool parseMaterialScript)
{
    if (materialName.empty())
    {
        Ogre::LogManager::getSingleton().logMessage("Material name is empty.");
        return;
    }
 
    if (groupName.empty())
    {
        Ogre::LogManager::getSingleton().logMessage("Group name is empty.");
        return;
    }
 
    if (filename.empty())
    {
        Ogre::LogManager::getSingleton().logMessage("Filename is empty.");
        return;
    }
 
    UnloadMaterials(filename);
    UnloadVertexPrograms(filename);
    UnloadFragmentPrograms(filename);
 
    if (parseMaterialScript)
    {
        Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(filename);
        if(!stream.isNull())
        {
            try
            {
                Ogre::MaterialManager::getSingleton().parseScript(stream, groupName);
                Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(materialName);
                if (!materialPtr.isNull())
                {
                    materialPtr->compile();
                    materialPtr->load();
                }
            }
            catch (Ogre::Exception &e)
            {
                StringUtil::StrStreamType msg;
                msg << "Exception: FILE: " << __FILE__ << " LINE: " << __LINE__ << " DESC: " << e.getFullDescription() << std::endl;
                Ogre::LogManager::getSingleton().logMessage(msg.str());
            }
        }
        stream->close();
 
        ///
        /// RELOAD MATERIAL SCRIPT CONTENTS
        ///
        stream = Ogre::ResourceGroupManager::getSingleton().openResource(filename);
        if(!stream.isNull())
        {
            try
            {
                ///
                /// RELOAD ALL MATERIAL CONTENTS IN FILE
                ///
                while(!stream->eof())
                {
                    std::string line = stream->getLine();
                    StringUtil::trim(line);
                    ///
                    /// RELOAD MATERIALS
                    ///
                    if (StringUtil::startsWith(line, "material"))
                    {
                        Ogre::vector<Ogre::String>::type vec = StringUtil::split(line," \t:");
                        bool skipFirst = true;
                        for (Ogre::vector<Ogre::String>::type::iterator it = vec.begin(); it < vec.end(); ++it)
                        {
                            if (skipFirst)
                            {
                                skipFirst = false;
                                continue;
                            }
                            std::string match = (*it);
                            StringUtil::trim(match);
                            if (!match.empty())
                            {
                                LoadResource(Ogre::MaterialManager::getSingletonPtr(), match, groupName);
                                break;
                            }
                        }
                    }
                    ///
                    /// RELOAD VERTEX PROGRAMS
                    ///
                    if (StringUtil::startsWith(line, "vertex_program") && !StringUtil::startsWith(line, "vertex_program_ref"))
                    {
                        Ogre::vector<Ogre::String>::type vec = StringUtil::split(line," \t");
                        bool skipFirst = true;
                        for (Ogre::vector<Ogre::String>::type::iterator it = vec.begin(); it < vec.end(); ++it)
                        {
                            if (skipFirst)
                            {
                                skipFirst = false;
                                continue;
                            }
                            std::string match = (*it);
                            StringUtil::trim(match);
                            if (!match.empty())
                            {
                                LoadResource(Ogre::HighLevelGpuProgramManager::getSingletonPtr(), match, groupName);
                                break;
                            }
                        }
                    }
                    ///
                    /// RELOAD FRAGMENT PROGRAMS
                    ///
                    if (StringUtil::startsWith(line, "fragment_program") && !StringUtil::startsWith(line, "fragment_program_ref"))
                    {
                        Ogre::vector<Ogre::String>::type vec = StringUtil::split(line," \t");
                        bool skipFirst = true;
                        for (Ogre::vector<Ogre::String>::type::iterator it = vec.begin(); it < vec.end(); ++it)
                        {
                            if (skipFirst)
                            {
                                skipFirst = false;
                                continue;
                            }
                            std::string match = (*it);
                            StringUtil::trim(match);
                            if (!match.empty())
                            {
                                LoadResource(Ogre::HighLevelGpuProgramManager::getSingletonPtr(), match, groupName);
                                break;
                            }
                        }
                    }
                }
            }
            catch (Ogre::Exception &e)
            {
                StringUtil::StrStreamType msg;
                msg << "Exception: FILE: " << __FILE__ << " LINE: " << __LINE__ << " DESC: " << e.getFullDescription() << std::endl;
                Ogre::LogManager::getSingleton().logMessage(msg.str());
            }
        }
        stream->close();
 
        try
        {
            // Do a render test if it fails, leave materials unloaded
            Ogre::Root::getSingleton().renderOneFrame();
            return;
        }
        catch (Ogre::Exception &e)
        {
            UnloadVertexPrograms(filename);
 
            StringUtil::StrStreamType msg;
            msg << "Render test failed. Unloading vertex programs." << std::endl;
            msg << "Exception: FILE: " << __FILE__ << " LINE: " << __LINE__ << " DESC: " << e.getFullDescription() << std::endl;
            Ogre::LogManager::getSingleton().logMessage(msg.str());
        }
 
        try
        {
            // Do a render test if it fails, leave materials unloaded
            Ogre::Root::getSingleton().renderOneFrame();
        }
        catch (Ogre::Exception &e)
        {
            // Don't load the script this time
            ReloadMaterial(materialName, groupName, filename, false);
 
            StringUtil::StrStreamType msg;
            msg << "Render test failed. Unloading materials." << std::endl;
            msg << "Exception: FILE: " << __FILE__ << " LINE: " << __LINE__ << " DESC: " << e.getFullDescription() << std::endl;
            Ogre::LogManager::getSingleton().logMessage(msg.str());
        }
    }
}
예제 #13
0
int decode_thread(void *arg) {

  VideoState *is = (VideoState *)arg;
  AVFormatContext *pFormatCtx = avformat_alloc_context ();
  AVPacket pkt1, *packet = &pkt1;

  int video_index = -1;
  int audio_index = -1;
  int i;

  is->videoStream=-1;
  is->audioStream=-1;
  is->quit = 0;

  Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton ().openResource (is->resourceName);
  if(stream.isNull ())
    throw std::runtime_error("Failed to open video resource");
  is->stream = stream;

  AVIOContext	 *ioContext = 0;

  ioContext = avio_alloc_context(NULL, 0, 0, is, OgreResource_Read, OgreResource_Write, OgreResource_Seek);
  if (!ioContext)
    throw std::runtime_error("Failed to allocate ioContext ");

  pFormatCtx->pb = ioContext;

  global_video_state = is;
  // will interrupt blocking functions if we quit!
  //url_set_interrupt_cb(decode_interrupt_cb);

  // Open video file
  /// \todo leak here, ffmpeg or valgrind bug ?
  if (avformat_open_input(&pFormatCtx, is->resourceName.c_str(), NULL, NULL))
    throw std::runtime_error("Failed to open video input");

  // Retrieve stream information
  if(avformat_find_stream_info(pFormatCtx, NULL)<0)
    throw std::runtime_error("Failed to retrieve stream information");

  // Dump information about file onto standard error
  av_dump_format(pFormatCtx, 0, is->resourceName.c_str(), 0);

  for(i=0; i < (int)pFormatCtx->nb_streams; i++) {
    if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO &&
       video_index < 0) {
      video_index=i;
    }
    if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO &&
       audio_index < 0) {
      audio_index=i;
    }
  }

  if(audio_index >= 0) {
    stream_component_open(is, audio_index, pFormatCtx);
  }
  if(video_index >= 0) {
    stream_component_open(is, video_index, pFormatCtx);
  }

  if(is->videoStream >= 0 /*|| is->audioStream < 0*/)
  {

    // main decode loop

    for(;;) {
      if(is->quit) {
        break;
      }
      if( (is->audioStream >= 0 && is->audioq.size > MAX_AUDIOQ_SIZE) ||
         is->videoq.size > MAX_VIDEOQ_SIZE) {
        boost::this_thread::sleep(boost::posix_time::milliseconds(10));
        continue;
      }
      if(av_read_frame(pFormatCtx, packet) < 0) {
        break;
      }
      // Is this a packet from the video stream?
      if(packet->stream_index == is->videoStream) {
        packet_queue_put(&is->videoq, packet);
      } else if(packet->stream_index == is->audioStream) {
        packet_queue_put(&is->audioq, packet);
      } else {
        av_free_packet(packet);
      }
    }
    /* all done - wait for it */
    while(!is->quit) {
      // EOF reached, all packets processed, we can exit now
      if (is->audioq.nb_packets == 0 && is->videoq.nb_packets == 0)
        break;
      boost::this_thread::sleep(boost::posix_time::milliseconds(100));
    }
  }

  is->quit = 1;

  is->audioq.cond.notify_one();
  is->videoq.cond.notify_one();
 
  if (is->video_thread.joinable())
	is->video_thread.join();

  if (is->audioStream >= 0)
    avcodec_close(is->audio_st->codec);
  if (is->videoStream >= 0)
    avcodec_close(is->video_st->codec);

  sws_freeContext (is->sws_context);
  avformat_close_input(&pFormatCtx);
  pFormatCtx = NULL;

  av_free(ioContext);

  return 0;
}
bool FvFTDTerrainPageSerializerImpl::ImportTerrainPage(
	Ogre::DataStreamPtr &kStream, FvTerrainPage *pkDest)
{
	if(kStream.isNull() || kStream->eof())
		return false;

	FTDTerrainHeader kFTDHeader;
	kStream->read(&kFTDHeader,sizeof(FTDTerrainHeader));
	if(kFTDHeader.m_uiIdentify != FTDTerrainHeader::IDENTIFY)
	{
		return false;
	}

	FTDChunkHeader kChunkHeader;
	char *pcTempData = new char[409600];
	while(!kStream->eof())
	{
		if(kStream->read(&kChunkHeader,sizeof(FTDChunkHeader))
			!= sizeof(FTDChunkHeader))
			continue;

		FV_ASSERT(kChunkHeader.m_uiSize < 409600);
		if(kStream->read(pcTempData,kChunkHeader.m_uiSize)
			!= kChunkHeader.m_uiSize)
			continue;

		Ogre::DataStreamPtr spData(OGRE_NEW Ogre::MemoryDataStream(pcTempData,
			kChunkHeader.m_uiSize));
		switch(kChunkHeader.m_uiID)
		{
		case ID_HEIGHTS:
		case ID_HEIGHTS_1:
		case ID_HEIGHTS_2:
		case ID_HEIGHTS_3:
		case ID_HEIGHTS_4:
		case ID_HEIGHTS_5:
		case ID_HEIGHTS_6:
			{
				FvUInt32 uiLodLevel = kChunkHeader.m_uiID - ID_HEIGHTS;
				if(uiLodLevel == pkDest->m_spTerrainSettings->DefaultHeightMapLod())
					this->ReadHeightMap(spData,pkDest,uiLodLevel);
			}
			break;
		case ID_HOLE_MAP:
			this->ReadHoleMap(pcTempData,kChunkHeader.m_uiSize,pkDest);
			break;
		case ID_DOMINANT_TEXUTRES:
			this->ReadDominantTextureMap(pcTempData,kChunkHeader.m_uiSize,pkDest);
			break;
#ifndef FV_SERVER
		case ID_NORMALS:
			this->ReadNormalMap(spData,pkDest);
			break;
		case ID_LOD_TEXTURE:
			this->ReadLodTextureMap(spData,pkDest);
			break;
		case ID_LOD_NORMALS:
			this->ReadLodNormalMap(spData,pkDest);
			break;
		case ID_HORIZON_SHADOWS:
			this->ReadHorizonShadowMap(pcTempData,kChunkHeader.m_uiSize,pkDest);
			break;
		case ID_THUMBNAIL:
			break;
		default:
			if(kChunkHeader.m_uiID >= ID_LAYER_BEGIN)
			{
				this->ReadLayerMap(spData,pkDest,kChunkHeader.m_uiID - ID_LAYER_BEGIN);
			}
			break;
#endif // !FV_SERVER
		}
	}
	delete[] pcTempData;

	if(pkDest->m_kMaterialNames.size() == 0)
		pkDest->m_eOceanType = FvTerrainPage::OCEAN_TYPE_ONLY;

	for(size_t i = 0; i < pkDest->m_kMaterialNames.size(); i++)
	{
		FV_ASSERT(pkDest->m_spTerrainSettings);
		FV_ASSERT(!pkDest->m_kMaterialNames[i].empty());
		if(pkDest->m_spTerrainSettings->IsOceanMap(
			pkDest->m_kMaterialNames[i]))
		{
			pkDest->m_eOceanType = FvTerrainPage::OCEAN_TYPE_LAND;
			break;
		}
	}

	if(pkDest->m_kHeights.getData() == NULL)
		return false;

#ifndef FV_SERVER
	pkDest->GenerateCombinedLayers();
	pkDest->GenerateMaterial();
#endif // !FV_SERVER

	return true;
}
qint64 OgreNetworkReply::bytesAvailable() const
{
    if (mDataStream.isNull())
        return 0;
    return QNetworkReply::bytesAvailable() + mDataStream->size() - mDataStream->tell();
}
예제 #16
0
파일: Main.cpp 프로젝트: Ali-il/gamekit
bool OgreKit::setup(void)
{
	LOG_FOOT;
	  
	if (assetMgr)
	{
#if USE_APK_ARCHIVE
		Ogre::ArchiveManager::getSingleton().addArchiveFactory(new Ogre::APKFileSystemArchiveFactory(assetMgr));
		Ogre::ArchiveManager::getSingleton().addArchiveFactory(new Ogre::APKZipArchiveFactory(assetMgr));

		Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/", "APKFileSystem",  Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
#endif
	}

#if USE_APK_ARCHIVE
	Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(m_blend, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
	if (stream.isNull())
	{
		gkPrintf("Error: Can't open file %s.", m_blend.c_str());
		return false;
	}

	size_t size = stream->size();
	char* buf = new char[size];
	stream->read(buf, size);

	gkBlendFile* blend = gkBlendLoader::getSingleton().loadFromMemory(buf,size,gkBlendLoader::LO_ALL_SCENES);	
#else
	gkBlendFile* blend = gkBlendLoader::getSingleton().loadFile(m_blend,gkBlendLoader::LO_ALL_SCENES); //, "", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);	
#endif
	if (!blend)
	{
		LOGI("File loading failed.\n");
		return false;
	}

	LOG_FOOT;

	m_scene = blend->getMainScene();
	if (!m_scene)
	{
		LOGI("No usable scenes found in blend.\n");
		return false;
	}

	LOG_FOOT;

	m_scene->createInstance();

	LOG_FOOT;
	
	m_scene->getMainCamera()->getCamera()->setAutoAspectRatio(true);

	// add input hooks
	gkWindow* win = gkWindowSystem::getSingleton().getMainWindow();
	m_input = static_cast<OIS::AndroidInputManager*>(win->getInputManager());

	LOG_FOOT;


	return true;
}