Skip to content

Commit

Permalink
fix model baking
Browse files Browse the repository at this point in the history
  • Loading branch information
VirtualBrightPlayz committed Nov 26, 2022
1 parent 9bb4640 commit 994c193
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
24 changes: 12 additions & 12 deletions CBRE.Editor/Compiling/Lightmap/Lightmapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,19 @@ public Lightmapper(Document document) {
TextureU = (decimal)(x.TextureU),
TextureV = (decimal)(x.TextureV),
});
tFace.Vertices.Clear();
tFace.Vertices.AddRange(verts);
/*for (int i = 0; i < mesh.Vertices.Count - 1; i+=2) {
tFace.Vertices.Add(verts.ElementAt(i+0));
for (int i = 0; i < mesh.Vertices.Count; i+=3) {
tFace.Vertices.Clear();
tFace.Vertices.Add(verts.ElementAt(i));
tFace.Vertices.Add(verts.ElementAt(i+1));
}*/
tFace.Plane = new DataStructures.Geometric.Plane(tFace.Vertices[0].Location, tFace.Vertices[1].Location, tFace.Vertices[2].Location);
tFace.Vertices.ForEach(v => { v.LMU = -500.0f; v.LMV = -500.0f; });
tFace.UpdateBoundingBox();
LMFace face = new LMFace(tFace.Clone());
BoxF faceBox = new BoxF(face.BoundingBox.Start - new Vector3F(3.0f, 3.0f, 3.0f), face.BoundingBox.End + new Vector3F(3.0f, 3.0f, 3.0f));
// opaqueFaces.Add(face);
modelFaces.Add(face);
tFace.Vertices.Add(verts.ElementAt(i+2));
tFace.Plane = new DataStructures.Geometric.Plane(tFace.Vertices[0].Location, tFace.Vertices[1].Location, tFace.Vertices[2].Location);
tFace.Vertices.ForEach(v => { v.LMU = -500.0f; v.LMV = -500.0f; });
tFace.UpdateBoundingBox();
LMFace face = new LMFace(tFace.Clone());
BoxF faceBox = new BoxF(face.BoundingBox.Start - new Vector3F(3.0f, 3.0f, 3.0f), face.BoundingBox.End + new Vector3F(3.0f, 3.0f, 3.0f));
// opaqueFaces.Add(face);
modelFaces.Add(face);
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions CBRE.Providers/Map/RMeshProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ public static void SaveToFile(string path, DataStructures.MapObjects.Map map, Te
new Vector3F(fv.Location.XZY()),
new Vector2F((float)fv.TextureU, (float)fv.TextureV),
new Vector2F((float)fv.LMU, (float)fv.LMV), Color.FromArgb(0xff, (byte)(fv.Color.X * 255f), (byte)(fv.Color.Y * 255f), (byte)(fv.Color.Z * 255f)))));
/*
for (int i = 0; i < vertices.Count; i+=3) {
triangles.Add(new RMesh.RMesh.Triangle((ushort)i, (ushort)(i+1), (ushort)(i+2)));
}
/*triangles.AddRange(face.GetTriangleIndices().Chunk(3).Select(c => new RMesh.RMesh.Triangle(
(ushort)(c[0] + indexOffset), (ushort)(c[1] + indexOffset), (ushort)(c[2] + indexOffset))));*/
*/
triangles.AddRange(face.GetTriangleIndices().Chunk(3).Select(c => new RMesh.RMesh.Triangle(
(ushort)(c[0] + indexOffset), (ushort)(c[1] + indexOffset), (ushort)(c[2] + indexOffset))));
indexOffset += face.Vertices.Count;

if (face.Texture.Name.ToLowerInvariant() == "tooltextures/invisible_collision") {
Expand Down

0 comments on commit 994c193

Please sign in to comment.