Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
janadamec1 committed Sep 20, 2024
1 parent eb99ffc commit 674e97b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ automatic-windows-resources.res
code/*.or
code/*.compiled
castle-engine-output
backup/

# secret files
AndroidSigningProperties.txt
5 changes: 5 additions & 0 deletions castle_model_converter.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@ var
Node: TX3DRootNode;
EventsHandler: TEventsHandler;
OutputStream: TStream;
UrlProcessing: TUrlProcessing;
begin
ApplicationProperties.ApplicationName := 'castle-model-converter';
ApplicationProperties.Version := Version;
UrlProcessing := suNone; // TODO: get the value from parameters

{ parse command-line, calculating InputUrl and OutputUrl }
Parameters.Parse(Options, @OptionProc, nil);
Expand Down Expand Up @@ -226,6 +228,9 @@ begin
else
OutputStream := StdOutStream;

if UrlProcessing <> suNone then
ProcessUrls(Node, OutputUrl, UrlProcessing);

SaveNode(Node, OutputStream, OutputMimeType,
{ generator (metadata) } 'castle-model-converter, https://castle-engine.io/castle-model-converter',
{ source (metadata) } ExtractURIName(InputUrl));
Expand Down
16 changes: 15 additions & 1 deletion castle_model_viewer.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -2702,8 +2702,13 @@ procedure TEventsHandler.MenuClick(const MenuItem: TMenuItem);
procedure SaveAs;
var
ProposedSaveName: string;
UrlProcessing: TUrlProcessing;
RootNodeCopy, RootNodeToSave: TX3DRootNode;
begin
ProposedSaveName := SceneUrl;
UrlProcessing := suNone;
//UrlProcessing := suCopyResourcesToSubdirectory; // TODO: get the value somehow
RootNodeCopy := nil;

// if we cannot save to SceneUrl format, propose to save as X3D
if not TFileFilterList.Matches(SaveNode_FileFilters, ProposedSaveName) then
Expand All @@ -2714,8 +2719,15 @@ procedure TEventsHandler.MenuClick(const MenuItem: TMenuItem);
{$ifdef CATCH_EXCEPTIONS}
try
{$endif}
if UrlProcessing = suNone then
RootNodeToSave := Scene.RootNode
else begin
RootNodeCopy := Scene.RootNode.DeepCopy as TX3DRootNode;
ProcessUrls(RootNodeCopy, ProposedSaveName, UrlProcessing);
RootNodeToSave := RootNodeCopy;
end;

SaveNode(Scene.RootNode, ProposedSaveName, SaveGenerator,
SaveNode(RootNodeToSave, ProposedSaveName, SaveGenerator,
ExtractURIName(SceneUrl));

{$ifdef CATCH_EXCEPTIONS}
Expand All @@ -2727,6 +2739,8 @@ procedure TEventsHandler.MenuClick(const MenuItem: TMenuItem);
end;
end;
{$endif}
if RootNodeCopy <> nil then
FreeAndNil(RootNodeCopy);
end;
end;

Expand Down

0 comments on commit 674e97b

Please sign in to comment.