Browse Source

player

master
alistair 1 year ago
parent
commit
8cf6e62c24
  1. 11
      assets/models/xenia_the_linux_mascot/license.txt
  2. BIN
      assets/models/xenia_the_linux_mascot/scene.bin
  3. 2031
      assets/models/xenia_the_linux_mascot/scene.gltf
  4. BIN
      assets/models/xenia_the_linux_mascot/textures/body_baseColor.png
  5. 1
      assets/shaders/g_frag.gl
  6. 21
      source/main.cpp
  7. 7
      source/mesh.cpp
  8. 1
      source/uniform-buffer.hpp

11
assets/models/xenia_the_linux_mascot/license.txt

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
Model Information:
* title: Xenia The Linux Mascot
* source: https://sketchfab.com/3d-models/xenia-the-linux-mascot-27f9de8e2687426cb77b52117b1e8ffd
* author: nickisdoge (https://sketchfab.com/nickisdoge)
Model License:
* license type: CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)
* requirements: Author must be credited. Commercial use is allowed.
If you use this 3D model in your project be sure to copy paste this credit wherever you share it:
This work is based on "Xenia The Linux Mascot" (https://sketchfab.com/3d-models/xenia-the-linux-mascot-27f9de8e2687426cb77b52117b1e8ffd) by nickisdoge (https://sketchfab.com/nickisdoge) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)

BIN
assets/models/xenia_the_linux_mascot/scene.bin

Binary file not shown.

2031
assets/models/xenia_the_linux_mascot/scene.gltf

File diff suppressed because it is too large Load Diff

BIN
assets/models/xenia_the_linux_mascot/textures/body_baseColor.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

1
assets/shaders/g_frag.gl

@ -87,6 +87,7 @@ main() { @@ -87,6 +87,7 @@ main() {
} else {
gNormal = normalize(TBN * normal);
}
gNormal = Normal;
// and the diffuse per-fragment color
vec4 tex = texture(material.texture_diffuse1, theTexCoord);

21
source/main.cpp

@ -497,10 +497,6 @@ int main_loop(game_state& g) @@ -497,10 +497,6 @@ int main_loop(game_state& g)
Model ground {g.asset_dir / "models"/ "ground.glb"};
Model log {g.asset_dir / "models"/ "large_tree_log" / "scene.gltf"};
log.enable_instancing();
log.buffer_instances(init_model_transforms(1000, extent, p,0,0, 0, 10));
Model ntrees {g.asset_dir / "models"/ "trees_low_poly" / "scene.gltf"};
ntrees.enable_instancing();
@ -523,6 +519,8 @@ int main_loop(game_state& g) @@ -523,6 +519,8 @@ int main_loop(game_state& g)
grass.enable_instancing();
grass.buffer_instances(init_model_transforms(10000, extent, p,0,0, 0, 8));
Model xenia {g.asset_dir / "models"/ "xenia_the_linux_mascot" / "scene.gltf"};
Model dry_grass {g.asset_dir / "models"/ "dry_grass" / "scene.gltf"};
dry_grass.enable_instancing();
dry_grass.buffer_instances(init_model_transforms(10000, extent, p,0,0, 0, 9));
@ -637,6 +635,8 @@ int main_loop(game_state& g) @@ -637,6 +635,8 @@ int main_loop(game_state& g)
model_ubo->view(cam.view_transform);
model_ubo->view_pos(glm::vec4(transform.position, 0));
model_ubo->projection(cam.projection);
//tri_shader->set("view", cam.view_transform);
//tri_shader->set("projection", cam.projection);
@ -651,6 +651,18 @@ int main_loop(game_state& g) @@ -651,6 +651,18 @@ int main_loop(game_state& g)
camera_light.light_pos = glm::vec4(parent_transform.position, 0);
mat_ubo->lights()[0] = camera_light;
mat_ubo->update_all_fields();
//xenia.draw(mat_ubo, model_ubo, forward_pass_shader, glm::rotate(t1, (float)M_PI, glm::vec3(1,0,0)));
auto xenia_transform = glm::mat4(1);
xenia_transform = glm::translate(xenia_transform, parent_transform.position);
xenia_transform = glm::translate(xenia_transform, glm::vec3(0, -8, 0));
xenia_transform = glm::rotate(xenia_transform, (float)M_PI, glm::vec3(1,0,0));
xenia_transform = glm::rotate(xenia_transform, (float)M_PI/2 - (glm::radians(cam.euler_angles[0] * walking_state.z) - glm::radians(90 * walking_state.x)), glm::vec3(0,1,0));
xenia_transform = glm::scale(xenia_transform, glm::vec3(0.5));
xenia.draw(mat_ubo, model_ubo, forward_pass_shader, xenia_transform);
for(auto entity: view) {
static_model_transform &model = view.get<static_model_transform>(entity);
//tri_shader->set("model", model.get_transform());
@ -666,7 +678,6 @@ int main_loop(game_state& g) @@ -666,7 +678,6 @@ int main_loop(game_state& g)
srand(920731031);
auto t1 = glm::mat4(1);
log.draw(mat_ubo, model_ubo, forward_pass_shader, t1);
ground.draw(mat_ubo, model_ubo, forward_pass_shader, t1);
model.draw(mat_ubo, model_ubo, forward_pass_shader, t1);
ferns.draw(mat_ubo, model_ubo, forward_pass_shader, t1);

7
source/mesh.cpp

@ -19,6 +19,9 @@ Mesh::Mesh(std::vector<struct vertex> vertices, @@ -19,6 +19,9 @@ Mesh::Mesh(std::vector<struct vertex> vertices,
: vertices(vertices), indices(indices), textures(textures),
transform(transform) {
static int total_vertices = 0;
total_vertices += vertices.size();
spdlog::info("Total vertices: {}", total_vertices);
average_position = glm::vec3(0);
for (auto v : vertices) {
average_position += v.position;
@ -168,7 +171,7 @@ void Mesh::draw(std::shared_ptr<ubo_proxy<material_properties>> ubo_mat, @@ -168,7 +171,7 @@ void Mesh::draw(std::shared_ptr<ubo_proxy<material_properties>> ubo_mat,
bind_textures_for_draw(ubo_mat, shader);
// we set the transform for this mesh
ubo_model->model(this->transform * transform);
ubo_model->model(transform * this->transform);
ubo_model->instancing_enabled(0);
ubo_model->update_all_fields();
// draw mesh
@ -190,7 +193,7 @@ void Mesh::draw_instanced( @@ -190,7 +193,7 @@ void Mesh::draw_instanced(
int num_instances) {
bind_textures_for_draw(ubo_mat, shader);
ubo_model->model(this->transform * transform);
ubo_model->model(transform * this->transform);
ubo_model->instancing_enabled(1);
ubo_model->update_all_fields();

1
source/uniform-buffer.hpp

@ -74,7 +74,6 @@ struct material_properties { @@ -74,7 +74,6 @@ struct material_properties {
for (int i = 0; i < normal_texture.size(); i++) {
auto tex = normal_texture[i];
shader->set(fmt::format("material.texture_normal{}", i + 1), tex);
spdlog::info("Texture {}", fmt::format("material.texture_normal{}", i));
}
}
};

Loading…
Cancel
Save