ftp.nice.ch/pub/next/unix/graphics/rayshade.4.0.s.tar.gz#/rayshade.4.0/liblight/infinite.c

This is infinite.c in view mode; [Download] [Up]

/*
 * infinite.c
 *
 * Copyright (C) 1989, 1991, Craig E. Kolb
 * All rights reserved.
 *
 * This software may be freely copied, modified, and redistributed
 * provided that this copyright notice is preserved on all copies.
 *
 * You may not distribute this software, in whole or in part, as part of
 * any commercial product without the express consent of the authors.
 *
 * There is no warranty or other guarantee of fitness of this software
 * for any purpose.  It is provided solely "as is".
 *
 * $Id$
 *
 * $Log$
 */
#include "light.h"
#include "infinite.h"

static LightMethods *iInfMethods = NULL;

Infinite *
InfiniteCreate(dir)
Vector *dir;
{
	Infinite *inf;

	inf = (Infinite *)share_malloc(sizeof(Infinite));
	inf->dir = *dir;
	if (VecNormalize(&inf->dir) == 0.) {
		RLerror(RL_ABORT, "Invalid directional light.\n");
		return (Infinite *)NULL;
	}
	return inf;
}

LightMethods *
InfiniteMethods()
{
	if (iInfMethods == (LightMethods *)NULL) {
		iInfMethods = LightMethodsCreate();
		iInfMethods->intens = InfiniteIntens;
		iInfMethods->dir = InfiniteDirection;
	}
	return iInfMethods;
}

int
InfiniteIntens(inf, lcolor, cache, ray, dist, noshadow, color)
Infinite *inf;
Color *lcolor, *color;
ShadowCache *cache;
Ray *ray;
Float dist;
int noshadow;
{
	return !Shadowed(color, lcolor, cache, ray, dist, noshadow);
}

void
InfiniteDirection(lp, pos, dir, dist)
Infinite *lp;
Vector *pos, *dir;
Float *dist;
{
	*dir = lp->dir;
	*dist = FAR_AWAY;
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.