View Single Post
Old 11.09.2006, 09:53   #17
Stazis
Архивный участник
 
Join Date: Feb 2005
Posts: 200
Default

It is easy part - i was looking a way to get a direct access to G16 texture pixels. Since i was not feeling good about writing my own stream reading procedure i just injected this array into TUTObjectClassTexture class
Code:
TUTObjectClassTexture = class(TUTObject)
  private
   
    FLan : array [0..255,0..255] of single;
   ....
   function GetLan(x,y: integer): single;
  protected
    ...
  public
    property Lan[x,y: integer] : single read GetLan;
  end;
Code:
procedure TUTObjectClassTexture.InterpretObject;  
........
  TEXF_G16: // not tested
            begin
              for y := 0 to MipMap.height - 1 do
                for x := 0 to MipMap.width - 1 do
                  begin
                    // read 16-bit grayscale value for this pixel and convert to 8-bit value.
                    FLan[x,y]:=FOwner.read_word(buffer);
                    rgba[0]:=word(round(FLan[x,y]/256));
.......


function TUTObjectClassTexture.GetLan(x,y: integer): single;
begin
  result:=FLan[x,y];
end;
but i should warn you ... this source is old and contains lot of misunderstandings ... e.g. CSG part is totally not needed couse there is already compiled BSP-tree for CSG in .unr file - i spent about month to develop my own CSG-compilation algorithm and derm i was angry when understood that it was useless.
There was pretty much other changes in ut_packages to make it read correctly lineage formats ... u will need to figure out them by yourself.
Stazis is offline