diff --git a/cosmos_client/assets/blocks/thruster.json b/cosmos_client/assets/blocks/thruster.json index 1a47e8112..f6e10b81d 100644 --- a/cosmos_client/assets/blocks/thruster.json +++ b/cosmos_client/assets/blocks/thruster.json @@ -1,10 +1,10 @@ { "texture": { - "back": "missing", - "front": "laser_cannon_front", - "left": "laser_cannon_left_right", - "right": "laser_cannon_left_right", - "top": "laser_cannon_top_bottom", - "bottom": "laser_cannon_top_bottom" + "back": "thruster_back", + "front": "ship_hull", + "left": "thruster_left_right", + "right": "thruster_left_right", + "top": "thruster_top_bottom", + "bottom": "thruster_top_bottom" } } \ No newline at end of file diff --git a/cosmos_client/src/asset/asset_loading.rs b/cosmos_client/src/asset/asset_loading.rs index d21de5916..6eaf5a30a 100644 --- a/cosmos_client/src/asset/asset_loading.rs +++ b/cosmos_client/src/asset/asset_loading.rs @@ -35,6 +35,19 @@ pub struct MainAtlas { pub uv_mapper: UVMapper, } +impl MainAtlas { + pub fn uvs_for_index(&self, index: usize) -> Rect { + let rect = self.atlas.textures[index]; + + Rect::new( + rect.min.x / self.atlas.size.x, + rect.min.y / self.atlas.size.y, + rect.max.x / self.atlas.size.x, + rect.max.y / self.atlas.size.y, + ) + } +} + #[derive(Resource, Reflect, FromReflect)] pub struct IlluminatedAtlas { pub material: Handle, @@ -112,6 +125,7 @@ fn check_assets_ready( let mut texture_atlas_builder = TextureAtlasBuilder::default(); for handle in &asset.handles { + println!("doing {:?}", server.get_handle_path(handle)); let Some(texture) = images.get(&handle) else { warn!("{:?} did not resolve to an `Image` asset.", server.get_handle_path(handle)); continue; @@ -122,7 +136,7 @@ fn check_assets_ready( let atlas = texture_atlas_builder .finish(&mut images) - .expect("Built atlas"); + .expect("Failed to build atlas"); let material_handle = materials.add(StandardMaterial { base_color_texture: Some(atlas.texture.clone()), @@ -298,6 +312,8 @@ fn load_block_textxures( } } + println!("{unlocalized_name}: {map:?}"); + registry.register(BlockTextureIndex { id: 0, unlocalized_name: unlocalized_name.to_owned(), diff --git a/cosmos_client/src/rendering/structure_renderer.rs b/cosmos_client/src/rendering/structure_renderer.rs index aa350ac58..81a442bb9 100644 --- a/cosmos_client/src/rendering/structure_renderer.rs +++ b/cosmos_client/src/rendering/structure_renderer.rs @@ -2,9 +2,9 @@ use crate::block::lighting::{BlockLightProperties, BlockLighting}; use crate::materials::CosmosMaterial; use crate::state::game_state::GameState; use bevy::prelude::{ - Added, App, BuildChildren, Component, DespawnRecursiveExt, EventReader, IntoSystemConfigs, - Mesh, OnUpdate, PbrBundle, PointLight, PointLightBundle, StandardMaterial, Transform, Vec3, - Without, + warn, Added, App, BuildChildren, Component, DespawnRecursiveExt, EventReader, + IntoSystemConfigs, Mesh, OnUpdate, PbrBundle, PointLight, PointLightBundle, StandardMaterial, + Transform, Vec3, Without, }; use bevy::reflect::{FromReflect, Reflect}; use bevy::render::mesh::{Indices, PrimitiveTopology}; @@ -91,7 +91,7 @@ impl StructureRenderer { fn render( &mut self, structure: &Structure, - uv_mapper: &UVMapper, + atlas: &MainAtlas, blocks: &Registry, lighting: &Registry, materials: &OneToManyRegistry, @@ -140,7 +140,7 @@ impl StructureRenderer { }; self.chunk_renderers[flatten(x, y, z, self.width, self.height)].render( - uv_mapper, + atlas, materials, lighting, chunk, @@ -405,7 +405,7 @@ fn monitor_needs_rendered_system( renderer.render( structure, - &atlas.uv_mapper, + &atlas, &blocks, &lighting, &materials, @@ -633,7 +633,7 @@ impl ChunkRenderer { /// Renders a chunk into mesh information that can then be turned into a bevy mesh fn render( &mut self, - uv_mapper: &UVMapper, + atlas: &MainAtlas, materials: &OneToManyRegistry, lighting: &Registry, chunk: &Chunk, @@ -771,16 +771,17 @@ impl ChunkRenderer { }); let Some(image_index) = index.atlas_index_from_face(*face) else { + warn!("Missing image index -- {index:?}"); continue; }; - let uvs = uv_mapper.map(image_index); + let uvs = atlas.uvs_for_index(image_index); mesh_info.add_mesh_information( mesh.info_for_face(*face), [cx, cy, cz], - [uvs[0].x, uvs[0].y], - [uvs[1].x, uvs[1].y], + [uvs.min.x, uvs.min.y], + [uvs.max.x, uvs.max.y], ); } diff --git a/cosmos_server/world/0_0_0/oJj8YWwl1A0lcPXjfHAG4BEI2J6SLSVQsu3xn0MdNlqxQ7g8YO7gnIHXzvO1jNNt.cent b/cosmos_server/world/0_0_0/oJj8YWwl1A0lcPXjfHAG4BEI2J6SLSVQsu3xn0MdNlqxQ7g8YO7gnIHXzvO1jNNt.cent index 934c9c04c..c7e890c8b 100644 Binary files a/cosmos_server/world/0_0_0/oJj8YWwl1A0lcPXjfHAG4BEI2J6SLSVQsu3xn0MdNlqxQ7g8YO7gnIHXzvO1jNNt.cent and b/cosmos_server/world/0_0_0/oJj8YWwl1A0lcPXjfHAG4BEI2J6SLSVQsu3xn0MdNlqxQ7g8YO7gnIHXzvO1jNNt.cent differ diff --git a/cosmos_server/world/0_0_0/ysbLWCLigtiPK5QPJweepIb2bnlcRb0jIseu0bv7luBcD3dHiOAVarBuBqEBJK2Y.cent b/cosmos_server/world/0_0_0/ysbLWCLigtiPK5QPJweepIb2bnlcRb0jIseu0bv7luBcD3dHiOAVarBuBqEBJK2Y.cent index 95f418d5f..62621366f 100644 Binary files a/cosmos_server/world/0_0_0/ysbLWCLigtiPK5QPJweepIb2bnlcRb0jIseu0bv7luBcD3dHiOAVarBuBqEBJK2Y.cent and b/cosmos_server/world/0_0_0/ysbLWCLigtiPK5QPJweepIb2bnlcRb0jIseu0bv7luBcD3dHiOAVarBuBqEBJK2Y.cent differ