void Plane::Scale(const VECTOR Vector, const TRANSFORM *tr) { DBL Length; if(Trans == NULL) { VDivEq(Normal_Vector, Vector); VLength(Length, Normal_Vector); VInverseScaleEq(Normal_Vector, Length); Distance /= Length; Compute_BBox(); } else { Transform(tr); } }
static void Scale_Plane (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans) { DBL Length; PLANE *Plane = (PLANE *) Object; if (Plane->Trans == NULL) { VDivEq(Plane->Normal_Vector, Vector); VLength(Length, ((PLANE *)Object)->Normal_Vector); VInverseScaleEq (((PLANE *)Object)->Normal_Vector, Length); ((PLANE *)Object)->Distance /= Length; Compute_Plane_BBox(Plane); } else { Transform_Plane (Object, Trans); } }
static void Box_UVCoord(UV_VECT Result, OBJECT *Object, INTERSECTION *Inter) { VECTOR P, Box_Diff; BOX *Box = (BOX *)Object; /* Transform the point into the cube's space */ if (Box->Trans != NULL) MInvTransPoint(P, Inter->IPoint, Box->Trans); else Assign_Vector(P, Inter->IPoint); VSub(Box_Diff,Box->bounds[1],Box->bounds[0]); /* this line moves the bottom,left,front corner of the box to <0,0,0> */ VSubEq(P, Box->bounds[0]); /* this line normalizes the face offsets */ VDivEq(P, Box_Diff); /* if no normalize above, then we should use Box->UV_Trans and also inverse-transform the bounds */ /* The following code does a variation of cube environment mapping. All the textures are not mirrored when the cube is viewed from outside. */ switch (Inter->i1) { case SIDE_X_0: Result[U] = (P[Z] / 4.0); Result[V] = (1.0 / 3.0) + (P[Y] / 3.0); break; case SIDE_X_1: Result[U] = (3.0 / 4.0) - (P[Z] / 4.0); Result[V] = (1.0 / 3.0) + (P[Y] / 3.0); break; case SIDE_Y_0: Result[U] = (1.0 / 4.0) + (P[X] / 4.0); Result[V] = (P[Z] / 3.0); break; case SIDE_Y_1: Result[U] = (1.0 / 4.0) + (P[X] / 4.0); Result[V] = (3.0 / 3.0) - (P[Z] / 3.0); break; case SIDE_Z_0: Result[U] = 1.0 - (P[X] / 4.0); Result[V] = (1.0 / 3.0) + (P[Y] / 3.0); break; case SIDE_Z_1: Result[U] = (1.0 / 4.0) + (P[X] / 4.0); Result[V] = (1.0 / 3.0) + (P[Y] / 3.0); break; default: Error("Unknown box side in Box_Normal()."); } /* This is the original cube environment mapping. The texture is correct when viewed from inside the cube. switch (Inter->i1) { case SIDE_X_0: Result[U] = (1.0 / 4.0) - (P[Z] / 4.0); Result[V] = (1.0 / 3.0) + (P[Y] / 3.0); break; case SIDE_X_1: Result[U] = (2.0 / 4.0) + (P[Z] / 4.0); Result[V] = (1.0 / 3.0) + (P[Y] / 3.0); break; case SIDE_Y_0: Result[U] = (1.0 / 4.0) + (P[X] / 4.0); Result[V] = (1.0 / 3.0) - (P[Z] / 3.0); break; case SIDE_Y_1: Result[U] = (1.0 / 4.0) + (P[X] / 4.0); Result[V] = (2.0 / 3.0) + (P[Z] / 3.0); break; case SIDE_Z_0: Result[U] = (1.0 / 4.0) + (P[X] / 4.0); Result[V] = (1.0 / 3.0) + (P[Y] / 3.0); break; case SIDE_Z_1: Result[U] = 1.0 - (P[X] / 4.0); Result[V] = (1.0 / 3.0) + (P[Y] / 3.0); break; default: Error("Unknown box side in Box_Normal()."); } */ }