Texture Mapping
1 messages in this thread
I wrote these procedures for Texture Mapping. They have not been
tested yet, but I going to make a demo when I find the time These
Fucntions not included do the following: Dif(A,B) returns the result
of subtract the smaller of the two from the larger. Small(A,B)
returns the smaller of the two. Div10(A) returns the rounded result
of A divided by 10,:Note even if it'd bellow ten then it'll retunr
the closet ten such as 5 would give you a 1 I made Div10 like this to
avoid reals Function Div10(A:Integer):Integer; Var
R:Integer;
Begin
R:=A div 10;
If A-R*10 >=5 then R:=R+1;
Div10:=R;
End;
Plot3D Projects a point to a 640x480x256 screen with perspective projection.
This was written in TP V 7.0
The type area looks like this
Type
Area=Object
X1,Y1,Z1,X2,Y2,Z2:Integer;
Texture:Pointer;
Constrcutor Area.Create (nx1,ny1,nz1,nx2,ny2,nz2:Integer);
Destructor Destory;
Procedure Display;
End;
Area.Display
Var
Map[0..65534] of Byte Absolute Texture;
X,Y,Z,Zs:Integer;
A,B,Zdif:Byte;
Begin
Zdif:=Dif(Z1,Z2);
Zs:=Small(Z1,Z2);
For a:=0 to 255 do begin
For b:=0 to 255 do begin
Z:=(B shr 1)+(A shr 1)+1;
Plot3D(Small(X1,X2)+B,Small(Y1,Y2)+A,Zs+Div10(Div10(Z*100 shr 8)*
Zdif)),Map[a*256+(B-1)]);
End;
End;
End;
Note: These must be 256×256 bitmaps, X1,Y1,Z1,X2,Y2,Z2 define a plane
in 3d space into which the bitmap is to be mapped onto and there can
only be one bitmap.