Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- // Framework includes
- #include "BsApplication.h"
- #include "Resources/BsResources.h"
- #include "Resources/BsBuiltinResources.h"
- #include "Material/BsMaterial.h"
- #include "Components/BsCCamera.h"
- #include "Components/BsCRenderable.h"
- #include "Components/BsCAnimation.h"
- #include "Components/BsCSkybox.h"
- #include "RenderAPI/BsRenderAPI.h"
- #include "RenderAPI/BsRenderWindow.h"
- #include "Components/BsCAnimation.h"
- #include "Scene/BsSceneObject.h"
- #include "Physics/BsPhysicsMaterial.h"
- #include "BsPrerequisites.h"
- #include "Reflection/BsRTTIType.h"
- #include "Resources/BsResources.h"
- #include "Resources/BsResourceManifest.h"
- #include "Mesh/BsMesh.h"
- #include "Importer/BsImporter.h"
- #include "Importer/BsMeshImportOptions.h"
- #include "Importer/BsTextureImportOptions.h"
- #include "Text/BsFontImportOptions.h"
- #include "FileSystem/BsFileSystem.h"
- #include "Input/BsVirtualInput.h"
- #include "Configuration.h"
- #include "Framework.h"
- #include "Assets.h"
- namespace bs
- {
- struct Assets assets;
- /** Load the resources we'll be using throughout the example. */
- Assets loadAssets()
- {
- Assets assets;
- // Load the 3D model and the animation clip
- assets.characterSO = SceneObject::create("Character");
- assets.characterAnimation = assets.characterSO->addComponent<CAnimation>();
- // Set up a path to the model resource
- const Path dataPath = DATA_PATH;
- const Path meshPath = dataPath + "Meshes/Characters/Character.fbx";
- // Set up mesh import options so that we import information about the skeleton and the skin, as well as any
- // animation clips the model might have.
- SPtr<MeshImportOptions> meshImportOptions = MeshImportOptions::create();
- meshImportOptions->setImportSkin(true);
- meshImportOptions->setImportAnimation(true);
- // The FBX file contains multiple resources (a mesh and an animation clip), therefore we use importAll() method,
- // which imports all resources in a file.
- //Vector<SubResource> modelResources = gImporter().importAll(meshPath, meshImportOptions);
- auto resources = gImporter().importAll(meshPath, meshImportOptions);
- assets.characterMesh = static_resource_cast<Mesh>(resources[0].value);
- assets.characterWalkingAnimClip = static_resource_cast<AnimationClip>(resources[1].value);
- assets.characterRenderable = assets.characterSO->addComponent<CRenderable>();
- assets.characterRenderable->setMesh(assets.characterMesh);
- // Load PBR textures for the 3D model
- assets.characterTexture = Framework::loadTexture(GTexture::HumanTest);
- // Create a material using the default physically based shader, and apply the PBR textures we just loaded
- HShader shader = gBuiltinResources().getBuiltinShader(BuiltinShader::Standard);
- assets.characterMaterial = Material::create(shader);
- assets.characterMaterial->setTexture("gAlbedoTex", assets.characterTexture);
- assets.characterRenderable->setMaterial(assets.characterMaterial);
- // Load an environment map
- assets.skyCubemap = Framework::loadTexture(GTexture::WhiteSky, false, true, false);
- return assets;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement