//TODO: Simplify method to translate point without using point geometries. public static SphereNode BoundingSphereNode(SphereNode sphere1, SphereNode sphere2) { SphereNode minSp = (sphere1.radius < sphere2.radius) ? sphere1 : sphere2; SphereNode maxSp = (sphere1.radius < sphere2.radius) ? sphere2 : sphere1; double centersDistance = DistanceBetweenCenters(minSp, maxSp); double[] vectorCoord = minSp.center.Zip(maxSp.center, (sp1, sp2) => sp2 - sp1).ToArray(); using (Point minCenter = SphereNode.Center(minSp)) using (Point maxCenter = SphereNode.Center(maxSp)) { Vector v = Vector.ByTwoPoints(minCenter, maxCenter); double translationDist = (centersDistance + (maxSp.radius - minSp.radius)) * 0.5; Point center = (Point)minCenter.Translate(v, translationDist); double radius = (centersDistance + minSp.radius + maxSp.radius) * 0.5; return(new SphereNode(new double[3] { center.X, center.Y, center.Z }, radius)); } }
public void Tessellate(IRenderPackage package, TessellationParameters parameters) { package.RequiresPerVertexColoration = true; Point center = SphereNode.Center(this); Autodesk.DesignScript.Geometry.Geometry geometry = Sphere.ByCenterPointRadius(center, this.radius); byte[] color = new byte[] { 0, 200, 200, 50 }; // As you add more data to the render package, you need // to keep track of the index where this coloration will // start from. geometry.Tessellate(package, parameters); if (package.MeshVertexCount > 0) { package.ApplyMeshVertexColors(CreateColorByteArrayOfSize(package.MeshVertexCount, color[0], color[1], color[2], color[3])); } center.Dispose(); geometry.Dispose(); }