Rust 3D with Fyrox - Basicsby
I'm not a game developer; I recently just started a side project as a break from tedious work in web dev as Rust web dev.
This post is more like a discovery and share post than a "how to" post. Every simple post aims to be "learn more than just it works", and this is the best way to get the most out of it than just simple "it works and go to the next challenge".
I'll start with what a mesh is for those who are NEW and don't have the slightest idea about game dev in 3D.
In 3D computer graphics and solid modelling, a polygon mesh is a collection of vertices, edges and faces that defines the shape of a polyhedral object. The faces usually consist of triangles (triangle mesh), quadrilaterals (quads), or other simple convex polygons (n-gons), since this simplifies rendering, but may also be more generally composed of concave polygons, or even polygons with holes.
But to be much more straightforward, a mesh is a piece of information about points in 3D space, and we connect those dots; we have shape. Additionally, mesh describes which point connects with which, so you will not have lines in the middle of the model.
Mesh files are like images. They have different formats (similar to png, jpg, and webp) and contain additional information (like texture or path to textures).
When you place the mesh in a 3d world, usually they are like ghosts. They don't react to anything; stuff can pass through them, gravity does not pull them down and so on. To have this, you must wrap them in a Rigid Body and collider.
This element is a wrapper which connects mesh with other objects and physics. The rigid body can have some offset from point (0,0,0), and all things in this group will have their own offset relative to the parent, not the entire world, the same goes for scale and other properties. Additionally, it's a group of objects which can have their own rigid bodies. For example, you can have the following:
Rigid Body - Position (10, 0, 0) -> (10, 0, 0) - Mesh - Rigid Body - Position (5, 0, 0) -> (15, 0, 0) - Mesh - Rigid Body - Position (0, 0, 0) -> (10, 0, 0) - Mesh
This element should be to a Rigid Body, and it adds physics to the component. So it can now be pulled by gravity, collide with other objects and so on.
But, and this is huge but, usually, collision does not have the shape of the mesh; it's a cube, a cylinder or a ball. It is because a calculating collision with too many objects is costly and slow, so it's better to be nearly correct than slow.