Lyatus / L

Public-domain modular game engine.
The Unlicense
45 stars 6 forks source link

Vulkan load 3D model example? #1

Closed frutas-fruit closed 2 years ago

frutas-fruit commented 2 years ago

Hey,

Been meaning to check this framework out for a while. Was wondering where I can look for any examples which demonstrate loading a 3D mesh (perhaps from an .obj file) from disk and rendering using vulkan? Quite stuck on how to achieve this atm.

Cheers

frutas-fruit commented 2 years ago

I'm also on linux, is this framework currently supported for it?

frutas-fruit commented 2 years ago

Ah no worries, I noticed there is a main.cpp which seems to have everything I want

frutas-fruit commented 2 years ago

@Lyatus Is the Issues section the best place to ask questions? Or is there somewhere better dedicated to Q&A?

Lyatus commented 2 years ago

Oh I'm sorry for some reason I didn't see the notifications for this until your last comment. Were you able to do what you want? This engine may not be the best resource if you're looking for a straight example of loading a mesh and then rendering it via Vulkan since those things are accomplished in different modules and all (most likely the assimp module but also the wavefront_obj module, and then the vulkan module). The Issues section is definitely the best place to ask questions, provided I read the notifications I'm supposed to 😅

frutas-fruit commented 2 years ago

Hey no worries, thanks for replying!

Were you able to do what you want?

Yeah kinda, I'm trying to figure out how to achieve it by directly writing it in c++ (using the frameworks API). But as I understand in the demo it's currently achieved by using the custom scripting language designed for L?

Lyatus commented 2 years ago

The sample is completely data-driven and uses a custom scripting language yes, but the engine can be controlled via C++ just as much (and it's something I should show case more, I've been thinking about a way to handle C++ projects via CMake but haven't started working on it yet).

In any case you'd have to create a camera and a primitive component, both on entities, so you'd start by calling Entity::create() which would give you a handle to an entity, then you can call entity->require_component<Transform/Camera/Primitive/etc>() to get handles to the components you want, and then you can edit the data in them (typically placing your objects via the Transform and specifying relevant shaders and rendering data for your Camera and Primitive).

I'd recommend trying to reuse the shaders/materials from the sample first especially for the camera since it's really just doing some rough PBR stuff (but later you can hop in there and do your own deferred rendering if you want to). I haven't been working on the engine for a while and I'm sorry to say it's not very user-friendly, it's mostly a big personal project that aims to be an engine for future games (one of which is being developed in the far background).

And by the way if you're trying to find Vulkan code to look at, it's all in the vulkan module and not anywhere else, I've been trying to compartmentalize stuff in modules as much as possible.

frutas-fruit commented 2 years ago

Thanks for the example! Yeah ECS part sounds quite nice, I've been using data-oriented frameworks heavily these past months, so it's nice to have this feature implemented out of the box. I'll probably be asking more Q's as I start getting into making a simple demo! :+1: