Skip to content

Commit 994c193

Browse files
fix model baking
1 parent 9bb4640 commit 994c193

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

CBRE.Editor/Compiling/Lightmap/Lightmapper.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,19 @@ public Lightmapper(Document document) {
125125
TextureU = (decimal)(x.TextureU),
126126
TextureV = (decimal)(x.TextureV),
127127
});
128-
tFace.Vertices.Clear();
129-
tFace.Vertices.AddRange(verts);
130-
/*for (int i = 0; i < mesh.Vertices.Count - 1; i+=2) {
131-
tFace.Vertices.Add(verts.ElementAt(i+0));
128+
for (int i = 0; i < mesh.Vertices.Count; i+=3) {
129+
tFace.Vertices.Clear();
130+
tFace.Vertices.Add(verts.ElementAt(i));
132131
tFace.Vertices.Add(verts.ElementAt(i+1));
133-
}*/
134-
tFace.Plane = new DataStructures.Geometric.Plane(tFace.Vertices[0].Location, tFace.Vertices[1].Location, tFace.Vertices[2].Location);
135-
tFace.Vertices.ForEach(v => { v.LMU = -500.0f; v.LMV = -500.0f; });
136-
tFace.UpdateBoundingBox();
137-
LMFace face = new LMFace(tFace.Clone());
138-
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));
139-
// opaqueFaces.Add(face);
140-
modelFaces.Add(face);
132+
tFace.Vertices.Add(verts.ElementAt(i+2));
133+
tFace.Plane = new DataStructures.Geometric.Plane(tFace.Vertices[0].Location, tFace.Vertices[1].Location, tFace.Vertices[2].Location);
134+
tFace.Vertices.ForEach(v => { v.LMU = -500.0f; v.LMV = -500.0f; });
135+
tFace.UpdateBoundingBox();
136+
LMFace face = new LMFace(tFace.Clone());
137+
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));
138+
// opaqueFaces.Add(face);
139+
modelFaces.Add(face);
140+
}
141141
}
142142
}
143143
}

CBRE.Providers/Map/RMeshProvider.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ public static void SaveToFile(string path, DataStructures.MapObjects.Map map, Te
9090
new Vector3F(fv.Location.XZY()),
9191
new Vector2F((float)fv.TextureU, (float)fv.TextureV),
9292
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)))));
93+
/*
9394
for (int i = 0; i < vertices.Count; i+=3) {
9495
triangles.Add(new RMesh.RMesh.Triangle((ushort)i, (ushort)(i+1), (ushort)(i+2)));
9596
}
96-
/*triangles.AddRange(face.GetTriangleIndices().Chunk(3).Select(c => new RMesh.RMesh.Triangle(
97-
(ushort)(c[0] + indexOffset), (ushort)(c[1] + indexOffset), (ushort)(c[2] + indexOffset))));*/
97+
*/
98+
triangles.AddRange(face.GetTriangleIndices().Chunk(3).Select(c => new RMesh.RMesh.Triangle(
99+
(ushort)(c[0] + indexOffset), (ushort)(c[1] + indexOffset), (ushort)(c[2] + indexOffset))));
98100
indexOffset += face.Vertices.Count;
99101

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

0 commit comments

Comments
 (0)