我刚刚下载了一个如何开始使用FireMonkey 3D的示例,但是无法重新编译在早期Delphi版本上编写的两个代码部分(我使用的是Delphi XE6):
第1部分
[dcc32错误] Unit1.pas(168):E2003未声明的标识符:'材料'
var
Mesh1: TMesh;
BMP: TBitmap;
//....
Mesh1.Material.Texture := BMP;
第二部分,错误:
[dcc32错误] Unit1.pas(221):E2003未声明的标识符:'Vector3DAdd'
[dcc32错误] Unit1.pas(222):E2003未声明的标识符:'Vector3DScale'
var
Camera1: TCamera;
//....
Camera1.Position.Vector := Vector3DAdd(Camera1.Position.Vector, Vector3DScale(Vector3D(0, 0, 1), (WheelDelta / 120) * 0.3));
如何更改它可以在新的Delphi版本下编译? 整个单位:
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.
答案 0 :(得分:3)
1)您需要维护一个TTextureMaterialSource
组件,将所需的位图分配给后者的Texture
属性,并将材质源组件的引用分配给相机#s MaterialSource
财产。
2)使用+
和*
运算符:
var
Camera1: TCamera;
//....
Camera1.Position.Vector := Camera1.Position.Vector +
Vector3D(0, 0, 1) * ((WheelDelta / 120) * 0.3);