Tangent Space Matrix

Started by
0 comments, last by MButchers 22 years, 1 month ago
Hello all, im currently implimenting Dot3 Bump mapping in the graphics side of my engine and am having problems generating the tangent matrix,could anyone possibly point out what is wrong with the following code
  

function TangentMatrix16(T: PTexCoords2f ;N: PVector3f): TMatrix16f;
var
  t3d,b: TVector3f;
begin
  Result := NullMatrix16;
  //generate and normalize t vector from 2d texture coords

  t3d := Vector3f(T[0],T[1],0);
  Normalize(t3d);

  //generate bi normal

  CrossProd(@n,@t3d,b);
  Normalize(b);

  //populate matrix

  Result[0] := t3d[0]; Result[1] := t3d[1]; Result[2] := t3d[2];
  Result[4] := b[0]; Result[5] := b[1]; Result[6] := b[2];
  Result[8] := n[0]; Result[9] := n[1]; Result[10] := n[2];

  Result[15] := 1;
end;

  
Many thanks Mark
Advertisement
Wow, I haven''t seen Pascal code in ages! That brings back some (haunting) memories! Next thing you know, someone will post some Fortran!

Timkin

This topic is closed to new replies.

Advertisement