Extract mesh and occluder generation to methods
This commit is contained in:
parent
91bddd5c12
commit
5dceedeaf1
|
@ -191,15 +191,36 @@ public partial class Mission : Node3D
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var cellNode = new Node3D();
|
|
||||||
|
|
||||||
var material = new StandardMaterial3D
|
var material = new StandardMaterial3D
|
||||||
{
|
{
|
||||||
AlbedoTexture = ImageTexture.CreateFromImage(image),
|
AlbedoTexture = ImageTexture.CreateFromImage(image),
|
||||||
TextureFilter = BaseMaterial3D.TextureFilterEnum.Nearest,
|
TextureFilter = BaseMaterial3D.TextureFilterEnum.Nearest,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MeshInstance3D mesh = GenerateMesh(vertices, normals, indices, lightmapUvs, material);
|
||||||
|
OccluderInstance3D occluderInstance = GenerateOccluder(vertices, indices);
|
||||||
|
|
||||||
|
var cellNode = new Node3D();
|
||||||
|
cellNode.AddChild(mesh);
|
||||||
|
cellNode.AddChild(occluderInstance);
|
||||||
|
|
||||||
|
AddChild(cellNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OccluderInstance3D GenerateOccluder(List<Vector3> vertices, List<int> indices)
|
||||||
|
{
|
||||||
|
var occluder = new ArrayOccluder3D();
|
||||||
|
occluder.SetArrays(vertices.ToArray(), indices.ToArray());
|
||||||
|
var occluderInstance = new OccluderInstance3D
|
||||||
|
{
|
||||||
|
Occluder = occluder,
|
||||||
|
BakeSimplificationDistance = 0.0f
|
||||||
|
};
|
||||||
|
return occluderInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MeshInstance3D GenerateMesh(List<Vector3> vertices, List<Vector3> normals, List<int> indices, List<Vector2> lightmapUvs, StandardMaterial3D material)
|
||||||
|
{
|
||||||
var arrMesh = new ArrayMesh();
|
var arrMesh = new ArrayMesh();
|
||||||
var arrays = new Godot.Collections.Array();
|
var arrays = new Godot.Collections.Array();
|
||||||
arrays.Resize((int)Mesh.ArrayType.Max);
|
arrays.Resize((int)Mesh.ArrayType.Max);
|
||||||
|
@ -216,18 +237,7 @@ public partial class Mission : Node3D
|
||||||
Mesh = arrMesh,
|
Mesh = arrMesh,
|
||||||
CastShadow = GeometryInstance3D.ShadowCastingSetting.On
|
CastShadow = GeometryInstance3D.ShadowCastingSetting.On
|
||||||
};
|
};
|
||||||
cellNode.AddChild(meshInstance);
|
return meshInstance;
|
||||||
|
|
||||||
var occluder = new ArrayOccluder3D();
|
|
||||||
occluder.SetArrays(vertices.ToArray(), indices.ToArray());
|
|
||||||
var occluderInstance = new OccluderInstance3D
|
|
||||||
{
|
|
||||||
Occluder = occluder,
|
|
||||||
BakeSimplificationDistance = 0.0f
|
|
||||||
};
|
|
||||||
cellNode.AddChild(occluderInstance);
|
|
||||||
|
|
||||||
AddChild(cellNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int[] CalcBaseUV(
|
private static int[] CalcBaseUV(
|
||||||
|
|
Loading…
Reference in New Issue