Skip to content

Commit

Permalink
Fix up texture coordinate handling from OBJ/COLLADA to CEM
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbot16 committed Nov 16, 2018
1 parent 4138122 commit a5818e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/collada_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'n> fmt::Display for Geometry<'n> {

write_source("mesh-positions", &self.mesh_positions, 3, FORMAT_POS)?;
write_source("mesh-normals", &self.mesh_normals, 3, FORMAT_POS)?;
write_source("mesh-map", &self.mesh_map, 3, FORMAT_TEX)?;
write_source("mesh-map", &self.mesh_map, 2, FORMAT_TEX)?;
}

writeln!(f, r##" <vertices id="{0}-mesh-vertices"><input semantic="POSITION" source="#{0}-mesh-positions"/></vertices>"##, self.name)?;
Expand Down Expand Up @@ -138,7 +138,7 @@ pub fn convert(cem: Scene<V2>) -> String {
geometry.mesh_normals[index*3 + 2] = normal.z;

geometry.mesh_map[index*2 + 0] = vertex.texture.x;
geometry.mesh_map[index*2 + 1] = vertex.texture.y;
geometry.mesh_map[index*2 + 1] = 1.0 - vertex.texture.y;
}

writeln!(string, "{}", geometry).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ fn obj_to_cem(i: &Object) -> V2 {
vertices.push(v2::Vertex {
position,
normal,
texture: Point2 { x: texture.u as f32, y: texture.v as f32 },
texture: Point2 { x: texture.u as f32, y: 1.0 - texture.v as f32 },
});

index
Expand Down Expand Up @@ -285,7 +285,7 @@ fn cem2_to_obj(cem: V2, frame_index: usize) -> String {

writeln!(string, "v {} {} {}", position.x, position.y, position.z).unwrap();
writeln!(string, "vn {} {} {}", normal.x, normal.y, normal.z).unwrap();
writeln!(string, "vt {} {}", texture.x, texture.y).unwrap();
writeln!(string, "vt {} {}", texture.x, 1.0 - texture.y).unwrap();
}

for &v2::Material { ref name, texture, ref triangles, vertex_offset, vertex_count: _vertex_count, ref texture_name } in &cem.materials {
Expand Down

0 comments on commit a5818e6

Please sign in to comment.