Project Raygine #6
I had to fix a lot of little bugs all over the place and I finally started replacing the old scene editing. There's no rendering yet, but reordering scene nodes and adding/removing them works. Adding components works too, though there's no real functionality to them yet.
There are also a few interesting tidbits that are now possible since the scene format is entirely working like a scriptable object in Unity; There's a flag to "expose" an entity. An asset file is a collection of objects, but per default, only the first one is displayed in the inspector when the asset is selected. It is, so to speak, the main object. But if you set the "expose" flag on an object, it will be displayed in the inspector as well. I need the expose mechanic for assets that are designed to have multiple objects that can be edited through the inspector and adding a toggle to each entity is easy to do. I am thinking like two steps forward already, but I think this is interesting for making prefabs: Exposed objects can be referred to from other assets.
So my thinking goes, that an entity could be flagged as "exposed" and in return it could be dropped into other scenes as a prefab node. I think I will deviate from Unity's implementation a bit: I think I would handle this via a "prefab" component. That component will take care about the instancing and tracking override values. It's still a little unclear to me how to do that in detail, but I have the feeling the direction is right.
On the screenshot, there's a little detail that can be overlooked but that sheds light on how the system works:
The entity here shows a few buttons to add new children / components or to remove the entity. This functionality is not provided by the inspector / scene editor but is provided by the type's gui script. It's a system to customize the rendering of the objects in the inspector.
Thinking about it, I think the hierarchy view should work in a similar way; if I have a prefab component, it would be good if the hierarchy mirrored the prefab's hierarchy, while editing is tunneled through the prefab component to capture override values.
This roadmap is very rough and likely to change much. It's more like a list of things I want to do in the near future.
- Entity components
- Primitive renderer: Exposing basic Raylib shapes and drawing them with a material asset
- Mesh renderer: Drawing a mesh using a mesh and material asset
- Camera: Rendering the scene from a camera's perspective
- Sprite renderer: Drawing a sprite using a material asset and a sprite asset
- Scripting component: A component that can be used to attach a script to an entity or run code specified via a multiline text field in the inspector
- Shader asset: A set of instructions how to draw things; Like which pass should be rendered when. I shouldn't make this more complicated than necessary because graphic rendering systems are complex and not my strength and neither my focus. I want to keep it simple while providing a minimum set of expected functionality.
- Material asset: Referencing a shader asset and providing values for the shader's variables
- Texture asset: A texture that can be referenced by a material asset. Should provide configurations how to preprocess the texture (like downscaling, mipmapping, target format, etc.)
- Mesh asset: A mesh that can be referenced by a mesh renderer component
- Sprite asset: A sprite that can be referenced by a sprite renderer component. References a texture asset and provides information about the sprite's position in the texture
- An isolated runtime environment that can be started inside the editor or as a standalone application. The runtime will load a scene asset and run it. The editor should be able to connect to it via TCP for back and forth communication as it will later possible running on a different device.
- Rendering the camera view
- This is a far future feature. It will need a lot of ground works that is to be done in the points above and is in itself a huge feature.