RSMV with texture support

Ah well. Pity we couldn’t see the source.

As it is, the program seems to texture in ortho mode so i can’t tell wether he’s gone to all the trouble of calculating the UV co-ords, he seems to texturing the grid as well? :smiley:
Bad use of glEnable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);

He seems to have figured out that the low colour numbers in the .dat relate to textures :slight_smile: - not sure if there should be a lookup table as some numbers don’t seem to match the textures.
EDIT: use texture if M[] > 1 else use color.

Might have figured out that the model triangles are textured according to the contents of M[], but these relate to the mapping ‘triangles’. hard to tell again because of the ortho mode texturing. :frowning:

He hasn’t made sure ALL of the textures are 128x128, some don’t load. :frowning:
Need to take another look at the textures and see if there is any 0 compression. You could add the extra pixels anyway and then offset the UV coordinates to compensate.

Maybe someone can get the source?

Doesn’t matter anyway, i’ll post some source (when it’s finished :eek: )

I actually remember this guy, he keeps getting banned for ‘accidentally’ infecting his file releases with backdoors and trojans (at least 3 specific times that I can remember, all ‘accidents’ according to him mind you). So if you download these files be careful…

Sad…

Anyway, after a 6 hour headache i finally realised delphi was using EFFING radians!!! LOL
Result :-

Yes, thats UV coords :smiley:
Just got to load more than the 1 texture, and maybe sort out any texture offsets.

If i post the source could someone else compile and release the program with the source? You’ll need the glaux packages installed. Don’t trust my computer :frowning:

(I even put in a SHIFT+ Rmouse button PAN function) :slight_smile:

Maybe we should move RSMV to google code. It would be easy to develope and find it.

Good idea, (was thinking sourforge…but that would kill it :slight_smile: )

Here’s where i’m at at the minute : http://uppit.com/T240HO
(exe NOT included)
(shift+Rmouse to pan)
Ignore the extra buttons and checkboxes, they are for my benefit.

Fugly code, slightly unstable(why?), no alpha blending(yet), no texture offset correction (yet), doesn’t read model format v2.

Most of the models seem ok, some like 10070.dat (included) are really fucked up, still trying to work out why.
Some textures are wrong! Model 1500.dat is the broken barrow shown by miss silab, the texture given by the model file is brick!!!
Maybe there is a texture overide in the locations or object dats?

Anyway, thought someone could have a play with it, got a busy week ahead and no time.

EDIT:new dat model :slight_smile: http://uppit.com/KT0831

how does one “accidentaly” infect their files with a backdoor trojan, and “forget” about the gpl.

Look at his picture and take particular notice at the frames title…

Direct replacement for the trig unit, it was trying to do inverse cos of 1.001.

Should texture everthing correctly (or near enough), there seems to be some small scaling issue with the textures on some models, but they might be badly scaled like that anyway.

One thing you might notice is that the tops of the trees have a badly mapped triangle, i thought this was my error, BUT, it is actually mapped like that, go look at the oak trees in the game…


unit trig;

interface

uses
  Windows, OpenGL,SysUtils, FileRSM, OpenGl1x, Math;

type
 Tex3Vx2UV = array[0..2] of TVector2d;

function SinRule(lenb,angA,angB : Double) : Double;
function len3D(x1,y1,z1,x2,y2,z2 : Integer) : Double;
function CosRule(len1,len2,len3 : Double) : Double;
procedure DoStuff;

var
  UV: array of Tex3Vx2UV;

implementation


// procedure to calculate all of the UV coordinates in the model file
// Call after loading the model and before displaying

procedure DoStuff;
var
ti,i,k,testflag,s0,su,sv : Integer;
lenau,lenaq,lenuq,lenus,lenav,lenvq,lentv : Double;
Angle_U,Angle_V,U_number,V_number,Angle_A,Angle_B : Double;
Error_Angle : Double;
begin

SetLength(UV, 0); SetLength(UV, GNumTriangles);

// for each triangle in model
for i := 0 to high(F) do
begin
 testflag := 0;
//for each point in model triangle.
for k := 0 to 2 do
  begin

    if M[i] >1 then

        begin    //E1

        ti := ( (M[i] + 2) div 4) -1;
        lenau := len3D(V[Tex[ti][0]][0], V[Tex[ti][0]][1], V[Tex[ti][0]][2], V[Tex[ti][2]][0], V[Tex[ti][2]][1], V[Tex[ti][2]][2]) ;
        lenaq := len3D(V[Tex[ti][0]][0], V[Tex[ti][0]][1], V[Tex[ti][0]][2], V[F[i][k]][0], V[F[i][k]][1], V[F[i][k]][2]) ;
        lenuq := len3D(V[Tex[ti][2]][0], V[Tex[ti][2]][1], V[Tex[ti][2]][2], V[F[i][k]][0], V[F[i][k]][1], V[F[i][k]][2]) ;
        lenav := len3D(V[Tex[ti][0]][0], V[Tex[ti][0]][1], V[Tex[ti][0]][2], V[Tex[ti][1]][0], V[Tex[ti][1]][1], V[Tex[ti][1]][2]) ;
        lenvq := len3D(V[Tex[ti][1]][0], V[Tex[ti][1]][1], V[Tex[ti][1]][2], V[F[i][k]][0], V[F[i][k]][1], V[F[i][k]][2]) ;



        Error_angle := 0;
//get angle A and B  for error correction.
        If (lenaq <> 0) AND (lenau <> 0) AND (lenav <> 0) AND (lenaq <> 0) then
        begin
          Angle_A := CosRule(lenaq,lenau,lenuq) ;
          Angle_B := CosRule(lenav,lenaq,lenvq) ;
          Error_angle := (Angle_A + Angle_B) - 90;
        end;


//calculate U number

if (lenau = lenaq ) AND (lenuq = 0) then U_number := 1.0
else if (lenaq = 0) OR (lenau-lenaq = 0 ) then U_number := 0.0
 else
 begin
 Angle_U := CosRule(lenau,lenuq,lenaq) ;
 lenus := SinRule(lenuq,(90-Angle_U - Error_Angle),90) ;
If lenau <> 0 then U_number := (lenau - lenus) * (1 / lenau)
else MessageBox(0, PChar('division by Zero'), PChar('NaN'), MB_OK);
 end;

//calculate V_number

if (lenav =lenaq) AND (lenvq = 0)  then V_number := 1.0
else if (lenaq = 0) OR (lenav-lenaq = 0) then V_number := 0.0
else
 begin
 Angle_V := CosRule(lenvq,lenav,lenaq);
 lentv := SinRule(lenvq, (90 - Angle_V - Error_Angle), 90);
If lenav <> 0 then  V_number := (lenav - lentv) * (1 / lenav)
else MessageBox(0, PChar('division by Zero'), PChar('NaN'), MB_OK);
 end;



 UV[i][k][0] := V_number;
 UV[i][k][1] := 1-U_number;

end else       //end E1
begin
//for when no texture is used
UV[i][k][0] := 0;
UV[i][k][1] := 0;
end ;

end;  //end of k loop



end; //end of i loop

end;  //end of procedure


function len3D(x1,y1,z1,x2,y2,z2 : Integer) : Double;
begin
Result := Sqrt( ((x1-x2)*(x1-x2))+ ((y1-y2)*(y1-y2))+ ((z1-z2)*(z1-z2)) );
end;


function CosRule(len1,len2,len3 : Double) : Double;
var
temp1, radtemp : Double;
// len1 = a, len2 = b, len3 = c
begin
If (len1 <= 0) OR (len2 <= 0) then  MessageBox(0, PChar('division by Zero'), PChar('NaN'), MB_OK);
temp1 := ((len1*len1)+(len2*len2)-(len3*len3))/(2*len1*len2);
if (temp1 < 1.0) AND (temp1 > -1.0) then begin
//if (temp1 < 1.0) then begin
radtemp := ArcCos(temp1);
Result := RadToDeg(ArcCos(temp1));
end else if (temp1 >= 1.0) then Result := 0
else if (temp1 <= -1.0) then result := 180;

//Result := ArcCos(temp1);
end;

function SinRule(lenb,angA,angB: Double) : Double;
var
temp1, radtemp : Double;
begin
// a / Sin(A) = b / Sin(B)
// therefore a = (b * Sin(A))/ Sin(B)
        if (Sin(DegToRad(angB))) <= 0 then MessageBox(0, PChar('division by Zero in sin'), PChar('NaN'), MB_OK);
Result := (lenb * Sin(DegToRad(angA)) ) / (Sin(DegToRad(angB)));
end;

end.

Uppit sucks. :frowning: It’s down as well.[br][br][size=1]Posted on: August 26, 2008, 10:46:06 pm[/size][hr]Soo… this pretty much dead huh?