第四节 ogre 2.3实现一个简单的模型纹理贴图

news2024/11/28 14:15:04

本节简单介绍下如何使用Ogre 2.3加载模型,并给模型贴上纹理材质。

一. 安装ogre 2.3

主要有两种安装方法:

  1. 简单安装方法,使用scripts for Ogre 2.3 脚本,按照官网给出的步骤安装即可。需要注意的是脚本解压后的 *.bat 文件需要修改下 CMAKE 路径,否则很容易提示找到不对 CMAKE。下载地址为: https://github.com/OGRECave/ogre-next/releases/download/bin-releases/build_ogre_scripts-v2-3.7z
  2. 复杂安装方法,下载源码,编译安装。这部分官网都有介绍。

二. 创建新项目

由于官方源码Sample项目中的例子过于繁杂,我们不需要那么多功能,这里仅把所需要的功能代码拿过来,省略了一些负责的部分。

2.1 资源初始化

我们参考官网给的源码例子,在源码文件中GraphicsSystem.cpp
中有个方法
void GraphicsSystem::initialize( const Ogre::String &windowTitle )
该方法用于资源初始化,但是该方法中首先是SDL2写的弹出框,我们这里并不需要,这部分不要。主要使用的是该方法中的326行,这几个方法:

setupResources();
loadResources();
chooseSceneManager();
createCamera();
mWorkspace = setupCompositor();

在这里插入图片描述

2.2 设置资源

加载resource2.cfg中的配置资源,这里设置为两部分,一个是.cfg中配置的材质,另一个是项目中额外用的材质,初始化的时候都加载进项目中。

void setupCfgResources(void)
    {
        // Load resource paths from config file
        Ogre::ConfigFile cf;
        cf.load( AndroidSystems::openFile( mResourcePath + "resources2.cfg" ) );

        // Go through all sections & settings in the file
        Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

        Ogre::String secName, typeName, archName;
        while( seci.hasMoreElements() )
        {
            secName = seci.peekNextKey();
            Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();

            if( secName != "Hlms" )
            {
                Ogre::ConfigFile::SettingsMultiMap::iterator i;
                for (i = settings->begin(); i != settings->end(); ++i)
                {
                    typeName = i->first;
                    archName = i->second;
                    //这里可能需要修改下
                    //Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
					//archName, typeName, secName);
                    addResourceLocation( archName, typeName, secName );
                }
            }
        }
    }

如果需要用到额外的材质,需要另外加载

void setupExtraResources(void)
{
	Ogre::ConfigFile cf;
	cf.load("resources2.cfg");

	Ogre::String dataFolder = cf.getSetting("DoNotUseAsResource", "Hlms", "");

	if (dataFolder.empty())
		dataFolder = "./";
	else if (*(dataFolder.end() - 1) != '/')
		dataFolder += "/";

	const char* c_locations[2] =
	{	 //本项目另外用到的材质
		"2.0/scripts/materials/PbsMaterials",
		"2.0/scripts/materials/HLMSEditor"
	};
	
	for(size_t i = 0; i < 2; ++i)
	{
		Ogre::String dataFolderFull = dataFolder + c_locations[i];
		Ogre::ResourceGroupManager::getSingleton().addResourceLocation(dataFolderFull, getMediaReadArchiveType(), "General");
	}
}

2.3 加载资源

 void loadResources(void)
    {
        registerHlms();
        // Initialise, parse scripts etc
        Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups( true );
    }

加载HLMS材质

void registerHlms(void)
{
    Ogre::ConfigFile cf;
    Ogre::String mResourcePath = "";
    cf.load((mResourcePath + "resources2.cfg"));

#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
    Ogre::String rootHlmsFolder = Ogre::macBundlePath() + '/' +
        cf.getSetting("DoNotUseAsResource", "Hlms", "");
#else
    Ogre::String rootHlmsFolder = mResourcePath + cf.getSetting("DoNotUseAsResource", "Hlms", "");
#endif

    if (rootHlmsFolder.empty())
        rootHlmsFolder = "./";
    else if (*(rootHlmsFolder.end() - 1) != '/')
        rootHlmsFolder += "/";

    //At this point rootHlmsFolder should be a valid path to the Hlms data folder

    Ogre::HlmsUnlit* hlmsUnlit = 0;
    Ogre::HlmsPbs* hlmsPbs = 0;

    //For retrieval of the paths to the different folders needed
    Ogre::String mainFolderPath;
    Ogre::StringVector libraryFoldersPaths;
    Ogre::StringVector::const_iterator libraryFolderPathIt;
    Ogre::StringVector::const_iterator libraryFolderPathEn;

    Ogre::ArchiveManager& archiveManager = Ogre::ArchiveManager::getSingleton();

    const Ogre::String& archiveType = getMediaReadArchiveType();

    {
        //Create & Register HlmsUnlit
        //Get the path to all the subdirectories used by HlmsUnlit
        Ogre::HlmsUnlit::getDefaultPaths(mainFolderPath, libraryFoldersPaths);
        Ogre::Archive* archiveUnlit = archiveManager.load(rootHlmsFolder + mainFolderPath,
            archiveType, true);
        Ogre::ArchiveVec archiveUnlitLibraryFolders;
        libraryFolderPathIt = libraryFoldersPaths.begin();
        libraryFolderPathEn = libraryFoldersPaths.end();
        while (libraryFolderPathIt != libraryFolderPathEn)
        {
            Ogre::Archive* archiveLibrary =
                archiveManager.load(rootHlmsFolder + *libraryFolderPathIt, archiveType, true);
            archiveUnlitLibraryFolders.push_back(archiveLibrary);
            ++libraryFolderPathIt;
        }

        //Create and register the unlit Hlms
        hlmsUnlit = OGRE_NEW Ogre::HlmsUnlit(archiveUnlit, &archiveUnlitLibraryFolders);
        Ogre::Root::getSingleton().getHlmsManager()->registerHlms(hlmsUnlit);
    }

    {
        //Create & Register HlmsPbs
        //Do the same for HlmsPbs:
        Ogre::HlmsPbs::getDefaultPaths(mainFolderPath, libraryFoldersPaths);
        Ogre::Archive* archivePbs = archiveManager.load(rootHlmsFolder + mainFolderPath,
            archiveType, true);

        //Get the library archive(s)
        Ogre::ArchiveVec archivePbsLibraryFolders;
        libraryFolderPathIt = libraryFoldersPaths.begin();
        libraryFolderPathEn = libraryFoldersPaths.end();
        while (libraryFolderPathIt != libraryFolderPathEn)
        {
            Ogre::Archive* archiveLibrary =
                archiveManager.load(rootHlmsFolder + *libraryFolderPathIt, archiveType, true);
            archivePbsLibraryFolders.push_back(archiveLibrary);
            ++libraryFolderPathIt;
        }

        //Create and register
        hlmsPbs = OGRE_NEW Ogre::HlmsPbs(archivePbs, &archivePbsLibraryFolders);
        Ogre::Root::getSingleton().getHlmsManager()->registerHlms(hlmsPbs);
    }

    Ogre::RenderSystem* renderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();
    if (renderSystem->getName() == "Direct3D11 Rendering Subsystem")
    {
        //Set lower limits 512kb instead of the default 4MB per Hlms in D3D 11.0
        //and below to avoid saturating AMD's discard limit (8MB) or
        //saturate the PCIE bus in some low end machines.
        bool supportsNoOverwriteOnTextureBuffers;
        renderSystem->getCustomAttribute("MapNoOverwriteOnDynamicBufferSRV",
            &supportsNoOverwriteOnTextureBuffers);

        if (!supportsNoOverwriteOnTextureBuffers)
        {
            hlmsPbs->setTextureBufferDefaultSize(512 * 1024);
            hlmsUnlit->setTextureBufferDefaultSize(512 * 1024);
        }
    }
}

const char* getMediaReadArchiveType(void)
{
#if OGRE_PLATFORM != OGRE_PLATFORM_ANDROID
    return "FileSystem";
#else
    return "APKFileSystem";
#endif
}

2.4 创建场景

const size_t numThreads = 1u;
	sceneManager = root->createSceneManager(ST_GENERIC, numThreads, "ExampleSMInstance");

2.5 创建摄像机

void createCamera(void)
{
	// Create & setup camera
	Ogre::Camera* camera = sceneManager->createCamera("Main Camera");
	// Position it at 500 in Z direction
	camera->setPosition(Ogre::Vector3(0, 5, 15));
	// Look back along -Z
	camera->lookAt(Ogre::Vector3(0, 0, 0));
	camera->setNearClipDistance(0.2f);
	camera->setFarClipDistance(1000.0f);
	camera->setAutoAspectRatio(true);
}

2.6 创建基础组合器

// Setup a basic compositor with a blue clear colour
	CompositorManager2* compositorManager = root->getCompositorManager2();
	const String workspaceName("Demo Workspace");
	const ColourValue backgroundColour(0.2f, 0.4f, 0.6f);
	compositorManager->createBasicWorkspaceDef(workspaceName, backgroundColour, IdString());
	compositorManager->addWorkspace(sceneManager, window->getTexture(), camera, workspaceName, true);

2.7 创建模型,并加载纹理贴图

void createScene01(void)
{
	//-------------------------------------------------------------------------
	// V2 mesh loading
	Ogre::Item* item = sceneManager->createItem("Sphere1000.mesh",
		Ogre::ResourceGroupManager::
		AUTODETECT_RESOURCE_GROUP_NAME,
		Ogre::SCENE_DYNAMIC);
	item->setDatablock("Marble"); //这里为纹理材质,一定要加载PbsMaterials.material材质!!!
	item->setVisibilityFlags(0x000000002);

	Ogre::SceneNode* mSceneNode = sceneManager->getRootSceneNode(Ogre::SCENE_DYNAMIC)->
		createChildSceneNode(Ogre::SCENE_DYNAMIC);
	mSceneNode->scale(3.0, 3.0, 3.0);
	mSceneNode->attachObject(item);

	//光照 很重要!!!不写的话,纹理贴图无法显示出来
	Ogre::Light* light = sceneManager->createLight();
	Ogre::SceneNode* lightNode = ((Ogre::SceneNode*)sceneManager->getRootSceneNode()->createChild());
	lightNode->attachObject(light);
	light->setPowerScale(2.0f);
	light->setType(Ogre::Light::LT_DIRECTIONAL);
	light->setDirection(Ogre::Vector3(-1, -1, -1).normalisedCopy());
	sceneManager->setAmbientLight((Ogre::ColourValue(0.3f, 0.5f, 0.7f) * 0.1f * 0.75f),
		(Ogre::ColourValue(0.6f, 0.45f, 0.3f) * 0.065f * 0.75f),
		((-light->getDirection()) + (Ogre::Vector3::UNIT_Y * 0.2f)));
}

2.8 完整代码如下:

main.cpp

#include "Hlms.h"

#include "OgreCamera.h"
#include "OgreRoot.h"
#include "OgreWindow.h"
#include "Compositor/OgreCompositorManager2.h"
#include "OgreWindowEventUtilities.h"
#include "OgreItem.h"
#include "OgreSceneManager.h"
//
#include "OgreHlmsUnlitDatablock.h"
#include "OgreHlmsPbsDatablock.h"
#include "OgreHlmsSamplerblock.h"
#include "OgreMesh.h"
#include "OgreMesh2.h"
#include "OgreMeshManager.h"
#include "OgreMeshManager2.h"
#include "OgreTextureFilters.h"
#include "OgreTextureGpuManager.h"

Ogre::Root* root = NULL;
Ogre::SceneManager* sceneManager = NULL;
Ogre::Camera* camera = NULL;
//加载资源
void setupResources(void);

void setupCfgResources(void);

void setupExtraResources(void);

void loadResources(void);

void createCamera(void);

void createScene01(void);

class MyWindowEventListener : public Ogre::WindowEventListener
{
	bool mQuit;

public:
	MyWindowEventListener() : mQuit(false) {}
	virtual void windowClosed(Ogre::Window* rw) { mQuit = true; }

	bool getQuit(void) const { return mQuit; }
};

int main(int argc, const char* argv[])
{
	using namespace Ogre;

	const String pluginsFolder = "./";
	const String writeAccessFolder = "./";

#ifndef OGRE_STATIC_LIB
#if OGRE_DEBUG_MODE
	const char* pluginsFile = "plugins_d.cfg";
#else
	const char* pluginsFile = "plugins.cfg";
#endif
#endif
	root = OGRE_NEW Root(pluginsFolder + pluginsFile,
		writeAccessFolder + "ogre.cfg",
		writeAccessFolder + "Ogre.log");

	Ogre::RenderSystem* renderSystem = root->getRenderSystemByName("Direct3D11 Rendering Subsystem");
	if (!(renderSystem))
	{
		printf("Render system not found!\n");
		return -1;
	}
	// Initialize Root
	root->setRenderSystem(renderSystem);
	root->getRenderSystem()->setConfigOption("sRGB Gamma Conversion", "Yes");
	root->getRenderSystem()->setConfigOption("Full Screen", "No");
	Window* window = root->initialise(true, "Tutorial 00: Basic");
	MyWindowEventListener myWindowEventListener;
	WindowEventUtilities::addWindowEventListener(window, &myWindowEventListener);

	//加载资源
	setupResources();

	//加载HLMS
	loadResources();

	// Create SceneManager
	const size_t numThreads = 1u;
	sceneManager = root->createSceneManager(ST_GENERIC, numThreads, "ExampleSMInstance");

	//摄像机
	createCamera();

	// Setup a basic compositor with a blue clear colour
	CompositorManager2* compositorManager = root->getCompositorManager2();
	const String workspaceName("Demo Workspace");
	const ColourValue backgroundColour(0.2f, 0.4f, 0.6f);
	compositorManager->createBasicWorkspaceDef(workspaceName, backgroundColour, IdString());
	compositorManager->addWorkspace(sceneManager, window->getTexture(), camera, workspaceName, true);

	createScene01();

	bool bQuit = false;

	while (!bQuit)
	{
		WindowEventUtilities::messagePump();
		bQuit = myWindowEventListener.getQuit() || !root->renderOneFrame();
	}

	WindowEventUtilities::removeWindowEventListener(window, &myWindowEventListener);

	OGRE_DELETE root;
	root = 0;

	return 0;
}

void setupCfgResources(void)
{
	// Load resource paths from config file
	Ogre::ConfigFile cf;
	cf.load("resources2.cfg");

	// Go through all sections & settings in the file
	Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

	Ogre::String secName, typeName, archName;
	while (seci.hasMoreElements())
	{
		secName = seci.peekNextKey();
		Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext();

		if (secName != "Hlms")
		{
			Ogre::ConfigFile::SettingsMultiMap::iterator i;
			for (i = settings->begin(); i != settings->end(); ++i)
			{
				typeName = i->first;
				archName = i->second;
				Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
					archName, typeName, secName);
			}
		}
	}
}

void setupExtraResources(void)
{
	Ogre::ConfigFile cf;
	cf.load("resources2.cfg");

	Ogre::String dataFolder = cf.getSetting("DoNotUseAsResource", "Hlms", "");

	if (dataFolder.empty())
		dataFolder = "./";
	else if (*(dataFolder.end() - 1) != '/')
		dataFolder += "/";

	const char* c_locations[5] =
	{
		"2.0/scripts/materials/PbsMaterials",
		"2.0/scripts/materials/HLMSEditor"
	};
	
	for(size_t i = 0; i < 2; ++i)
	{
		Ogre::String dataFolderFull = dataFolder + c_locations[i];
		Ogre::ResourceGroupManager::getSingleton().addResourceLocation(dataFolderFull, getMediaReadArchiveType(), "General");
	}
}

void setupResources(void)
{
	//1.加载resource2.cfg
	setupCfgResources();
	//2.加载额外需要的资源
	setupExtraResources();
}

void loadResources(void)
{
	registerHlms();

	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(true);
}

void createCamera(void)
{
	// Create & setup camera
	camera = sceneManager->createCamera("Main Camera");
	// Position it at 500 in Z direction
	camera->setPosition(Ogre::Vector3(0, 5, 15));
	// Look back along -Z
	camera->lookAt(Ogre::Vector3(0, 0, 0));
	camera->setNearClipDistance(0.2f);
	camera->setFarClipDistance(1000.0f);
	camera->setAutoAspectRatio(true);
}

void createScene01(void)
{
	//-------------------------------------------------------------------------
	/*Ogre::HlmsManager* hlmsManager = root->getHlmsManager();
	assert(dynamic_cast<Ogre::HlmsPbs*>(hlmsManager->getHlms(Ogre::HLMS_PBS)));
	Ogre::HlmsPbs* hlmsPbs = static_cast<Ogre::HlmsPbs*>(hlmsManager->getHlms(Ogre::HLMS_PBS));
	Ogre::TextureGpuManager* textureMgr = root->getRenderSystem()->getTextureGpuManager();

	Ogre::String datablockName = "Test" + Ogre::StringConverter::toString(0);
	Ogre::HlmsPbsDatablock* datablock = static_cast<Ogre::HlmsPbsDatablock*>(
		hlmsPbs->createDatablock(datablockName,
			datablockName,
			Ogre::HlmsMacroblock(),
			Ogre::HlmsBlendblock(),
			Ogre::HlmsParamVec()));

	Ogre::TextureGpu* texture = textureMgr->createOrRetrieveTexture(
		"SaintPetersBasilica.dds",
		Ogre::GpuPageOutStrategy::Discard,
		Ogre::TextureFlags::PrefersLoadingFromFileAsSRGB,
		Ogre::TextureTypes::TypeCube,
		Ogre::ResourceGroupManager::
		AUTODETECT_RESOURCE_GROUP_NAME,
		Ogre::TextureFilter::TypeGenerateDefaultMipmaps);

	datablock->setTexture(Ogre::PBSM_REFLECTION, texture);
	datablock->setDiffuse(Ogre::Vector3(1.0f, 1.0f, 1.0f));

	datablock->setRoughness(std::max(0.02f, 3 / std::max(1.0f, (float)(8 - 1))));
	datablock->setFresnel(Ogre::Vector3(3 / std::max(1.0f, (float)(8 - 1))), false);*/

	// V2 mesh loading
	Ogre::Item* item = sceneManager->createItem("Sphere1000.mesh",
		Ogre::ResourceGroupManager::
		AUTODETECT_RESOURCE_GROUP_NAME,
		Ogre::SCENE_DYNAMIC);
	item->setDatablock("Marble");
	//item->setDatablock(datablock);
	item->setVisibilityFlags(0x000000002);

	Ogre::SceneNode* mSceneNode = sceneManager->getRootSceneNode(Ogre::SCENE_DYNAMIC)->
		createChildSceneNode(Ogre::SCENE_DYNAMIC);
	mSceneNode->scale(3.0, 3.0, 3.0);
	mSceneNode->attachObject(item);

	//光照
	Ogre::Light* light = sceneManager->createLight();
	Ogre::SceneNode* lightNode = ((Ogre::SceneNode*)sceneManager->getRootSceneNode()->createChild());
	lightNode->attachObject(light);
	light->setPowerScale(2.0f);
	light->setType(Ogre::Light::LT_DIRECTIONAL);
	light->setDirection(Ogre::Vector3(-1, -1, -1).normalisedCopy());
	sceneManager->setAmbientLight((Ogre::ColourValue(0.3f, 0.5f, 0.7f) * 0.1f * 0.75f),
		(Ogre::ColourValue(0.6f, 0.45f, 0.3f) * 0.065f * 0.75f),
		((-light->getDirection()) + (Ogre::Vector3::UNIT_Y * 0.2f)));
}

Hlms.h

#pragma once

#include "OgreConfigFile.h"
#include <OgreArchiveManager.h>
#include "OgreHlmsManager.h"
#include <OgreHlmsPbs.h>
#include "OgreHlmsUnlit.h"
       
const char* getMediaReadArchiveType(void);

void registerHlms(void)
{
    Ogre::ConfigFile cf;
    Ogre::String mResourcePath = "";
    cf.load((mResourcePath + "resources2.cfg"));

#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
    Ogre::String rootHlmsFolder = Ogre::macBundlePath() + '/' +
        cf.getSetting("DoNotUseAsResource", "Hlms", "");
#else
    Ogre::String rootHlmsFolder = mResourcePath + cf.getSetting("DoNotUseAsResource", "Hlms", "");
#endif

    if (rootHlmsFolder.empty())
        rootHlmsFolder = "./";
    else if (*(rootHlmsFolder.end() - 1) != '/')
        rootHlmsFolder += "/";

    //At this point rootHlmsFolder should be a valid path to the Hlms data folder

    Ogre::HlmsUnlit* hlmsUnlit = 0;
    Ogre::HlmsPbs* hlmsPbs = 0;

    //For retrieval of the paths to the different folders needed
    Ogre::String mainFolderPath;
    Ogre::StringVector libraryFoldersPaths;
    Ogre::StringVector::const_iterator libraryFolderPathIt;
    Ogre::StringVector::const_iterator libraryFolderPathEn;

    Ogre::ArchiveManager& archiveManager = Ogre::ArchiveManager::getSingleton();

    const Ogre::String& archiveType = getMediaReadArchiveType();

    {
        //Create & Register HlmsUnlit
        //Get the path to all the subdirectories used by HlmsUnlit
        Ogre::HlmsUnlit::getDefaultPaths(mainFolderPath, libraryFoldersPaths);
        Ogre::Archive* archiveUnlit = archiveManager.load(rootHlmsFolder + mainFolderPath,
            archiveType, true);
        Ogre::ArchiveVec archiveUnlitLibraryFolders;
        libraryFolderPathIt = libraryFoldersPaths.begin();
        libraryFolderPathEn = libraryFoldersPaths.end();
        while (libraryFolderPathIt != libraryFolderPathEn)
        {
            Ogre::Archive* archiveLibrary =
                archiveManager.load(rootHlmsFolder + *libraryFolderPathIt, archiveType, true);
            archiveUnlitLibraryFolders.push_back(archiveLibrary);
            ++libraryFolderPathIt;
        }

        //Create and register the unlit Hlms
        hlmsUnlit = OGRE_NEW Ogre::HlmsUnlit(archiveUnlit, &archiveUnlitLibraryFolders);
        Ogre::Root::getSingleton().getHlmsManager()->registerHlms(hlmsUnlit);
    }

    {
        //Create & Register HlmsPbs
        //Do the same for HlmsPbs:
        Ogre::HlmsPbs::getDefaultPaths(mainFolderPath, libraryFoldersPaths);
        Ogre::Archive* archivePbs = archiveManager.load(rootHlmsFolder + mainFolderPath,
            archiveType, true);

        //Get the library archive(s)
        Ogre::ArchiveVec archivePbsLibraryFolders;
        libraryFolderPathIt = libraryFoldersPaths.begin();
        libraryFolderPathEn = libraryFoldersPaths.end();
        while (libraryFolderPathIt != libraryFolderPathEn)
        {
            Ogre::Archive* archiveLibrary =
                archiveManager.load(rootHlmsFolder + *libraryFolderPathIt, archiveType, true);
            archivePbsLibraryFolders.push_back(archiveLibrary);
            ++libraryFolderPathIt;
        }

        //Create and register
        hlmsPbs = OGRE_NEW Ogre::HlmsPbs(archivePbs, &archivePbsLibraryFolders);
        Ogre::Root::getSingleton().getHlmsManager()->registerHlms(hlmsPbs);
    }

    Ogre::RenderSystem* renderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();
    if (renderSystem->getName() == "Direct3D11 Rendering Subsystem")
    {
        //Set lower limits 512kb instead of the default 4MB per Hlms in D3D 11.0
        //and below to avoid saturating AMD's discard limit (8MB) or
        //saturate the PCIE bus in some low end machines.
        bool supportsNoOverwriteOnTextureBuffers;
        renderSystem->getCustomAttribute("MapNoOverwriteOnDynamicBufferSRV",
            &supportsNoOverwriteOnTextureBuffers);

        if (!supportsNoOverwriteOnTextureBuffers)
        {
            hlmsPbs->setTextureBufferDefaultSize(512 * 1024);
            hlmsUnlit->setTextureBufferDefaultSize(512 * 1024);
        }
    }
}

const char* getMediaReadArchiveType(void)
{
#if OGRE_PLATFORM != OGRE_PLATFORM_ANDROID
    return "FileSystem";
#else
    return "APKFileSystem";
#endif
}

三. VS工程项目配置,重要!!!涉及到OGRE资源的加载

记住: .exe,.dll,.cfg,.pdb资源都在一个目录下。

  1. 设置工作目录
    在这里插入图片描述我的本地电脑
    工作目录
    $(OutDir)
    D:\Project\vsproject\3DGIS\OgreNexTest\OgreDemoApp-master\build2019\Debug\
    命令
    $(TargetPath)
    D:\Project\vsproject\3DGIS\OgreNexTest\OgreDemoApp-master\build2019\Debug\DemoApp.exe

  2. 将Ogre2.3的bin/Debug目录下的资源拷贝到$(OutDir)目录下。
    在这里插入图片描述在这里插入图片描述

  3. 材质资源复制,这里路径可以自己选择。只要resource2.cfg中配置正确即可。
    在这里插入图片描述
    在这里插入图片描述在这里插入图片描述

  4. C/C++ -> 附加包含目录
    在这里插入图片描述

  5. 链接器 -> 输入 -> 附加依赖项
    在这里插入图片描述6. 到这里项目配置结束了,就可以运行代码看看效果啦
    在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/620291.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【Java|golang】2611. 老鼠和奶酪

有两只老鼠和 n 块不同类型的奶酪&#xff0c;每块奶酪都只能被其中一只老鼠吃掉。 下标为 i 处的奶酪被吃掉的得分为&#xff1a; 如果第一只老鼠吃掉&#xff0c;则得分为 reward1[i] 。 如果第二只老鼠吃掉&#xff0c;则得分为 reward2[i] 。 给你一个正整数数组 reward1…

SpringCloud-Gateway过滤器

路由过滤器 GatewayFilter GatewayFilter 是网关中提供的一种过滤器&#xff0c;可以对进入网关的请求和微服务返回的响应做处理。 路由过滤器的作用是什么&#xff1f; 对路由的请求或想象做加工处理&#xff0c;比如添加请求头配置子路由下的过滤器只对当前路由的请求生效…

monkey测试关机/重启问题分析(二)

systemui关机dialog相关 1、systemui下拉关机按钮 通过Android 布局分析工具发现 按钮布局 base/packages/SystemUI/res-keyguard/layout/footer_actions.xml 按钮初始化和点击事件 frameworks/base/packages/SystemUI/src/com/android/systemui/qs/FooterActionsControlle…

斐波那契算法的理解

1.斐波那契数列 &#xff1a; 数组&#xff1a;int[] F{1, 1, 2, 3, 5, 8, 13, 21, 34, 55 }; 特点&#xff1a; 从第三个数开始&#xff0c;后边每一个数都是前两个数的和 。F[k]F[k-1]F[k-2]; 如图所示&#xff1a; ①low、mid、high都是F数组的索引&#xff0c;F[k]-1表示…

基础实验篇 | 课程总体介绍(一)

本讲主要介绍多旋翼的特点及选用多旋翼作为实验平台的原因、对于无人系统教育的一些新需求、RflySim平台对于飞控的底层控制算法的开发优势、本期平台课程的设置、以及如何开发自驾仪系统。 相较于固定翼和直升机&#xff0c;多旋翼具有机械结构简单、 易维护的优点。以四旋翼…

操作Arrays.asList的list报UnsupportedOperationException的坑

Arrays.asList() 将数组转换成List集合 /*** Returns a fixed-size list backed by the specified array. (Changes to* the returned list "write through" to the array.) This method acts* as bridge between array-based and collection-based APIs, in* com…

通过Python封装商品ID获取阿里巴巴商品详情数据,阿里巴巴商品详情数据API接口,阿里巴巴API接口

目的&#xff1a;通过Python封装商品ID获取阿里巴巴商品详情数据&#xff0c;本文将给出Python代码的一些思路和示例。 首先&#xff0c;你需要找到获取阿里巴巴商品详情数据的API接口。阿里巴巴开放平台提供了一些API接口&#xff0c;例如阿里巴巴开放平台商品API&#xff0c…

软件开发项目成本控制的7个重点

1、精细计划预算和管控机制 制定详细的项目计划和预算&#xff0c;包括资源需求、人力资源、时间表和财务预测等&#xff0c;以确保项目不会超出预算。实时跟踪项目的实际开支和进度&#xff0c;并对计划进行调整&#xff0c;以便更好地管理成本。 软件开发项目成本控制的7个重…

MongoDB Study Notes

文章目录 1 MongoDB快速入门1.1 什么是MongDB1.2 部署安装——基于docker1.3 基本概念1.4 基本操作1.4.1 查看所有数据库1.4.2 切换数据库1.4.3 创建数据库1.4.4 删除数据库1.4.5 查看数据库中表1.4.6 新增数据1.4.7 查询数据1.4.8 更新数据1.4.8.1 更新不存在字段1.4.8.2 更新…

Nginx 504 gateway timeout

方案 调整这几个参数来调大nginx的超时时间。 proxy_connect_timeout proxy_send_timeout proxy_read_timeoutnginx 三个代理超时时间配置 proxy_connect_timeout 60s; Defines a timeout for establishing a connection with a proxied server. It should be noted that thi…

【期末划重点】计算机英语(2)(更新中)

阿金的计算机英语&#xff0c;线下考试版~ 时隔半年&#xff0c;又开始赌徒模式啦 这次尝试用大数据文本分析&#xff0c;精准备考 欢迎补充 2023计英期末考赌徒版 Part 1 词汇题&#xff08;20题&#xff0c;40分&#xff09;1、词库说明2、本题答题技巧3、背词方法4、完整词库…

【Python实战】Python采集情感音频

成年人的世界真不容易啊 总是悲伤大于欢喜 爱情因为懵懂而快乐 却走进了复杂和困惑的婚姻 前言 我最近喜欢去听情感类的节目&#xff0c;比如说&#xff0c;婚姻类&#xff0c;我可能老了吧。我就想着怎么把音乐下载下来了&#xff0c;保存到手机上&#xff0c;方便我们业余时…

jdk配置语句以及idea配置问题idea科学使用

一、第一步上链接 官网地址&#xff0c;不过每次都在变版本不过都一样没事&#xff1a; https://www.oracle.com/java/technologies/downloads/ idea2021官网 https://www.jetbrains.com/zh-cn/idea/download/other.html 你可以下载右边付费的版本&#xff0c;如果想下载左边…

IPO观察丨绿源持续推进IPO,这次不止“一部车能骑10年”

近期&#xff0c;国内两轮电动车行业又有新动态。业内老牌企业绿源集团更新招股书&#xff0c;继续推进上市进程&#xff0c;中信建投国际担任保荐人。 其实去年11月&#xff0c;绿源已向港交所递交招股书&#xff0c;只不过受若干原因影响&#xff0c;在今年5月失效。当然&am…

synchronized简单理解

一、简述 1.1 synchronized介绍 synchronized是一种互斥锁&#xff0c;也成为同步锁&#xff0c;它的作用是保证在同一时刻&#xff0c;被修饰的代码块或方法只会有一个线程执行&#xff0c;以到达保证并发安全效果。在JDK1.6以前&#xff0c;很多人称之为重量级锁&#xff0…

作为一名仓库管理人员,如何有效地管理仓库?

作为一名仓库管理人员&#xff0c;如何有效地管理仓库&#xff1f; 有效仓库管理主要可以分为四个方面&#xff1a; 出入库 库存调拨 库存盘点 虚拟库存/实际库存管理 当然仓库管理最基本的硬件条件还是需要准备好的&#xff0c;比如将仓库分一下区域&#xff0c;以便之后商…

layui(3)——内置模块弹出层

弹出层 1.基础参数 使用模块layer layui.use(layer, function(){var layer layui.layer;}); <script>layui.use(layer, function () {var layer layui.layer;layer.open({// layer提供了5种层类型。可传入的值有&#xff1a;0&#xff08;信息框&…

极简操作!跟着官方教程,下载并使用汉化版Figma!

随着云端协作设计工具的发展&#xff0c;Figma 作为一款基于云端的国外云端协作工具&#xff0c;尽管无需下载即可在线使用&#xff0c;但在国内却常常遇到加载缓慢、需要刷新重进的问题。此外&#xff0c;Figma 在实际使用过程中&#xff0c;常常需要搭配其他软件或第三方插件…

vue3+element plus,使用分页total修改成中文

vue3element plus&#xff0c;使用分页total修改成中文 使用element plus的分页功能 el-pagination 的时候&#xff0c;total属性显示是英文 这是我建的一个新项目&#xff0c;总数显示的Total 1000 我们的需求是显示中文&#xff0c;共 1000 条 这个就很尴尬&#xff0c;组件…

JAVA基础,区别于C++

JAVA 基础 1. 数据类型 字节型 byte 1 字节 -128~127 短整型 short 2 字节 -32768~32767 整型 int 4 字节 -2147483648~2147483647 长整型 long 8 字节 -9223372036854775808L~92…