Replies: 5 comments 4 replies
-
So something like this: graph LR
A{Scene} --> B(SceneObject0)
A{Scene} --> C[Camera]
B(SceneObject0) --> H[Model0]
B(SceneObject0) --> D(SceneObject1)
D(SceneObject1) --> I[Model1]
D(SceneObject1) --> J[Model2]
D(SceneObject1) --> E(SceneObject2)
D(SceneObject1) --> F(SceneObject3)
With the Scene and SceneObjects forming the hierarchy. Do we need to add any functionality to the existing model in respect of this, eg. get the SceneObject it belongs to? In three.js, you add the Camera to the scene, (and you can add more than one), but then everything is scene-based there. Why the need for rootMatrix in DrawScene? Won't that come from the Scene, Camera or root SceneObject? |
Beta Was this translation helpful? Give feedback.
-
[EDITED] I think the camera mentioned is the same camera3D we already use when drawing models, that in this case would also be used to draw the scene. This might be easier for us, the users, to integrate this new functionality in our workflow(?). |
Beta Was this translation helpful? Give feedback.
-
I started trying out to implement the API. I simplfied and renamed a few things:
Implementing the GLTF file loading will however be a major pain, the loader for the model loading looks anything but fun. It probably makes sense to have the scene API and the GLTF loading API split into distinct files. A very basic example looks like this right now: SceneId sceneId = LoadScene();
SceneModelId firTreeId = AddModelToScene(sceneId, firTree, "fir tree", 1);
for (int i = 0; i < 100; i++)
{
SceneNodeId firTreeNodeId = AcquireSceneNode(sceneId);
SetSceneNodeModel(firTreeNodeId, firTreeId);
float rx = GetRandomValue(-400, 400) * 0.01f;
float rz = GetRandomValue(-400, 400) * 0.01f;
SetSceneNodePosition(firTreeNodeId, rx, 0, rz);
}
(...)
BeginMode3D(camera);
DrawScene(sceneId, camera, MatrixIdentity(), 0, SCENE_DRAW_SORT_NONE);
EndMode3D(); |
Beta Was this translation helpful? Give feedback.
-
While this effort is commendable, I think it is way out of scope for raylib. It involves making major decisions that raylib shouldn't make as a low-level rendering library. |
Beta Was this translation helpful? Give feedback.
-
As commented, this is a high-level system that I don't think raylib needs but it could be useful as a higher-level module for use or reference. |
Beta Was this translation helpful? Give feedback.
-
When working on a game during the last raylib gamejam, I realized again how difficult it is to handle scene data and how much it would help to have a working solution to that problem.
It is right now pretty difficult to use 3D content for games: While 3d formats like OBJ / GLTF / etc can be loaded quite easily, a lot of highly useful information is lost:
A typical use case is the desire to export a (simple) level from Blender to use it as part of a game in raylib. The problem is now that there is no way to identify individual objects, and if there are lots of instances, the mesh copies lead to a lot of inefficiencies. Additionally, the model rendering doesn't do any culling. The current workaround is to load meshes individually and assemble them via code or own editors - but this is hardly convenient.
Scene loading + management is not a trivial topic, but there are a few features that wouldn't be complicated to implement and that would enable beginners to get started more easily.
In my experience, the core problems that need to be regularly solved are
I don't think we need a one-solution-fits-it-all solution, just enough that it becomes easy to load / create scenes from external programs like blender in a game.
I have worked on such systems since the beginning of the year in C + raylib and think I could spend time on working something out that could be used as a drop-in-solution, but I would like to get other people opinion on this so I don't develop something that no one is really interested in using.
The API functions I would like to have would look something like this:
I would find it important to not let the user deal with pointers to minimize memory handling errors. SceneObjectIds would be indices with a generation counter, so object deletion would never cause problems with memory associated errors. As long as a scene is not unloaded, using the API should be failsafe.
While this API is pretty basic, I think it would really help as a starting point for most users. Keeping the codebase short and easy to use would be the primary goals.
Beta Was this translation helpful? Give feedback.
All reactions