One thing to remember is that all prims (ignoring trees) are extrusions of a base pattern. A Sphere is a circle that is stretched and then shrunk along a sine wave path. Given this it would actually be possible to make a primitive prim mesh where you could specify the base pattern using a list of points and then the list of extrusion path points.
Here are some examples to describe the concept in a more programmatically manor.
To assemble the arrays you start with a sphere and replace the extrusion circle with the base pattern and you replace the sine wave arc with the second 1D array.
WARNING: The following is a cross between C++ and PHP and will not compile.
CODE
struct STRUCT_1D_POINT16 {
int16 x; // representing -100% to 100% of the Size.
int16 y; // representing -100% to 100% of the Size.
}
#define f(n) (int16)(n * 0x7FFF)
// Here is a 1m cube using the concept.
//I know it would be silly to make a cube using this method, but it’s possible,
struct SendACube {
//usual object items ObjectType = TYPE_1D_MESH;
vector size = <1, 1, 1>;
byte BaseSegmentCount = 4;
STRUCT_1D_POINT16 Bsp[] = {f(1), f(1)},{ f(1), f(-1)},{ f(-1), f(-1)},{ f(-1), f(1)};
byte ExtrusionSegmentCount = 0;
//blank
}
//here is a tube with a flare on one end.
struct SendACube {
//usual object items ObjectType = TYPE_1D_MESH;
vector size = <1, 1, 10>;
byte BaseSegmentCount = 0;
//blank
byte ExtrusionSegmentCount = 2;
STRUCT_1D_POINT16 Esp[] = {f(.8), f(-1)},{ f(.8), f(.5)},{ f(1), f(1)};
}
Here is the deconstruction concept in code like structures
CODE
//create base point array
struct POINT_F {
float x;
float y;
}
#define n2f(n) (float)( (float)n / (float)0x7fff);
POINT_F BasePoints[MAX_POINTS] ;
integer BasePointCount = Prim-> BaseSegmentCount;
if (BaseSegmentCount = 0){
//Load a circle into array based on LOD
}else{
for (int i = 0 ; i< BasePointCount;++i){
BasePoints.x = n2f(Prim->Bsp.x) * Prim->size.x;
BasePoints.y = n2f(Prim->Bsp.y) * Prim->size.y;
}
}
//The array is extruded based on X as the scale
// and Y as the point on the extrusion.
if (prim-> ExtrusionSegmentCount = 0){
//load points {1,-1},{1,1};
}else{
//load points as above
};
//Extrude using Y as percent of extrusion and X as scale.
//1. Add tris of base using first ExtrusionSegment
//2. Fill middle as needed using
//3 Add tris of top using last ExtrusionSegment
Possible future improvements.
1. Add the ability to add Bezier points in the 1D arrays. This would make it easier to make rounded curves.