Ok, thanks for Eugene’s last hint, I think I have this working. I take the IndexBuffer for the triangles of a StaticModel Sphere, and convert them into sets of lines.
This code is not really optimized and is designed more for clarity. I also don’t (yet) throw away duplicate lines.
private void CreateStellarHaloNode()
{
stellarHaloNode = universeNode.CreateChild();
stellarHaloNode.Scale = new Vector3(130000.0f, 130000.0f, 130000.0f);
var haloComp = stellarHaloNode.CreateComponent<StaticModel>();
haloComp.Model = CoreAssets.Models.Sphere.Clone();
var geometry = haloComp.Model.GetGeometry(0, 0);
var indexBuffer = geometry.IndexBuffer;
var indexCount = indexBuffer.IndexCount;
var triangleCount = indexCount / 3;
unsafe
{
var newIndices = new short[indexCount * 2];
var shadowData = (short *)indexBuffer.ShadowData;
for (var i = 0; i < triangleCount; i++)
{
var a = shadowData[i * 3];
var b = shadowData[i * 3 + 1];
var c = shadowData[i * 3 + 2];
newIndices[i * 6 + 0] = a;
newIndices[i * 6 + 1] = b;
newIndices[i * 6 + 2] = b;
newIndices[i * 6 + 3] = c;
newIndices[i * 6 + 4] = c;
newIndices[i * 6 + 5] = a;
}
indexBuffer.SetSize(indexCount * 2, false, false);
fixed (short *indexPtr = &newIndices[0])
{
indexBuffer.SetDataRange(indexPtr, 0, indexCount * 2, true);
}
geometry.SetDrawRange(PrimitiveType.LineList, 0, indexCount * 2);
}
var haloMaterial = Material.FromColor(new Color(0.0f, 1.0f, 0.0f, 0.25f), false);
var tech = ResourceCache.GetTechnique(NO_TEXTURE_UNLIT_ALPHA);
haloMaterial.SetTechnique(0, tech);
haloMaterial.RenderOrder = RENDER_ORDER_STRUCTURE;
haloComp.SetMaterial(haloMaterial);
}
Here is what it looks like:
I don’t necessarily like the way this is tessellated compared to SceneKit’s way (see image in initial posting), but I can live with it.
Thanks again for the help. I couldn’t have done this without you.