I cant get this to work? I was wondering if anyone could give it a look over and see if im doing something wrong.
CALCULATE THE TANGENT, BINORMAL, AND NORMAL
void triangle::calcN(){
vector temp1;
vector temp2;
temp1 = (theTri[0] - theTri[1]);
temp2 = (theTri[0] - theTri[2]);
this->normal = (temp1.cross(temp2));
this->normal.norm();
}
void triangle::calcT(float s0,float t0,float s1,float t1){
vector temp1,temp2,result;
//get tangent X
temp1.set((theTri[1].getX()-theTri[0].getX()),s0,t0);
temp2.set((theTri[2].getX()-theTri[0].getX()),s1,t1);
result = (temp1.cross(temp2));
tangent.setX(-result.getY()(1/result.getX()));
//get tangent Y
temp1.setX((theTri[0].getY()-theTri[1].getY()));
temp2.setX((theTri[0].getY()-theTri[2].getY()));
result = (temp1.cross(temp2));
tangent.setY(-result.getY()(1/result.getX()));
//get tangent Z
temp1.setX((theTri[0].getZ()-theTri[1].getZ()));
temp2.setX((theTri[0].getZ()-theTri[2].getZ()));
result = (temp1.cross(temp2));
tangent.setZ(-result.getY()*(1/result.getX()));
}
void triangle::calcB(){
this->binormal = (normal.cross(tangent));
}
AM I INPUTING THE MATRIX WRONG SOMEHOW?
// tangent part of matrix
tangentMatrix[0] = tbn->getT().getX();
tangentMatrix[1] = tbn->getT().getY();
tangentMatrix[2] = tbn->getT().getZ();
tangentMatrix[3] = 0.0f;
// binormal part of matrix
tangentMatrix[4] = tbn->getB().getX();
tangentMatrix[5] = tbn->getB().getY();
tangentMatrix[6] = tbn->getB().getZ();
tangentMatrix[7] = 0.0f;
// normal part of matrix
tangentMatrix[8] = tbn->getN().getX();
tangentMatrix[9] = tbn->getN().getY();
tangentMatrix[10] = tbn->getN().getZ();
tangentMatrix[11] = 0.0f;
// filler for 4x4
tangentMatrix[12] = 0.0f;
tangentMatrix[13] = 0.0f;
tangentMatrix[14] = 0.0f;
tangentMatrix[15] = 1.0f;
glMatrixMode(GL_MATRIX0_ARB);
glLoadMatrixf(tangentMatrix);
I am using a fragment shader (ARBfp1.0) to calculate the per pixel dot products and it just doesn’t seem to look per pixel at all!