Search Blogs Blogs

Simplify Insight3D primitive creation with the primitive factory

By: cozzi
In AGI Components 2010 r11, we introduced a new helper class for creating Insight3D primitives that will save you many key strokes. This static class is named PrimitiveFactory, and has methods to create latitude longitude grids, polygons, circles, ellipses and sectors, each in a single line of code. Since Insight3D decouples geometric computation from rendering, drawing something like a circle on the globe given its position and radius requires a few steps: compute the boundary positions for the circle, compute triangles for the boundary's interior and finally create a triangle mesh to draw the interior's triangles. Code for this looks like: SurfaceShapesResult shape = SurfaceShapes.ComputeCircle(earth, center, radius); SurfaceTriangulatorResult triangles = SurfacePolygonTriangulator.Compute(earth, shape.Positions); TriangleMeshPrimitive mesh = new TriangleMeshPrimitive(); mesh.Set(triangles); The new PrimitiveFactory can be used to do this in a single line of code: TriangleMeshPrimitive mesh = PrimitiveFactory.CreateCircle(earth, center, radius); When you don't need the flexibility of decoupled computation and rendering, using the PrimitiveFactory will increase your productivity and make your code more concise. For more information, see the documentation on ADN.
Posted: 12/21/2010 10:10:31 PM