Skip to content

Commit

Permalink
added scene renderer, camera, light, gltf loader bugfixes and progress
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcypher89 committed Jun 9, 2024
1 parent 11e5f3c commit 6fd5401
Show file tree
Hide file tree
Showing 19 changed files with 464 additions and 174 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp"
"typeinfo": "cpp",
"chrono": "cpp"
}
}
2 changes: 1 addition & 1 deletion config/base/base.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
this_cxxflags += -Wall # enable all warnings
this_cxxflags += -Wnon-virtual-dtor # warn if base class has non-virtual destructor
this_cxxflags += -Werror # treat warnings as errors
# this_cxxflags += -Wfatal-errors # stop on first error encountered
this_cxxflags += -Wfatal-errors # stop on first error encountered
this_cxxflags += -fstrict-aliasing # in order to comply with the c++ standard more strictly
this_cxxflags += -g # include debugging symbols
this_cxxflags += -std=c++17
Expand Down
Binary file added res/default/texture_default_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/default/texture_default_normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/default/texture_default_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions res/main.res
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ tex_spray_arm{
file {spray/arm.jpg} mipmap{linear}
}

texture_default_black{
file {default/texture_default_black.png} mipmap{linear}
}

texture_default_white{
file {default/texture_default_white.png} mipmap{linear}
}

texture_default_normal{
file {default/texture_default_normal.png} mipmap{linear}
}

tex_cube_env_hata{
file_px{envs/hata/px.png}
file_nx{envs/hata/nx.png}
Expand Down
Binary file added res/samples_gltf/spray.glb
Binary file not shown.
27 changes: 18 additions & 9 deletions src/carcockpit/car_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,19 @@ car_widget::car_widget(utki::shared_ref<ruis::context> context, all_parameters p
LOG([&](auto& o) {
o << "<< LOAD GLTF >>" << std::endl;
})

ruis::render::gltf_loader l(*this->context.get().renderer.get().factory, true);
demoscene = l.load(papki::fs_file("../res/samples_gltf/parent_and_children.glb")).to_shared_ptr();
//demoscene = l.load(papki::fs_file("../res/samples_gltf/spray.glb")).to_shared_ptr();

sc_renderer = std::make_shared<ruis::render::scene_renderer>(this->context);
sc_renderer->set_scene(demoscene);
}

void car_widget::update(uint32_t dt)
{
demoscene->update(dt);

this->fps_sec_counter += dt;
this->time += dt;
float ft = static_cast<float>(this->time) / std::milli::den;
Expand Down Expand Up @@ -457,20 +464,22 @@ void car_widget::render(const ruis::matrix4& matrix) const
// modelview,
// this->tex_cube_env_hata->tex());

ruis::mat4 mtrx;
// ruis::mat4 mtrx;

auto vaao1 = demoscene->nodes[0].get().mesh_.get()->primitives[0].get().vao.to_shared_ptr();
mtrx = demoscene->nodes[0].get().get_transformation_matrix();
application::inst()
.shader_phong_v.render(*vaao1, mvp * mtrx, modelview * mtrx, this->tex_test->tex(), light_pos_view, light_int);
// auto vaao1 = demoscene->nodes[0].get().mesh_.get()->primitives[0].get().vao.to_shared_ptr();
// mtrx = demoscene->nodes[0].get().get_transformation_matrix();
// application::inst()
// .shader_phong_v.render(*vaao1, mvp * mtrx, modelview * mtrx, this->tex_test->tex(), light_pos_view, light_int);

auto vaao2 = demoscene->nodes[0].get().children[0].get().mesh_.get()->primitives[0].get().vao.to_shared_ptr();
mtrx *= demoscene->nodes[0].get().children[0].get().get_transformation_matrix();
application::inst()
.shader_phong_v.render(*vaao2, mvp * mtrx, modelview * mtrx, this->tex_test->tex(), light_pos_view, light_int);
// auto vaao2 = demoscene->nodes[0].get().children[0].get().mesh_.get()->primitives[0].get().vao.to_shared_ptr();
// mtrx *= demoscene->nodes[0].get().children[0].get().get_transformation_matrix();
// application::inst()
// .shader_phong_v.render(*vaao2, mvp * mtrx, modelview * mtrx, this->tex_test->tex(), light_pos_view, light_int);

phong_s->render(*this->light_vao, mvp_monkey, modelview_monkey, this->tex_test->tex(), light_pos_view, light_int);

sc_renderer->render();

// advanced_s->render(
// *this->car_vao,
// mvp,
Expand Down
2 changes: 2 additions & 0 deletions src/carcockpit/car_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
// #include "../ruis/render/scene/shaders/shader_phong.hpp"
// #include "../ruis/render/scene/shaders/shader_skybox.hpp"
#include "../ruis/render/scene/scene.hpp"
#include "../ruis/render/scene/scene_renderer.hpp"

#include "shaders/shader_adv.hpp"
#include "shaders/shader_phong.hpp"
Expand All @@ -42,6 +43,7 @@ namespace carcockpit {
class car_widget : public ruis::fraction_widget, public ruis::updateable, virtual public ruis::widget
{
std::shared_ptr<ruis::render::scene> demoscene;
std::shared_ptr<ruis::render::scene_renderer> sc_renderer;

std::shared_ptr<ruis::res::texture_2d> tex;
std::shared_ptr<ruis::res::texture_2d> tex_test;
Expand Down
Loading

0 comments on commit 6fd5401

Please sign in to comment.