summaryrefslogtreecommitdiff
path: root/world/src/main.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-01-07 12:25:37 +0100
committermetamuffin <metamuffin@disroot.org>2025-01-07 12:25:37 +0100
commitd81eebe423fd3e00df5ff035ec24fe7fb37f2c62 (patch)
treee96dddf8e179f47dc030729d6f725c30dfa372d9 /world/src/main.rs
parent31ae23b7eb8cd0b688be07ae6cb4b5a96ee02a68 (diff)
downloadweareserver-d81eebe423fd3e00df5ff035ec24fe7fb37f2c62.tar
weareserver-d81eebe423fd3e00df5ff035ec24fe7fb37f2c62.tar.bz2
weareserver-d81eebe423fd3e00df5ff035ec24fe7fb37f2c62.tar.zst
albedo texture works
Diffstat (limited to 'world/src/main.rs')
-rw-r--r--world/src/main.rs35
1 files changed, 16 insertions, 19 deletions
diff --git a/world/src/main.rs b/world/src/main.rs
index 033d176..7bcd021 100644
--- a/world/src/main.rs
+++ b/world/src/main.rs
@@ -1,6 +1,7 @@
#![feature(iter_array_chunks)]
use anyhow::Result;
use clap::Parser;
+use log::info;
use rand::random;
use std::{
io::Write,
@@ -12,7 +13,7 @@ use std::{
use weareshared::{
Affine3A, Vec3A,
packets::{Data, Object, Packet, ReadWrite},
- resources::{Attribute, AttributeArray, IndexArray, Part, Prefab},
+ resources::{AttributeArray, IndexArray, Part, Prefab},
store::ResourceStore,
vec3a,
};
@@ -73,38 +74,34 @@ fn main() -> Result<()> {
.array_chunks::<3>()
.collect::<Vec<_>>();
- let mut albedo = None;
+ let mut tex_pbr_albedo = None;
if let Some(tex) = p.material().pbr_metallic_roughness().base_color_texture() {
let s = tex.texture().source().source();
if let gltf::image::Source::View { view, mime_type } = s {
- let buf = &buffers[view.buffer().index()];
- albedo = Some(store.set(&buf.0)?);
+ info!("albedo texture is of type {mime_type:?}");
+ let buf = &buffers[view.buffer().index()].0
+ [view.offset()..view.offset() + view.length()];
+ tex_pbr_albedo = Some(store.set(buf)?);
}
}
let part = store.set(
&Part {
va_position: Some([
- Attribute::Vertex(store.set(&AttributeArray(pos_x).write_alloc())?),
- Attribute::Vertex(store.set(&AttributeArray(pos_y).write_alloc())?),
- Attribute::Vertex(store.set(&AttributeArray(pos_z).write_alloc())?),
+ store.set(&AttributeArray(pos_x).write_alloc())?,
+ store.set(&AttributeArray(pos_y).write_alloc())?,
+ store.set(&AttributeArray(pos_z).write_alloc())?,
]),
va_normal: Some([
- Attribute::Vertex(store.set(&AttributeArray(norm_x).write_alloc())?),
- Attribute::Vertex(store.set(&AttributeArray(norm_y).write_alloc())?),
- Attribute::Vertex(store.set(&AttributeArray(norm_z).write_alloc())?),
+ store.set(&AttributeArray(norm_x).write_alloc())?,
+ store.set(&AttributeArray(norm_y).write_alloc())?,
+ store.set(&AttributeArray(norm_z).write_alloc())?,
]),
va_texcoord: Some([
- Attribute::Vertex(store.set(&AttributeArray(uv_x).write_alloc())?),
- Attribute::Vertex(store.set(&AttributeArray(uv_y).write_alloc())?),
+ store.set(&AttributeArray(uv_x).write_alloc())?,
+ store.set(&AttributeArray(uv_y).write_alloc())?,
]),
- va_pbr_albedo: albedo.map(|a| {
- [
- Attribute::Texture(a, 0),
- Attribute::Texture(a, 1),
- Attribute::Texture(a, 2),
- ]
- }),
+ tex_pbr_albedo,
index: Some(store.set(&IndexArray(index).write_alloc())?),
..Part::default()
}