www.xbdev.net xbdev - software development
Monday December 10, 2018
home | about | contact | Donations

     
 

The Maths of 3D

You can't have 3D without a little maths...

 

Tangents Binormals Normals

by bkenwright@xbdev.net

 

 

Well if you code in 3D, your sure enough to come across Tangents and Binormals.  These couple of vectors are used in combination with the Normal vector to produce bump mapping, parallax bump mapping or even displacement mapping.  As if I recall it was Blinn who came up with the solution of using the texture coodinates to generate the Tangent vector.  The vector perpendicular to the Tangent and Normal is the Binormal.

 

Sometimes its easy to put an equation together - or use an API to create them.  But its sometimes worth trying to code it and actually visualise it.

 

So I put together a set of functions which generates the Normal, Tangent and Binormal and renderes them to a mesh surface.

 

In actual fact, the hardest part of the demo was writing the sphere mesh algorithm - which fill a ID3DXMesh* variable with the mesh texture coods, vertice positions and incdices.  If you have time you might want to look at the code in xsphere.cpp and see how it works.  I'm sure you can take it to a new level and possibly optimise it or shrink it down.  I'd be glad of an email if you find a smaller better way of improving it.

 

A good reference for further reading on Tangents and Binormals and all the maths and equations, is Mathematics for 3D Game Programming by Eric Lengyel.

 

The demo program was programmed with Visual Studio and DirectX9.0.

 

 

Download Demo (Executable)

 

Download (Source)

 

 

 

 

 

 
 Visitor: 9534626  { 209.237.238.175 } Copyright (c) 2002-2017 xbdev.net - All rights reserved.
Designated tutorial and software are the property of their respective owners.