Description
Currently loading content in Stride at runtime without the windows specific libraries is a pain and not well documented. This is a bit of a personal document I wanted to bring up publicly in case others want to pitch in findings or help out in research and documentation.
Loadable Content
Images or Textures
This one is actually easy and only requires a couple of lines already.
// supported files should be dds, bmp, jpg, png, gif, tiff, wmp, tga
var file = File.OpenRead("test.png");
// graphics device can come from the game class or the ScriptComponent class.
var texture = Texture.Load(GraphicsDevice, file);
Image is also the same but you most likely want the above.
Models and Skeletons
This one is annoyingly close to being easy but fails when trying to actually add the ModelComponent
to a scene.
- Add Stride.Importer.3D
- create a new
MeshConverter
class and load a file.
var meshConverter = new MeshConverter(new LoggerResult());
var model = _meshConverter.Convert(_modelPath + "FPS_Arms_GameReadyVer.fbx", _modelPath, false);
- Calculate the bounding boxes.
- Add the model to a component and to an entity in the scene.
var modelComponent = new ModelComponent()
{
Model = model,
BoundingBox = model.BoundingBox,
BoundingSphere = model.BoundingSphere,
};
var entity = new Entity()
{
modelComponent
};
entity.Scene = Entity.Scene;
- witness the crash in the
ModelComponent
class :(
Audio
Honestly no clue where to even start here. It seems like the required classes are in the OpenAL wrapper but hidden as internal? I may just be missing something there though.
I did however do some playing around with a custom implementation of audio with the added bonus of Steams audio engine. It's very unfinished though.
https://github.com/Doprez/Doprez.Stride.SteamAudio
Shaders
Again not really sure where to start here but it looks like it may be possible using this for direct3d and this for opengl/vulkan
Although Im not sure if those source files expect SDSL or HLSL. Based on my brief research it looks like it should be for hlsls and GLSL but it's a bit of a rabbit hole.
Tasks
- Model import extensions (Im feel like I'm annoyingly close to something usable but debugging this is a pain so far.)
- Skeleton import extensions
- Audio import extensions
- Texture import extensions (Its already pretty simple though so maybe not?)
- Shader import extensions (May be worth waiting on the shader rewrite?)
- Video import extensions (Adding video with a code-first approach #200)