====== Primitives ======
Due to performance optimization Gorilla3D introduces their own primitive models.
Default FireMonkey primitives TCube, TSphere, TPlane and TCylinder are still supported, but they reduce render speed a lot when there is used large subdivisioning by the user.
A sphere could reach an enormous amount of vertices, when subdivision is set to high values.
Each time the sphere gets rendered, all those vertices are transfered to GPU.
To solve this problem, the Gorilla3D primitives TGorillaCube, TGorillaSphere, TGorillaCylinder and TGorillaPlane are inherited from TGorillaMesh and are able to use static framebuffers for fast rendering.
Static framebuffers will only push vertex data once to the GPU and render the elements only by switching to the framebuffer.
===== Supported primitives =====
==== TGorillaCube ====
{{:0.8.4:p_cube.jpg?nolink&600|}}
uses
Gorilla.Cube;
[...]
begin
FCube := TGorillaCube.Create(GorillaViewport1);
FCube.Parent := GorillaViewport1;
/// increase the number vertices, but in many cases subdivisions of 1 are enough for a cube.
{$IFDEF MSWINDOWS}
/// only on window platform a large number of vertices.
FCube.SubdivisionsDepth := 128;
FCube.SubdivisionsHeight := 128;
FCube.SubdivisionsWidth := 128;
{$ELSE}
// Android platform is limited to 32K vertices for meshes.
FCube.SubdivisionsDepth := 32;
FCube.SubdivisionsHeight := 32;
FCube.SubdivisionsWidth := 32;
{$ENDIF}
/// make it larger
FCube.SetSize(2, 2, 2);
/// to forbid mouse interaction use:
FCube.SetHitTestValue(false);
end;
==== TGorillaSphere ====
{{:0.8.4:p_sphere.jpg?nolink&600|}}
uses
Gorilla.Sphere;
[...]
begin
FSphere := TGorillaSphere.Create(GorillaViewport1);
FSphere.Parent := GorillaViewport1;
/// create a sphere with more detail
{$IFDEF MSWINDOWS}
/// create a very detailled sphere.
FSphere.SubdivisionsAxes := 128;
FSphere.SubdivisionsHeight := 128;
{$ELSE}
/// on Android platform number of vertices is limited to 32K.
FSphere.SubdivisionsAxes := 32;
FSphere.SubdivisionsHeight := 32;
{$ENDIF}
/// make it larger
FSphere.SetSize(2, 2, 2);
/// to forbid mouse interaction
FSphere.SetHitTestValue(false);
end;
==== TGorillaCylinder ====
{{:0.8.4:p_cyl.jpg?nolink&600|}}
uses
Gorilla.Cylinder;
[...]
begin
FCylinder:= TGorillaCylinder.Create(GorillaViewport1);
FCylinder.Parent := GorillaViewport1;
{$IFDEF MSWINDOWS}
/// create a very detailled cylinder.
FCylinder.SubdivisionsAxes := 128;
FCylinder.SubdivisionsCap := 32;
FCylinder.SubdivisionsHeight := 32;
{$ELSE}
/// on Android platform number of vertices is limited to 32K.
FCylinder.SubdivisionsAxes := 32;
FCylinder.SubdivisionsCap := 1;
FCylinder.SubdivisionsHeight := 1;
{$ENDIF}
/// make it larger
FCylinder.SetSize(2, 2, 2);
/// to forbid mouse interaction
FCylinder.SetHitTestValue(false);
end;
==== TGorillaCapsule ====
{{:0.8.4:p_capsule.jpg?nolink&600|}}
uses
Gorilla.Capsule;
[...]
begin
FCapsule:= TGorillaCapsule.Create(GorillaViewport1);
FCapsule.Parent := GorillaViewport1;
FCapsule.Radius := 0.35;
{$IFDEF MSWINDOWS}
/// create a very detailled capsule.
FCapsule.Segments := 128;
FCapsule.Rings := 64;
{$ELSE}
/// on Android platform number of vertices is limited to 32K.
FCapsule.Segments := 32;
FCapsule.Rings := 8;
{$ENDIF}
/// make it larger
FCapsule.SetSize(2.75, 2, 2.75);
/// to forbid mouse interaction
FCapsule.SetHitTestValue(false);
end;
==== TGorillaPlane ====
{{:0.8.4:p_plane.jpg?nolink&600|}}
uses
Gorilla.Plane;
[...]
begin
FPlane:= TGorillaPlane.Create(GorillaViewport1);
FPlane.Parent := GorillaViewport1;
/// placing it as floor
FPlane.RotationAngle.X := -90;
{$IFDEF MSWINDOWS}
/// create a very detailled plane.
FPlane.SubdivisionsHeight := 128;
FPlane.SubdivisionsWidth := 128;
{$ELSE}
/// on Android platform number of vertices is limited to 32K.
FPlane.SubdivisionsHeight := 16;
FPlane.SubdivisionsWidth := 16;
{$ENDIF}
/// make it larger
FPlane.SetSize(10, 5, 0.1);
/// to forbid mouse interaction
FPlane.SetHitTestValue(false);
end;
==== TGorillaCone ====
{{:0.8.4:p_cone.jpg?nolink&600|}}
uses
Gorilla.Cone;
[...]
begin
FCone := TGorillaCone.Create(GorillaViewport1);
FCone.Parent := GorillaViewport1;
FCone.TopRadius := 0.01;
FCone.BottomRadius := 2;
{$IFDEF MSWINDOWS}
/// create a very detailled cone.
FCone.Sides := 128;
FCone.HeightSegments := 128;
{$ELSE}
/// on Android platform number of vertices is limited to 32K.
FCone.Sides := 32;
FCone.HeightSegments := 1;
{$ENDIF}
/// make it larger
FCone.SetSize(2, 2, 2);
/// to forbid mouse interaction
FCone.SetHitTestValue(false);
end;
==== TGorillaTube ====
{{:0.8.4:p_tube.jpg?nolink&600|}}
uses
Gorilla.Tube;
[...]
begin
FTube := TGorillaTube.Create(GorillaViewport1);
FTube.Parent := GorillaViewport1;
FTube.TopRadius1 := 0.25;
FTube.TopRadius2 := 0.15;
FTube.BottomRadius1 := 0.5;
FTube.BottomRadius2 := 0.15;
{$IFDEF MSWINDOWS}
/// create a very detailled tube.
FTube.Sides := 128;
{$ELSE}
/// on Android platform number of vertices is limited to 32K.
FTube.Sides := 24;
{$ENDIF}
/// make it larger
FTube.SetSize(2, 2, 2);
/// to forbid mouse interaction
FTube.SetHitTestValue(false);
end;
==== TGorillaTorus ====
{{:0.8.4:p_torus.jpg?nolink&600|}}
uses
Gorilla.Torus;
[...]
begin
FTorus := TGorillaTorus.Create(GorillaViewport1);
FTorus.Parent := GorillaViewport1;
FTorus.Radius1 := 1;
FTorus.Radius2 := 0.3;
{$IFDEF MSWINDOWS}
/// create a very detailled torus.
FTorus.RadSegments := 128;
FTorus.Sides := 128;
{$ELSE}
/// on Android platform number of vertices is limited to 32K.
FTorus.RadSegments := 24;
FTorus.Sides := 18;
{$ENDIF}
/// make it larger
FTorus.SetSize(2, 2, 2);
/// to forbid mouse interaction
FTorus.SetHitTestValue(false);
end;
==== TGorillaGrid ====
{{:0.8.4:p_grid.jpg?nolink&600|}}
uses
Gorilla.Grid;
[...]
begin
FGrid := TGorillaGrid.Create(GorillaViewport1);
FGrid.Parent := GorillaViewport1;
/// make it larger
FGrid.SetSize(10, 10, 10);
/// pre configure grid, othwise nothing will be rendered
FGrid.DefaultLines := 16;
FGrid.Frequency := 0.25;
FGrid.Marks := 0.5;
FGrid.LineColor := TAlphaColorRec.Cornflowerblue;
end;
==== TGorillaGrid3D ====
The Grid3D component is a container holding 3 instances of TGorillaGrid for each 3D axis: GridX, GridY and GridZ.
{{:0.8.4:p_grid3d.jpg?nolink&600|}}
uses
Gorilla.Grid;
[...]
begin
FGrid3D := TGorillaGrid3D.Create(GorillaViewport1);
FGrid3D.Parent := GorillaViewport1;
/// make it larger
FGrid3D.SetSize(10, 10, 10);
/// to modify each grid inside of the container use GridX, GridY or GridZ property
FGrid3D.GridX.DefaultLines := 16;
FGrid3D.GridX.Frequency := 1.5;
FGrid3D.GridX.Marks := 2.5;
FGrid3D.GridX.LineColor := TAlphaColorRec.Cornflowerblue;
end;
==== TGorillaModel ====
{{:0.8.4:p_model.jpg?nolink&600|}}
For detailled reading on loading models, please have a closer look [[models|here]].
Next step: [[cameras|Cameras]]