zenith пре 3 година
родитељ
комит
56352988c7
4 измењених фајлова са 9 додато и 6 уклоњено
  1. 1 1
      Cargo.toml
  2. 6 4
      chair_exporter.py
  3. 1 1
      examples/reader/src/main.rs
  4. 1 0
      src/io.rs

+ 1 - 1
Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 [package]
 name = "chair"
 name = "chair"
-version = "0.1.1"
+version = "0.1.2"
 edition = "2021"
 edition = "2021"
 description = "An efficient binary mesh format which is both small and extremely fast to read."
 description = "An efficient binary mesh format which is both small and extremely fast to read."
 readme = "README.md"
 readme = "README.md"

+ 6 - 4
chair_exporter.py

@@ -7,7 +7,7 @@ bl_info = {
 	"blender": (3, 0, 0),
 	"blender": (3, 0, 0),
 	"location": "File > Import-Export > Chair Mesh (.chr)",
 	"location": "File > Import-Export > Chair Mesh (.chr)",
 	# Same as the crate version
 	# Same as the crate version
-	"version": (0, 1, 1),
+	"version": (0, 1, 2),
 	"category": "Import-Export"
 	"category": "Import-Export"
 }
 }
 
 
@@ -173,6 +173,10 @@ def write_model(path, objects, indices, export_colours, export_normals, export_u
 	if export_colours:
 	if export_colours:
 		f.write((1).to_bytes(2, "little"))
 		f.write((1).to_bytes(2, "little"))
 		f.write(bytes([255, 255, 255, 255]))
 		f.write(bytes([255, 255, 255, 255]))
+	if 1 > 255:
+		colour_size = 2
+	else:
+		colour_size = 1
 
 
 	# TODO: export texture names
 	# TODO: export texture names
 	if export_uvs:
 	if export_uvs:
@@ -202,14 +206,12 @@ def write_model(path, objects, indices, export_colours, export_normals, export_u
 
 
 		if export_uvs:
 		if export_uvs:
 			# TODO: actual texture index
 			# TODO: actual texture index
-			f.write(bytes([0]))
+			f.write((0).to_bytes(colour_size, "little"))
 		if short_uvs:
 		if short_uvs:
 			write_uvs = write_vec2_byte
 			write_uvs = write_vec2_byte
 		else:
 		else:
 			write_uvs = write_vec2_float
 			write_uvs = write_vec2_float
 
 
-		# TODO: texture name index
-
 		# Write data
 		# Write data
 		for v in obj[0]:
 		for v in obj[0]:
 			write_pos(f, v[0])
 			write_pos(f, v[0])

+ 1 - 1
examples/reader/src/main.rs

@@ -22,7 +22,7 @@ fn main() {
 	let bytes = fs::read(path)
 	let bytes = fs::read(path)
 		.expect("Failed to read file");
 		.expect("Failed to read file");
 	let atlas = DummyAtlas;
 	let atlas = DummyAtlas;
-	let (vertices, indices) = MeshReader::new::<BasicVertex>(&atlas, None)
+	let (vertices, indices) = MeshReader::new::<BasicVertex>(&atlas, Some(""))
 		.read::<BasicVertex>(&bytes)
 		.read::<BasicVertex>(&bytes)
 		.expect("Failed to read mesh data");
 		.expect("Failed to read mesh data");
 	println!("Got {} vertices and {} indices", vertices.len(), indices.len());
 	println!("Got {} vertices and {} indices", vertices.len(), indices.len());

+ 1 - 0
src/io.rs

@@ -241,6 +241,7 @@ impl<'a, A: Atlas> MeshReader<'a, A> {
 				} else {
 				} else {
 					([1.0; 3], [0.0; 3])
 					([1.0; 3], [0.0; 3])
 				};
 				};
+				debug!("Scale is {scale:?}, offset is {offset:?}");
 
 
 				let region = if features.contains(MeshFeature::Textured) {
 				let region = if features.contains(MeshFeature::Textured) {
 					textures.get(bytes.read_u8()? as usize)
 					textures.get(bytes.read_u8()? as usize)