Results 1 to 5 of 5

Thread: Optimizing my X-Files (DirectX)

  1. #1

    Optimizing my X-Files (DirectX)

    Hello,

    I need a tool (free) that can load an DirectX X-File, and then optimize it (so it gets smaller in memory usage) and then again saves it.

    Any ideas please?
    I already found some free tools, but most cannot import .x :roll:

    Firle

  2. #2

    Optimizing my X-Files (DirectX)

    What do you mean by "optimize - reducing .X file size"? Removing some (bad) vertices? Or something other?

    Btw, if your mesh is saved in text .X file format you can save it in binary form - this will reduce file size to single digit percent of it's text version.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  3. #3

    Optimizing my X-Files (DirectX)

    Hello,

    I tried myself to make a small tool to saves it in binary, but everytime I save I get an error exception (error in d3dx9_28.dll) and receive a 0 byte file.

    Here my code:

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls,D3DX9, OmegaScreen;

    type
    TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    XenScreen: TOmegaScreen;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    private
    { Private-Deklarationen }
    public
    { Public-Deklarationen }
    end;

    var
    Form1: TForm1;
    mesh: ID3DXMesh;
    _pAdjacency, _pD3DXMtrlBuffer : ID3DXBuffer;
    _d3dxMaterials : PD3DXMaterial;
    nummaterials: dword;

    implementation

    {$R *.dfm}

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if opendialog1.execute then
    D3DXLoadMeshFromX(pChar(opendialog1.Files[0]), D3DXMESH_SYSTEMMEM,
    xenScreen.Device, @_pAdjacency, @_pD3DXMtrlBuffer,nil,
    @NumMaterials, Mesh);
    end;

    procedure TForm1.Button2Click(Sender: TObject);
    begin
    if savedialog1.execute then
    D3DXSaveMeshToX(pChar(opendialog1.Files[0]),Mesh, @_pAdjacency, @_pD3DXMtrlBuffer,
    nil,NumMaterials,D3DXF_FILEFORMAT_BINARY);
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    xenscreen.Init;
    end;

    end.
    Using latest Clootie headers with Omega for screen component.

    So I tried to save it to binary but reduce vertices that are not seen or very small or something would be also great.

    Thanks,
    Firle

  4. #4

    Optimizing my X-Files (DirectX)

    When saving mesh to file you should pass not pointers to ID3DXBuffer, but pointers to actual data.

    So, something like this:
    Code:
      p1:= pAdjacency.GetBufferPointer;
      p2:= pD3DXMtrlBuffer.GetBufferPointer;
    
      D3DXSaveMeshToX(pChar(opendialog1.Files[0]),Mesh, p1, p2, nil, NumMaterials, D3DXF_FILEFORMAT_BINARY);
    There are only 10 types of people in this world; those who understand binary and those who don't.

  5. #5

    Optimizing my X-Files (DirectX)

    Thanks Clootie, I'll try that

    Firle

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •