Exemplo n.º 1
0
void Parametric::Normal(VECTOR Result, Intersection *Inter, TraceThreadData *Thread) const
{
	VECTOR RU, RV;
	UV_VECT uv_vect;

	uv_vect[U] = Inter->Iuv[U];
	uv_vect[V] = Inter->Iuv[V];
	RU[X] = RV[X] = -Evaluate_Function_UV(Thread->functionContext, *(Function[X]), uv_vect);
	RU[Y] = RV[Y] = -Evaluate_Function_UV(Thread->functionContext, *(Function[Y]), uv_vect);
	RU[Z] = RV[Z] = -Evaluate_Function_UV(Thread->functionContext, *(Function[Z]), uv_vect);

	uv_vect[U] += accuracy;
	RU[X] += Evaluate_Function_UV(Thread->functionContext, *(Function[X]), uv_vect);
	RU[Y] += Evaluate_Function_UV(Thread->functionContext, *(Function[Y]), uv_vect);
	RU[Z] += Evaluate_Function_UV(Thread->functionContext, *(Function[Z]), uv_vect);

	uv_vect[U] = Inter->Iuv[U];
	uv_vect[V] += accuracy;
	RV[X] += Evaluate_Function_UV(Thread->functionContext, *(Function[X]), uv_vect);
	RV[Y] += Evaluate_Function_UV(Thread->functionContext, *(Function[Y]), uv_vect);
	RV[Z] += Evaluate_Function_UV(Thread->functionContext, *(Function[Z]), uv_vect);

	VCross(Result, RU, RV);
	if (Trans != NULL)
		MTransNormal(Result, Result, Trans);
	VNormalize(Result, Result);
}
Exemplo n.º 2
0
void Parametric_Normal(VECTOR Result, OBJECT* Object, INTERSECTION* Inter)
{
	VECTOR RU, RV;
	PARAMETRIC * Par = (PARAMETRIC *)Object;
	VECTOR * IPoint = &(Inter->IPoint);
	UV_VECT uv_vect;

	uv_vect[U] = Par->last_u;
	uv_vect[V] = Par->last_v;
	RU[X] = RV[X] = -Evaluate_Function_UV(*(Par->Function[X]), uv_vect);
	RU[Y] = RV[Y] = -Evaluate_Function_UV(*(Par->Function[Y]), uv_vect);
	RU[Z] = RV[Z] = -Evaluate_Function_UV(*(Par->Function[Z]), uv_vect);

	uv_vect[U] += Par->accuracy;
	RU[X] += Evaluate_Function_UV(*(Par->Function[X]), uv_vect);
	RU[Y] += Evaluate_Function_UV(*(Par->Function[Y]), uv_vect);
	RU[Z] += Evaluate_Function_UV(*(Par->Function[Z]), uv_vect);

	uv_vect[U] = Par->last_u;
	uv_vect[V] += Par->accuracy;
	RV[X] += Evaluate_Function_UV(*(Par->Function[X]), uv_vect);
	RV[Y] += Evaluate_Function_UV(*(Par->Function[Y]), uv_vect);
	RV[Z] += Evaluate_Function_UV(*(Par->Function[Z]), uv_vect);

	VCross(Result, RU, RV);
	if (Par->Trans != NULL)
		MTransNormal(Result, Result, Par->Trans);
	VNormalize(Result, Result);
}