Giter Site home page Giter Site logo

Comments (8)

walbourn avatar walbourn commented on June 7, 2024

The map file is intended to contain:

newIndex,oldIndex

This means that vertex newIndex in the new mesh came originally from oldIndex in the original mesh. This is supposed to account for both duplicates from the clean process and the new parameterization.

from uvatlas.

gyxiaochina avatar gyxiaochina commented on June 7, 2024

Thank you for your reply. That is actually what I thought the _map.txt indicates, but what I found out later in my experimental results somewhat baffled me. For example, I still used this per-vertex-color OBJ as input original mesh original mesh, then I applied "-t -c -m -wf" switches on this input mesh to generate a new mesh together with a resulting _map.txt file. This _map.txt looks like below:

0,0
1,1
2,2
...

This pattern of same newIndex vs. oldIndex goes all the way down till line#67151 before the newIndex and oldIndex are different. I assume this means the new indices 0, 1, and 2 in the new mesh corresponds to old indices 0, 1, and 2 in the original mesh, respectively. However, the 3D coordinates of vertices 0, 1, and 2 in the original mesh are:

v 0.236947 -1.026314 0.613356
v -1.028812 -0.994679 0.613356
v 0.490099 -1.011664 0.613356

while the 3D coordinates of vertices 0, 1, and 2 in the new mesh are:

v -0.522509 -1.03974 0.676644
v -0.522509 -1.03742 0.657444
v -0.556232 -1.03742 0.676644

These two set of 3D coordinates look quite different. I previously thought they should be similar if not exactly the same, since no large scale spatial transformation is required for the mesh partition. Then what did I do wrong?

Thank you very much!

from uvatlas.

walbourn avatar walbourn commented on June 7, 2024

What if you try without the -t -c switches?

from uvatlas.

gyxiaochina avatar gyxiaochina commented on June 7, 2024

I just tried "-m -wf" as you advised. The results still show mismatches between the vertices in the original mesh and the vertices in the new mesh.

from uvatlas.

Raildex avatar Raildex commented on June 7, 2024

How am I supposed to read the map.txt file in the first place?
I also noticed the vertex positions to be shuffled to some degree.

I am using uvatlastool.exe from C# and I am not sure how to transfer the UVs of the new mesh to the old mesh.

My function looks like this:

private void ApplyLightmapUVs(ref RoomMesh mesh, StreamReader resultMeshReader, StreamReader mappingReader)
{
	List<Vector2> newUVs = new List<Vector2>();
	using (resultMeshReader)
	{
		string line = resultMeshReader.ReadLine();
		while (line != null)
		{
			if (line.StartsWith("vt"))
			{
				var splits = line.Split(" ");
				var u = float.Parse(splits[1]);
				var v = float.Parse(splits[2]);
				newUVs.Add(new Vector2(u, v));
			}
			line = resultMeshReader.ReadLine();
		}
		
	}
	using (mappingReader)
	{
		string line = mappingReader.ReadLine();
		while (line != null)
		{
			var splits = line.Split(",");
			var oldIdx = int.Parse(splits[1]);
			var newIdx = int.Parse(splits[0]);
			RoomVertex oldVertex = mesh.Vertices[oldIdx];
			RoomVertex newVertex = oldVertex;
			newVertex.LightmapUV = newUVs[newIdx]; // apply new UVs
			mesh.Vertices[oldIdx] = newVertex;
			line = mappingReader.ReadLine();
		}
	}
	ExportRoomToOBJ(mesh, "Temp/test.obj",true); // sanity check. shows messed up UVs
}

resultMeshReader is the obj file of the result mesh after uvatlastool.exe.
mappingReader is the mapping file.
However, the obj I export for a sanity check has messed up UVs.
I have attached all meshes
Temp.zip

from uvatlas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.