Hi!!
I have a problem, I'm working in a 3D creator appz, I'm useing a 3D engine library, but I need to port it to lazars, all the port now is ok, but I have a problem with one file, because it uses TBitmap.ScanLine, and lazarus don't, then I read many forums and articles by Mattias, but really I'm new in Object Pascal and I don't understand how to make this, I hoppe you can help me how to do this...
The code is this:
----------------------------------------------------------------------------------
unit World3D;
interface
uses
Windows, Model3D, Dialogs, Graphics, ColorConv, Global, Camera, Math;
type
TRGBTripleArray = array[0..32767] of TRGBTriple;
PRGBTripleArray = ^TRGBTripleArray;
TRGBFixed = record
R : integer;
G : integer;
B : integer;
end;
TPointColor = record
X : single;
Y : single;
RGB : TRGBTriple;
end;
TPointColorTriangle = array[0..2] of TPointColor;
TPointLight = record
X : single;
Y : single;
N : TPoint3DSingle;
S : TPoint3DSingle;
end;
TPointLightTriangle = array[0..2] of TPointLight;
TPointTriangle = array[0..2] of TPointFloat;
TLight = record
Position : TPoint3D; // position of light in world
Luminance : byte; // brightness
end;
TVisibleIndex = record
ObjectIndex : integer;
Index : integer;
Distance : Real;
end;
TVisibleIndexArray = array of TVisibleIndex;
T3DWorld = Class(TObject)
private
FWireframe : boolean;
FPhong : boolean;
FBackfaceRemoval : boolean;
FAmbient : byte; // ambient light intensity
FScreenRect : TRect;
FBackgroundColor : TColor;
Scanlines : array of pRGBTripleArray;
procedure SetScreenRect(ARect : TRect);
procedure RenderWireframe;
procedure QuickSort(var A: TVisibleIndexArray; iLo, iHi: Integer);
function PerspectiveProject(APoint3D : TPoint3D) : TPointFloat;
procedure FlatFace(AObject, AFace : integer);
procedure GouraudFace(AObject, AFace : integer);
procedure PhongFace(AObject, AFace : integer);
procedure GouraudPoly(W, H : integer ; V : TPointColorTriangle);
procedure PhongPoly(W, H : integer ; V : TPointLightTriangle ;
Hue, Sat, Lum, Amb : byte);
procedure WuLine(x1, y1, x2, y2 : integer ; R, G, B : byte);
public
Objects : array of T3DModel; // array of objects in world
Camera : TCamera;
Light : TLight;
OffScrBmp : TBitmap; // off screen bitmap for drawing to
procedure Render;
procedure ClearBitmap;
property ScreenRect : TRect read FScreenRect write SetScreenRect;
property Wireframe : boolean read FWireframe write FWireframe;
property Phong : boolean read FPhong write FPhong;
property BackfaceRemoval : boolean read FBackFaceRemoval write FBackFaceRemoval;
property Ambient : byte read FAmbient write FAmbient;
property BackgroundColor : TColor read FBackgroundColor write FBackgroundColor;
constructor Create;
destructor Destroy; override;
end;
----------------------------------------------------------------------------
Tks
Bruno Chavez