Skip to main content

Posts

Showing posts from February, 2023

How to load glTF models at runtime in C++ using Unreal Engine (glTFRuntime plugin)

Unreal Engine provides loading of 3D models stored in Content directory as a format of converted assets. However, In some project, you may need to load 3D models at runtime which cannot be stored at Content directory.  What is glTF? glTF is a standard format (ISO/IEC International Standard) for 3D asset delivery and interchange. Wide variety of application and service supports glTF. https://www.khronos.org/gltf/ glTFRuntime plugin You can use glTF 3D files in Unreal Engine thanks to the glTFRutime plugin .   https://github.com/rdeioris/glTFRuntime However, most of the documentation focuses on Blueprint usage. If you want to use this plugin in C++, you can use below example. (This plugin already provides AglTFRuntimeAssetActor class, but this class is derived from AActor to show how to use C++ APIs).    How to use glTF 3D model as a member component of an actor To use this plugin in my project, I had to use it as a member component of my pre-existing actor class....

Which string class consumes lower memory between std::string and FString in C++ using Unreal Engine

In many programming projects, strings are a fundamental data type that are used extensively to represent text, identifiers, and other types of data. However, strings can also consume a significant amount of memory, particularly if they are used extensively or if they contain large amounts of data. In a project that needs to save memory, it is important to carefully consider the memory usage of string objects and to take steps to minimize it. When we use Unreal Engine, FString is easy to use class due to the convenience of functionalities and tight coupling of engine's overall structure. However in some specific situation, you can use std::string instead. Let's check memory consumption of string classes. // 13 characters std:: string  MyStdString  =   "Hello, world!" ; FString  MyFString  =   "Hello, world!" ;   UE_LOG(LogTemp, Log, TEXT( "allocated size[std::string] = %d" ), MyStdString.capacity()); UE_...