/usr/src/castle-game-engine-4.1.1/x3d/teapot/teapot_3d_to_pascal.lpr is in castle-game-engine-src 4.1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | {
Copyright 2010-2013 Michalis Kamburelis.
This file is part of "Castle Game Engine".
"Castle Game Engine" is free software; see the file COPYING.txt,
included in this distribution, for details about the copyright.
"Castle Game Engine" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
----------------------------------------------------------------------------
}
{ Convert teapot VRML file teapot.wrl into Pascal source file
with 4 Teapot constants.
This way we get Utah teapot coordinate data in Pascal. }
uses SysUtils, X3DNodes, X3DLoad;
var
Model: TX3DNode;
procedure HandleCoords(const BlenderName, PascalName: string);
var
G: TGroupNode;
IFS: TIndexedFaceSetNode;
C: TCoordinateNode;
I: Integer;
Merged: Cardinal;
begin
{ We know how a VRML file generated by Blender looks like, so we simply assume
in the code below that it's as expected (1st child of the Group is a Shape etc.).
In case of problems, we can simply fail with an exception. }
G := Model.FindNodeByName(TGroupNode, 'ME_' + BlenderName, false) as TGroupNode;
IFS := (G.FdChildren[0] as TShapeNode).FdGeometry.Value as TIndexedFaceSetNode;
C := IFS.FdCoord.Value as TCoordinateNode;
Merged := C.FdPoint.Items.MergeCloseVertexes(0.001);
Writeln(ErrOutput, 'Merged close vertexes on mesh ', BlenderName, ': ', Merged, ' changed.');
Writeln('Teapot' + PascalName + 'Coord: array [0..', C.FdPoint.Count - 1, '] of TVector3Single = (');
for I := 0 to C.FdPoint.Count - 1 do
begin
Write(Format('(%g, %g, %g)', [
C.FdPoint.Items.L[I][0],
C.FdPoint.Items.L[I][1],
C.FdPoint.Items.L[I][2] ]));
if I < C.FdPoint.Count - 1 then Write(',');
Writeln;
end;
Writeln(');');
Writeln('Teapot' + PascalName + 'CoordIndex: array [0..', IFS.FdCoordIndex.Count - 1, '] of LongInt = (');
for I := 0 to IFS.FdCoordIndex.Count - 1 do
begin
Write(IFS.FdCoordIndex.Items[I]);
if I < IFS.FdCoordIndex.Count - 1 then Write(', ');
if IFS.FdCoordIndex.Items[I] < 0 then Writeln;
end;
Writeln(');');
end;
begin
Model := Load3D('teapot.wrl');
try
HandleCoords('TeapotManifold', 'Manifold');
HandleCoords('Teapot', '');
finally FreeAndNil(Model) end;
end.
|