Recent

Author Topic: GLScene MeshObjects  (Read 4128 times)

dicepd

  • Full Member
  • ***
  • Posts: 163
GLScene MeshObjects
« on: August 22, 2017, 01:26:49 pm »
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:

Code: Pascal  [Select][+][-]
  1. procedure TTestMeshObject.MakePlane(width, depth: Single);
  2. var
  3.   X, Y: Single;
  4. begin
  5.   X := width / 2.0;
  6.   Y := depth / 2.0;
  7.  
  8.   // define a rect coplanar to the xy plane
  9.   // raised by 12 units in the positive Z axis
  10.  
  11.   // define vertices in CCW rotation from xy positive quadrant
  12.   AddNormal(0, 0, 1);    // normal is positive z for all vertices
  13.   AddTexCoords(0, 1);
  14.   AddVertex(X, Y, 12);
  15.  
  16.   AddNormal(0, 0, 1);
  17.   AddTexCoords(1, 1);
  18.   AddVertex(X, -Y, 12);
  19.  
  20.   AddNormal(0, 0, 1);
  21.   AddTexCoords(0, 1);
  22.   AddVertex(-X, -Y, 12);
  23.  
  24.   AddNormal(0, 0, 1);
  25.   AddTexCoords(1, 0);
  26.   AddVertex(-X, Y, 12);
  27.  
  28.   // Define two tris from a viewpoint looking towards neg Z
  29.   // i.e standard top viewpoint in a real world orientation
  30.   AddFace(0,1,2);  // top right, top left, bottom left     CCW winding
  31.   AddFace(0,2,3);  // top right, bottom left, bottom right  CCW winding
  32.  
  33.   // This should result in a rect which is 12 units above the xy plane
  34.   // back culled faces should be the faces facing the origin.
  35.  
  36. end;
  37.  
  38.  

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
« Last Edit: August 22, 2017, 01:53:58 pm by dicepd »
Lazarus 1.8rc5 Win64 / Linux gtk2 64 / FreeBSD qt4

dicepd

  • Full Member
  • ***
  • Posts: 163
Re: GLScene MeshObjects
« Reply #1 on: August 22, 2017, 02:52:55 pm »
Looks like my own stupidity :-[

Points 2 and 4 transposed.

Ah well writing about it cleared the head.
Lazarus 1.8rc5 Win64 / Linux gtk2 64 / FreeBSD qt4

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: GLScene MeshObjects
« Reply #2 on: August 27, 2017, 10:07:36 am »
Hi, good  8-) Don't remember if i don't answer here don't forget to post questions on : https://sourceforge.net/p/glscene/discussion/

Just a question the procedure MakePlane in my unit "GLMeshObjectHelpe" don't work correctly ? What is her last modified date ? because i posted severals version in GLScene's forum.

Cheers

 

TinyPortal © 2005-2018