Formula.dpr 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. {: Generates a 3D mesh from a height-field function.
  2. The left viewer shows a triangle-based mesh, the right viewer uses a
  3. triangle-strip-based mesh, both mesh are based on the same height-field and
  4. have the same resolution.
  5. This sample wants to demonstrate a few things :<ul>
  6. <li>how to define a mesh (triangle & triangle strip)
  7. <li>what the default normal calculations looks like
  8. <li>TriangleStrips are faster, but slightly more complex to use
  9. </ul>
  10. In triangle mode, the normals are computed on a triangle basis, hence the
  11. facetted look, for triangle-strip, they are computed for each vertex based
  12. on the triangle it completes (smooth along strip-direction).
  13. The reader may make the "good" looking version (ie. smooth aspect in all
  14. direction) by calculating the proper normal from the formula instead of
  15. using standard normal calculations.
  16. Sample framerates (K6-400 + Sofware OpenGL), 5000 triangles (cResolution=25) :
  17. - mmTriangles : 9.6 FPS
  18. - mmTriangleStrip : 17.2 FPS
  19. Sample framerates (K7-500 + GeForce 256), 20000 triangles (cResolution=50) :
  20. - mmTriangles : 53 FPS
  21. - mmTriangleStrip : 202 FPS
  22. }
  23. program Formula;
  24. uses
  25. Forms,
  26. fFormula in 'fFormula.pas' {FormFormula};
  27. {$R *.RES}
  28. begin
  29. Application.Initialize;
  30. Application.CreateForm(TFormFormula, FormFormula);
  31. Application.Run;
  32. end.