Scott Ayers
04-02-2010, 06:57 PM
Using the example about splines Lennart gave as a guide. I tried to expand on it and create a quad polygon object.
I'm almost there. But I'm stuck on the building of the polygon section.
I can build a triangle. But I can't seem to figure out how to build a quad.
////////Create Points Section////////
var mypoly = AllocObject(Opolygon); // the empty object
var pointcount = 4;
var arr = new(array, pointcount);
mypoly->SetPoints(arr);
var vc = new(VariableChanged); // Important
vc->Init(0,pointcount); // Important
mypoly->Message(MSG_POINTS_CHANGED,vc); // Important
mypoly->SetPoint(0,vector(-100,0,-100));
mypoly->SetPoint(1,vector(-100,0,100));
mypoly->SetPoint(2,vector(100,0,100));
mypoly->SetPoint(3,vector(100,0,-100));
doc->InsertObject(mypoly,NULL,NULL);
////////Create Polygon Section////////
var polycount = mypoly->GetPolygonCount();
vc->Init(polycount, polycount+1); // add 1 new polygon
var ok = mypoly->MultiMessage(MSG_POLYGONS_CHANGED, vc);
var p = mypoly->GetPolygon(polycount);
// Create the new poly based on the points
p->a = 0;
p->b = 1;
p->c = 2;
p->d = 3;
p->a = mypoly->GetPointCount()-1; <---Creates a triangle polygon
mypoly->SetPolygon(polycount, p);
mypoly->Message(MSG_UPDATE); // Notify object of change
Can anyone give me a hint?
Am I doing this the right way?
-ScottA
I'm almost there. But I'm stuck on the building of the polygon section.
I can build a triangle. But I can't seem to figure out how to build a quad.
////////Create Points Section////////
var mypoly = AllocObject(Opolygon); // the empty object
var pointcount = 4;
var arr = new(array, pointcount);
mypoly->SetPoints(arr);
var vc = new(VariableChanged); // Important
vc->Init(0,pointcount); // Important
mypoly->Message(MSG_POINTS_CHANGED,vc); // Important
mypoly->SetPoint(0,vector(-100,0,-100));
mypoly->SetPoint(1,vector(-100,0,100));
mypoly->SetPoint(2,vector(100,0,100));
mypoly->SetPoint(3,vector(100,0,-100));
doc->InsertObject(mypoly,NULL,NULL);
////////Create Polygon Section////////
var polycount = mypoly->GetPolygonCount();
vc->Init(polycount, polycount+1); // add 1 new polygon
var ok = mypoly->MultiMessage(MSG_POLYGONS_CHANGED, vc);
var p = mypoly->GetPolygon(polycount);
// Create the new poly based on the points
p->a = 0;
p->b = 1;
p->c = 2;
p->d = 3;
p->a = mypoly->GetPointCount()-1; <---Creates a triangle polygon
mypoly->SetPolygon(polycount, p);
mypoly->Message(MSG_UPDATE); // Notify object of change
Can anyone give me a hint?
Am I doing this the right way?
-ScottA
