THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/04/2012 at 03:40, xxxxxxxx wrote:
GVO is really nice because you simply create the geometry within that function and then return the final PolygonObject that you created. For example if you wanted to create a single polygon you could do it like this.
PolygonObject *polyObj = PolygonObject::Alloc(4,1); //Allocate a Polygon Object with 4 points and 1 polygon
if (!polyObj) return NULL; //Check to make sure the pointer is valid if not return NULL, prevents crashing
Vector *padr=NULL; //Declare a Vector array to hold the points
CPolygon *vadr=NULL; //Declare an array of CPolygons to hold the polys
padr = polyObj->GetPointW(); //assign the points array to your polygon object points array
vadr = polyObj->GetPolygonW(); //assign the polygon array to your polygon object's poly array
padr[0] = Vector(0,-400,-400); //place your points at your desired locations.
padr[1] = Vector(0,-400,400);
padr[2] = Vector(0,400,400);
padr[3] = Vector(0,400,-400);
vadr[0] = CPolygon(0,1,2,3); // Assign the 4 points to a CPolygon
return polyObj; //return your final object
Just drop that code in to GVO without anything else and see what it does.
Also if you want to create primitives such as a cube. You would do something like this.
BaseObject* cube = BaseObject::Alloc(Ocube);
if(!cube) return NULL;
return cube;
basically because PolygonObject is derived from BaseObject, you can return either a BaseObject or a PolygonObject and it will show up through GVO.
Hope that helps.
~Shawn