Vector help...

Blitz3D Forums/Blitz3D Programming/Vector help...

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Im trying to understand tangent space and therefore apply it in Blitz... I'm not very good with vectors though, can someone explain some of this..?

//X being the cross product
For each face {
	(x,y,z) = (p2->x-p1->x,p2->u-p1->u,p2->v-p1->v) X (p3->x-p1->x,p3->u-p1->u,p3->v-p1->v)
	if (x!=0) {
		NORMALIZE(x,y,z)
		p1->Tx += -y/x;
		p1->Bx += -z/x;
		p2->Tx += -y/x;
		p2->Bx += -z/x;
		p3->Tx += -y/x;
		p3->Bx += -z/x;
	}
	(x,y,z) = (p2->y-p1->y,p2->u-p1->u,p2->v-p1->v) X (p3->y-p1->y,p3->u-p1->u,p3->v-p1->v)
	if (x!=0) {
		NORMALIZE(x,y,z)
		p1->Ty += -y/x;
		p1->By += -z/x;
		p2->Ty += -y/x;
		p2->By += -z/x;
		p3->Ty += -y/x;
		p3->By += -z/x;
	}
	(x,y,z) = (p2->z-p1->z,p2->u-p1->u,p2->v-p1->v) X (p3->z-p1->z,p3->u-p1->u,p3->v-p1->v)
	if (x!=0) {
		NORMALIZE(x,y,z)
		p1->Tz += -y/x;
		p1->Bz += -z/x;
		p2->Tz += -y/x;
		p2->Bz += -z/x;
		p3->Tz += -y/x;
		p3->Bz += -z/x;
	}
}
For each vertex {
	NORMALIZE(T)
	NORMALIZE(B)
	newN = TxB
	//Check direction of N according to a classic normal computation method:
	//sometimes N needs to be reversed
	if newN . oldN > 0
		N = newN
	else	N = -newN
}


I don't understand how to normalize a vecotr (alothugh i heard its meant to result in the length being 1?) and what does it mean 'X is the cross product.' The cross product of what? Just the vertex? :) If anyone can go through that code, i'd really appriate it xD