PDA

View Full Version : Simba 3D Engine



ReadySteadyGo
01-22-2012, 05:36 PM
A simple 3D Rendering engine that loads the .obj file format and displays 3D models.

Screenshot:
http://i.imgur.com/vOgVU.png

program new;

const
FILE_NAME = 'monkey.obj';

SCREEN_WIDTH = 600;
SCREEN_HEIGHT = 400;

type

TPoint3D = record
x, y, z: Extended;
end;
TVector3D = TPoint3D;

TMatrix3x3 = record
Data: Array of Extended;
end;

TMatrix4x4 = record
Data: Array[0..15] of Extended;
end;

TTriangleFace = record
a, b, c: Integer;
end;

TEntity = record
Name: String;
Vertices: Array of TPoint3D;
VertexNormals: Array of TPoint3D;
Faces: Array of TTriangleFace;
FaceNormals: Array of TVector3D;
WorldPosition: TPoint3D;
end;

TLight = record
Direction: TVector3D;
end;


var
MainForm: TForm;
StartButton: TButton;


function Point3D(x, y, z: Extended): TPoint3D;
begin
Result.x := x;
Result.y := y;
Result.z := z;
end;

function Vector3D(x, y, z: Extended): TVector3D;
begin
Result.x := x;
Result.y := y;
Result.z := z;
end;

function Multiply_Point3D_Matrix3x3(p: TPoint3D; m: TMatrix3x3): TPoint3D;
begin
Result.x := (m.Data[0] * p.x) + (m.Data[1] * p.y) + (m.Data[2] * p.z);
Result.y := (m.Data[3] * p.x) + (m.Data[4] * p.y) + (m.Data[5] * p.z);
Result.z := (m.Data[6] * p.x) + (m.Data[7] * p.y) + (m.Data[8] * p.z);
end;

function DeclareLighting: Array of TLight;
begin
SetLength(Result, 1);

Result[0].Direction := Vector3D(-2.0, 2.0, 2.0);
end;

procedure DrawLine(c: TCanvas; p1, p2: TPoint; Color: Integer);
begin
c.Pen.Color := Color;
c.MoveTo(p1.x, p1.y);
c.LineTo(p2.x, p2.y);
end;

procedure DrawPixel(c: TCanvas; x, y, Color: Integer);
begin
DrawLine(c, Point(x, y), Point(x, y+1), Color);
end;



procedure DrawTriangleF(const Canvas: TCanvas; const p1, p2, p3: TPoint; Color: Integer);
var
DxyLeft, DxyRight, xs, xe, tv1, tv2: Extended;
i: Integer;
begin
tv1 := (p3.x-p1.x);
tv2 := (p3.y-p1.y);
DxyLeft := tv1/tv2;
tv1 := p2.x-p1.x;
tv2 := p2.y-p1.y;
DxyRight := tv1/tv2;

xs := p1.x;
xe := p1.x;

if p1.y < p2.y then
for i := p1.y to p2.y do
begin
DrawLine(Canvas, Point(round(xs), i), Point(round(xe), i), Color);
xs := xs + DxyLeft;
xe := xe + DxyRight;
end
else
for i := p1.y downto p2.y do
begin
DrawLine(Canvas, Point(Round(xs), i), Point(Round(xe), i), Color);
xs := xs - DxyLeft;
xe := xe - DxyRight;
end;
end;

procedure DrawTriangle(const Canvas: TCanvas; const p1, p2, p3: TPoint; Color: Integer);
var
tv1, tv2, dxy: Extended;
tpay: TPointArray;
FourthPoint: TPoint;
begin
tpay := [p1, p2, p3];

SortTPAByY(tpay, True);

if (tpay[0].y = tpay[1].y) and (tpay[0].y = tpay[2].y) and (tpay[1].y = tpay[2].y) then
Exit;

if (tpay[0].y = tpay[1].y) then
begin
DrawTriangleF(Canvas, tpay[2], tpay[0], tpay[1], Color);
Exit;
end else
if (tpay[1].y = tpay[2].y) then
begin
DrawTriangleF(Canvas, tpay[0], tpay[1], tpay[2], Color);
Exit;
end;

tv1 := (tpay[2].x-tpay[0].x);
tv2 := (tpay[2].y-tpay[0].y);
dxy := tv1/tv2;

FourthPoint := Point(Round(tpay[0].x + (dxy * (tpay[1].y - tpay[0].y))), tpay[1].y);

DrawTriangleF(Canvas, tpay[0], FourthPoint, tpay[1], Color);
DrawTriangleF(Canvas, tpay[2], tpay[1], FourthPoint, Color);

end;

function SplitRegExprEx(Expr, Data: string): TStringArray;
var
DataArr: TStringList;
I: integer;
begin
DataArr := TStringList.Create;
try
SplitRegExpr(Expr, Data, DataArr);
SetArrayLength(Result, DataArr.Count);
for I := 0 to DataArr.Count - 1 do
Result[I] := DataArr.Strings[I];
finally
DataArr.Free;
end;
end;

function CombineStringArrays(const a: Array of TStringArray): TStringArray;
var
i, j, c, l, h: Integer;
begin
h := High(a);
for i := 0 to h do
IncEx(l, Length(a[i]));

SetLength(Result, l);

c := 0;

for i := 0 to h do
for j := 0 to High(a[i]) do
begin
Result[c] := a[i][j];
Inc(c);
end;
end;

function LoadEntity(FileName: String): TEntity;
var
OBJFile: Longint;
OBJString: String;
i, j, c, a, b, f, SLength, tl: integer;
S: TStringArray;
SL: Array of TStringArray;
Face: TStringArray;
TmpVertexNormals: Array of TVector3D;
begin
OBJFile := OpenFile(FileName, True);
ReadFileString(OBJFile, OBJString, FileSize(OBJFile));
CloseFile(OBJFile);
S := SplitRegExprEx('\n', OBJString);

SLength := Length(S);
SetLength(SL, SLength);

c := 0;

for i := 0 to SLength-1 do
begin
if Length(S[i]) <> 0 then
if not ExecRegExpr('#', S[i]) then
begin
SL[c] := SplitRegExprEx('\s', S[i]);
Inc(c);
end;
end;

SetLength(SL, c);
tl := Length(SL);
SetLength(Result.Vertices, tl);
SetLength(TmpVertexNormals, tl);
SetLength(Result.Faces, tl);
SetLength(Result.VertexNormals, tl);

a := 0;
b := 0;
f := 0;
for i := 0 to c-1 do

if SL[i][0] = 'v' then
begin
Result.Vertices[a] := Point3d(StrToFloat(SL[i][1]), StrToFloat(SL[i][2]), StrToFloat(SL[i][3]));
Inc(a);
end else

if SL[i][0] = 'vn' then
begin
TmpVertexNormals[b] := Vector3d(StrToFloat(SL[i][1]), StrToFloat(SL[i][2]), StrToFloat(SL[i][3]));
Inc(b);
end else

if SL[i][0] = 'f' then
begin
Face := CombineStringArrays([SplitRegExprEx('\/', SL[i][1]),
SplitRegExprEx('\/', SL[i][2]),
SplitRegExprEx('\/', SL[i][3])]);

Result.Faces[f].a := StrToInt(Face[0])-1;
Result.Faces[f].b := StrToInt(Face[3])-1;
Result.Faces[f].c := StrToInt(Face[6])-1;

//WriteLn(Result.Faces[f]);
Result.VertexNormals[Result.Faces[f].a] := TmpVertexNormals[StrToInt(Face[2])-1];
Result.VertexNormals[Result.Faces[f].b] := TmpVertexNormals[StrToInt(Face[5])-1];
Result.VertexNormals[Result.Faces[f].c] := TmpVertexNormals[StrToInt(Face[8])-1];

Inc(f);
end;

SetLength(Result.Vertices, a);
SetLength(Result.VertexNormals, b);
SetLength(Result.Faces, f);
Result.Name := FILE_NAME;
Result.WorldPosition := Point3D(0, 0, 5.0);
end;

function PerspectiveProject(Vertices: Array of TPoint3D): TPointArray;
var
h, i: Integer;
begin
SetLength(Result, Length(Vertices));
h := High(Vertices);

for i := 0 to h do
with Result[i] do
begin
x := Round((Vertices[i].x * (1.0 / Vertices[i].z)) * 400);
y := Round((Vertices[i].y * (1.0 / Vertices[i].z)) * 400);
end;
end;

function RotatePointsY(p: Array of TPoint3D; pheta{radians}: Extended): Array of TPoint3D;
var
m: TMatrix3x3;
i, l: integer;
begin
SetLength(m.Data, 9);
m.Data := [Cos(pheta), 0, Sin(pheta),
0, 1, 0,
-Sin(pheta), 0, Cos(pheta)];
//WriteLn(p);

l := Length(p);
SetLength(Result, l);
for i := 0 to l-1 do
Result[i] := Multiply_Point3D_Matrix3x3(p[i], m);

//WriteLn(Result);
end;

function V_Subtract(vr1, vr2: TVector3D): TVector3D;
begin
Result.x := vr1.x - vr2.x;
Result.y := vr1.y - vr2.y;
Result.z := vr1.z - vr2.z;
end;

function Dot(vr1, vr2: TVector3D): Extended;
begin
Result := vr1.x * vr2.x + vr1.y * vr2.y + vr1.z * vr2.z;
end;

function Cross(vr1, vr2: TVector3D): TVector3D;
begin
Result := Vector3D( (vr1.y * vr2.z) - (vr1.z * vr2.y),
(vr1.z * vr2.x) - (vr1.x * vr2.z),
(vr1.x * vr2.y) - (vr1.y * vr2.x));
end;

function BackfaceCull(var e: TEntity): array of Boolean;
var
u, v, FaceNormal, CameraVector: TVector3D;
p1, p2, p3: TPoint3D;
i, Len: Integer;
Check: Extended;
begin
Len := Length(e.Faces);
SetLength(Result, Len);
SetLength(e.FaceNormals, Len);
for i := 0 to Len-1 do
begin
p1 := e.Vertices[e.Faces[i].a];
p2 := e.Vertices[e.Faces[i].b];
p3 := e.Vertices[e.Faces[i].c];
u := V_Subtract(p2, p1);
v := V_Subtract(p3, p1);

e.FaceNormals[i] := Cross(u, v);

CameraVector := Vector3D(0, 0, 1);

Check := Dot(e.FaceNormals[i], CameraVector);

Result[i] := Check >= 0;
end;
end;

function CalculateFaceColor(FaceNormal: TVector3D; Lighting: Array of TLight): Integer;
var
Len, i: Integer;
a: Extended;
begin
Len := Length(Lighting);
for i := 0 to Len-1 do
a := Dot(Lighting[i].Direction, FaceNormal);

Result := HSLToColor(1, 0, 100 - (100*a)*1.6);
end;

procedure Render(Sender: TObject);
var
Cube: TEntity;
i, j, L, Offsetx, Offsety, t, fp1, fp2, FaceColor: Integer;
mbmp: TMufasaBitmap;
tbmp: TBitmap;
CubePoints: TPointArray;
p1, p2: TPoint;
Backfaces: Array of Boolean;
Lighting: Array of TLight;
begin

Cube := LoadEntity(FILE_NAME);
Lighting := DeclareLighting;
t := GetSystemTime;

L := Length(Cube.Vertices);

Cube.Vertices := RotatePointsY(Cube.Vertices, radians(180.0));

Backfaces := BackfaceCull(Cube);

for i := 0 to L-1 do // change to Matrix transformation if speed permits
begin
Cube.Vertices[i].x := Cube.Vertices[i].x + Cube.WorldPosition.x;
Cube.Vertices[i].y := Cube.Vertices[i].y + Cube.WorldPosition.y;
Cube.Vertices[i].z := Cube.Vertices[i].z + Cube.WorldPosition.z;
end;




//WriteLn(Cube.Vertices);
CubePoints := PerspectiveProject(Cube.Vertices);

Offsetx := SCREEN_WIDTH / 2;
Offsety := SCREEN_HEIGHT / 2;

for i := 0 to L - 1 do
begin
CubePoints[i].x := CubePoints[i].x + Offsetx;
CubePoints[i].y := (-CubePoints[i].y) + Offsety;
end;

mbmp := TMufasaBitmap.Create;
mbmp.SetSize(SCREEN_WIDTH, SCREEN_HEIGHT);
//mbmp.DrawTPA(CubePoints, clWhite);
tbmp := mbmp.ToTBitmap;

//WriteLn(CubePoints[Cube.Faces[2].b]);

for i := 0 to High(Cube.Faces) do
begin
if Backfaces[i] then
Continue;
FaceColor := CalculateFaceColor(Cube.FaceNormals[i], Lighting);
DrawTriangle(tbmp.Canvas, CubePoints[Cube.Faces[i].a], CubePoints[Cube.Faces[i].b], CubePoints[Cube.Faces[i].c], FaceColor);
//WriteLn(Cube.FaceNormals[i]);
{for j := 0 to 2 do
begin
fp1 := j;
fp2 := (j+1) mod 3;
//Writeln(i);
case fp1 of
0: p1 := CubePoints[Cube.Faces[i].a];
1: p1 := CubePoints[Cube.Faces[i].b];
2: p1 := CubePoints[Cube.Faces[i].c];
end;
case fp2 of
0: p2 := CubePoints[Cube.Faces[i].a];
1: p2 := CubePoints[Cube.Faces[i].b];
2: p2 := CubePoints[Cube.Faces[i].c];
end;
//writeln(p1);
DrawLine(tbmp.Canvas, p1, p2, clBlack);
end; }
end;

mbmp.LoadFromTBitmap(tbmp);
mbmp.DrawToCanvas(0, 0, MainForm.Canvas);
WriteLn(GetSystemTime - t);
end;

procedure InitForm;
begin
MainForm := TForm.Create(nil);

with MainForm do
begin
Caption := 'Pumbaa';
Width := SCREEN_WIDTH;
Height := SCREEN_HEIGHT;
Position := poScreenCenter;
end;

StartButton := TButton.Create(MainForm);
with StartButton do
begin
Parent := MainForm;
Caption := 'Start';
OnClick := @Render;
end;



end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
MainForm.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

procedure ShowForm;
begin
SafeInitForm;
SafeShowFormModal;
end;

begin
ShowForm;
end.

Save the following as "monkey.obj" in the same directory as you save the above:


# Blender v2.61 (sub 0) OBJ File: ''
# www.blender.org
o Monkey
v 0.437500 0.176654 0.762818
v -0.437500 0.176654 0.762818
v 0.500000 0.105064 0.685862
v -0.500000 0.105064 0.685862
v 0.546875 0.064205 0.577146
v -0.546875 0.064205 0.577146
v 0.351562 -0.013266 0.617490
v -0.351562 -0.013266 0.617490
v 0.351562 0.043087 0.718138
v -0.351562 0.043087 0.718138
v 0.351562 0.145666 0.778956
v -0.351562 0.145666 0.778956
v 0.273438 0.177169 0.794064
v -0.273438 0.177169 0.794064
v 0.203125 0.105965 0.740542
v -0.203125 0.105965 0.740542
v 0.156250 0.065363 0.647449
v -0.156250 0.065363 0.647449
v 0.078125 0.252966 0.652171
v -0.078125 0.252966 0.652171
v 0.140625 0.254382 0.738097
v -0.140625 0.254382 0.738097
v 0.242188 0.255283 0.792777
v -0.242188 0.255283 0.792777
v 0.273438 0.341209 0.791361
v -0.273438 0.341209 0.791361
v 0.203125 0.402800 0.735651
v -0.203125 0.402800 0.735651
v 0.156250 0.448124 0.641142
v -0.156250 0.448124 0.641142
v 0.351562 0.525723 0.608609
v -0.351562 0.525723 0.608609
v 0.351562 0.464905 0.711187
v -0.351562 0.464905 0.711187
v 0.351562 0.372197 0.775223
v -0.351562 0.372197 0.775223
v 0.437500 0.340694 0.760115
v -0.437500 0.340694 0.760115
v 0.500000 0.401899 0.680971
v -0.500000 0.401899 0.680971
v 0.546875 0.446965 0.570839
v -0.546875 0.446965 0.570839
v 0.625000 0.251422 0.558434
v -0.625000 0.251422 0.558434
v 0.562500 0.253224 0.667794
v -0.562500 0.253224 0.667794
v 0.468750 0.254640 0.753720
v -0.468750 0.254640 0.753720
v 0.476562 0.254897 0.769342
v -0.476562 0.254897 0.769342
v 0.445312 0.348763 0.775609
v -0.445312 0.348763 0.775609
v 0.351562 0.388206 0.798400
v -0.351562 0.388206 0.798400
v 0.265625 0.349407 0.814667
v -0.265625 0.349407 0.814667
v 0.226562 0.255669 0.816211
v -0.226562 0.255669 0.816211
v 0.265625 0.169743 0.817627
v -0.265625 0.169743 0.817627
v 0.351562 0.255798 0.824023
v -0.351562 0.255798 0.824023
v 0.351562 0.130429 0.802648
v -0.351562 0.130429 0.802648
v 0.445312 0.169100 0.778570
v -0.445312 0.169100 0.778570
v 0.000000 0.441857 0.735008
v 0.000000 0.365029 0.814409
v 0.000000 -0.667496 0.745473
v 0.000000 -0.307398 0.786421
v 0.000000 -0.174346 0.799856
v 0.000000 -0.761491 0.731395
v 0.000000 0.416106 0.594788
v 0.000000 0.579631 0.560839
v 0.000000 0.889306 -0.561603
v 0.000000 0.548394 -0.860714
v 0.000000 0.056660 -0.829171
v 0.000000 -0.388553 -0.345208
v 0.203125 -0.178207 0.565513
v -0.203125 -0.178207 0.565513
v 0.312500 -0.428045 0.577443
v -0.312500 -0.428045 0.577443
v 0.351562 -0.685822 0.581690
v -0.351562 -0.685822 0.581690
v 0.367188 -0.881752 0.545851
v -0.367188 -0.881752 0.545851
v 0.328125 -0.936561 0.538940
v -0.328125 -0.936561 0.538940
v 0.179688 -0.959480 0.570572
v -0.179688 -0.959480 0.570572
v 0.000000 -0.974717 0.594264
v 0.437500 -0.131854 0.533495
v -0.437500 -0.131854 0.533495
v 0.632812 -0.030176 0.539633
v -0.632812 -0.030176 0.539633
v 0.828125 0.155754 0.442807
v -0.828125 0.155754 0.442807
v 0.859375 0.439411 0.586590
v -0.859375 0.439411 0.586590
v 0.710938 0.494606 0.616935
v -0.710938 0.494606 0.616935
v 0.492188 0.612807 0.677496
v -0.492188 0.612807 0.677496
v 0.320312 0.769808 0.721790
v -0.320312 0.769808 0.721790
v 0.156250 0.731137 0.745868
v -0.156250 0.731137 0.745868
v 0.062500 0.504477 0.741789
v -0.062500 0.504477 0.741789
v 0.164062 0.426749 0.766511
v -0.164062 0.426749 0.766511
v 0.125000 0.317260 0.760501
v -0.125000 0.317260 0.760501
v 0.203125 0.105965 0.740542
v -0.203125 0.105965 0.740542
v 0.375000 0.027207 0.702772
v -0.375000 0.027207 0.702772
v 0.492188 0.073561 0.670754
v -0.492188 0.073561 0.670754
v 0.625000 0.198158 0.645260
v -0.625000 0.198158 0.645260
v 0.640625 0.307518 0.643458
v -0.640625 0.307518 0.643458
v 0.601562 0.385890 0.657794
v -0.601562 0.385890 0.657794
v 0.429688 0.449282 0.711445
v -0.429688 0.449282 0.711445
v 0.250000 0.481171 0.749987
v -0.250000 0.481171 0.749987
v 0.000000 -0.753422 0.746889
v 0.109375 -0.706554 0.746117
v -0.109375 -0.706554 0.746117
v 0.117188 -0.824111 0.724613
v -0.117188 -0.824111 0.724613
v 0.062500 -0.871237 0.709763
v -0.062500 -0.871237 0.709763
v 0.000000 -0.879178 0.702080
v 0.000000 -0.182930 0.753116
v 0.000000 -0.128378 0.744404
v 0.101562 -0.136190 0.744532
v -0.101562 -0.136190 0.744532
v 0.125000 -0.214175 0.753631
v -0.125000 -0.214175 0.753631
v 0.085938 -0.276796 0.746849
v -0.085938 -0.276796 0.746849
v 0.398438 -0.035799 0.672556
v -0.398438 -0.035799 0.672556
v 0.617188 0.064977 0.624014
v -0.617188 0.064977 0.624014
v 0.726562 0.213008 0.598134
v -0.726562 0.213008 0.598134
v 0.742188 0.385761 0.649983
v -0.742188 0.385761 0.649983
v 0.687500 0.425976 0.719642
v -0.687500 0.425976 0.719642
v 0.437500 0.559929 0.787757
v -0.437500 0.559929 0.787757
v 0.312500 0.654310 0.825270
v -0.312500 0.654310 0.825270
v 0.203125 0.631133 0.841279
v -0.203125 0.631133 0.841279
v 0.101562 0.443530 0.836556
v -0.101562 0.443530 0.836556
v 0.125000 -0.088163 0.814063
v -0.125000 -0.088163 0.814063
v 0.210938 -0.433539 0.718177
v -0.210938 -0.433539 0.718177
v 0.250000 -0.691703 0.698991
v -0.250000 -0.691703 0.698991
v 0.265625 -0.809261 0.677487
v -0.265625 -0.809261 0.677487
v 0.234375 -0.903513 0.647786
v -0.234375 -0.903513 0.647786
v 0.164062 -0.919136 0.648043
v -0.164062 -0.919136 0.648043
v 0.000000 -0.934630 0.656112
v 0.000000 0.058839 0.725692
v 0.000000 0.223523 0.762046
v 0.328125 0.488725 0.734235
v -0.328125 0.488725 0.734235
v 0.164062 0.152962 0.747581
v -0.164062 0.152962 0.747581
v 0.132812 0.223394 0.754234
v -0.132812 0.223394 0.754234
v 0.117188 -0.675308 0.745602
v -0.117188 -0.675308 0.745602
v 0.078125 -0.432896 0.757235
v -0.078125 -0.432896 0.757235
v 0.000000 -0.432896 0.757235
v 0.000000 -0.315853 0.747493
v 0.093750 -0.260529 0.785649
v -0.093750 -0.260529 0.785649
v 0.132812 -0.213403 0.800499
v -0.132812 -0.213403 0.800499
v 0.109375 -0.119923 0.783332
v -0.109375 -0.119923 0.783332
v 0.039062 -0.112112 0.783203
v -0.039062 -0.112112 0.783203
v 0.000000 -0.189454 0.831359
v 0.046875 -0.135031 0.814835
v -0.046875 -0.135031 0.814835
v 0.093750 -0.142843 0.814964
v -0.093750 -0.142843 0.814964
v 0.109375 -0.212888 0.831745
v -0.109375 -0.212888 0.831745
v 0.078125 -0.236709 0.808697
v -0.078125 -0.236709 0.808697
v 0.000000 -0.275766 0.809341
v 0.257812 -0.303319 0.559761
v -0.257812 -0.303319 0.559761
v 0.164062 -0.230442 0.714831
v -0.164062 -0.230442 0.714831
v 0.179688 -0.300745 0.715989
v -0.179688 -0.300745 0.715989
v 0.234375 -0.240828 0.558731
v -0.234375 -0.240828 0.558731
v 0.000000 -0.863555 0.701822
v 0.046875 -0.855743 0.701694
v -0.046875 -0.855743 0.701694
v 0.093750 -0.808488 0.724356
v -0.093750 -0.808488 0.724356
v 0.093750 -0.730117 0.738691
v -0.093750 -0.730117 0.738691
v 0.000000 -0.770332 0.669032
v 0.093750 -0.738958 0.676329
v -0.093750 -0.738958 0.676329
v 0.093750 -0.801835 0.653924
v -0.093750 -0.801835 0.653924
v 0.046875 -0.841021 0.646756
v -0.046875 -0.841021 0.646756
v 0.000000 -0.848833 0.646885
v 0.171875 0.231591 0.777540
v -0.171875 0.231591 0.777540
v 0.187500 0.168971 0.770758
v -0.187500 0.168971 0.770758
v 0.335938 0.442114 0.750630
v -0.335938 0.442114 0.750630
v 0.273438 0.434560 0.766382
v -0.273438 0.434560 0.766382
v 0.421875 0.411126 0.766768
v -0.421875 0.411126 0.766768
v 0.562500 0.362970 0.689426
v -0.562500 0.362970 0.689426
v 0.585938 0.300350 0.682644
v -0.585938 0.300350 0.682644
v 0.578125 0.206484 0.676377
v -0.578125 0.206484 0.676377
v 0.476562 0.113390 0.716979
v -0.476562 0.113390 0.716979
v 0.375000 0.074719 0.741057
v -0.375000 0.074719 0.741057
v 0.226562 0.122231 0.779342
v -0.226562 0.122231 0.779342
v 0.179688 0.309706 0.776253
v -0.179688 0.309706 0.776253
v 0.210938 0.387820 0.774966
v -0.210938 0.387820 0.774966
v 0.234375 0.371811 0.751789
v -0.234375 0.371811 0.751789
v 0.195312 0.309320 0.752819
v -0.195312 0.309320 0.752819
v 0.242188 0.137468 0.755650
v -0.242188 0.137468 0.755650
v 0.375000 0.097896 0.725048
v -0.375000 0.097896 0.725048
v 0.460938 0.128756 0.701099
v -0.460938 0.128756 0.701099
v 0.546875 0.221978 0.668309
v -0.546875 0.221978 0.668309
v 0.554688 0.292281 0.667150
v -0.554688 0.292281 0.667150
v 0.531250 0.347090 0.674061
v -0.531250 0.347090 0.674061
v 0.414062 0.402928 0.743463
v -0.414062 0.402928 0.743463
v 0.281250 0.410997 0.758957
v -0.281250 0.410997 0.758957
v 0.335938 0.418551 0.743205
v -0.335938 0.418551 0.743205
v 0.203125 0.184208 0.747067
v -0.203125 0.184208 0.747067
v 0.195312 0.238888 0.746166
v -0.195312 0.238888 0.746166
v 0.109375 0.470914 0.601698
v -0.109375 0.470914 0.601698
v 0.195312 0.674141 0.606163
v -0.195312 0.674141 0.606163
v 0.335938 0.697189 0.582343
v -0.335938 0.697189 0.582343
v 0.484375 0.563751 0.545474
v -0.484375 0.563751 0.545474
v 0.679688 0.461172 0.484655
v -0.679688 0.461172 0.484655
v 0.796875 0.413789 0.454182
v -0.796875 0.413789 0.454182
v 0.773438 0.170218 0.372246
v -0.773438 0.170218 0.372246
v 0.601562 0.006822 0.414006
v -0.601562 0.006822 0.414006
v 0.437500 -0.086015 0.470231
v -0.437500 -0.086015 0.470231
v 0.000000 0.903078 0.274222
v 0.000000 0.982954 -0.094332
v 0.000000 -0.206355 -0.668566
v 0.000000 -0.457786 0.195068
v 0.000000 -0.968836 0.476964
v 0.000000 -0.798915 0.356961
v 0.000000 -0.564958 0.329665
v 0.000000 -0.479676 0.289192
v 0.851562 0.235244 0.050819
v -0.851562 0.235244 0.050819
v 0.859375 0.319497 -0.052146
v -0.859375 0.319497 -0.052146
v 0.773438 0.258381 -0.441817
v -0.773438 0.258381 -0.441817
v 0.460938 0.425857 -0.710237
v -0.460938 0.425857 -0.710237
v 0.734375 -0.045710 0.071075
v -0.734375 -0.045710 0.071075
v 0.593750 -0.127686 -0.161981
v -0.593750 -0.127686 -0.161981
v 0.640625 -0.014891 -0.429500
v -0.640625 -0.014891 -0.429500
v 0.335938 0.043740 -0.664873
v -0.335938 0.043740 -0.664873
v 0.234375 -0.344822 0.411987
v -0.234375 -0.344822 0.411987
v 0.179688 -0.409759 0.264599
v -0.179688 -0.409759 0.264599
v 0.289062 -0.704534 0.394473
v -0.289062 -0.704534 0.394473
v 0.250000 -0.493497 0.398809
v -0.250000 -0.493497 0.398809
v 0.328125 -0.907374 0.413443
v -0.328125 -0.907374 0.413443
v 0.140625 -0.751660 0.379623
v -0.140625 -0.751660 0.379623
v 0.125000 -0.533069 0.368207
v -0.125000 -0.533069 0.368207
v 0.164062 -0.937976 0.453015
v -0.164062 -0.937976 0.453015
v 0.218750 -0.274133 0.434263
v -0.218750 -0.274133 0.434263
v 0.210938 -0.218809 0.472419
v -0.210938 -0.218809 0.472419
v 0.203125 -0.163614 0.502764
v -0.203125 -0.163614 0.502764
v 0.210938 -0.387869 0.170476
v -0.210938 -0.387869 0.170476
v 0.296875 -0.316834 -0.260440
v -0.296875 -0.316834 -0.260440
v 0.343750 -0.157298 -0.536544
v -0.343750 -0.157298 -0.536544
v 0.453125 0.860763 -0.397047
v -0.453125 0.860763 -0.397047
v 0.453125 0.928403 -0.085620
v -0.453125 0.928403 -0.085620
v 0.453125 0.855308 0.220314
v -0.453125 0.855308 0.220314
v 0.460938 0.530446 0.421006
v -0.460938 0.530446 0.421006
v 0.726562 0.411729 0.329199
v -0.726562 0.411729 0.329199
v 0.632812 0.457697 0.273747
v -0.632812 0.457697 0.273747
v 0.640625 0.703931 0.043096
v -0.640625 0.703931 0.043096
v 0.796875 0.564483 0.115716
v -0.796875 0.564483 0.115716
v 0.796875 0.615173 -0.127340
v -0.796875 0.615173 -0.127340
v 0.640625 0.746680 -0.207642
v -0.640625 0.746680 -0.207642
v 0.640625 0.672259 -0.456450
v -0.640625 0.672259 -0.456450
v 0.796875 0.533069 -0.368207
v -0.796875 0.533069 -0.368207
v 0.617188 0.318427 -0.591264
v -0.617188 0.318427 -0.591264
v 0.484375 0.014425 -0.547187
v -0.484375 0.014425 -0.547187
v 0.820312 0.324734 -0.208503
v -0.820312 0.324734 -0.208503
v 0.406250 -0.169406 0.151249
v -0.406250 -0.169406 0.151249
v 0.429688 -0.198761 -0.207691
v -0.429688 -0.198761 -0.207691
v 0.890625 0.402334 -0.241036
v -0.890625 0.402334 -0.241036
v 0.773438 -0.142665 -0.122666
v -0.773438 -0.142665 -0.122666
v 1.039062 -0.106955 -0.326407
v -1.039062 -0.106955 -0.326407
v 1.281250 0.047601 -0.430530
v -1.281250 0.047601 -0.430530
v 1.351562 0.313319 -0.427095
v -1.351562 0.313319 -0.427095
v 1.234375 0.500793 -0.430184
v -1.234375 0.500793 -0.430184
v 1.023438 0.471349 -0.320309
v -1.023438 0.471349 -0.320309
v 1.015625 0.409244 -0.295845
v -1.015625 0.409244 -0.295845
v 1.187500 0.431005 -0.397780
v -1.187500 0.431005 -0.397780
v 1.265625 0.282330 -0.410957
v -1.265625 0.282330 -0.410957
v 1.210938 0.071421 -0.407482
v -1.210938 0.071421 -0.407482
v 1.031250 -0.044077 -0.304003
v -1.031250 -0.044077 -0.304003
v 0.828125 -0.072491 -0.131636
v -0.828125 -0.072491 -0.131636
v 0.921875 0.355722 -0.224641
v -0.921875 0.355722 -0.224641
v 0.945312 0.299884 -0.294043
v -0.945312 0.299884 -0.294043
v 0.882812 -0.026910 -0.210523
v -0.882812 -0.026910 -0.210523
v 1.039062 -0.006049 -0.367138
v -1.039062 -0.006049 -0.367138
v 1.187500 0.086401 -0.446797
v -1.187500 0.086401 -0.446797
v 1.234375 0.242630 -0.449371
v -1.234375 0.242630 -0.449371
v 1.171875 0.352118 -0.443361
v -1.171875 0.352118 -0.443361
v 1.023438 0.337783 -0.364989
v -1.023438 0.337783 -0.364989
v 0.843750 0.285548 -0.215671
v -0.843750 0.285548 -0.215671
v 0.835938 0.167347 -0.276232
v -0.835938 0.167347 -0.276232
v 0.757812 0.089232 -0.274945
v -0.757812 0.089232 -0.274945
v 0.820312 0.081421 -0.274816
v -0.820312 0.081421 -0.274816
v 0.843750 0.011118 -0.273658
v -0.843750 0.011118 -0.273658
v 0.812500 -0.020128 -0.273143
v -0.812500 -0.020128 -0.273143
v 0.726562 -0.001158 -0.070303
v -0.726562 -0.001158 -0.070303
v 0.718750 -0.026266 -0.171466
v -0.718750 -0.026266 -0.171466
v 0.718750 0.035968 -0.188118
v -0.718750 0.035968 -0.188118
v 0.796875 0.199622 -0.214255
v -0.796875 0.199622 -0.214255
v 0.890625 0.237778 -0.269579
v -0.890625 0.237778 -0.269579
v 0.890625 0.229066 -0.324130
v -0.890625 0.229066 -0.324130
v 0.812500 -0.020900 -0.320012
v -0.812500 -0.020900 -0.320012
v 0.851562 0.010346 -0.320526
v -0.851562 0.010346 -0.320526
v 0.828125 0.072837 -0.321556
v -0.828125 0.072837 -0.321556
v 0.765625 0.088460 -0.321814
v -0.765625 0.088460 -0.321814
v 0.843750 0.166575 -0.323101
v -0.843750 0.166575 -0.323101
v 1.039062 0.321259 -0.419412
v -1.039062 0.321259 -0.419412
v 1.187500 0.335723 -0.489973
v -1.187500 0.335723 -0.489973
v 1.257812 0.234046 -0.496111
v -1.257812 0.234046 -0.496111
v 1.210938 0.077946 -0.485725
v -1.210938 0.077946 -0.485725
v 1.046875 -0.006950 -0.421818
v -1.046875 -0.006950 -0.421818
v 0.882812 -0.019999 -0.265332
v -0.882812 -0.019999 -0.265332
v 0.953125 0.283360 -0.348466
v -0.953125 0.283360 -0.348466
v 0.890625 0.103954 -0.329882
v -0.890625 0.103954 -0.329882
v 0.937500 0.056957 -0.336922
v -0.937500 0.056957 -0.336922
v 1.000000 0.118934 -0.369197
v -1.000000 0.118934 -0.369197
v 0.960938 0.166060 -0.354346
v -0.960938 0.166060 -0.354346
v 1.015625 0.228165 -0.378810
v -1.015625 0.228165 -0.378810
v 1.054688 0.181168 -0.385850
v -1.054688 0.181168 -0.385850
v 1.109375 0.204473 -0.394047
v -1.109375 0.204473 -0.394047
v 1.085938 0.266965 -0.395077
v -1.085938 0.266965 -0.395077
v 1.023438 0.429461 -0.491517
v -1.023438 0.429461 -0.491517
v 1.250000 0.459677 -0.554523
v -1.250000 0.459677 -0.554523
v 1.367188 0.288597 -0.504823
v -1.367188 0.288597 -0.504823
v 1.312500 0.045928 -0.532079
v -1.312500 0.045928 -0.532079
v 1.039062 -0.094035 -0.490705
v -1.039062 -0.094035 -0.490705
v 0.789062 -0.130389 -0.326021
v -0.789062 -0.130389 -0.326021
v 0.859375 0.376454 -0.389067
v -0.859375 0.376454 -0.389067
vn 0.664993 -0.188873 0.722573
vn -0.664993 -0.188873 0.722573
vn 0.829427 -0.295814 0.473862
vn -0.829427 -0.295814 0.473862
vn 0.415548 -0.785882 0.457940
vn -0.415548 -0.785882 0.457940
vn 0.359950 -0.495943 0.790238
vn -0.359950 -0.495943 0.790238
vn -0.078666 -0.525538 0.847126
vn 0.078666 -0.525538 0.847126
vn -0.269627 -0.833462 0.482329
vn 0.269627 -0.833462 0.482329
vn -0.770656 -0.326230 0.547415
vn 0.770656 -0.326230 0.547415
vn -0.468941 -0.179823 0.864730
vn 0.468941 -0.179823 0.864730
vn -0.476732 0.204804 0.854858
vn 0.476732 0.204804 0.854858
vn -0.767202 0.335456 0.546689
vn 0.767202 0.335456 0.546689
vn -0.251927 0.825759 0.504634
vn 0.251927 0.825759 0.504634
vn -0.094933 0.582971 0.806928
vn 0.094933 0.582971 0.806928
vn 0.366742 0.549459 0.750730
vn -0.366742 0.549459 0.750730
vn 0.414055 0.775185 0.477123
vn -0.414055 0.775185 0.477123
vn 0.827747 0.303068 0.472212
vn -0.827747 0.303068 0.472212
vn 0.671345 0.208836 0.711114
vn -0.671345 0.208836 0.711114
vn 0.811107 0.316381 -0.491944
vn -0.811107 0.316381 -0.491944
vn 0.205152 0.811711 -0.546844
vn -0.205152 0.811711 -0.546844
vn -0.422314 0.772945 -0.473506
vn 0.422314 0.772945 -0.473506
vn -0.824060 0.314741 -0.471024
vn 0.824060 0.314741 -0.471024
vn -0.813733 -0.356356 -0.459182
vn 0.813733 -0.356356 -0.459182
vn -0.422314 -0.788125 -0.447782
vn 0.422314 -0.788125 -0.447782
vn 0.205153 -0.829286 -0.519804
vn -0.205153 -0.829286 -0.519804
vn 0.799477 -0.358974 -0.481637
vn -0.799477 -0.358974 -0.481637
vn 0.400039 -0.047271 0.915278
vn -0.400039 -0.047271 0.915278
vn 0.306938 -0.159957 0.938191
vn -0.306938 -0.159957 0.938191
vn 0.094512 -0.167318 0.981362
vn -0.094512 -0.167318 0.981362
vn -0.062353 -0.011902 0.997983
vn 0.062353 -0.011902 0.997983
vn -0.062357 0.042416 0.997152
vn 0.062357 0.042416 0.997152
vn 0.099561 0.189042 0.976909
vn -0.099561 0.189042 0.976909
vn 0.303571 0.181020 0.935455
vn -0.303571 0.181020 0.935455
vn 0.400163 0.072228 0.913593
vn -0.400163 0.072228 0.913593
vn 0.123092 -0.853412 0.506495
vn -0.123092 -0.853412 0.506495
vn 0.218986 -0.857151 0.466195
vn -0.218986 -0.857151 0.466195
vn 0.590198 -0.443991 0.674195
vn -0.590198 -0.443991 0.674195
vn 0.768894 -0.040078 0.638119
vn -0.768894 -0.040078 0.638119
vn 0.779649 0.100157 0.618155
vn -0.779649 0.100157 0.618155
vn 0.324141 -0.810847 0.487299
vn -0.324141 -0.810847 0.487299
vn 0.385730 -0.652229 0.652541
vn -0.385730 -0.652229 0.652541
vn 0.689468 -0.409518 0.597435
vn -0.689468 -0.409518 0.597435
vn 0.658751 -0.352546 0.664649
vn -0.658751 -0.352546 0.664649
vn 0.546548 0.383023 0.744700
vn -0.546548 0.383023 0.744700
vn 0.506447 0.655747 0.559917
vn -0.506447 0.655747 0.559917
vn 0.609244 0.526541 0.592938
vn -0.609244 0.526541 0.592938
vn -0.044065 0.673231 0.738118
vn 0.044065 0.673231 0.738118
vn -0.724614 0.328765 0.605680
vn 0.724614 0.328765 0.605680
vn -0.588035 0.564978 0.578805
vn 0.588035 0.564978 0.578805
vn 0.536054 -0.378492 0.754580
vn -0.536054 -0.378492 0.754580
vn 0.220694 -0.454824 0.862803
vn -0.220694 -0.454824 0.862803
vn -0.079395 -0.518157 0.851592
vn 0.079395 -0.518157 0.851592
vn -0.082465 -0.645032 0.759693
vn 0.082465 -0.645032 0.759693
vn 0.045703 -0.553082 0.831872
vn -0.045703 -0.553082 0.831872
vn 0.278429 -0.197582 0.939914
vn -0.278429 -0.197582 0.939914
vn 0.381303 -0.167407 0.909166
vn -0.381303 -0.167407 0.909166
vn 0.335744 -0.272965 0.901535
vn -0.335744 -0.272965 0.901535
vn 0.376240 0.075500 0.923441
vn -0.376240 0.075500 0.923441
vn -0.135216 0.283653 0.949346
vn 0.135216 0.283653 0.949346
vn 0.396091 -0.418693 0.817195
vn -0.396091 -0.418693 0.817195
vn 0.185556 -0.231708 0.954924
vn -0.185556 -0.231708 0.954924
vn 0.009907 -0.178651 0.983863
vn -0.009907 -0.178651 0.983863
vn 0.072066 -0.684783 0.725175
vn -0.072066 -0.684783 0.725175
vn 0.186336 -0.559082 0.807902
vn -0.186336 -0.559082 0.807902
vn 0.315685 -0.255825 0.913727
vn -0.315685 -0.255825 0.913727
vn 0.306302 -0.010801 0.951873
vn -0.306302 -0.010801 0.951873
vn 0.326550 -0.115180 0.938136
vn -0.326550 -0.115180 0.938136
vn -0.013675 0.073872 0.997174
vn 0.013675 0.073872 0.997174
vn -0.002626 -0.049199 0.998786
vn 0.002626 -0.049199 0.998786
vn 0.000000 0.016475 0.999864
vn 0.817393 -0.575034 -0.034714
vn -0.817393 -0.575034 -0.034714
vn 0.949363 0.226122 -0.218127
vn -0.949363 0.226122 -0.218127
vn 0.082479 0.900348 -0.427284
vn -0.082479 0.900348 -0.427284
vn -0.883625 0.360453 0.298800
vn 0.883625 0.360453 0.298800
vn 0.420706 -0.875884 0.236289
vn -0.420706 -0.875884 0.236289
vn 0.287348 -0.561994 0.775625
vn -0.287348 -0.561994 0.775625
vn -0.654224 0.609349 0.447979
vn 0.654224 0.609349 0.447979
vn 0.105227 0.799061 0.591970
vn -0.105227 0.799061 0.591970
vn 0.758175 0.301175 0.578329
vn -0.758175 0.301175 0.578329
vn 0.388922 -0.703316 0.595052
vn -0.388922 -0.703316 0.595052
vn 0.046275 0.247351 0.967820
vn -0.046275 0.247351 0.967820
vn 0.033480 -0.386633 0.921626
vn -0.033480 -0.386633 0.921626
vn -0.445163 -0.146483 0.883387
vn 0.445163 -0.146483 0.883387
vn -0.218218 -0.421996 0.879943
vn 0.218218 -0.421996 0.879943
vn 0.434064 -0.114340 0.893596
vn -0.434064 -0.114340 0.893596
vn 0.300753 0.065809 0.951429
vn -0.300753 0.065809 0.951429
vn 0.812285 0.309228 0.494541
vn -0.812285 0.309228 0.494541
vn 0.875310 0.264153 0.405039
vn -0.875310 0.264153 0.405039
vn 0.938484 0.165132 0.303279
vn -0.938484 0.165132 0.303279
vn 0.223706 -0.641913 0.733419
vn -0.223706 -0.641913 0.733419
vn -0.153610 -0.183723 0.970902
vn 0.153610 -0.183723 0.970902
vn -0.273274 -0.086706 0.958021
vn 0.273274 -0.086706 0.958021
vn -0.097590 0.211232 0.972552
vn 0.097590 0.211232 0.972552
vn -0.158236 0.953750 0.255581
vn 0.158236 0.953750 0.255581
vn -0.693430 0.710275 0.121099
vn 0.693430 0.710275 0.121099
vn -1.000000 0.000000 0.000000
vn 1.000000 -0.000000 0.000000
vn 0.305141 -0.942879 0.133671
vn -0.305141 -0.942879 0.133671
vn 0.029814 -0.282384 0.958838
vn -0.029814 -0.282384 0.958838
vn 0.135293 -0.332564 0.933326
vn -0.135293 -0.332564 0.933326
vn -0.508542 -0.261982 0.820214
vn 0.508542 -0.261982 0.820214
vn -0.384277 -0.026721 0.922831
vn 0.384277 -0.026721 0.922831
vn -0.208288 0.053482 0.976604
vn 0.208288 0.053482 0.976604
vn -0.572077 -0.465671 0.675187
vn 0.572077 -0.465671 0.675187
vn -0.136922 -0.742367 0.655853
vn 0.136922 -0.742367 0.655853
vn 0.408843 -0.595762 0.691314
vn -0.408843 -0.595762 0.691314
vn 0.574030 -0.401317 0.713746
vn -0.574030 -0.401317 0.713746
vn 0.566535 -0.083349 0.819812
vn -0.566535 -0.083349 0.819812
vn 0.570336 0.131377 0.810838
vn -0.570336 0.131377 0.810838
vn 0.482290 0.573110 0.662527
vn -0.482290 0.573110 0.662527
vn 0.260407 0.623618 0.737081
vn -0.260407 0.623618 0.737081
vn 0.163957 0.375782 0.912089
vn -0.163957 0.375782 0.912089
vn -0.017820 0.265397 0.963975
vn 0.017820 0.265397 0.963975
vn 0.327339 -0.402584 0.854854
vn -0.327339 -0.402584 0.854854
vn 0.281071 -0.245742 0.927691
vn -0.281071 -0.245742 0.927691
vn -0.254192 -0.639501 0.725551
vn 0.254192 -0.639501 0.725551
vn -0.026016 -0.836611 0.547180
vn 0.026016 -0.836611 0.547180
vn -0.351809 -0.245751 0.903237
vn 0.351809 -0.245751 0.903237
vn -0.352309 0.004409 0.935873
vn 0.352309 0.004409 0.935873
vn -0.131653 0.475185 0.869981
vn 0.131653 0.475185 0.869981
vn -0.034219 0.628830 0.776789
vn 0.034219 0.628830 0.776789
vn 0.360263 0.595536 0.718016
vn -0.360263 0.595536 0.718016
vn 0.498785 0.541185 0.677003
vn -0.498785 0.541185 0.677003
vn 0.666667 -0.322305 0.672067
vn -0.666667 -0.322305 0.672067
vn 0.816466 -0.063670 0.573872
vn -0.816466 -0.063670 0.573872
vn 0.784010 0.126180 0.607789
vn -0.784010 0.126180 0.607789
vn -0.530629 0.806910 -0.259477
vn 0.530629 0.806910 -0.259477
vn -0.851109 0.363286 -0.378994
vn 0.851109 0.363286 -0.378994
vn -0.244586 0.860263 -0.447354
vn 0.244586 0.860263 -0.447354
vn 0.592382 0.741413 -0.315263
vn -0.592382 0.741413 -0.315263
vn 0.368548 0.870512 -0.326163
vn -0.368548 0.870512 -0.326163
vn 0.282140 0.910260 -0.303025
vn -0.282140 0.910260 -0.303025
vn 0.856131 0.125780 -0.501217
vn -0.856131 0.125780 -0.501217
vn 0.534226 -0.730387 -0.425602
vn -0.534226 -0.730387 -0.425602
vn 0.384903 -0.820139 -0.423346
vn -0.384903 -0.820139 -0.423346
vn 0.233519 -0.593325 -0.770347
vn -0.233519 -0.593325 -0.770347
vn 0.244866 -0.074238 -0.966711
vn -0.244866 -0.074238 -0.966711
vn 0.116271 -0.467954 -0.876071
vn -0.116271 -0.467954 -0.876071
vn 0.115196 -0.985748 -0.122602
vn -0.115196 -0.985748 -0.122602
vn 0.118367 -0.970507 -0.210012
vn -0.118367 -0.970507 -0.210012
vn 0.959736 -0.013133 -0.280596
vn -0.959736 -0.013133 -0.280596
vn 0.931868 0.157488 -0.326833
vn -0.931868 0.157488 -0.326833
vn 0.162606 0.004440 -0.986681
vn -0.162606 0.004440 -0.986681
vn -0.018766 -0.233734 -0.972119
vn 0.018766 -0.233734 -0.972119
vn 0.753776 -0.302259 -0.583490
vn -0.753776 -0.302259 -0.583490
vn 0.919601 0.131861 -0.370063
vn -0.919601 0.131861 -0.370063
vn 0.929736 0.309484 -0.199525
vn -0.929736 0.309484 -0.199525
vn 0.912018 0.333759 -0.238387
vn -0.912018 0.333759 -0.238387
vn 0.940691 0.332748 -0.066181
vn -0.940691 0.332748 -0.066181
vn 0.176090 -0.887584 -0.425660
vn -0.176090 -0.887584 -0.425660
vn 0.370784 -0.486371 -0.791178
vn -0.370784 -0.486371 -0.791178
vn 0.310668 -0.836014 -0.452290
vn -0.310668 -0.836014 -0.452290
vn 0.279339 -0.953520 -0.112998
vn -0.279339 -0.953520 -0.112998
vn 0.313873 -0.934959 -0.165334
vn -0.313873 -0.934959 -0.165334
vn 0.976161 -0.209316 -0.057423
vn -0.976161 -0.209316 -0.057423
vn 0.826725 -0.502491 0.253040
vn -0.826725 -0.502491 0.253040
vn 0.344853 -0.131130 -0.929452
vn -0.344853 -0.131130 -0.929452
vn 0.120261 0.968155 0.219574
vn -0.120261 0.968155 0.219574
vn 0.127513 0.971222 -0.201165
vn -0.127513 0.971222 -0.201165
vn 0.349226 0.582686 -0.733838
vn -0.349226 0.582686 -0.733838
vn 0.415251 0.895592 -0.159631
vn -0.415251 0.895592 -0.159631
vn 0.184540 0.714769 0.674574
vn -0.184540 0.714769 0.674574
vn 0.605564 0.781921 0.147962
vn -0.605564 0.781921 0.147962
vn 0.703301 0.677139 -0.216450
vn -0.703301 0.677139 -0.216450
vn 0.667944 0.188891 -0.719841
vn -0.667944 0.188891 -0.719841
vn 0.494774 0.421770 -0.759808
vn -0.494774 0.421770 -0.759808
vn 0.642323 0.742921 -0.188386
vn -0.642323 0.742921 -0.188386
vn 0.718225 0.681217 0.141763
vn -0.718225 0.681217 0.141763
vn 0.738828 0.406154 0.537747
vn -0.738828 0.406154 0.537747
vn 0.342772 0.923329 -0.173123
vn -0.342772 0.923329 -0.173123
vn 0.226983 0.586913 0.777182
vn -0.226983 0.586913 0.777182
vn -0.172189 0.088487 -0.981081
vn 0.172189 0.088487 -0.981081
vn 0.042460 0.921441 0.386191
vn -0.042460 0.921441 0.386191
vn -0.161572 0.200600 0.966258
vn 0.161572 0.200600 0.966258
vn 0.979149 0.198078 0.045075
vn -0.979149 0.198078 0.045075
vn 0.946968 0.096905 0.306367
vn -0.946968 0.096905 0.306367
vn 0.979450 0.189421 -0.069267
vn -0.979450 0.189421 -0.069267
vn 0.993774 0.029428 -0.107453
vn -0.993774 0.029428 -0.107453
vn 0.711563 -0.699916 0.061599
vn -0.711563 -0.699916 0.061599
vn 0.372160 -0.922780 0.099868
vn -0.372160 -0.922780 0.099868
vn 0.446529 -0.860511 0.245220
vn -0.446529 -0.860511 0.245220
vn 0.606579 -0.753713 0.252941
vn -0.606579 -0.753713 0.252941
vn 0.732489 -0.632765 0.251134
vn -0.732489 -0.632765 0.251134
vn 0.263733 -0.435778 0.860548
vn -0.263733 -0.435778 0.860548
vn 0.556817 -0.330650 -0.761988
vn -0.556817 -0.330650 -0.761988
vn 0.500432 -0.294185 -0.814263
vn -0.500432 -0.294185 -0.814263
vn 0.318954 -0.856201 -0.406434
vn -0.318954 -0.856201 -0.406434
vn 0.719759 -0.640076 -0.268794
vn -0.719759 -0.640076 -0.268794
vn 0.497205 -0.453026 -0.739969
vn -0.497205 -0.453026 -0.739969
vn 0.350559 0.394760 0.849278
vn -0.350559 0.394760 0.849278
vn 0.456551 0.185845 0.870071
vn -0.456551 0.185845 0.870071
vn 0.258262 0.121294 0.958430
vn -0.258262 0.121294 0.958430
vn 0.245528 -0.064311 0.967254
vn -0.245528 -0.064311 0.967254
vn 0.464293 -0.045342 0.884520
vn -0.464293 -0.045342 0.884520
vn 0.622462 -0.292594 0.725900
vn -0.622462 -0.292594 0.725900
vn 0.450021 0.668799 0.591768
vn -0.450021 0.668799 0.591768
vn -0.266664 0.838802 0.474660
vn 0.266664 0.838802 0.474660
vn -0.828395 0.237520 0.507293
vn 0.828395 0.237520 0.507293
vn -0.525062 -0.343866 0.778503
vn 0.525062 -0.343866 0.778503
vn 0.454637 -0.555121 0.696524
vn -0.454637 -0.555121 0.696524
vn 0.699601 -0.440535 0.562573
vn -0.699601 -0.440535 0.562573
vn 0.722009 -0.684415 -0.101382
vn -0.722009 -0.684415 -0.101382
vn -0.191904 0.301403 0.933986
vn 0.191904 0.301403 0.933986
vn 0.904808 -0.376687 -0.198569
vn -0.904808 -0.376687 -0.198569
vn 0.103418 0.171291 0.979778
vn -0.103418 0.171291 0.979778
vn 0.084056 0.937516 0.337637
vn -0.084056 0.937516 0.337637
vn 0.644606 -0.075779 0.760750
vn -0.644606 -0.075779 0.760750
vn 0.430935 0.486615 0.759935
vn -0.430935 0.486615 0.759935
vn 0.803235 -0.478941 0.354161
vn -0.803235 -0.478941 0.354161
vn 0.581122 -0.401186 0.708059
vn -0.581122 -0.401186 0.708059
vn 0.591001 -0.419184 0.689204
vn -0.591001 -0.419184 0.689204
vn 0.981815 -0.181344 -0.056165
vn -0.981815 -0.181344 -0.056165
vn 0.910486 -0.398384 -0.110934
vn -0.910486 -0.398384 -0.110934
vn 0.997202 -0.019323 -0.072215
vn -0.997202 -0.019323 -0.072215
vn 0.731310 -0.651071 0.203204
vn -0.731310 -0.651071 0.203204
vn 0.786718 -0.606069 0.117281
vn -0.786718 -0.606069 0.117281
vn 0.702247 -0.700223 0.128595
vn -0.702247 -0.700223 0.128595
vn 0.184048 0.980611 -0.067289
vn -0.184048 0.980611 -0.067289
vn 0.935190 0.332137 0.122904
vn -0.935190 0.332137 0.122904
vn 0.663348 -0.745254 0.067566
vn -0.663348 -0.745254 0.067566
vn -0.008522 0.998147 0.060257
vn 0.008522 0.998147 0.060257
vn 0.623691 -0.700445 0.346968
vn -0.623691 -0.700445 0.346968
vn 0.273312 -0.886504 0.373378
vn -0.273312 -0.886504 0.373378
vn -0.832769 -0.511597 -0.211577
vn 0.832769 -0.511597 -0.211577
vn -0.833909 0.229482 -0.501930
vn 0.833909 0.229482 -0.501930
vn -0.565464 0.780437 -0.266776
vn 0.565464 0.780437 -0.266776
vn -0.055965 0.997143 0.050737
vn 0.055965 0.997143 0.050737
vn 0.144498 0.038526 0.988755
vn -0.144498 0.038526 0.988755
vn 0.327452 0.080020 0.941473
vn -0.327452 0.080020 0.941473
vn 0.312667 0.038802 0.949070
vn -0.312667 0.038802 0.949070
vn 0.170988 0.043580 0.984309
vn -0.170988 0.043580 0.984309
vn 0.348658 0.299552 0.888091
vn -0.348658 0.299552 0.888091
vn 0.400583 -0.019246 0.916059
vn -0.400583 -0.019246 0.916059
vn 0.257194 -0.044382 0.965340
vn -0.257194 -0.044382 0.965340
vn 0.063697 0.005826 0.997952
vn -0.063697 0.005826 0.997952
vn -0.363700 0.713892 0.598398
vn 0.363700 0.713892 0.598398
vn 0.629882 0.048235 0.775192
vn -0.629882 0.048235 0.775192
vn 0.447210 -0.185854 0.874906
vn -0.447210 -0.185854 0.874906
vn 0.507163 -0.200279 0.838256
vn -0.507163 -0.200279 0.838256
vn 0.525823 0.275231 0.804834
vn -0.525823 0.275231 0.804834
vn 0.297964 0.592655 0.748317
vn -0.297964 0.592655 0.748317
vn 0.093038 -0.993594 -0.064140
vn -0.093038 -0.993594 -0.064140
vn 0.500580 -0.865404 0.022232
vn -0.500580 -0.865404 0.022232
vn 0.928516 -0.245135 0.278867
vn -0.928516 -0.245135 0.278867
vn 0.839260 0.541720 -0.046711
vn -0.839260 0.541720 -0.046711
vn -0.235535 0.932352 -0.274306
vn 0.235535 0.932352 -0.274306
vn -0.449919 0.881532 -0.143091
vn 0.449919 0.881532 -0.143091
vn -0.538364 -0.023634 -0.842381
vn 0.538364 -0.023634 -0.842381
vn -0.191040 -0.040261 -0.980756
vn 0.191040 -0.040261 -0.980756
vn 0.404624 0.011518 -0.914410
vn -0.404624 0.011518 -0.914410
vn -0.781868 0.623373 0.009409
vn 0.781868 0.623373 0.009409
vn 0.542773 -0.219639 -0.810651
vn -0.542773 -0.219639 -0.810651
vn -0.247398 -0.927793 -0.279274
vn 0.247398 -0.927793 -0.279274
s off
f 47//1 1//1 3//1
f 47//1 3//1 45//1
f 4//2 2//2 48//2
f 4//2 48//2 46//2
f 45//3 3//3 5//3
f 45//3 5//3 43//3
f 6//4 4//4 46//4
f 6//4 46//4 44//4
f 3//5 9//5 7//5
f 3//5 7//5 5//5
f 8//6 10//6 4//6
f 8//6 4//6 6//6
f 1//7 11//7 9//7
f 1//7 9//7 3//7
f 10//8 12//8 2//8
f 10//8 2//8 4//8
f 11//9 13//9 15//9
f 11//9 15//9 9//9
f 16//10 14//10 12//10
f 16//10 12//10 10//10
f 9//11 15//11 17//11
f 9//11 17//11 7//11
f 18//12 16//12 10//12
f 18//12 10//12 8//12
f 15//13 21//13 19//13
f 15//13 19//13 17//13
f 20//14 22//14 16//14
f 20//14 16//14 18//14
f 13//15 23//15 21//15
f 13//15 21//15 15//15
f 22//16 24//16 14//16
f 22//16 14//16 16//16
f 23//17 25//17 27//17
f 23//17 27//17 21//17
f 28//18 26//18 24//18
f 28//18 24//18 22//18
f 21//19 27//19 29//19
f 21//19 29//19 19//19
f 30//20 28//20 22//20
f 30//20 22//20 20//20
f 27//21 33//21 31//21
f 27//21 31//21 29//21
f 32//22 34//22 28//22
f 32//22 28//22 30//22
f 25//23 35//23 33//23
f 25//23 33//23 27//23
f 34//24 36//24 26//24
f 34//24 26//24 28//24
f 35//25 37//25 39//25
f 35//25 39//25 33//25
f 40//26 38//26 36//26
f 40//26 36//26 34//26
f 33//27 39//27 41//27
f 33//27 41//27 31//27
f 42//28 40//28 34//28
f 42//28 34//28 32//28
f 39//29 45//29 43//29
f 39//29 43//29 41//29
f 44//30 46//30 40//30
f 44//30 40//30 42//30
f 37//31 47//31 45//31
f 37//31 45//31 39//31
f 46//32 48//32 38//32
f 46//32 38//32 40//32
f 47//33 37//33 51//33
f 47//33 51//33 49//33
f 52//34 38//34 48//34
f 52//34 48//34 50//34
f 37//35 35//35 53//35
f 37//35 53//35 51//35
f 54//36 36//36 38//36
f 54//36 38//36 52//36
f 35//37 25//37 55//37
f 35//37 55//37 53//37
f 56//38 26//38 36//38
f 56//38 36//38 54//38
f 25//39 23//39 57//39
f 25//39 57//39 55//39
f 58//40 24//40 26//40
f 58//40 26//40 56//40
f 23//41 13//41 59//41
f 23//41 59//41 57//41
f 60//42 14//42 24//42
f 60//42 24//42 58//42
f 13//43 11//43 63//43
f 13//43 63//43 59//43
f 64//44 12//44 14//44
f 64//44 14//44 60//44
f 11//45 1//45 65//45
f 11//45 65//45 63//45
f 66//46 2//46 12//46
f 66//46 12//46 64//46
f 1//47 47//47 49//47
f 1//47 49//47 65//47
f 50//48 48//48 2//48
f 50//48 2//48 66//48
f 61//49 65//49 49//49
f 50//50 66//50 62//50
f 63//51 65//51 61//51
f 62//52 66//52 64//52
f 61//53 59//53 63//53
f 64//54 60//54 62//54
f 61//55 57//55 59//55
f 60//56 58//56 62//56
f 61//57 55//57 57//57
f 58//58 56//58 62//58
f 61//59 53//59 55//59
f 56//60 54//60 62//60
f 61//61 51//61 53//61
f 54//62 52//62 62//62
f 61//63 49//63 51//63
f 52//64 50//64 62//64
f 89//65 174//65 176//65
f 89//65 176//65 91//65
f 176//66 175//66 90//66
f 176//66 90//66 91//66
f 87//67 172//67 174//67
f 87//67 174//67 89//67
f 175//68 173//68 88//68
f 175//68 88//68 90//68
f 85//69 170//69 172//69
f 85//69 172//69 87//69
f 173//70 171//70 86//70
f 173//70 86//70 88//70
f 83//71 168//71 170//71
f 83//71 170//71 85//71
f 171//72 169//72 84//72
f 171//72 84//72 86//72
f 81//73 166//73 168//73
f 81//73 168//73 83//73
f 169//74 167//74 82//74
f 169//74 82//74 84//74
f 79//75 92//75 146//75
f 79//75 146//75 164//75
f 147//76 93//76 80//76
f 147//76 80//76 165//76
f 92//77 94//77 148//77
f 92//77 148//77 146//77
f 149//78 95//78 93//78
f 149//78 93//78 147//78
f 94//79 96//79 150//79
f 94//79 150//79 148//79
f 151//80 97//80 95//80
f 151//80 95//80 149//80
f 96//81 98//81 152//81
f 96//81 152//81 150//81
f 153//82 99//82 97//82
f 153//82 97//82 151//82
f 98//83 100//83 154//83
f 98//83 154//83 152//83
f 155//84 101//84 99//84
f 155//84 99//84 153//84
f 100//85 102//85 156//85
f 100//85 156//85 154//85
f 157//86 103//86 101//86
f 157//86 101//86 155//86
f 102//87 104//87 158//87
f 102//87 158//87 156//87
f 159//88 105//88 103//88
f 159//88 103//88 157//88
f 104//89 106//89 160//89
f 104//89 160//89 158//89
f 161//90 107//90 105//90
f 161//90 105//90 159//90
f 106//91 108//91 162//91
f 106//91 162//91 160//91
f 163//92 109//92 107//92
f 163//92 107//92 161//92
f 108//93 67//93 68//93
f 108//93 68//93 162//93
f 68//94 67//94 109//94
f 68//94 109//94 163//94
f 110//95 128//95 160//95
f 110//95 160//95 162//95
f 161//96 129//96 111//96
f 161//96 111//96 163//96
f 128//97 179//97 158//97
f 128//97 158//97 160//97
f 159//98 180//98 129//98
f 159//98 129//98 161//98
f 126//99 156//99 158//99
f 126//99 158//99 179//99
f 159//100 157//100 127//100
f 159//100 127//100 180//100
f 124//101 154//101 156//101
f 124//101 156//101 126//101
f 157//102 155//102 125//102
f 157//102 125//102 127//102
f 122//103 152//103 154//103
f 122//103 154//103 124//103
f 155//104 153//104 123//104
f 155//104 123//104 125//104
f 120//105 150//105 152//105
f 120//105 152//105 122//105
f 153//106 151//106 121//106
f 153//106 121//106 123//106
f 118//107 148//107 150//107
f 118//107 150//107 120//107
f 151//108 149//108 119//108
f 151//108 119//108 121//108
f 116//109 146//109 148//109
f 116//109 148//109 118//109
f 149//110 147//110 117//110
f 149//110 117//110 119//110
f 114//111 164//111 146//111
f 114//111 146//111 116//111
f 147//112 165//112 115//112
f 147//112 115//112 117//112
f 114//113 181//113 177//113
f 114//113 177//113 164//113
f 177//114 182//114 115//114
f 177//114 115//114 165//114
f 110//115 162//115 68//115
f 110//115 68//115 112//115
f 68//116 163//116 111//116
f 68//116 111//116 113//116
f 112//117 68//117 178//117
f 112//117 178//117 183//117
f 178//118 68//118 113//118
f 178//118 113//118 184//118
f 177//119 181//119 183//119
f 177//119 183//119 178//119
f 184//120 182//120 177//120
f 184//120 177//120 178//120
f 135//121 137//121 176//121
f 135//121 176//121 174//121
f 176//122 137//122 136//122
f 176//122 136//122 175//122
f 133//123 135//123 174//123
f 133//123 174//123 172//123
f 175//124 136//124 134//124
f 175//124 134//124 173//124
f 131//125 133//125 172//125
f 131//125 172//125 170//125
f 173//126 134//126 132//126
f 173//126 132//126 171//126
f 166//127 187//127 185//127
f 166//127 185//127 168//127
f 186//128 188//128 167//128
f 186//128 167//128 169//128
f 131//129 170//129 168//129
f 131//129 168//129 185//129
f 169//130 171//130 132//130
f 169//130 132//130 186//130
f 144//131 190//131 189//131
f 144//131 189//131 187//131
f 189//132 190//132 145//132
f 189//132 145//132 188//132
f 185//133 187//133 189//133
f 185//133 189//133 69//133
f 189//134 188//134 186//134
f 189//134 186//134 69//134
f 130//135 131//135 185//135
f 130//135 185//135 69//135
f 186//135 132//135 130//135
f 186//135 130//135 69//135
f 142//136 193//136 191//136
f 142//136 191//136 144//136
f 192//137 194//137 143//137
f 192//137 143//137 145//137
f 140//138 195//138 193//138
f 140//138 193//138 142//138
f 194//139 196//139 141//139
f 194//139 141//139 143//139
f 139//140 197//140 195//140
f 139//140 195//140 140//140
f 196//141 198//141 139//141
f 196//141 139//141 141//141
f 138//142 71//142 197//142
f 138//142 197//142 139//142
f 198//143 71//143 138//143
f 198//143 138//143 139//143
f 190//144 144//144 191//144
f 190//144 191//144 70//144
f 192//145 145//145 190//145
f 192//145 190//145 70//145
f 70//146 191//146 206//146
f 70//146 206//146 208//146
f 207//147 192//147 70//147
f 207//147 70//147 208//147
f 71//148 199//148 200//148
f 71//148 200//148 197//148
f 201//149 199//149 71//149
f 201//149 71//149 198//149
f 197//150 200//150 202//150
f 197//150 202//150 195//150
f 203//151 201//151 198//151
f 203//151 198//151 196//151
f 195//152 202//152 204//152
f 195//152 204//152 193//152
f 205//153 203//153 196//153
f 205//153 196//153 194//153
f 193//154 204//154 206//154
f 193//154 206//154 191//154
f 207//155 205//155 194//155
f 207//155 194//155 192//155
f 199//156 204//156 202//156
f 199//156 202//156 200//156
f 203//157 205//157 199//157
f 203//157 199//157 201//157
f 199//158 208//158 206//158
f 199//158 206//158 204//158
f 207//159 208//159 199//159
f 207//159 199//159 205//159
f 139//160 140//160 164//160
f 139//160 164//160 177//160
f 165//161 141//161 139//161
f 165//161 139//161 177//161
f 140//162 142//162 211//162
f 140//162 211//162 164//162
f 212//163 143//163 141//163
f 212//163 141//163 165//163
f 142//164 144//164 213//164
f 142//164 213//164 211//164
f 214//165 145//165 143//165
f 214//165 143//165 212//165
f 144//166 187//166 166//166
f 144//166 166//166 213//166
f 167//167 188//167 145//167
f 167//167 145//167 214//167
f 81//168 209//168 213//168
f 81//168 213//168 166//168
f 214//169 210//169 82//169
f 214//169 82//169 167//169
f 209//170 215//170 211//170
f 209//170 211//170 213//170
f 212//171 216//171 210//171
f 212//171 210//171 214//171
f 79//172 164//172 211//172
f 79//172 211//172 215//172
f 212//173 165//173 80//173
f 212//173 80//173 216//173
f 131//174 130//174 72//174
f 131//174 72//174 222//174
f 72//175 130//175 132//175
f 72//175 132//175 223//175
f 133//176 131//176 222//176
f 133//176 222//176 220//176
f 223//177 132//177 134//177
f 223//177 134//177 221//177
f 135//178 133//178 220//178
f 135//178 220//178 218//178
f 221//179 134//179 136//179
f 221//179 136//179 219//179
f 137//180 135//180 218//180
f 137//180 218//180 217//180
f 219//181 136//181 137//181
f 219//181 137//181 217//181
f 217//182 218//182 229//182
f 217//182 229//182 231//182
f 230//183 219//183 217//183
f 230//183 217//183 231//183
f 218//184 220//184 227//184
f 218//184 227//184 229//184
f 228//185 221//185 219//185
f 228//185 219//185 230//185
f 220//186 222//186 225//186
f 220//186 225//186 227//186
f 226//187 223//187 221//187
f 226//187 221//187 228//187
f 222//188 72//188 224//188
f 222//188 224//188 225//188
f 224//189 72//189 223//189
f 224//189 223//189 226//189
f 224//190 231//190 229//190
f 224//190 229//190 225//190
f 230//191 231//191 224//191
f 230//191 224//191 226//191
f 225//192 229//192 227//192
f 228//193 230//193 226//193
f 183//194 181//194 234//194
f 183//194 234//194 232//194
f 235//195 182//195 184//195
f 235//195 184//195 233//195
f 112//196 183//196 232//196
f 112//196 232//196 254//196
f 233//197 184//197 113//197
f 233//197 113//197 255//197
f 110//198 112//198 254//198
f 110//198 254//198 256//198
f 255//199 113//199 111//199
f 255//199 111//199 257//199
f 181//200 114//200 252//200
f 181//200 252//200 234//200
f 253//201 115//201 182//201
f 253//201 182//201 235//201
f 114//202 116//202 250//202
f 114//202 250//202 252//202
f 251//203 117//203 115//203
f 251//203 115//203 253//203
f 116//204 118//204 248//204
f 116//204 248//204 250//204
f 249//205 119//205 117//205
f 249//205 117//205 251//205
f 118//206 120//206 246//206
f 118//206 246//206 248//206
f 247//207 121//207 119//207
f 247//207 119//207 249//207
f 120//208 122//208 244//208
f 120//208 244//208 246//208
f 245//209 123//209 121//209
f 245//209 121//209 247//209
f 122//210 124//210 242//210
f 122//210 242//210 244//210
f 243//211 125//211 123//211
f 243//211 123//211 245//211
f 124//212 126//212 240//212
f 124//212 240//212 242//212
f 241//213 127//213 125//213
f 241//213 125//213 243//213
f 126//214 179//214 236//214
f 126//214 236//214 240//214
f 237//215 180//215 127//215
f 237//215 127//215 241//215
f 179//216 128//216 238//216
f 179//216 238//216 236//216
f 239//217 129//217 180//217
f 239//217 180//217 237//217
f 128//218 110//218 256//218
f 128//218 256//218 238//218
f 257//219 111//219 129//219
f 257//219 129//219 239//219
f 238//220 256//220 258//220
f 238//220 258//220 276//220
f 259//221 257//221 239//221
f 259//221 239//221 277//221
f 236//222 238//222 276//222
f 236//222 276//222 278//222
f 277//223 239//223 237//223
f 277//223 237//223 279//223
f 240//224 236//224 278//224
f 240//224 278//224 274//224
f 279//225 237//225 241//225
f 279//225 241//225 275//225
f 242//226 240//226 274//226
f 242//226 274//226 272//226
f 275//227 241//227 243//227
f 275//227 243//227 273//227
f 244//228 242//228 272//228
f 244//228 272//228 270//228
f 273//229 243//229 245//229
f 273//229 245//229 271//229
f 246//230 244//230 270//230
f 246//230 270//230 268//230
f 271//231 245//231 247//231
f 271//231 247//231 269//231
f 248//232 246//232 268//232
f 248//232 268//232 266//232
f 269//233 247//233 249//233
f 269//233 249//233 267//233
f 250//234 248//234 266//234
f 250//234 266//234 264//234
f 267//235 249//235 251//235
f 267//235 251//235 265//235
f 252//236 250//236 264//236
f 252//236 264//236 262//236
f 265//237 251//237 253//237
f 265//237 253//237 263//237
f 234//238 252//238 262//238
f 234//238 262//238 280//238
f 263//239 253//239 235//239
f 263//239 235//239 281//239
f 256//240 254//240 260//240
f 256//240 260//240 258//240
f 261//241 255//241 257//241
f 261//241 257//241 259//241
f 254//242 232//242 282//242
f 254//242 282//242 260//242
f 283//243 233//243 255//243
f 283//243 255//243 261//243
f 232//244 234//244 280//244
f 232//244 280//244 282//244
f 281//245 235//245 233//245
f 281//245 233//245 283//245
f 67//246 108//246 284//246
f 67//246 284//246 73//246
f 285//247 109//247 67//247
f 285//247 67//247 73//247
f 108//248 106//248 286//248
f 108//248 286//248 284//248
f 287//249 107//249 109//249
f 287//249 109//249 285//249
f 106//250 104//250 288//250
f 106//250 288//250 286//250
f 289//251 105//251 107//251
f 289//251 107//251 287//251
f 104//252 102//252 290//252
f 104//252 290//252 288//252
f 291//253 103//253 105//253
f 291//253 105//253 289//253
f 102//254 100//254 292//254
f 102//254 292//254 290//254
f 293//255 101//255 103//255
f 293//255 103//255 291//255
f 100//256 98//256 294//256
f 100//256 294//256 292//256
f 295//257 99//257 101//257
f 295//257 101//257 293//257
f 98//258 96//258 296//258
f 98//258 296//258 294//258
f 297//259 97//259 99//259
f 297//259 99//259 295//259
f 96//260 94//260 298//260
f 96//260 298//260 296//260
f 299//261 95//261 97//261
f 299//261 97//261 297//261
f 94//262 92//262 300//262
f 94//262 300//262 298//262
f 301//263 93//263 95//263
f 301//263 95//263 299//263
f 308//264 309//264 328//264
f 308//264 328//264 338//264
f 329//265 309//265 308//265
f 329//265 308//265 339//265
f 307//266 308//266 338//266
f 307//266 338//266 336//266
f 339//267 308//267 307//267
f 339//267 307//267 337//267
f 306//268 307//268 336//268
f 306//268 336//268 340//268
f 337//269 307//269 306//269
f 337//269 306//269 341//269
f 89//270 91//270 306//270
f 89//270 306//270 340//270
f 306//271 91//271 90//271
f 306//271 90//271 341//271
f 87//272 89//272 340//272
f 87//272 340//272 334//272
f 341//273 90//273 88//273
f 341//273 88//273 335//273
f 85//274 87//274 334//274
f 85//274 334//274 330//274
f 335//275 88//275 86//275
f 335//275 86//275 331//275
f 83//276 85//276 330//276
f 83//276 330//276 332//276
f 331//277 86//277 84//277
f 331//277 84//277 333//277
f 330//278 336//278 338//278
f 330//278 338//278 332//278
f 339//279 337//279 331//279
f 339//279 331//279 333//279
f 330//280 334//280 340//280
f 330//280 340//280 336//280
f 341//281 335//281 331//281
f 341//281 331//281 337//281
f 326//282 332//282 338//282
f 326//282 338//282 328//282
f 339//283 333//283 327//283
f 339//283 327//283 329//283
f 81//284 83//284 332//284
f 81//284 332//284 326//284
f 333//285 84//285 82//285
f 333//285 82//285 327//285
f 209//286 342//286 344//286
f 209//286 344//286 215//286
f 345//287 343//287 210//287
f 345//287 210//287 216//287
f 81//288 326//288 342//288
f 81//288 342//288 209//288
f 343//289 327//289 82//289
f 343//289 82//289 210//289
f 79//290 215//290 344//290
f 79//290 344//290 346//290
f 345//291 216//291 80//291
f 345//291 80//291 347//291
f 79//292 346//292 300//292
f 79//292 300//292 92//292
f 301//293 347//293 80//293
f 301//293 80//293 93//293
f 77//294 324//294 352//294
f 77//294 352//294 304//294
f 353//295 325//295 77//295
f 353//295 77//295 304//295
f 304//296 352//296 350//296
f 304//296 350//296 78//296
f 351//297 353//297 304//297
f 351//297 304//297 78//297
f 78//298 350//298 348//298
f 78//298 348//298 305//298
f 349//299 351//299 78//299
f 349//299 78//299 305//299
f 305//300 348//300 328//300
f 305//300 328//300 309//300
f 329//301 349//301 305//301
f 329//301 305//301 309//301
f 326//302 328//302 348//302
f 326//302 348//302 342//302
f 349//303 329//303 327//303
f 349//303 327//303 343//303
f 296//304 298//304 318//304
f 296//304 318//304 310//304
f 319//305 299//305 297//305
f 319//305 297//305 311//305
f 76//306 316//306 324//306
f 76//306 324//306 77//306
f 325//307 317//307 76//307
f 325//307 76//307 77//307
f 302//308 358//308 356//308
f 302//308 356//308 303//308
f 357//309 359//309 302//309
f 357//309 302//309 303//309
f 303//310 356//310 354//310
f 303//310 354//310 75//310
f 355//311 357//311 303//311
f 355//311 303//311 75//311
f 75//312 354//312 316//312
f 75//312 316//312 76//312
f 317//313 355//313 75//313
f 317//313 75//313 76//313
f 292//314 294//314 362//314
f 292//314 362//314 364//314
f 363//315 295//315 293//315
f 363//315 293//315 365//315
f 364//316 362//316 368//316
f 364//316 368//316 366//316
f 369//317 363//317 365//317
f 369//317 365//317 367//317
f 366//318 368//318 370//318
f 366//318 370//318 372//318
f 371//319 369//319 367//319
f 371//319 367//319 373//319
f 372//320 370//320 376//320
f 372//320 376//320 374//320
f 377//321 371//321 373//321
f 377//321 373//321 375//321
f 314//322 378//322 374//322
f 314//322 374//322 376//322
f 375//323 379//323 315//323
f 375//323 315//323 377//323
f 316//324 354//324 374//324
f 316//324 374//324 378//324
f 375//325 355//325 317//325
f 375//325 317//325 379//325
f 354//326 356//326 372//326
f 354//326 372//326 374//326
f 373//327 357//327 355//327
f 373//327 355//327 375//327
f 356//328 358//328 366//328
f 356//328 366//328 372//328
f 367//329 359//329 357//329
f 367//329 357//329 373//329
f 358//330 360//330 364//330
f 358//330 364//330 366//330
f 365//331 361//331 359//331
f 365//331 359//331 367//331
f 290//332 292//332 364//332
f 290//332 364//332 360//332
f 365//333 293//333 291//333
f 365//333 291//333 361//333
f 74//334 360//334 358//334
f 74//334 358//334 302//334
f 359//335 361//335 74//335
f 359//335 74//335 302//335
f 284//336 286//336 288//336
f 284//336 288//336 290//336
f 289//337 287//337 285//337
f 289//337 285//337 291//337
f 284//338 290//338 360//338
f 284//338 360//338 74//338
f 361//339 291//339 285//339
f 361//339 285//339 74//339
f 73//340 284//340 74//340
f 74//341 285//341 73//341
f 294//342 296//342 310//342
f 294//342 310//342 362//342
f 311//343 297//343 295//343
f 311//343 295//343 363//343
f 310//344 312//344 368//344
f 310//344 368//344 362//344
f 369//345 313//345 311//345
f 369//345 311//345 363//345
f 312//346 382//346 370//346
f 312//346 370//346 368//346
f 371//347 383//347 313//347
f 371//347 313//347 369//347
f 314//348 376//348 370//348
f 314//348 370//348 382//348
f 371//349 377//349 315//349
f 371//349 315//349 383//349
f 348//350 350//350 386//350
f 348//350 386//350 384//350
f 387//351 351//351 349//351
f 387//351 349//351 385//351
f 318//352 384//352 386//352
f 318//352 386//352 320//352
f 387//353 385//353 319//353
f 387//353 319//353 321//353
f 298//354 300//354 384//354
f 298//354 384//354 318//354
f 385//355 301//355 299//355
f 385//355 299//355 319//355
f 300//356 344//356 342//356
f 300//356 342//356 384//356
f 343//357 345//357 301//357
f 343//357 301//357 385//357
f 342//358 348//358 384//358
f 385//359 349//359 343//359
f 300//360 346//360 344//360
f 345//361 347//361 301//361
f 314//362 322//362 380//362
f 314//362 380//362 378//362
f 381//363 323//363 315//363
f 381//363 315//363 379//363
f 316//364 378//364 380//364
f 316//364 380//364 324//364
f 381//365 379//365 317//365
f 381//365 317//365 325//365
f 320//366 386//366 380//366
f 320//366 380//366 322//366
f 381//367 387//367 321//367
f 381//367 321//367 323//367
f 350//368 352//368 380//368
f 350//368 380//368 386//368
f 381//369 353//369 351//369
f 381//369 351//369 387//369
f 324//370 380//370 352//370
f 353//371 381//371 325//371
f 400//372 388//372 414//372
f 400//372 414//372 402//372
f 415//373 389//373 401//373
f 415//373 401//373 403//373
f 400//374 402//374 404//374
f 400//374 404//374 398//374
f 405//375 403//375 401//375
f 405//375 401//375 399//375
f 398//376 404//376 406//376
f 398//376 406//376 396//376
f 407//377 405//377 399//377
f 407//377 399//377 397//377
f 396//378 406//378 408//378
f 396//378 408//378 394//378
f 409//379 407//379 397//379
f 409//379 397//379 395//379
f 394//380 408//380 410//380
f 394//380 410//380 392//380
f 411//381 409//381 395//381
f 411//381 395//381 393//381
f 392//382 410//382 412//382
f 392//382 412//382 390//382
f 413//383 411//383 393//383
f 413//383 393//383 391//383
f 410//384 420//384 418//384
f 410//384 418//384 412//384
f 419//385 421//385 411//385
f 419//385 411//385 413//385
f 408//386 422//386 420//386
f 408//386 420//386 410//386
f 421//387 423//387 409//387
f 421//387 409//387 411//387
f 406//388 424//388 422//388
f 406//388 422//388 408//388
f 423//389 425//389 407//389
f 423//389 407//389 409//389
f 404//390 426//390 424//390
f 404//390 424//390 406//390
f 425//391 427//391 405//391
f 425//391 405//391 407//391
f 402//392 428//392 426//392
f 402//392 426//392 404//392
f 427//393 429//393 403//393
f 427//393 403//393 405//393
f 402//394 414//394 416//394
f 402//394 416//394 428//394
f 417//395 415//395 403//395
f 417//395 403//395 429//395
f 318//396 320//396 444//396
f 318//396 444//396 442//396
f 445//397 321//397 319//397
f 445//397 319//397 443//397
f 320//398 390//398 412//398
f 320//398 412//398 444//398
f 413//399 391//399 321//399
f 413//399 321//399 445//399
f 310//400 318//400 442//400
f 310//400 442//400 312//400
f 443//401 319//401 311//401
f 443//401 311//401 313//401
f 382//402 430//402 414//402
f 382//402 414//402 388//402
f 415//403 431//403 383//403
f 415//403 383//403 389//403
f 412//404 418//404 440//404
f 412//404 440//404 444//404
f 441//405 419//405 413//405
f 441//405 413//405 445//405
f 438//406 446//406 444//406
f 438//406 444//406 440//406
f 445//407 447//407 439//407
f 445//407 439//407 441//407
f 434//408 446//408 438//408
f 434//408 438//408 436//408
f 439//409 447//409 435//409
f 439//409 435//409 437//409
f 432//410 448//410 446//410
f 432//410 446//410 434//410
f 447//411 449//411 433//411
f 447//411 433//411 435//411
f 430//412 448//412 432//412
f 430//412 432//412 450//412
f 433//413 449//413 431//413
f 433//413 431//413 451//413
f 414//414 430//414 450//414
f 414//414 450//414 416//414
f 451//415 431//415 415//415
f 451//415 415//415 417//415
f 312//416 448//416 430//416
f 312//416 430//416 382//416
f 431//417 449//417 313//417
f 431//417 313//417 383//417
f 312//418 442//418 446//418
f 312//418 446//418 448//418
f 447//419 443//419 313//419
f 447//419 313//419 449//419
f 442//420 444//420 446//420
f 447//421 445//421 443//421
f 416//422 450//422 452//422
f 416//422 452//422 476//422
f 453//423 451//423 417//423
f 453//423 417//423 477//423
f 450//424 432//424 462//424
f 450//424 462//424 452//424
f 463//425 433//425 451//425
f 463//425 451//425 453//425
f 432//426 434//426 460//426
f 432//426 460//426 462//426
f 461//427 435//427 433//427
f 461//427 433//427 463//427
f 434//428 436//428 458//428
f 434//428 458//428 460//428
f 459//429 437//429 435//429
f 459//429 435//429 461//429
f 436//430 438//430 456//430
f 436//430 456//430 458//430
f 457//431 439//431 437//431
f 457//431 437//431 459//431
f 438//432 440//432 454//432
f 438//432 454//432 456//432
f 455//433 441//433 439//433
f 455//433 439//433 457//433
f 440//434 418//434 474//434
f 440//434 474//434 454//434
f 475//435 419//435 441//435
f 475//435 441//435 455//435
f 428//436 416//436 476//436
f 428//436 476//436 464//436
f 477//437 417//437 429//437
f 477//437 429//437 465//437
f 426//438 428//438 464//438
f 426//438 464//438 466//438
f 465//439 429//439 427//439
f 465//439 427//439 467//439
f 424//440 426//440 466//440
f 424//440 466//440 468//440
f 467//441 427//441 425//441
f 467//441 425//441 469//441
f 422//442 424//442 468//442
f 422//442 468//442 470//442
f 469//443 425//443 423//443
f 469//443 423//443 471//443
f 420//444 422//444 470//444
f 420//444 470//444 472//444
f 471//445 423//445 421//445
f 471//445 421//445 473//445
f 418//446 420//446 472//446
f 418//446 472//446 474//446
f 473//447 421//447 419//447
f 473//447 419//447 475//447
f 458//448 456//448 480//448
f 458//448 480//448 478//448
f 481//449 457//449 459//449
f 481//449 459//449 479//449
f 478//450 480//450 482//450
f 478//450 482//450 484//450
f 483//451 481//451 479//451
f 483//451 479//451 485//451
f 484//452 482//452 488//452
f 484//452 488//452 486//452
f 489//453 483//453 485//453
f 489//453 485//453 487//453
f 486//454 488//454 490//454
f 486//454 490//454 492//454
f 491//455 489//455 487//455
f 491//455 487//455 493//455
f 464//456 476//456 486//456
f 464//456 486//456 492//456
f 487//457 477//457 465//457
f 487//457 465//457 493//457
f 452//458 484//458 486//458
f 452//458 486//458 476//458
f 487//459 485//459 453//459
f 487//459 453//459 477//459
f 452//460 462//460 478//460
f 452//460 478//460 484//460
f 479//461 463//461 453//461
f 479//461 453//461 485//461
f 458//462 478//462 462//462
f 458//462 462//462 460//462
f 463//463 479//463 459//463
f 463//463 459//463 461//463
f 454//464 474//464 480//464
f 454//464 480//464 456//464
f 481//465 475//465 455//465
f 481//465 455//465 457//465
f 472//466 482//466 480//466
f 472//466 480//466 474//466
f 481//467 483//467 473//467
f 481//467 473//467 475//467
f 470//468 488//468 482//468
f 470//468 482//468 472//468
f 483//469 489//469 471//469
f 483//469 471//469 473//469
f 468//470 490//470 488//470
f 468//470 488//470 470//470
f 489//471 491//471 469//471
f 489//471 469//471 471//471
f 466//472 492//472 490//472
f 466//472 490//472 468//472
f 491//473 493//473 467//473
f 491//473 467//473 469//473
f 464//474 492//474 466//474
f 467//475 493//475 465//475
f 392//476 390//476 504//476
f 392//476 504//476 502//476
f 505//477 391//477 393//477
f 505//477 393//477 503//477
f 394//478 392//478 502//478
f 394//478 502//478 500//478
f 503//479 393//479 395//479
f 503//479 395//479 501//479
f 396//480 394//480 500//480
f 396//480 500//480 498//480
f 501//481 395//481 397//481
f 501//481 397//481 499//481
f 398//482 396//482 498//482
f 398//482 498//482 496//482
f 499//483 397//483 399//483
f 499//483 399//483 497//483
f 400//484 398//484 496//484
f 400//484 496//484 494//484
f 497//485 399//485 401//485
f 497//485 401//485 495//485
f 388//486 400//486 494//486
f 388//486 494//486 506//486
f 495//487 401//487 389//487
f 495//487 389//487 507//487
f 494//488 502//488 504//488
f 494//488 504//488 506//488
f 505//489 503//489 495//489
f 505//489 495//489 507//489
f 494//490 496//490 500//490
f 494//490 500//490 502//490
f 501//491 497//491 495//491
f 501//491 495//491 503//491
f 496//492 498//492 500//492
f 501//493 499//493 497//493
f 314//494 382//494 388//494
f 314//494 388//494 506//494
f 389//495 383//495 315//495
f 389//495 315//495 507//495
f 314//496 506//496 504//496
f 314//496 504//496 322//496
f 505//497 507//497 315//497
f 505//497 315//497 323//497
f 320//498 322//498 504//498
f 320//498 504//498 390//498
f 505//499 323//499 321//499
f 505//499 321//499 391//499

Brandon
01-22-2012, 05:52 PM
This looks epic!!!! I might do some secret work on it now that I know it's possible.. I asked this question before and not a single person besides DGBY and Richard knew what I was talking about..

My question was actually if simba can render 3D images so I can use Gouraud/Phong shading on it..

Try it! I will try it :)
http://en.wikipedia.org/wiki/Phong_shading
http://en.wikipedia.org/wiki/Gouraud_shading

ReadySteadyGo
01-22-2012, 05:56 PM
Gourad shading is easy, I've already started it. You just need the vertex normals (which my parser already stores) and rasterize triangles with interpolation between the 3 colours. Give me 10 minutes and I'll post an example. :P Phong will take far too long in Simba unfortunately.

I'm glad someone's interested. What would be very cool is to make a Simba Community game.

maigel
01-22-2012, 06:05 PM
What would be very cool is to make a Simba Community game.

It would sure be an interesting project. But wouldn't making the game in simba make it very slow?

momotron
01-22-2012, 06:08 PM
Ooooh this looks interesting *subscribes*

nielsie95
01-22-2012, 06:29 PM
Very cool!

ReadySteadyGo
01-22-2012, 06:36 PM
I did say 10 minutes, but I got stuck on interpolation. Thought people might find this interesting:
http://i.imgur.com/s3xdu.png

Will implement gouroud now.


Thanks everyone

onilika
01-22-2012, 08:01 PM
wow, quite interesting! I used to do some stuff using Maya, but now I don't have it on computer. Might go back to it!
Anyways, the monkeys looks good! Keep on the road :D

~onilika

[XoL]
01-22-2012, 10:11 PM
Very cool stuff, great work :D

Sin
01-22-2012, 10:24 PM
Gourad shading is easy, I've already started it. You just need the vertex normals (which my parser already stores) and rasterize triangles with interpolation between the 3 colours.

Wat.

grats
01-22-2012, 10:31 PM
woo the blender monkey!


and yea that would be cool to have a community simba game, like blender has that game they've been working on

what genre?

Zyt3x
01-22-2012, 10:35 PM
How fast is it?

E: That is actually pretty fast..! Well done! now add rotation :D

jakeyboy29
01-22-2012, 11:07 PM
Threads like this make me feel so retarded

ReadySteadyGo
01-23-2012, 04:33 AM
Thank you for the comments guys :)

Gouraud implementation:
Looks absolutely dreadful, it could be to do with the Z order. I'm also not sure how all the smudges are being formed. I think I need to try with simpler models so I can be sure I have the basics right.

I also played around with the colour and rotation a little bit. I'm getting ghost colours so I'm not sure if I've fudged a calculation somewhere.

http://i.imgur.com/kdp5Z.png

http://i.imgur.com/N3Ors.png

http://i.imgur.com/WtvjN.png

program new;

// hit Q to stop


const
SHADE = FALSE;
FILE_NAME = 'monkey.obj';

SCREEN_WIDTH = 600;
SCREEN_HEIGHT = 400;

type

TPoint3D = record
x, y, z: Extended;
end;
TVector3D = TPoint3D;

TMatrix3x3 = record
Data: Array of Extended;
end;

TMatrix4x4 = record
Data: Array[0..15] of Extended;
end;

TTriangleFace = record
a, b, c: Integer;
end;

TEntity = record
Name: String;
Vertices: Array of TPoint3D;
VertexNormals: Array of TPoint3D;
Faces: Array of TTriangleFace;
FaceNormals: Array of TVector3D;
WorldPosition: TPoint3D;
end;

TLight = record
Direction: TVector3D;
end;


var
MainForm: TForm;
StartButton: TButton;


function Point3D(x, y, z: Extended): TPoint3D;
begin
Result.x := x;
Result.y := y;
Result.z := z;
end;

function Vector3D(x, y, z: Extended): TVector3D;
begin
Result.x := x;
Result.y := y;
Result.z := z;
end;

function Multiply_Point3D_Matrix3x3(p: TPoint3D; m: TMatrix3x3): TPoint3D;
begin
Result.x := (m.Data[0] * p.x) + (m.Data[1] * p.y) + (m.Data[2] * p.z);
Result.y := (m.Data[3] * p.x) + (m.Data[4] * p.y) + (m.Data[5] * p.z);
Result.z := (m.Data[6] * p.x) + (m.Data[7] * p.y) + (m.Data[8] * p.z);
end;

function DeclareLighting: Array of TLight;
begin
SetLength(Result, 1);

Result[0].Direction := Vector3D(1.0, -1.0, 0.5);
end;

procedure DrawLine(c: TCanvas; p1, p2: TPoint; Color: Integer);
begin
c.Pen.Color := Color;
c.MoveTo(p1.x, p1.y);
c.LineTo(p2.x, p2.y);
end;

procedure DrawPixel(c: TCanvas; x, y, Color: Integer);
begin
DrawLine(c, Point(x, y), Point(x, y+1), Color);
end;

function InterpolateColor(c1, c2: Integer; Percentage: Extended): Integer;
var
c1r, c1g, c1b, c2r, c2g, c2b, R, G, B: Integer;
begin
ColorToRGB(c1, c1r, c1g, c1b);
ColorToRGB(c2, c2r, c2g, c2b);


R := Round((c1r * Percentage + c2r * (1 - Percentage)));
G := Round((c1g * Percentage + c2g * (1 - Percentage)));
B := Round((c1b * Percentage + c2b * (1 - Percentage)));

Result := RGBtoColor(R, G, B);
end;

procedure DrawTriangle(const Canvas: TCanvas; const p1, p2, p3: TPoint; Color: TIntegerArray; Gouroud:Boolean);
var
DxyLeft, DxyRight, NewDxyRight, xs, xe, tv1, tv2, percenta, percentb: Extended;
i, j, a, b: Integer;
begin
tv1 := (p3.x-p1.x);
tv2 := (p3.y-p1.y);
DxyLeft := tv1/tv2;
tv1 := p2.x-p1.x;
tv2 := p2.y-p1.y;
DxyRight := tv1/tv2;

if (p2.y <> p3.y) then
begin
tv1 := p2.x-p3.x;
tv2 := p2.y-p3.y;
NewDxyRight := tv1/tv2;
end;

xs := p1.x;
xe := p1.x;

if p2.y > p1.y then
for i := p1.y to p3.y do
begin
if Gouroud then
begin


if i <= p2.y then
begin
percenta := ((100.0 / (p2.y - p1.y)) * (i - p1.y))/100; //(i - p1.y)/(p2.y - p1.y); //
a := InterpolateColor(Color[1], Color[0], percenta);
end else
begin
percenta := ((100.0 / (p3.y - p2.y)) * (i - p2.y))/100;
a := InterpolateColor(Color[2], Color[1], percenta);
end;
percentb := ((100.0 / (p3.y - p1.y)) * (i - p1.y))/100; //(i - p1.y)/(p3.y - p1.y); //
b := InterpolateColor(Color[2], Color[0], percentb);


if p2.x > p3.x then
for j := round(xs) to round(xe) do
begin
if xs = xe then
DrawPixel(Canvas, j, i, Color[0])
else
DrawPixel(Canvas, j, i, InterpolateColor(a, b, ((100 / (xe - xs)) * (j - xs))/100)); //(j - xs)/(xe - xs)));
end
else
for j := round(xs) downto round(xe) do
begin
if xs = xe then
DrawPixel(Canvas, j, i, Color[0])
else
DrawPixel(Canvas, j, i, InterpolateColor(a, b, ((100 / (xe - xs)) * (j - xs))/100)); //(j - xs)/(xe - xs)));
end;
end else
DrawLine(Canvas, Point(round(xs), i), Point(round(xe), i), Color[0]);
xs := xs + DxyLeft;
xe := xe + DxyRight;

if i = p2.y then
DxyRight := NewDxyRight;
end
else
for i := p1.y downto p3.y do
begin
if Gouroud then
begin

percenta := ((100.0 / (p1.y - p2.y)) * (i - p2.y))/100; //(i - p1.y)/(p2.y - p1.y); //
a := InterpolateColor(Color[0], Color[1], percenta);
b := InterpolateColor(Color[0], Color[2], percenta);

for j := round(xs) to round(xe) do
begin
if xs = xe then
DrawPixel(Canvas, j, i, Color[0])
else
DrawPixel(Canvas, j, i, InterpolateColor(a, b, ((100 / (xe - xs)) * (j - xs))/100)); //(j - xs)/(xe - xs)));
end
end else
DrawLine(Canvas, Point(round(xs), i), Point(round(xe), i), Color[0]);
xs := xs - DxyLeft;
xe := xe - DxyRight;
end;
end;

procedure ShadeTriangle(const Canvas: TCanvas; const p1, p2, p3: TPoint; Color: TIntegerArray; Gouroud:Boolean);
var
tpay: TPointArray;
CA: TIntegerArray;
i: Integer;
begin
tpay := [p1, p2, p3];
SortTPAByY(tpay, True);

Setlength(CA, 3);

if Gouroud then
begin
for i := 0 to 2 do
if tpay[i] = p1 then
CA[i] := Color[0]
else
if tpay[i] = p2 then
CA[i] := Color[1]
else
if tpay[i] = p3 then
CA[i] := Color[2];
end else
CA[0] := Color[0];

if (tpay[0].y = tpay[1].y) and (tpay[0].y = tpay[2].y) and (tpay[1].y = tpay[2].y) then
Exit;

if (tpay[0].y = tpay[1].y) then
begin
if tpay[0].x > tpay[1].x then
DrawTriangle(Canvas, tpay[2], tpay[0], tpay[1], [CA[2], CA[0], CA[1]], Gouroud)
else
DrawTriangle(Canvas, tpay[2], tpay[1], tpay[0], [CA[2], CA[1], CA[0]], Gouroud);
Exit;
end else
if (tpay[1].y = tpay[2].y) then
begin
if tpay[2].x > tpay[1].x then
DrawTriangle(Canvas, tpay[0], tpay[2], tpay[1], [CA[0], CA[2], CA[1]], Gouroud)
else
DrawTriangle(Canvas, tpay[0], tpay[1], tpay[2], [CA[0], CA[1], CA[2]], Gouroud);
Exit;
end;

DrawTriangle(Canvas, tpay[0], tpay[1], tpay[2], [CA[0], CA[1], CA[2]], Gouroud)
end;

function SplitRegExprEx(Expr, Data: string): TStringArray;
var
DataArr: TStringList;
I: integer;
begin
DataArr := TStringList.Create;
try
SplitRegExpr(Expr, Data, DataArr);
SetArrayLength(Result, DataArr.Count);
for I := 0 to DataArr.Count - 1 do
Result[I] := DataArr.Strings[I];
finally
DataArr.Free;
end;
end;

function CombineStringArrays(const a: Array of TStringArray): TStringArray;
var
i, j, c, l, h: Integer;
begin
h := High(a);
for i := 0 to h do
IncEx(l, Length(a[i]));

SetLength(Result, l);

c := 0;

for i := 0 to h do
for j := 0 to High(a[i]) do
begin
Result[c] := a[i][j];
Inc(c);
end;
end;

function LoadEntity(FileName: String): TEntity;
var
OBJFile: Longint;
OBJString: String;
i, c, a, b, f, SLength, tl: integer;
S: TStringArray;
SL: Array of TStringArray;
Face: TStringArray;
TmpVertexNormals: Array of TVector3D;
begin
OBJFile := OpenFile(FileName, True);
ReadFileString(OBJFile, OBJString, FileSize(OBJFile));
CloseFile(OBJFile);
S := SplitRegExprEx('\n', OBJString);

SLength := Length(S);
SetLength(SL, SLength);

c := 0;

for i := 0 to SLength-1 do
begin
if Length(S[i]) <> 0 then
if not ExecRegExpr('#', S[i]) then
begin
SL[c] := SplitRegExprEx('\s', S[i]);
Inc(c);
end;
end;

SetLength(SL, c);
tl := Length(SL);
SetLength(Result.Vertices, tl);
SetLength(TmpVertexNormals, tl);
SetLength(Result.Faces, tl);
SetLength(Result.VertexNormals, tl);

a := 0;
b := 0;
f := 0;
for i := 0 to c-1 do

if SL[i][0] = 'v' then
begin
Result.Vertices[a] := Point3d(StrToFloat(SL[i][1]), StrToFloat(SL[i][2]), StrToFloat(SL[i][3]));
Inc(a);
end else

if SL[i][0] = 'vn' then
begin
TmpVertexNormals[b] := Vector3d(StrToFloat(SL[i][1]), StrToFloat(SL[i][2]), StrToFloat(SL[i][3]));
Inc(b);
end else

if SL[i][0] = 'f' then
begin
Face := CombineStringArrays([SplitRegExprEx('\/', SL[i][1]),
SplitRegExprEx('\/', SL[i][2]),
SplitRegExprEx('\/', SL[i][3])]);

Result.Faces[f].a := StrToInt(Face[0])-1;
Result.Faces[f].b := StrToInt(Face[3])-1;
Result.Faces[f].c := StrToInt(Face[6])-1;

//WriteLn(Result.Faces[f]);
Result.VertexNormals[Result.Faces[f].a] := TmpVertexNormals[StrToInt(Face[2])-1];
Result.VertexNormals[Result.Faces[f].b] := TmpVertexNormals[StrToInt(Face[5])-1];
Result.VertexNormals[Result.Faces[f].c] := TmpVertexNormals[StrToInt(Face[8])-1];

Inc(f);
end;

SetLength(Result.Vertices, a);
SetLength(Result.VertexNormals, a);
SetLength(Result.Faces, f);
Result.Name := FILE_NAME;
Result.WorldPosition := Point3D(0, 0, 5.0);
end;

function PerspectiveProject(Vertices: Array of TPoint3D): TPointArray;
var
h, i: Integer;
begin
SetLength(Result, Length(Vertices));
h := High(Vertices);

for i := 0 to h do
with Result[i] do
begin
x := Round((Vertices[i].x * (1.0 / Vertices[i].z)) * 400);
y := Round((Vertices[i].y * (1.0 / Vertices[i].z)) * 400);
end;
end;

function RotatePointsY(p: Array of TPoint3D; pheta{radians}: Extended): Array of TPoint3D;
var
m: TMatrix3x3;
i, l: integer;
begin
SetLength(m.Data, 9);
m.Data := [Cos(pheta), 0, Sin(pheta),
0, 1, 0,
-Sin(pheta), 0, Cos(pheta)];
//WriteLn(p);

l := Length(p);
SetLength(Result, l);
for i := 0 to l-1 do
Result[i] := Multiply_Point3D_Matrix3x3(p[i], m);

//WriteLn(Result);
end;

function V_Subtract(vr1, vr2: TVector3D): TVector3D;
begin
Result.x := vr1.x - vr2.x;
Result.y := vr1.y - vr2.y;
Result.z := vr1.z - vr2.z;
end;

function Dot(vr1, vr2: TVector3D): Extended;
begin
Result := vr1.x * vr2.x + vr1.y * vr2.y + vr1.z * vr2.z;
end;

function Cross(vr1, vr2: TVector3D): TVector3D;
begin
Result := Vector3D( (vr1.y * vr2.z) - (vr1.z * vr2.y),
(vr1.z * vr2.x) - (vr1.x * vr2.z),
(vr1.x * vr2.y) - (vr1.y * vr2.x));
end;

function BackfaceCull(var e: TEntity): array of Boolean;
var
u, v, CameraVector: TVector3D;
p1, p2, p3: TPoint3D;
i, Len: Integer;
Check: Extended;
begin
Len := Length(e.Faces);
SetLength(Result, Len);
SetLength(e.FaceNormals, Len);
for i := 0 to Len-1 do
begin
p1 := e.Vertices[e.Faces[i].a];
p2 := e.Vertices[e.Faces[i].b];
p3 := e.Vertices[e.Faces[i].c];
u := V_Subtract(p2, p1);
v := V_Subtract(p3, p1);

e.FaceNormals[i] := Cross(u, v);

CameraVector := Vector3D(0, 0, 1);

Check := Dot(e.FaceNormals[i], CameraVector);

Result[i] := Check >= 0;
end;
end;

function CalculateFaceColor(FaceNormal: TVector3D; Lighting: Array of TLight): Integer;
var
Len, i: Integer;
a: Extended;
begin
Len := Length(Lighting);
for i := 0 to Len-1 do
a := Dot(Lighting[i].Direction, FaceNormal);

Result := HSLToColor(10, 50, 100 - (100*a));
end;

procedure Render(Cube: TEntity; Lighting: Array of TLight; Rotation: Extended);
var
i, L, Offsetx, Offsety, t, FaceColor, c1, c2, c3: Integer;
mbmp: TMufasaBitmap;
tbmp: TBitmap;
CubePoints: TPointArray;
Backfaces: Array of Boolean;
begin

t := GetSystemTime;

L := Length(Cube.Vertices);

Cube.Vertices := RotatePointsY(Cube.Vertices, radians(Rotation));

Backfaces := BackfaceCull(Cube);

for i := 0 to L-1 do // change to Matrix transformation if speed permits
begin
Cube.Vertices[i].x := Cube.Vertices[i].x + Cube.WorldPosition.x;
Cube.Vertices[i].y := Cube.Vertices[i].y + Cube.WorldPosition.y;
Cube.Vertices[i].z := Cube.Vertices[i].z + Cube.WorldPosition.z;
end;

//WriteLn(Cube.Vertices);
CubePoints := PerspectiveProject(Cube.Vertices);

Offsetx := SCREEN_WIDTH / 2;
Offsety := SCREEN_HEIGHT / 2;

for i := 0 to L - 1 do
begin
CubePoints[i].x := CubePoints[i].x + Offsetx;
CubePoints[i].y := (-CubePoints[i].y) + Offsety;
end;

mbmp := TMufasaBitmap.Create;
mbmp.SetSize(SCREEN_WIDTH, SCREEN_HEIGHT);
//mbmp.DrawTPA(CubePoints, clWhite);
tbmp := mbmp.ToTBitmap;

//WriteLn(CubePoints[Cube.Faces[2].b]);

for i := 0 to High(Cube.Faces) do
begin
if Backfaces[i] then
Continue;
//FaceColor := CalculateFaceColor(Cube.FaceNormals[i], Lighting);
//ShadeTriangle(tbmp.Canvas, CubePoints[Cube.Faces[i].a], CubePoints[Cube.Faces[i].b], CubePoints[Cube.Faces[i].c], [FaceColor], False);

c1 := CalculateFaceColor(Cube.VertexNormals[Cube.Faces[i].a], Lighting);
c2 := CalculateFaceColor(Cube.VertexNormals[Cube.Faces[i].b], Lighting);
c3 := CalculateFaceColor(Cube.VertexNormals[Cube.Faces[i].c], Lighting);

ShadeTriangle(tbmp.Canvas, CubePoints[Cube.Faces[i].a], CubePoints[Cube.Faces[i].b], CubePoints[Cube.Faces[i].c], [c1, c2, c3], True);

//WriteLn(Cube.FaceNormals[i]);
{for j := 0 to 2 do
begin
fp1 := j;
fp2 := (j+1) mod 3;
//Writeln(i);
case fp1 of
0: p1 := CubePoints[Cube.Faces[i].a];
1: p1 := CubePoints[Cube.Faces[i].b];
2: p1 := CubePoints[Cube.Faces[i].c];
end;
case fp2 of
0: p2 := CubePoints[Cube.Faces[i].a];
1: p2 := CubePoints[Cube.Faces[i].b];
2: p2 := CubePoints[Cube.Faces[i].c];
end;
//writeln(p1);
DrawLine(tbmp.Canvas, p1, p2, clBlack);
end; }
end;

mbmp.LoadFromTBitmap(tbmp);
mbmp.DrawToCanvas(0, 0, MainForm.Canvas);
WriteLn(GetSystemTime - t);
end;

procedure Start(Sender: TObject);
var
Cube: TEntity;
Lighting: Array of TLight;
Rotation: Extended;
begin
Cube := LoadEntity(FILE_NAME);
Lighting := DeclareLighting;
Rotation := 190.0;

Render(Cube, Lighting, Rotation);

{repeat
if IsKeyDown(VK_RIGHT) then
begin
Rotation := Rotation + 10;
Render(Cube, Lighting, Rotation);
end;
if IsKeyDown(VK_LEFT) then
begin
Rotation := Rotation - 10;
Render(Cube, Lighting, Rotation);
end;
if IsKeyDown(51) then
Break;
Wait(400);
until False; }
end;

procedure InitForm;
begin
MainForm := TForm.Create(nil);

with MainForm do
begin
Caption := 'Pumbaa';
Width := SCREEN_WIDTH;
Height := SCREEN_HEIGHT;
Position := poScreenCenter;
end;

StartButton := TButton.Create(MainForm);
with StartButton do
begin
Parent := MainForm;
Caption := 'Start';
OnClick := @Start;
end;



end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
MainForm.ShowModal;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

procedure ShowForm;
begin
SafeInitForm;
SafeShowFormModal;
end;

begin
ShowForm;
end.

Brandon
01-23-2012, 04:37 AM
For gouraud shading, don't u need a hell of a lot more polygons/shapes on the monkey? Like wayyyyyy more triangles?

ReadySteadyGo
01-23-2012, 04:42 AM
For gouraud shading, don't u need a hell of a lot more polygons/shapes on the monkey? Like wayyyyyy more triangles?

It depends on the model. For the monkey, yes because it's detailed. Simpler things can still use gouraud shading effectively though.

The third one, I posted looks slightly better as I adjusted the lighting.

Another issue is that I'm not using z-sorting atm, so it not dealing with concave areas well at all, there is no order in the way faces are being rendered.

Dan Cardin
01-23-2012, 05:17 AM
A couple of people have made very simple 2d things before in SCAR afaik, I remember making a very very simple rotating cube/object thing. This, however far surpasses everything done before. Very very cool.

Wizzup?
01-23-2012, 10:55 AM
RSG, I could look into exporting the OGL API to scripts if that would help. I think Dgby had started some work on this actually. Then you could do this with hardware acceleration.

Zyt3x
01-23-2012, 12:34 PM
A couple of people have made very simple 2d things before in SCAR afaik, I remember making a very very simple rotating cube/object thing. This, however far surpasses everything done before. Very very cool.Well, me and almost have been messing around with 3D in Simba a lot, but it's true, this surpasses that by several miles :p

ReadySteadyGo
01-23-2012, 01:06 PM
RSG, I could look into exporting the OGL API to scripts if that would help. I think Dgby had started some work on this actually. Then you could do this with hardware acceleration.

That would help an insane amount. It was quite fun doing it within the virtual computer that simba provides, a great learning opportunity to learn how this stuff is actually done. But having the opengl API would make it actually possible to make realtime 3D games in Simba, which can only be a good thing for this community. Simba is a fantastic tool to learn with.

Thank you Zyt3x and Dan Cardin :P. It's not actually that big of a step from a simple cube. I've just added a parser so polygons can be created in 3D software.

Zyt3x
01-23-2012, 01:10 PM
RSG, I could look into exporting the OGL API to scripts if that would help. I think Dgby had started some work on this actually. Then you could do this with hardware acceleration.You didn't want to do that last time I asked you :@ oh well, late is better than never

Dgby714
01-23-2012, 01:26 PM
RSG, I could look into exporting the OGL API to scripts if that would help. I think Dgby had started some work on this actually. Then you could do this with hardware acceleration.

I was just using the opengl library when I did that.

Kyle Undefined
01-23-2012, 01:45 PM
Ohh that's some cool stuff! Going to play around with it later :D

Wizzup?
01-23-2012, 03:01 PM
You didn't want to do that last time I asked you :@ oh well, late is better than never

I still don't want to do it, but I'm just saying it's very possible. If someone else feels like adding it, they should feel free to do that. :p

Silent
01-25-2012, 02:21 PM
This is one of the coolest things I've ever seen done with Simba. Great work man!

I agree openGL API support would be sweet, although I can't say I would have the slightest clue on where to start with any of that....

Anyway, looks bad ass, nice job.

'Toxin
01-31-2012, 07:46 PM
Threads like this make me feel so retarded

I feel the same way...

ReadySteadyGo
01-31-2012, 08:27 PM
I could write a tutorial, if enough people are interested.

NickMystre
01-31-2012, 08:41 PM
I would be interested - however, I know that it would be way over my head.

Sorry - not the kind of interest you were looking for. :)

But I am sure there are others who would love it.

Gala
02-29-2012, 11:29 AM
I recently discovered this thread and I am realy impressed. I must say I was thinking myself about creating a Render- or Physicsengine.
But my knowledge of maths (matrices etc) are at the moment.
Could you make a tut I would be really glad. Or at least refer to some good sources?
(I am using such engines very often, but never understood how to code one)

ReadySteadyGo
02-29-2012, 08:38 PM
I recently discovered this thread and I am realy impressed. I must say I was thinking myself about creating a Render- or Physicsengine.
But my knowledge of maths (matrices etc) are at the moment.
Could you make a tut I would be really glad. Or at least refer to some good sources?
(I am using such engines very often, but never understood how to code one)

Hi Gala. Cool that you're interested. What exactly would you like to know? The knowledge you really need is Vectors, Matrixes and how to manipulate them. Once you understand these principles it becomes very simple. Try reading through my code, I tried to keep it rather clean. Let me know if there are any specifics that you are interested in.

Gala
03-01-2012, 05:56 AM
I have a good knowledge of vectors and I am learning matrixes right now. I already took a look at your script, but I couldnt understand several parts. Could you explain how exactly you used matrixes to render it? (the idea behind)

ReadySteadyGo
03-06-2012, 01:42 PM
Hi Gala,

What you need to do is look into what you're actually doing. You have a view point, a plane (your screen), and the points on the object that you'd like to project. For each point you need to work out the intersection between that point and the view point. That is the idea, it's very simple. You can connect these points to draw a wireframe. Where it get's more complicated is when you want to light and shade the object. Try rendering the wireframe of a cube to get started playing with it.

Let me know how it goes!

edit: I just reread what you wrote. All matrices are used for it flexibility of working with vectors. You can do it all with just multiplication and trigonometry. Forget about matrixes until you have a good working knowledge of 3D vectors. They don't provide anything useful until you need to manipulate everything in a flexible way.

Gala
03-10-2012, 02:33 PM
@ReadySteadyGo

I think I got the matrixes now. I really want to learn shading/rendering with matrixes, because my final goal is a simple game engine with matrixes/vectors, like in minecraft. (With simple, I mean really simple things like basic friction, gravity and collision.) Dynamic physics is more important than shading, so I think I won't struggle with anything other than the simple shader in your first post.

btw: Where do you get documentations about the .obj file?

ReadySteadyGo
03-10-2012, 05:35 PM
@ReadySteadyGo

I think I got the matrixes now. I really want to learn shading/rendering with matrixes, because my final goal is a simple game engine with matrixes/vectors, like in minecraft. (With simple, I mean really simple things like basic friction, gravity and collision.) Dynamic physics is more important than shading, so I think I won't struggle with anything other than the simple shader in your first post.

btw: Where do you get documentations about the .obj file?

Cool.

A wavefront obj file is a text based format, so I didn't need any documentation, it's readable. 'v' = vertex, 'vt' = vertex texture, 'f' = face.