0
votes

I have just downloaded an example of how to start working with FireMonkey 3D but cannot recompile two code parts written on earlier Delphi version (I am using Delphi XE6):

1st part

[dcc32 Error] Unit1.pas(168): E2003 Undeclared identifier: 'Material'

var
  Mesh1: TMesh;
  BMP: TBitmap;
//....
Mesh1.Material.Texture := BMP;

2nd part, errors:

[dcc32 Error] Unit1.pas(221): E2003 Undeclared identifier: 'Vector3DAdd'

[dcc32 Error] Unit1.pas(222): E2003 Undeclared identifier: 'Vector3DScale'

var
Camera1: TCamera;
//....
Camera1.Position.Vector := Vector3DAdd(Camera1.Position.Vector, Vector3DScale(Vector3D(0, 0, 1), (WheelDelta / 120) * 0.3));

How to change it for it can be compiled under a new Delphi version? The whole unit:

unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UIConsts, System.UITypes, System.Classes, System.Variants, FMX.Types,
  FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Objects3D, FMX.Types3D, FMX.Layouts, FMX.Layers3D,
  System.Math.Vectors, FMX.Controls3D, FMX.MaterialSources, FMX.StdCtrls, FMX.Forms3D, FMX.Graphics;

type
  TForm1 = class(TForm3D)
    Camera1: TCamera;
    Mesh1: TMesh;
    procedure FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; var Handled: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure GenerateMesh(Func: Integer);
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

uses Math;

var
  Down: TPointF;

procedure TForm1.GenerateMesh(Func: Integer);
var
  BMP: TBitmap;
  BD: TBitmapData;
  k: Integer;
begin
  Mesh1.Data.Clear;


  BMP := TBitmap.Create(1, 360);
  BMP.Map(TMapAccess.ReadWrite, BD);
  for k := 0 to 359 do
    BD.SetPixel(0, k, CorrectColor(HSLtoRGB(k / 360, 0.75, 0.5)));
  BMP.Unmap(BD);

//  Mesh1.Material.Texture := BMP;
end;

procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer;
  var Handled: Boolean);
begin
//  Camera1.Position.Vector := Vector3DAdd(Camera1.Position.Vector,
//    Vector3DScale(Vector3D(0, 0, 1), (WheelDelta / 120) * 0.3));
end;

end.
1
It would really help if you'd explain what the problem is you're having with the code you posted. What compiler errors are you getting? Have you looked at the source code or documentation in XE6 to see if you can figure it out? What version of Delphi is the code you downloaded written for? - Ken White
Yes, sure, forgot about this, the question is modified. - Molochnik
Yes, got it :), I have just uploaded the whole demo project. The link is in the question. - Molochnik
Sorry about that, I have just checked the link (I uploaded it to the yandex.ru) it is working fine. Now I will upload it to somewhere else. - Molochnik
I removed all unnecessary code and commented two parts where it cannot be compiled. - Molochnik

1 Answers

3
votes

1) You need to maintain a TTextureMaterialSource component, assigning the desired bitmap to the latter's Texture property, and assign a reference to the material source component to camera's MaterialSource property.

2) Use the + and * operators:

var
  Camera1: TCamera;
//....
  Camera1.Position.Vector := Camera1.Position.Vector +
    Vector3D(0, 0, 1) * ((WheelDelta / 120) * 0.3);