Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
layer3d [2020/01/09 14:22] – [Fix Transparency] adminlayer3d [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1
Line 1: Line 1:
-====== 2D FMX Components ====== 
  
-Gorilla3D supports all default 2D Firemonkey components, like TLabel, TButton, TEdit and so on. 
- 
-===== On top ===== 
- 
-You can add those components as child of the TGorillaViewport instance to show them on top of the rendered 3D world. 
- 
-<file pascal> 
-FLabel := TLabel.Create(FGorilla); 
-FLabel.Parent := FGorilla; 
-FLabel.Text := 'TEST'; 
-</file> 
- 
-===== Layers ===== 
- 
-You can also integrate them inside of a layer component, like TLayer3D, TTextLayer3D, ... 
-**Using a layer may lead to misleading result in first place due to false default settings in FMX.** 
- 
-==== Fix Resolution ==== 
- 
-One of the most popular used layer is a transparent 3D layer where 2D FMX components are placed into. 
- 
-With default FMX settings this would look simply horrible. 
- 
-Here an example of a TLayer3D with a TEdit, TLabel, TButton and TRadioButton component. 
- 
-{{ :layer3d-1.jpg?nolink&400 | defect layer rendering}} 
- 
-We need to change a few properties to get this working. 
-To fix the shredded 2D rendering, we need to reset the resolution to a higher value than 50. 
- 
-<file pascal> 
-// set resolution higher than 72 at a size of [width=8, height=4] 
-FLayer.Resolution := 72; 
-</file> 
- 
-==== Fix Transparency ==== 
- 
-**Since v0.8.1 take a look at: [[transparency|Transparency]]** 
- 
-__For elder versions:__ To fix the false transparency, we have to play around with opacity. 
-Due to original FMX rendering order list generation, the opacity influences the order. 
- 
-At the moment a component can only display 2 transparent children layers correctly. 
-<file pascal> 
-if (Left.Opacity < 1) and (Right.Opacity >= 1) then 
-  Result := 1 // left layer will be in front 
-else if (Left.Opacity >= 1) and (Right.Opacity < 1) then 
-  Result := -1 // right layer will be in front 
- </file> 
- 
-Setup for 2 layers: 
-<file pascal> 
-TGorillaViewport 
-    TDummy (Opacity = 0.999) 
-        TLayer3D (Opacity = 1, Transparency = true) 
-            TImage 
-        TLayer3D (Opacity = 0.999, Transparency = true) 
-            TLabel 
-</file> 
- 
-If we need more transparent layers, we need work around with TDummy objects. 
-<file pascal> 
-TGorillaViewport 
-    TDummy (Opacity = 1) 
-        TLayer3D (Opacity = 1, Transparency = true) 
-            TImage 
-        TDummy (Opacity = 0.999) 
-            TLayer3D (Opacity = 1, Transparency = true) 
-                TImage 
-            TLayer3D (Opacity = 0.999, Transparency = true) 
-                TLabel 
-</file> 
- 
-In the end, the result should look like this: 
- 
-{{ ::layer3d-2.jpg?nolink&400 |}} 
- 
-Next step: [[scripting|Scripting]]