Have got around to the next stage of my program where I need parametric mesh generation for both display and calculation.
Borrowing from Jeromes code which he has offered at various times (GLMeshObjectHelper) I started off easy just trying to create a two tri plane (GLMeshObjectHelper uses quads, I need tris for computation reasons). All kind of works with the exception of the displayed faces.
This is the basic code for generating the plane:
procedure TTestMeshObject.MakePlane(width, depth: Single);
var
X, Y: Single;
begin
X := width / 2.0;
Y := depth / 2.0;
// define a rect coplanar to the xy plane
// raised by 12 units in the positive Z axis
// define vertices in CCW rotation from xy positive quadrant
AddNormal(0, 0, 1); // normal is positive z for all vertices
AddTexCoords(0, 1);
AddVertex(X, Y, 12);
AddNormal(0, 0, 1);
AddTexCoords(1, 1);
AddVertex(X, -Y, 12);
AddNormal(0, 0, 1);
AddTexCoords(0, 1);
AddVertex(-X, -Y, 12);
AddNormal(0, 0, 1);
AddTexCoords(1, 0);
AddVertex(-X, Y, 12);
// Define two tris from a viewpoint looking towards neg Z
// i.e standard top viewpoint in a real world orientation
AddFace(0,1,2); // top right, top left, bottom left CCW winding
AddFace(0,2,3); // top right, bottom left, bottom right CCW winding
// This should result in a rect which is 12 units above the xy plane
// back culled faces should be the faces facing the origin.
end;
However GLScene backculls the top of the plane and not the bottom.
I can't change the winding order of the tris as that is the expected winding for computation routines.
So something is wrong. Possibilties:
I have done something wrong in the generation code and can no longer see the wood from the trees.
I am missing some setting or not calling some base class method which should be called.
I found a bug.
Attached is a working test project which fully demonstrates the issue.
Peter