diff --git a/src/bsp.rs b/src/bsp.rs index 5df6131..4987acf 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -65,9 +65,9 @@ where let polygon_group_id=model::PolygonGroupId::new(polygon_group_id as u32); let face_texture=face.texture(); let face_texture_data=face_texture.texture_data(); - let (texture_u,texture_v)=(glam::Vec3A::from_slice(&face_texture.texture_transforms_u[0..3]),glam::Vec3A::from_slice(&face_texture.texture_transforms_v[0..3])); - let texture_offset=glam::vec2(face_texture.texture_transforms_u[3],face_texture.texture_transforms_v[3]); - let texture_size=glam::vec2(face_texture_data.width as f32,face_texture_data.height as f32); + //this would be better as a 4x2 matrix + let texture_transform_u=glam::Vec4::from_array(face_texture.texture_transforms_u)/(face_texture_data.width as f32); + let texture_transform_v=glam::Vec4::from_array(face_texture.texture_transforms_v)/(face_texture_data.height as f32); //this automatically figures out what the texture is trying to do and creates //a render config for it, and then returns the id to that render config @@ -79,12 +79,12 @@ where spam_normal.push(valve_transform(<[f32;3]>::from(normal))); let mut polygon_iter=face.vertex_positions().map(|vertex_position|{ let vertex_xyz=<[f32;3]>::from(vertex_position); - let pos=glam::Vec3A::from_array(vertex_xyz); let pos_idx=spam_pos.len(); spam_pos.push(valve_transform(vertex_xyz)); //calculate texture coordinates - let tex=(glam::vec2(pos.dot(texture_u),pos.dot(texture_v))+texture_offset)/texture_size; + let pos=glam::Vec3::from_array(vertex_xyz).extend(1.0); + let tex=glam::vec2(texture_transform_u.dot(pos),texture_transform_v.dot(pos)); let tex_idx=spam_tex.len() as u32; spam_tex.push(tex);