OCR_api.h. It should be pointed out that standard C library functions can be used in addition to any of the functions listed below.
float OCR_random ()
int OCR_reflect_ray (
AR_Vector *ray,
AR_Vector *normal,
AR_Vector *newray
)
ray, the surface normal (both normalized), and space for the resultant reflected ray (newray). It returns a normalized ray that points in the reflection direction.
void OCR_INVOKE_MAPPING (
AR_TextureData *pData,
AR_TextureInfo *pInfo,
AR_Point *ray
)
pData->TDcolor, which must be initialized to point to an AR_Rgba before the call. The argument ray is a pointer to the incident ray. This macro returns the constant out value of the texture if no texture is present, or if the texture does not apply to the current point. pData->TD[uv] is modified by this routine to equal pData->TDgeom>[uv]center automatically.
int OCR_initialize_texture (
AR_TextureInfo *texture
)
INIT() routine only.
int OCR_init_texture_transforms (
AR_TextureInfo *texture,
float *inverse_determanent
)
save_transformation in the SDL to alter the orientation of your solid texture. See the solid and environment texture prototypes for an example of usage.
void
OCR_set_texture_type (
int status,
int type,
int absolute
)
TEXTURE_STATUS, TEXTURE_TYPE, and TEXTURE_ABSOLUTE. See the Texture section for further discussion of this function.
AR_Boolean
OCR_bind_forward_reference (
AR_Triple *original,
AR_Triple *thing_being_bound
)
current_position() statement elsewhere in SDL. See the Initialize section of this document for more information on how to apply this function.
int
OCR_transform_point (
AR_Point* in_pt,
AR_Point* out_pt
)
in_pt and places the result in out_pt. This function is mostly useful for transforming a light's position into world space, and should only be called in the INIT routine (random results otherwise). The two arguments, in_pt and out_pt can point to the same AR_Point.
int
OCR_transform_normal (
AR_Point* in_norm,
AR_Point* out_norm
)
in_norm and places the result in out_norm. This function is mostly useful for transforming a light's direction based on the transformation matrix, and should only be called in the INIT routine (random results otherwise). The two arguments, in_norm and out_norm can point to the same AR_Point.Caution:
out_norm is not normalized, and in_norm is not required to be normalized.
int
OCR_transform_tangent (
AR_Point* in_tan,
AR_Point* out_tan
)
in_norm and places the result in out_norm. This function should only be called in the INIT routine (random results otherwise). Tangents should not be normalized. The two arguments, in_tan and out_tan can point to the same AR_Point.
int
OCR_texture_transform_point (
AR_Point* pt,
AR_Matrix matrix
)
matrix to the specified point (pt). It is used mostly in solid and environment textures to transform the current intersection point from world space back into object space (the space where the object was defined). Applying this matrix to the point applies any save_transformation matrices that were specified in the SDL.
int
OCR_texture_transform_vector (
AR_Vector* vector,
AR_Matrix matrix
)
matrix to the specified vector. In all other ways it is similar to OCR_texture_transform_point().
void OCR_NORMALIZE(
double length,
AR_Vector vector
)
vector, and places the length of the vector (before normalization) in length.
int
OCR_matrix_initialize (
AR_Matrix matrix
)
int
OCR_matrix_multiply (
float* matrix1,
float* matrix2,
float* result_matrix
)
matrix1 by matrix2 and returns the resulting matrix in result_matrix. The routine allows result_matrix to be one of matrix1 or matrix2. This function can be called by casting your matrices to (float *).
int
OCR_matrix_invert (
AR_Matrix matrix_in,
AR_Matrix matrix_out
)
matrix_in into matrix_out. The two matrices cannot be the same matrix. If the matrix is not invertable, OCR_fatal_error() is called and the renderer exits.
float OCR_noise3D (
double x,
double y,
double z
)
x, y, z), this function returns a 3D, continuous pseudo-random scalar value. See Ken Perlin's paper on Solid Textures for more information.
float OCR_noise2D (
double x,
double y
)
AR_Rgb OCR_color_noise2D (
double x,
double y
)
float OCR_check_shadow (
AR_LightInfo *light,
double length,
AR_Vector *direction,
AR_Point *pt,
AR_Rgba *shadow_color
)
Given a pointer to the
light to check for shadows on, this routine traces a ray from the intersection point (pt) following the normalized direction vector that points towards the light (direction). The shadow ray tracing stops after length units, which should be passed in as the distance to the light source. The float value returned is for backwards compatibility. The shadow_colour point contains the r,g,b values to multiply into the final result to produce colored shadows in the raytracer. This function can only be called from a Light CALC function in the raytracer.
int OCR_copy_TextureType (
AR_TextureType *pTo,
AR_TextureType *pFrom
)
pFrom into pTo. pTo must not be NULL, but all fields inside pTo are assumed to be NULL. If the structures cannot be copied for some reason, an error message is printed and the renderer aborts.
char *OCR_allocate (
unsigned int size
)
size bytes of memory. Upon failure, it prints an "Out of memory" message and aborts the renderer.
int
OCR_fatal_error (
char* error_string,
char* argument
)
error_string may contain a printf()-like directive that prints out the argument in the string. For example:
OCR_fatal_error( "This integer is wrong: %d ", i );
If there is no
printf()-like directive in the error_string, then the second argument should be NULL. For example:
OCR_fatal_error( "Problem initializing code.", NULL );
int OCR_message (
char* message_string,
char* argument
)
OCR_fatal_error() except the renderer is not aborted.
void OCR_want_tangents()